akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
	int w, h;
	while (cin >> w >> h, w) {
		vector<string> codes(h);
		REP(i, h)
			cin >> codes[i];
		vector<vector<string>> memo(h, vector<string>(w));
		REP(i, h)
			REP(j, w)
			memo[i][j] = codes[i][j];
		for (int i = h - 1;i >= 0;i--) {
			for (int j = w - 1;j >= 0;j--) {
				if (isdigit(codes[i][j])) {
					if (i != h - 1 && isdigit(codes[i + 1][j]))
						if (memo[i][j].length() < memo[i + 1][j].length() + 1)
							memo[i][j] = codes[i][j] + memo[i + 1][j];
						else if (memo[i][j].length() == memo[i + 1][j].length() + 1)
							memo[i][j] = max(memo[i][j], codes[i][j] + memo[i+1][j]);
					if (j != w - 1 && isdigit(codes[i][j+1]))
						if (memo[i][j].length() < memo[i][j+1].length() + 1)
							memo[i][j] = codes[i][j] + memo[i][j+1];
						else if (memo[i][j].length() == memo[i][j+1].length() + 1)
							memo[i][j] = max(memo[i][j], codes[i][j] + memo[i][j+1]);
				}
			}
		}
		string ans = "0";
		REP(i, h)
			REP(j, w) {
			if ('1' <= memo[i][j][0] && memo[i][j][0] <= '9') {
				if (ans.length() < memo[i][j].length())
					ans=memo[i][j];
				else if (ans.length() == memo[i][j].length())
					ans = max(ans, memo[i][j]);
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3160
#define NDEBUG
NDEBUG


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


typedef int64_t int64;


using namespace std;

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


namespace template_util {
    

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

    /// caide keep
    template<int N>
    struct bytetype {
        
    };

    /// caide keep
    template<>
    struct bytetype<4> {
        
    };

    /// caide keep
    template<>
    struct bytetype<3> {
        
    };

    /// caide keep
    template<>
    struct bytetype<2> {
        
    };

    /// caide keep
    template<>
    struct bytetype<1> {
        
    };

    /// caide keep
    template<>
    struct bytetype<0> {
        
    };

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


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

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

template<class T>
vector<T> next_vector(istream& in) {
    auto n = next<size_t>(in);
    return next_vector<T>(in, n);
}


int64 tryIt(const vector<int>& v, int cur) {
    int64 res = 0;
    int64 sum = 0;
    for (int x : v) {
        sum += x;
        if (cur == 1) {
            if (sum <= 0) {
                res += (-sum);
                ++res;
                sum = 1;
            }
        } else {
            if (sum >= 0) {
                res += (sum);
                ++res;
                sum = -1;
            }
        }
        cur = 1 - cur;
    }
    return res;
}

void solve(istream& in, ostream& out) {
    vector<int> v = next_vector<int>(in);
    int64 res = 1LL << 60;
    res = min(res, tryIt(v, 1));
    res = min(res, tryIt(v, 0));
    out << res << endl;
}


int main() {
    solve(cin, cout);
    return 0;
}



Measured memory_bytes: 640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

V, E = MAP()
st = [LIST() for _ in range(E)]

graph = [[] for _ in range(V)]
dag = [0]*V
for s, t in st:
	graph[s].append(t)
	dag[t] += 1

ans = [i for i, x in enumerate(dag) if x == 0]
q = deque([i for i, x in enumerate(dag) if x == 0])
while q:
	S = q.popleft()
	for node in graph[S]:
		dag[node] -= 1
		if dag[node] == 0:
			ans.append(node)
			q.append(node)

if sum(dag):
	print(-1)
else:
	print(*ans, sep="\n")




Measured memory_bytes: 16716
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  string s;
  cin>>s;
  vector<int>data;
  for(int i=0;i<s.size();i++){
    data.push_back(s.at(i)-'0');
  }
  int ans=0;
  for(int i=0;i<=999;i++){
    vector<int> tmp={i/100,(i%100)/10,i%10};
    int k=0;
    for(int j=0;j<N;j++){
      if(data[j]==tmp[k])k++;
      if(k==3){
        ans++;
        break;
      }
    }
  }
  cout<<ans<<endl;
}

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

int main(){
 ll a,b,c,d;cin>>a>>b>>c>>d;
 ll ans=-2000000000000000000;
ans=max(ans,a*c);
ans=max(ans,a*d);
ans=max(ans,b*c);
ans=max(ans,b*d);
 cout<<ans;
}


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

using namespace std;

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

	//string slimes;
	//cin >> slimes;
/*
	char slimes[n];
	for(int i =0; i<n; i++){
		scanf("%c", &slimes[i]);
	}
	
*/
	char slimes[n];
	vector<char> colors;

	scanf("%s", slimes);


	//cout << colors[0] << endl;
	//colors.push_back(slimes[0]);
	char tmp = slimes[0];
	//cout << slimes[0];
	int count = 1;
	for(int i=1; i<n; i++){
		if(tmp != slimes[i]){
			colors.push_back(slimes[i]);
			//cout << slimes[i];
			tmp = slimes[i];
			count += 1;
		}

	}


	printf("%d", count);

	return 0;
}


Measured memory_bytes: 512
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/
 
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
 
typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 1e9 + 7;
const int MAX_N = 5e5 + 5;
int dx[] = { -1LL,0,1LL,0 }, dy[] = { 0,1LL,0,-1LL };
vector<ll> prime;
 
ll inv[MAX_N], fac[MAX_N];
 
template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1LL; while (b > 0) { if (b & 1LL) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1LL] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) { a[i] = 1LL; }for (int i = 2; i < n + 1LL; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }
 
typedef pair<int, pair<int, int>> edge;
 
class UnionFind {
private:
	vector<int> par;
public:
	UnionFind(int N) { par = vector<int>(N, -1LL); }
	int find(int x);
	ll size(int x);
	void unite(int x, int y);
	bool same(int x, int y);
};

int UnionFind::find(int x) {
	if (par[x] < 0) return x;
	else return par[x] = find(par[x]);
}
 
ll UnionFind::size(int x) {
	return -par[find(x)];
}
 
void UnionFind::unite(int x, int y) {
	x = find(x);
	y = find(y);
 	if (x == y) return;
	//大きい方に小さい方をくっ付ける
	if (size(x) < size(y)) swap(x, y);

	par[x] += par[y];
	par[y] = x;
}
 
bool UnionFind::same(int x, int y) {
	x = find(x);
	y = find(y);
	return x == y;
}

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

	string s; cin >> s;
	if (s.size() < 4) {
		if (s == "ABC") cout << 1 << endl;
		else cout << 0 << endl;
		return 0;
	}
	int tmp = 0;
	int ans = 0;
	REP (i,s.size()-2) {
		if (s[i]=='A') tmp++;
		if (s[i]!='A') tmp=0;
		if (s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') {
			ans += tmp;
			if (i+4 < s.size()) {
				if (s[i+3]=='B'&&s[i+4]=='C') {
					tmp -= 1; i++; s[i+1] = 'A';
				} else {
					i += 2;
				}
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 720
#include<iostream>

using namespace std;

int main() {
	int H[10000], W[10000];

	for (int i = 0; i < 9999; i++) {
		cin >> H[i] >> W[i];
		if (H[i] == 0 && W[i] == 0) {
			break;
		}
	}

	for (int o = 0; o < 9999; o++) {

		if (H[o] == 0 && W[o] == 0) {
			break;
		}

		for (int m = 0; m < W[o]; m++) {
			cout << "#";
		}

		cout << endl;

		for (int k = 0; k < H[o]-2; k++) {
			cout << "#";
			for (int l = 0; l < W[o]-2; l++) {
				cout << ".";
			}
			cout << "#" << endl;
		}

		for (int n = 0; n < W[o]; n++) {
			cout << "#";
		}

		cout << endl << endl;

	}

	return 0;
}


Measured memory_bytes: 3016
import java.util.stream.IntStream;

public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt(), ap = 0, cp = 0;
        int[] a = IntStream.concat(IntStream.range(0, n).map(i -> scanner.nextInt()), IntStream.of(1000000001)).sorted().toArray();
        int[] b = IntStream.range(0, n).map(i -> scanner.nextInt()).sorted().toArray();
        int[] c = IntStream.concat(IntStream.range(0, n).map(i -> scanner.nextInt()), IntStream.of(1000000001)).sorted().toArray();
        long ans = 0;
        for (int i = 0; i < n; i++) {
            while (a[ap] < b[i]) ap++;
            while (c[cp] <= b[i]) cp++;
            ans += ap * (long)(n - cp);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 96560
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define ll  long long
#define endl '\n'
#define pi 3.14159265
int main()  
{     
    string a,b,c;
    cin>>a>>b>>c;
    ll ind1=0;
    ll ind2=0;
    ll ind3=0;
    ll ch=0;
    while(1)
    {
        if(ch==0)
        {
            if(ind1==a.length())
            {
                cout<<"A";
                return 0;
            }
            if(a[ind1]=='b')
                ch=1;
            else if(a[ind1]=='c')
                ch=2;
            ind1++;
            continue;
        }
        if(ch==1)
        {
            if(ind2==b.length())
            {
                cout<<"B";
                return 0;
            }
            if(b[ind2]=='a')
                ch=0;
            else if(b[ind2]=='c')
                ch=2;
            ind2++;
            continue;
        }
        if(ch==2)
        {
            if(ind3==c.length())
            {
                cout<<"C";
                return 0;
            }
            if(c[ind3]=='b')
                ch=1;
            else if(c[ind3]=='a')
                ch=0;
            ind3++;
            continue;
        }
    }
}   

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

int main(void)
{
    int N;
    int cnt = 0;
    string S;
    cin >> N;
    cin >> S;
    for (int i = 0; i < S.size(); i++)
    {
        if (S[i] == 'R')
        {
            cnt += 1;
        }
    }
    if (cnt > N / 2)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,double> PII;
const int inf = numeric_limits<int>::max();

double p;
int n;
vector< vector<PII> > G;
double dp[100100];
double dp2[100100];
int visited[100100];

double calc_dp(int node){
  visited[node] = 1;
  double ret = 0;
  for(int i = 0;i < (int)G[node].size();++i){
    if(!visited[G[node][i].first]){
      ret += p*(G[node][i].second
                + calc_dp(G[node][i].first));
    }
  }
  return dp[node] = ret;
}

double calc_dp2(int node){
  visited[node] = 1;
  double ret = dp[0];
  for(int i = 0;i < (int)G[node].size();++i){
    if(!visited[G[node][i].first]){
      ret += 
        p*(G[node][i].second + calc_dp2(G[node][i].first));
    }
  }
  return dp2[node] = ret;
}

int main(void){
  cin >> p >> n;
  G.resize(n);
  for(int i = 0;i < n-1;++i){
    int x,y;
    double c;
    cin >> x >> y >> c;
    --x;--y;
    G[x].push_back(PII(y,c));
    G[y].push_back(PII(x,c));
  }
  fill(dp,dp+100100,0);
  fill(dp2,dp2+100100,0);
  fill(visited,visited+100100,0);
  calc_dp(0);
  fill(visited,visited+100100,0);
  calc_dp2(0);
  cout << setprecision(15) << dp2[0] << endl;
  return 0;
}

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

int dp[50];

int main(){
  int n, i;

  scanf("%d",&n);
  if(n < 0 || 44 < n) exit(1);

  for(i=0; i<50; i++){
    dp[i]=-1;
  }

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

  return 0;
}

int fib(int n){
  if(n == 0 || n == 1) return dp[n]=1;
  if(dp[n] != -1) return dp[n];
  return dp[n]=fib(n-1)+fib(n-2);  
}



Measured memory_bytes: 2108
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
//C++11
#if __cplusplus == 201103L
#include <tuple>
#endif

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int main(){
  int N;
  while(cin>>N && N){
    vector<string> _city(N);
    REP(i, N) cin>>_city[i];
    vector<string> city;
    REP(i, N){
      bool ok = true;
      REP(j, N){
        if(i != j && _city[i].size() < _city[j].size() && _city[j].find(_city[i]) != -1) ok = false;
        if(i < j && _city[i] == _city[j]) ok = false;
      }
      if(ok) city.push_back(_city[i]);
    }
    N = city.size();
    int d[16][16] = {};
    REP(i, N)REP(j, N)if(i != j){
      string from = city[i];
      string to = city[j];
      int l = min(from.size(), to.size());
      for(int k = 1; k <= l; k++){
        if(from.substr(from.size() - k, k) == to.substr(0, k)){
          d[i][j] = k;
        }
      }
      if(from.size() <= to.size() && to.find(from) != -1) d[i][j] = l;
      if(to.size() <= from.size() && from.find(to) != -1) d[i][j] = l;
    }
    int dp[1<<16][16] = {};
    REP(S, 1<<N)REP(i, N) dp[S][i] = -INF;
    REP(i, N) dp[1<<i][i] = 0;
    REP(S, 1<<N)REP(from, N)if(dp[S][from] != -INF){
      REP(to, N)if(!(S >> to & 1)){
        int NS = S | 1<<to;
        dp[NS][to] = max(dp[NS][to], dp[S][from] + d[from][to]);
      }
    }
    int ans = 0;
    REP(i, N) ans += city[i].size();
    ans -= *max_element(dp[(1<<N)-1], dp[(1<<N)-1] + N);
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 5032
n = int(input())
arr = [int(input()) for x in range(n)]

arr.sort()

med = n // 2

# 偶奇で場合分け
if n % 2 == 0:
    ans = 2 * sum(arr[med + 1:]) - 2 * sum(arr[:med - 1]) + arr[med] - arr[med - 1]
# 初項と末項の組み合わせ方で場合分け
else:
    ans1 = 2 * sum(arr[med + 1:]) - 2 * sum(arr[:med - 1]) - arr[med - 1] - arr[med]
    ans2 = 2 * sum(arr[med + 2:]) - 2 * sum(arr[:med]) + arr[med + 1] + arr[med]
    ans = max(ans1, ans2)

print(ans)

Measured memory_bytes: 7516
H,W = map(int,input().split())
C = {}
for _ in range(H):
    A = input().strip()
    for i in range(W):
        if A[i] not in C:
            C[A[i]] = 0
        C[A[i]] += 1
cnt4 = 0
cnt1 = 0
for a in C:
    if C[a]>=4:
        cnt4 += C[a]//4
        C[a] = C[a]%4
    if C[a]%2==1:
        cnt1 += 1
if cnt4<(W//2)*(H//2):
    flag = 0
else:
    if H%2==1 and W%2==1:
        if cnt1==1:
            flag = 1
        else:
            flag = 0
    else:
        if cnt1==0:
            flag = 1
        else:
            flag = 0
if flag==1:
    print("Yes")
else:
    print("No")

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

int main() {
    int N, X;
    cin >> N >> X;
    vector<int> m(N);
    for (int i = 0; i < N; i++) {
        cin >> m[i];
        X -= m[i];
    }
    int minv = *min_element(m.begin(), m.end());
    int sum = N + X / minv;
    cout << sum << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.lang.System.in;

public class Main {
    static int n,m;
    static long mod = 1000000000+7;
    // static ArrayList<Integer>[] graph,tree;
    public static void main(String[] args)throws IOException {
        //BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        Scanner sc = new Scanner(System.in);
        //String[] buf = reader.readLine().split(" ");
        n = sc.nextInt();
        int maxn = 200000+5;
        ArrayList<Integer>[] rec = new ArrayList[maxn+1];
        for(int i=0;i<=maxn;i++) rec[i] = new ArrayList<>();
        int[] idx = new int[maxn+1];
        int[] c = new int[n];
        for(int i=0;i<n;i++){
            c[i] = sc.nextInt();
            rec[c[i]].add(i);
        }
        long[] dp = new long[n];
        dp[0] = 1;
        idx[c[0]]++;
        for(int i=1;i<n;i++){
            int cur = c[i];
            if(idx[cur]==0){
                dp[i] = dp[i-1];
            }else{
                int former = rec[cur].get(idx[cur]-1);
                if(former==i-1){
                    dp[i] = dp[i-1];
                } else{
                    if(former==0) dp[i] = (dp[i-1]+1)%mod;
                    else{
                        dp[i] = (dp[i-1]+dp[former])%mod;
                    }
                }
            }
            idx[cur]++;
        }
        System.out.println(dp[n-1]);
    }
}

Measured memory_bytes: 111880
//If you are trying to hack me I wish you can get it, Good Luck :D.
#include <bits/stdc++.h>
using namespace std;

#define debug(args...) fprintf (stderr,args)
#define pb push_back
#define mp make_pair

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

const int MAX = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const ll  MOD = 1000000007;

ll P[MAX], Q[MAX], R[MAX];
int x, y, a, b, c;

bool cmp(ll i, ll j) {
   return i > j;
}

int main() {
   cin >> x >> y >> a >> b >> c;

   for (int i = 0; i < a; i++)
      cin >> P[i];
   
   sort(P, P + a, cmp);
   
   for (int i = 0; i < b; i++)
      cin >> Q[i];
   
   sort(Q, Q + b, cmp);
         
   for (int i = 0; i < c; i++)
      cin >> R[i];

   sort(R, R + c, cmp);
   
   ll ans = 0;

   for (int i = 0; i < x; i++) ans += P[i];
   for (int i = 0; i < y; i++) ans += Q[i];

   for (int i = 0; i < c; i++) {
      int red = -1;
      if (x == 0 && y == 0) break;
      else if (x == 0) red = 1;
      else if (y == 0) red = 0;
      else if (P[x - 1] < Q[y - 1]) red = 0;
      else red = 1;

      if (red == 1 && Q[y - 1] < R[i]) {
         ans += (R[i] - Q[y - 1]);
         y--;
      } else if (red == 0 && P[x - 1] < R[i]) {
         ans += (R[i] - P[x - 1]);
         x--;
      } else break;      
   }

   cout << ans << '\n';
}


Measured memory_bytes: 2560
import numpy as np

N, K = map(int, input().split())
H = np.array(list(map(int, input().split())), dtype=np.int64)
dp = np.ones(N, dtype=np.int64) * (2 ** 62)
dp[0] = 0
for i in range(1, N):
    cost = np.abs(H[i - 1] - H[i : i + K])
    np.minimum(dp[i : i + K], dp[i - 1] + cost, out=dp[i : i + K])
print(dp[-1])


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

int main() {
    int A,B;
    cin >> A >> B;

    int count = 0;
    
    bool even = true;
    while (even) {
        if (A * count < B++ - 1) {
            count ++;
        }
        else {
            even = false;
            break;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(int argc, char const *argv[]) {
  int m,f,r,sum;
  char grade;
  while (1) {
    scanf("%d %d %d", &m, &f, &r);
    if(m==-1 && f==-1 && r==-1){
      break;
    }
    sum = m+f;
    grade = (sum<30 || m==-1 ||f==-1 ? 'F':(sum<50&&r<50 ? 'D':
    (sum<65 ? 'C':(sum<80 ? 'B':'A'))));
    printf("%c\n", grade);
  }
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define mod 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  lol n,m,a,b,c,d;
  string yes="Yes";
  string s;
  cin >>s;
  n=s.size();
  for(int i=0;i<n/2;i++){
    if(s[i]!=s[n-i-1]) yes="No";
  }
  m=(n-1)/2;
  for(int i=0;i<m/2;i++){
    if(s[i]!=s[m-i-1]) yes="No";
  }
  m=(n+3)/2;
  m--;
  for(int i=m;i<n;i++){
    if(s[i]!=s[n-i+m-1]) yes="No";
  }
  cout <<yes<<'\n';
  
  return (0);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

int dist(int x0, int y0, int x1, int y1) {
    return std::abs(x0 - x1) + std::abs(y0 - y1);
}

int main(void) {
    int N, M;
    std::vector<int> a, b, c, d;

    std::cin >> N;
    std::cin >> M;

    a.resize(N);
    b.resize(N);
    c.resize(M);
    d.resize(M);

    for (int i = 0; i < N; i++) {
        std::cin >> a[i];
        std::cin >> b[i];
    }

    for (int i = 0; i < M; i++) {
        std::cin >> c[i];
        std::cin >> d[i];
    }


    for (int i = 0; i < N; i++) {
        int min_id = -1;
        int min = 0x7fffffff;
        for (int j = 0; j < M; j++) {
            int dt = dist(a[i], b[i], c[j], d[j]);

            if (dt < min) {
                min_id = j;
                min = dt;
            }
        }

        std::cout << (min_id+1) << std::endl;
    }
}


Measured memory_bytes: 256
/*---------------------------------------------------------------------*/
#include<bits/stdc++.h>
//#include <cassert>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
/*---------------------------------------------------------------------*/
#define FAST        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ff          first
#define ss          second
#define ll          long long
#define ull         unsigned long long
#define pii         pair<int,int>
#define mp          make_pair
#define psb         push_back
#define psf         push_front
#define ppb         pop_back
#define ppf         pop_front
#define all(x)      x.begin(),x.end()
#define TESTS       int test;cin>>test;for(int tcase=1;tcase<=test;tcase++)
#define ordered_set tree< int, null_type, less_equal< int >, rb_tree_tag, tree_order_statistics_node_update>
/*--------------------------------------------------------------------*/
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v)
{ os << '{'; string sep;for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T> ostream& operator<<(ostream &os, const set<T> &v)
{ os << '{'; string sep;for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T> ostream& operator<<(ostream &os, const multiset<T> &v)
{ os << '{'; string sep;for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p)
{ return os << '(' << p.first << ", " << p.second << ')'; }
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#ifndef ONLINE_JUDGE
#define cc(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__);
#define OK      cerr << "LINE "<<__LINE__<<" :"<<endl;
#define ccm(x)  cerr << "(" << #x <<") : "<<endl;for(auto i : x){ cerr<<"["<<i.ff<<"] = "<<i.ss<<endl;}
#else
#define cc(...)
#define OK
#define ccm(x)
#endif
/*---------------------------------------------------------------------*/
#define MXN (ll)(1e6)
#define MOD (ll)(1e9+7)
#define INF (ll)(4e18)
#define inf (int)(2e9)

int main()
{
    FAST
    string s;cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='?') s[i]='D';
    }
    cout<<s<<endl;
    return 0;
}
/*--------------------------------------------------------------------*/
/*
>Check Corner Cases (n==1 or T==1)
>Overflow issues?
>LB / UB !!not found!! check?
>slow multi-set operations?try without multi-set
*/
/*--------------------------------------------------------------------*/
/* ---INPUT---
--------(1)------


-------(2)-------



-------(3)-------


-------(4)-------



--------------
*/
/*-----------------------MEHEDI HASAN,CSE-JU--------------------------*/



Measured memory_bytes: 3776
#!/usr/bin/env python3
#ABC137 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,m = LI()
ab = [LI() for _ in range(n)]
ab.sort(key = itemgetter(0))
ans = 0
h = []
j = 0
for i in range(m)[::-1]:
    while j < n and m - ab[j][0] >= i:
        a,b = ab[j]
        heappush(h,(-b,a))
        j += 1
    if h:
        x,a = heappop(h)
        ans -= x
print(ans)


Measured memory_bytes: 86620
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {

    input!(
       n: usize,
       q: usize,
       s: String,
       p: [(usize,usize);q]
    );

    let mut p = p;

    let result = solve(n,s, &mut p);

    for r in result.iter(){
        println!("{:?}",r);
    }
}

pub fn solve(n: usize,s: String,p: &mut Vec<(usize,usize)>) -> Vec<usize>{
   let mut result = vec![];

    let mut increment: Vec<usize>  = vec![0;n];

    let chars: Vec<char> = s.chars().collect();
    let mut current = 0;

    loop {
        if chars[current] == 'A' && chars[(current + 1)] == 'C' {
            increment[(current + 1)] = 1 + if current == 0 {0} else {increment[(current)]}
        } else {
            increment[current] = if  current == 0 {0} else {increment[(current)]};
            increment[(current + 1)] =  increment[current];
        }
        if current + 2 == n {
           //increment[(current + 1)] =  increment[(current)];
            break
        }
        current = current + 1
    };
    for &(l,r) in p.iter() {
        let count = increment[(r - 1)] - increment[(l - 1)];
        result.push(count);
    }
    result
}




Measured memory_bytes: 11004
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,K;
  cin >>A>>B>>C>>K;
  int count=0;
  while(A>=B){
    B*=2;
    count++;
  }
  while(B>=C){
    C*=2;
    count++;
  }
  if(count<=K){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

int r, c, n;

int xi1, yi1, xi2, yi2;

inline bool boundary(int x, int y) {
    return (x == 0 || y == 0 || x == r || y == c);
}

map<int, int> mu, ml, md, mr;

void save(int x, int y, int i) {
    if (y == 0) {
        ml[x] = i;
    }
    else if (x == r) {
        md[y] = i;
    }
    else if (y == c) {
        mr[x] = i;
    }
    else {
        mu[y] = i;
    }
}

vector<int> stack;

void push(int x) {
//    DEBUG(x);
    if (stack.size() > 0 && stack.back() == x) {
        stack.pop_back();
    }
    else {
        stack.PB(x);
    }
}

int main() {
    GI(r);
    GI(c);
    GI(n);

    FOR1(i, n) {
        GI(xi1);
        GI(yi1);
        GI(xi2);
        GI(yi2);

        if (boundary(xi1, yi1) && boundary(xi2, yi2)) {
            save(xi1, yi1, i);
            save(xi2, yi2, i);
//            DEBUG(xi1);
//            DEBUG(yi1);
//            DEBUG(xi2);
//            DEBUG(yi2);
        }
    }

    for (auto it = ml.begin(); it != ml.end(); it++) {
        push(it->SS);
    }
    for (auto it = md.begin(); it != md.end(); it++) {
        push(it->SS);
    }
    for (auto it = mr.rbegin(); it != mr.rend(); it++) {
        push(it->SS);
    }
    for (auto it = mu.rbegin(); it != mu.rend(); it++) {
        push(it->SS);
    }

    if (stack.size() == 0) {
        printf("YES\n");
    }
    else {
        printf("NO\n");
    }


    return 0;
}

Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P=pair<int,int>;
using G=vector<vector<int>>;

int main(){
  int A, B;

  cin >> A >> B;

  if( A <= 5 ){
    cout << 0 << endl;
  }else if( A <= 12 ){
    cout << B/2 << endl;
  }else{
    cout << B << endl;
  }
}


Measured memory_bytes: 3628
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;
int main() {
    int N, K, x[100010], i, j, mind = 0x7FFFFFFF;
    cin >> N >> K;
    for (i = N; i--;) {
        cin >> x[i];
    }
    for (i = 0, j = K - 1; i <= N-K; i++, j++) {
        mind = min(
            mind,
            min(
                abs(x[i]) + abs(x[i] - x[j]),
                abs(x[j]) + abs(x[i] - x[j])
            )
        );
    }
    cout << mind << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n];
  long dp[n+1];
  for(int i=0;i<n;i++)
    cin>>a[i];
  
  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
  for(int i=2;i<n;i++)
  {
    	long mn=LONG_MAX;
    	for(int j=i-2;j<i;j++)
        {
          	if(abs(a[i]-a[j])+dp[j]<mn)
            {
              	mn=abs(a[i]-a[j])+dp[j];
            }
        }
    	dp[i]=mn;
  }
  cout<<dp[n-1]<<endl;
}


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

using namespace std;

int main(){
  int a[60000]={};
  int n,i,j;
  cin >> n;
  for(i=2;i*i<60000;i++){
    if(a[i]==0){
      j=i*i;
      while(j<60000){
        a[j]=1;
        j+=i;
      }
    }
  }
  int cnt=0;
  for(i=2;i<60000;i++){
    if(a[i]==0&&i%5==1){
      cout << i;
      cnt++;
      if(cnt==n)break;
      cout << " ";
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=924844033;
#define N 1055050

ll n,m,k;
ll a,b;
main(){
    k=in();
    a=in();b=in();
    if(b-a<=2){
        cout<<(1+k);
    }
    else{
        if(1ll+k<a){
            cout<<1+k;
        }
        else{
            ll ans=a;
            k-=(a-1);
            ans+=(b-a)*(k/2);
            k%=2;
            ans+=k;
            cout<<ans;
        }
    }
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
 
 
 
int main(void){
	string s,t;
	cin >> s >> t;
	int n=s.size();
	
	bool ok=false;
	int cur=0,idx=0;
	
	while(idx<n&&cur<t.size()){
		if(s[idx]==t[cur]) idx+=2;
		cur++;
	}
 
	if(idx>=n) ok=true;
 
	cur=0,idx=1;
	while(idx<n&&cur<t.size()){
		if(s[idx]==t[cur]) idx+=2;
		cur++;
	}
 
	if(idx>=n) ok=true;
 
	if(ok)
		puts("Yes");
	else
		puts("No");
	return 0;
}	

Measured memory_bytes: 3192
#include<stdio.h>
int kouyaku(int,int);

int main(){

  int x,y;

  scanf("%d%d",&x,&y);

  if(x>y) printf("%d",kouyaku(x,y));
  if(y>x) printf("%d",kouyaku(y,x));
  if(x==y) {printf("%d",x);}
  printf("\n");
  return 0;
}

int kouyaku(int a,int b)
{
  int r;
  if(a>b){
    while(b>0){
      r=a%b;
      a=b;
      b=r;
    }
  }
    return a;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
long long int sum_of_digits(long long int n){
    long long int sum=0;
    long long int dd=0;
while(n!=0){
        dd=n%10;
sum=sum+dd;
    n=n/10;
}
return sum;
}
int main() {
int a,b;
cin>>a>>b;
int i=0;
int d=0;
if(b==1){
    cout<<"0"<<endl;
}
else{
        int s=0,d=0;
while(s+a<b){

    s=s+a-1;
    d++;
}
cout<<d+1<<endl;
}
}






Measured memory_bytes: 256
function read_line()
    map(x->parse(Int64, x), split(readline()))
end

n = read_line()[1]
kraw = [Tuple{Int64,Int64}[] for i in 1:n]
col = ones(Int64, n) .* -1

for i in 2:n
    u,v,c = read_line()
    push!(kraw[u], (v, c))
    push!(kraw[v], (u, c))
end

function dfs(x)
    for (y,c) in kraw[x]
        if col[y] == -1
            col[y] = if c % 2 == 1 (1 - col[x]) else col[x] end
            dfs(y)
        end
    end
end

col[1] = 0
dfs(1)

for i in 1:n
    println(col[i])
end


Measured memory_bytes: 200580
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main{
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            while(true){
                int x = Integer.parseInt(br.readLine());
                if(x==0){
                    break;
                }
                
                String[] arr = br.readLine().split("\\s");
                Double[] data = new Double[x];
                Double sum = 0.0;
                for(int i=0; i<x; i++){
                    data[i] = Double.parseDouble(arr[i]);
                    sum += data[i];
                }
                
                Double avg = sum/x;
                Double tmp = 0.0;
                for(int i=0; i<x; i++){
                    tmp += Math.pow(data[i] - avg, 2);
                }
                Double stdev = Math.sqrt(tmp/x);
                System.out.println(String.valueOf(stdev));
            }
        } catch(IOException e) {
            e.printStackTrace();
        }
    }
}



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

int main(){
  int buttons;
  cin>>buttons;
  vector<vector<int>> gra(buttons,vector<int>(2,0));
  for(int i=0;i<buttons;i++){
    gra.at(i).at(0)=i+1;
    cin>>gra.at(i).at(1);
  }
  /*for(int i=0;i<buttons;i++){
    cout<<gra.at(i).at(0)<<","<<gra.at(i).at(1)<<endl;
  }*/
  bool judge=false;
  int x=gra.at(0).at(1);
  int count=1;
  if(x==2){
    judge=true;
  }
  else{
    for(int i=0;i<buttons;i++){
      int y=gra.at(x-1).at(1);
      x=y;
      count++;
      if(x==2){
        judge=true;
        break;
      }
    }
  }
  if(judge==true){
    cout<<count<<endl;
  }
  else{
    cout<<-1<<endl;
  }
}

Measured memory_bytes: 5760
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<cstdio>
typedef unsigned long long ull;
#define rep(i,a) for(int i=0;i<a;i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
using namespace std;
const double eps = 1e-10;
const double pi = acos(-1);
const double inf = (int)1e8;

int main(void){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if(a*b)printf("Open\n");
  else if(!a*!b*c)printf("Open\n");
  else printf("Close\n");
  return 0;
}

Measured memory_bytes: 1168
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int mx = 0, mi = 1000;
	rep(i,n){
		int a;
		cin >> a;
		chmax(mx, a);
		chmin(mi, a);
	}
	int ans = mx - mi;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3620
import sys
n, y = map(int, input().split())

for i in range(n+1):
    if i * 10000 > y:
        break
    for j in range(n-i+1):
        if i * 10000 + j * 5000 > y:
            break
        if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
            print(i, j, n-i-j)
            sys.exit(0)

print('-1 -1 -1')

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
int main(){
    int i;
    char s[101];
    scanf("%s",s);
    int a=strlen(s);
    for(i=0;i<a;i=i+2){
        if(s[i]=='L'){
            printf("No");
            return 0;
        }
    }
    for(i=1;i<a;i=i+2){
        if(s[i]=='R'){
            printf("No");
            return 0;
        }
    }
    printf("Yes");
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
#define int long long
typedef pair<int,int>pii;
const int mxN=2e5,M=1e9+7;
string s;
int n,ans,tot;
map<int,int>mp;
// LONG LONG CASE
int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>s;
    n=s.size();
    mp[0]=1;
    int pot=1LL;    
    for(int i=n-1;i>=0;i--){
        tot=tot+(s[i]-'0')*pot;
        tot=tot%2019;
        ans+=mp[tot];
        mp[tot]++;
        pot*=10LL;
        pot=pot%2019;
    }
    cout<<ans;
}

Measured memory_bytes: 3780
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <functional>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<ld> vld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N;
    cin >> N;
    multiset<int> mset;
    for (int n = 0; n < N; ++n) {
        int tmp;
        cin >> tmp;
        mset.insert(tmp);
    }
    
    int res = 0;
    while (!mset.empty()) {
        auto it = mset.end();
        --it;
        int max = *it;
        mset.erase(it);
        int x = 1;
        while (x <= max) x <<= 1;
        auto it2 = mset.find(x - max);
        if (it2 != mset.end()) {
            ++res;
            mset.erase(it2);
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 9600
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline
a,b,c,d,e,f = list(map(int,input().split()))
#水の入れ方を列挙
total_water_set = set()
for hund_a in range(0, f+1, 100*a):
    total_water = hund_a
    while total_water <= f:
        total_water_set.add(total_water)
        total_water += 100*b

total_water_set.remove(0)
#砂糖の入れ方を列挙
total_sugar_set = set()
for _c in range(0, f+1, c):
    total_sugar = _c
    while total_sugar <= f:
        total_sugar_set.add(total_sugar)
        total_sugar += d

max_nodo = 0
max_sugawater_weight = min(total_water_set)
max_sugar_weight = 0
import decimal
total_water_set = list(map(decimal.Decimal,total_water_set))
total_sugar_set = list(map(decimal.Decimal,total_sugar_set))
nodo_limit = 100 * decimal.Decimal(e) / (100+decimal.Decimal(e))
for water in total_water_set:
    for sugar in total_sugar_set:
        if water + sugar <= f:
            nodo = 100 * sugar / (water + sugar)
            if nodo > max_nodo and nodo <= nodo_limit:
                max_nodo = nodo
                max_sugawater_weight = water + sugar
                max_sugar_weight = sugar
print("{} {}".format(max_sugawater_weight,max_sugar_weight))

Measured memory_bytes: 5588
import java.util.Scanner;

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

		while (true) {
			int N = sc.nextInt();

			if (N == 0) {
				break;
			}

			int[] scores = new int[N];
			int sum = 0;
			for (int i = 0; i < N; i++) {
				scores[i] = sc.nextInt();
				sum += scores[i];
			}
			double ave = sum * 1.0 / N;
//			System.out.println(ave);

			double bunsan = 0;
			for (int score : scores) {
				bunsan += Math.pow( (score - ave) , 2);
			}
			bunsan /= N;

			System.out.println(Math.sqrt(bunsan));

		}


	}
}


Measured memory_bytes: 31432
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m1 = sc.nextInt();
        sc.nextInt();
        int m2 = sc.nextInt();
        System.out.println(m1 != m2 ? 1 : 0);
    }
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define M_PI 3.14159265358979323846
#define ALL(X) (X).begin(),(X).end()

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int Bingo[3][3];
int N;
vector<int> b;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    REP(i,3) REP(j,3) cin >> Bingo[i][j];
    cin >> N;
    b = fetch_vec<int>(N);
}

bool isBingo(){
    bool ans=false;
    int sum=0;
    REP(i,3) {
        sum=0;
        REP(j,3) {sum+=Bingo[i][j];}
        if(sum==0) ans=true;
    }
    REP(j,3) {
        sum=0;
        REP(i,3) {sum+=Bingo[i][j];}
        if(sum==0) ans=true;
    }
    sum = Bingo[0][0]+Bingo[1][1]+Bingo[2][2];
    if(sum==0) ans=true;
    sum = Bingo[2][0]+Bingo[1][1]+Bingo[0][2];
    if(sum==0) ans=true;
    return ans;
}

void solve(){
    REP(k,N){
        REP(i,3) REP(j,3) if(b[k]==Bingo[i][j]) Bingo[i][j]=0;
    }
    string ans = isBingo()?"Yes":"No";
    cout << ans << endl;
}   

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 256