akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    H, W = map(int, input().split())
    S = [list(input()) for _ in range(H)]
    M = [[-1, -1], [-1, 0], [-1, 1],
         [0, -1], [0, 0], [0, 1],
         [1, -1], [1, 0], [1, 1]]
    for h in range(H):
        for w in range(W):
            result = 0
            if S[h][w] == '#':
                continue
            for m in M:
                if (w + m[1] < 0
                    or h + m[0] < 0
                    or w + m[1] >= W
                        or h + m[0] >= H):
                    continue
                elif S[h + m[0]][w + m[1]] == '#':
                    result += 1
            S[h][w] = result
    for s in S:
        print(*s, sep='')


if __name__ == "__main__":
    main()


Measured memory_bytes: 3444
class Dice:
    
    def __init__(self, U, S, E, W, N, D):
        self.u, self.d = U, D
        self.e, self.w = E, W
        self.s, self.n = S, N       
    
    def roll(self, command):
        if command == 'E':
            self.e, self.u, self.w, self.d = self.u, self.w, self.d, self.e
        elif command == 'W':
            self.e, self.u, self.w, self.d = self.d, self.e, self.u, self.w
        elif command == 'S':
            self.s, self.u, self.n, self.d = self.u, self.n, self.d, self.s
        else:
            self.s, self.u, self.n, self.d = self.d, self.s, self.u, self.n

    def rightside(self, upside, forward):
        self.structure = {self.u:{self.w: self.s, self.s: self.e, self.e: self.n, self.n: self.w},
                          self.d:{self.n: self.e, self.e: self.s, self.s: self.w, self.w: self.n},
                          self.e:{self.u: self.s, self.s: self.d, self.d: self.n, self.n: self.u},
                          self.s:{self.u: self.w, self.w: self.d, self.d: self.e, self.e: self.u},
                          self.w:{self.u: self.n, self.n: self.d, self.d: self.s, self.s: self.u},
                          self.n:{self.u: self.e, self.e: self.d, self.d: self.w, self.w: self.u}}
        
        print(self.structure[upside][forward])

    def __eq__(self, other):

        other_hex = [other.u, other.s, other.e, other.w, other.n, other.d]
        self_hex = [self.u, self.s, self.e, self.w, self.n, self.d]
        if sorted(other_hex) != sorted(self_hex):
            return False

        for i in 'NNNNENNNENNNWNNNWNNNENNN':
            self.roll(i)
            if other.u == self.u and other.s == self.s and other.e == self.e \
            and other.w == self.w and other.n == self.n and other.d == self.d:
                return True
            
        return False

                

num = int(input())
dices = []
for i in range(num):
    U, S, E, W, N, D = [int(i) for i in input().split()]
    dice = Dice(U, S, E, W, N, D)
    dices.append(dice)

for i in range(num):
    for j in range(i+1, num):
        if dices[i] == dices[j]:
            print('No')
            break
    else:
        continue
    break
else:
    print('Yes')


Measured memory_bytes: 5624
package main

import (
	"fmt"
)

const mod = 1000000007

func pow(x, y int) int {
	if y == 0 {
		return 1
	} else if y%2 == 0 {
		x2 := pow(x, y/2)
		return x2 * x2 % mod
	} else {
		return x * pow(x, y-1) % mod
	}
}

func cmb(x, y int) int {
	if y > x {
		return 0
	}

	nu, de := 1, 1
	for i := 0; i < y; i++ {
		nu = nu * (x - i) % mod
		de = de * (i + 1) % mod
	}
	return nu * pow(de, mod-2) % mod
}

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)

	ans := pow(2, n) - 1
	ans -= cmb(n, a)
	ans -= cmb(n, b)
	ans = (ans%mod + mod) % mod
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;
typedef std::pair<LL, LL> P;
struct edge { LL u, v, cost; };
bool comp(const edge& e1, const edge& e2)
{
	return e1.cost < e2.cost;
}

class Union_Find
{
	std::vector<LL>per;
	std::vector<LL>rank;
public:
	void init(LL size)
	{
		rep(i, size)
		{
			per.push_back(i);
			rank.push_back(0);
		}
	}
	LL get_per(LL x)
	{
		if (x == per[x]) return x;
		return per[x] = get_per(per[x]);
	}
	bool is_same_per(LL x, LL y)
	{
		return get_per(x) == get_per(y);
	}
	void togett(LL x, LL y)
	{
		LL x_per = get_per(x), y_per = get_per(y);
		if (x_per == y_per)  return;
		if (rank[x_per] < rank[y_per]) per[x_per] = y_per;
		else
		{
			per[y_per] = x_per;
			if (rank[x_per] == rank[y_per]) ++rank[x_per];
		}
	}
};

const LL inf = 1123456789012345;
LL N;
std::vector<std::pair<LL, LL>>xp, yp;
std::vector<edge>edges;
Union_Find tree;

LL kruskal()
{
	std::sort(edges.begin(), edges.end(), comp);
	LL res = 0;
	for (auto e : edges)
	{
		if (!tree.is_same_per(e.u, e.v))
		{
			tree.togett(e.u, e.v);
			res += e.cost;
		}
	}
	return res;
}

int main()
{
	in >> N;
	std::vector<LL>x(N), y(N);
	tree.init(N + 1);
	rep(i, N)
	{
		in >> x[i] >> y[i];
		xp.push_back(std::make_pair(x[i], i + 1));
		yp.push_back(std::make_pair(y[i], i + 1));
	}
	std::sort(xp.begin(), xp.end());
	std::sort(yp.begin(), yp.end());
	rep(i, N - 1)
	{
		edges.push_back({ xp[i + 1].second,xp[i].second,xp[i + 1].first - xp[i].first });
		edges.push_back({ yp[i + 1].second,yp[i].second,yp[i + 1].first - yp[i].first });
	}
	out << kruskal() << std::endl;
	return 0;
}


Measured memory_bytes: 16136
#include <iostream>

using namespace std;

int main() {
  int target[3];
  int countF = 0;
  int countS = 0;
  std::cin >> target[0] >> target[1] >> target[2];

  for (int i = 0; i < 3; i++) {
    if (target[i] == 5) countF++;
    else if (target[i] == 7) countS++;
  }
  if (countF == 2 && countS == 1) std::cout << "YES" << std::endl;
  else std::cout << "NO" << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

int N, M, dp[100009], in[100009];
vector<int> G[100009];

int main() {
    cin >> N >> M;
    for(int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        G[x].push_back(y);
        in[y]++;
    }

    queue<int> que;
    for(int i = 1; i <= N; i++)
        if(in[i] == 0) que.push(i);

    while(!que.empty()) {
        int u = que.front();
        que.pop();
        for(int v : G[u])
            if(--in[v] == 0) {
                que.push(v);
                dp[v] = dp[u] + 1;
            }
    }

    int res = 0;
    for(int i = 1; i <= N; i++)
        res = max(res, dp[i]);

    cout << res << endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
// debug & operator << (debug & dd, P p) { dd << "(" << p.x << ", " << p.y << ")"; return dd; }



int main() {
	long long n;
	int x, mod;
	cin >> n >> x >> mod;
	vector<int> pos(mod, -1);
	long long sum = x;
	vector<long long> pref{x};
	pos[x] = 0;
	for(long long i = 1; i < n; ++i) {
		x = (long long) x * x % mod;
		sum += x;
		pref.push_back(pref.back() + x);
		if(pos[x] == -1) {
			pos[x] = i;
		}
		else {
			int cycle = i - pos[x];
			long long times = max(0LL, (n - i - 2) / cycle);
			if(times > 0) {
				sum += (pref[i] - pref[pos[x]]) * times;
				i += times * cycle;
			}
		}
	}
	printf("%lld\n", sum);
}


Measured memory_bytes: 4508
import itertools

N,M,R=map(int,input().split())
r=list(map(int,input().split()))
for i in range(R): r[i] -= 1

g = [ [1001001001] * N for _ in range(N) ]
for i in range(N):
  g[i][i] = 0

for _ in range(M):
  A,B,C=map(int,input().split())
  A-=1
  B-=1
  g[A][B] = C
  g[B][A] = C

def md(beg):
  d = [1001001001] * N
  done = [False] * N
  d[beg] = 0
  while True:
    cur = 1001001001
    pos = -1
    for i in range(N):
      if not done[i] and cur > d[i]:
        cur = d[i]
        pos = i
    if pos == -1:
      break
    done[pos] = True
    for i in range(N):
      d[i] = min(d[i], d[pos] + g[pos][i])
  return d

for i in range(R):
  g[r[i]] = md(r[i])

ans = 1001001001
for p in itertools.permutations(r):
  cur = 0
  for i in range(1, R):
    cur += g[p[i-1]][p[i]]
  ans = min(ans, cur)
print(ans)


Measured memory_bytes: 4084
from bisect import bisect_left
from random import randint
D = int(input())
Cs = list(map(int, input().split()))
Sss = []
for _ in range(D):
    Ss = list(map(int, input().split()))
    Sss.append(Ss)

def change(d, afterIdx):
    global score
    i = d - 1
    beforeIdx = Ts[i] - 1
    afterIdx -= 1
    if beforeIdx == afterIdx:
        return

    newScore = score

    before = lasts[beforeIdx]
    # dが何番目にあるか
    k1 = bisect_left(before, d)
    w = before[k1+1] - d
    h = d - before[k1-1]
    newScore -= Sss[i][beforeIdx]
    newScore -= w * h * Cs[beforeIdx]

    after = lasts[afterIdx]
    # dが何番目にあるか
    k2 = bisect_left(after, d)
    w = after[k2] - d
    h = d - after[k2-1]
    newScore += Sss[i][afterIdx]
    newScore += w * h * Cs[afterIdx]

    if newScore > score:
        lasts[beforeIdx].pop(k1)
        lasts[afterIdx].insert(k2, d)
        Ts[i] = afterIdx + 1
        score = newScore

Ts = []
for _ in range(D):
    Ts.append(randint(1, 26))

score = 0
lasts = [[0] for _ in range(26)]
for i, t in enumerate(Ts):
    d = i + 1
    t -= 1
    score += Sss[i][t]
    lasts[t].append(d)
    for j in range(26):
        score -= (d - lasts[j][-1]) * Cs[j]

for i in range(26):
    lasts[i].append(D+1)


for i in range(1000000):
    change(randint(1, D), randint(1, 26))

for t in Ts:
    print(t)


Measured memory_bytes: 83260
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <numeric>

using namespace std;
using ll = long long;
const ll INF = 1e18;

int main() {
    int N;
    cin >> N;
    ll a = 0;
    int v[100001] = {};
    for(int i = 0; i < N; i++) {
        cin >> a;
        v[a + 1]++;
        v[a]++;
        v[a - 1]++;
    }

    int max = 1;
    for (int i = 0; i < 100001; i++) {
        if(v[i] > max) {
            max = v[i];
        }
    }

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 1272
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;

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

	if (a == 1) {
		a = 14;
	}
	if (b == 1) {
		b = 14;
	}

	if (a > b) {
		cout << "Alice" << endl;
	}
	else if (a == b) {
		cout << "Draw" << endl;
	}
	else {
		cout << "Bob" << endl;
	}

	return 0;
}

Measured memory_bytes: 3660
n=int(input())
s=input()
R=[0]
G=[0]
B=[0]
for i in s:
  R.append(R[-1])
  G.append(G[-1])
  B.append(B[-1])
  if i=="R":R[-1]+=1
  elif i=="G":G[-1]+=1
  else:B[-1]+=1
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    if s[i]==s[j]:continue
    if "R" not in [s[i],s[j]]:
      ans+=R[-1]-R[j]
      if j+(j-i)<n:
        if s[j+(j-i)]=="R":ans-=1
    if "G" not in [s[i],s[j]]:
      ans+=G[-1]-G[j]
      if j+(j-i)<n:
        if s[j+(j-i)]=="G":ans-=1
    if "B" not in [s[i],s[j]]:
      ans+=B[-1]-B[j]
      if j+(j-i)<n:
        if s[j+(j-i)]=="B":ans-=1
print(ans)

Measured memory_bytes: 68696
// うしろのほうを優先
package main

import "fmt"

func main() {
	var N, X int
	fmt.Scan(&N, &X)
	A := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&A[i])
	}
	ans := 0
	for i := 1; i < N; i++ {
		if A[i-1]+A[i] > X {
			dif := A[i-1] + A[i] - X
			ans += dif
			A[i] = max(A[i]-dif, 0)
		}
	}
	fmt.Println(ans)
}

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

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}


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

using namespace std;
using ll = long long;


int main()
{
	int n;
	cin >> n;
	vector<long double> a(n);

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

	vector<vector<long double>> dp(n + 1, vector<long double>(n + 1)); // i枚投げた時表がj枚の確率
	dp[0][0] = 1;

	for(int i = 0; i < n; i++) {

			dp[i + 1][0] = dp[i][0] * (1 - a[i]);
		for(int j = 1; j <= n; j++) {

			dp[i + 1][j] = dp[i][j - 1] * a[i] + dp[i][j] * (1 - a[i]);

		}

	}
	


	cout << fixed <<setprecision(12) <<  accumulate(dp[n].begin() + (n / 2  +1), dp[n].end(), (long double)0.0) << endl; 

}

Measured memory_bytes: 141056
#include <algorithm>
#include <iostream>
#define N 394
using namespace std;

int main(){
  int n,s[N],l[N],p[N],dp[N][N],m,w,ans[N],flag=0;
  bool used[N];
  cin>>n;
  for(int i=0;i<n;i++) cin>>s[i]>>l[i]>>p[i];
  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++) dp[i][j]=-1;
  dp[0][0]=0;
  for(int i=0;i<N;i++)
    for(int j=s[0];j<=l[0];j++){
      if(i-j>=0&&dp[0][i-j]!=-1) dp[0][i]=dp[0][i-j]+p[0];
    }
  for(int i=1;i<n;i++){
    for(int j=0;j<N;j++) used[j]=false;
    for(int j=0;j<N;j++)
      for(int k=s[i];k<=l[i];k++){
	if(j-k>=0&&!used[j]&&dp[i][j-k]!=-1) used[j]=true,dp[i][j]=max(dp[i-1][j],dp[i][j-k]+p[i]);
	else dp[i][j]=max(dp[i][j],dp[i-1][j]);
      }
  }
  cin>>m;
  for(int i=0;i<m;i++){
    cin>>w;
    if(dp[n-1][w]==-1){
      flag=1;
      break;
    }else ans[i]=dp[n-1][w];
  }
  if(!flag)
    for(int i=0;i<m;i++) cout<<ans[i]<<endl;
  else cout<<-1<<endl;
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define each(it,v) for(auto &it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;

main()
{
        int x,a,b; cin>>x>>a>>b;
        if(abs(x-a)<abs(x-b))cout<<'A'<<endl;
        else cout<<'B'<<endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  ll n,y;
  cin>>n>>y;
  // a+b+c = n
  // 1000a + 5000b + 10000c = y
  FOR(c,0,20000){
    // a = n-c-b
    // 1000(n-c-b)+5000b+10000c = y
    // 4000b = y - 10000c - 1000n + 1000c
    ll b4000 = y - 10000ll*c - 1000ll*n + 1000ll*c;
    if(b4000%4000 != 0)continue;
    ll b = b4000 / 4000;
    ll a = n - c - b;
    if(b<0 || a<0)continue;
    printf("%lld %lld %lld\n",(ll)c,b,a);
    return 0;
  }
  puts("-1 -1 -1");
  return 0;
}


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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int n = sc.nextInt();
        int m = sc.nextInt();
        long ans = 0;
        fac = new long[m + 3];
        initFac(m + 2);
        for (int i = 0; i <= n; i++) {
            long sgn = (i % 2 == 0 ? 1 : -1);
            long toSquare = (nck(m - i, n - i) * fac[n - i]) % mod;
            long outside = (nck(m, i) * nck(n, i)) % mod;
            long total = (((outside * toSquare) % mod) * toSquare) % mod;
            total = (total * fac[i]) % mod;
            ans = (ans + sgn * total) % mod;
            if (ans < 0) ans += mod;
        }
        out.println(ans);
        out.close();
    }

    static long[] fac;
    static int mod = (int) 1e9 + 7;

    static void initFac(long n) {
        fac[0] = 1;
        for (int i = 1; i <= n; i++) {
            fac[i] = (fac[i - 1]  * i) % mod;
        }
    }

    static long exponentiation(long base, long exp)
    {
        long t = 1L;
        while (exp > 0) {

            // for cases where exponent
            // is not an even value
            if (exp % 2 != 0)
                t = (t * base) % mod;

            base = (base * base) % mod;
            exp /= 2;
        }
        return t % mod;
    }

    static long nck(int n, int k) {
        if (n < k)
            return 0;
        long den = inv((int) (fac[k] * fac[n - k] % mod));
        return fac[n] * den % mod;
    }

    static int pow(long b, int e) {
        long ans = 1;
        while (e > 0) {
            if (e % 2 == 1)
                ans = ans * b % mod;
            e >>= 1;
            b = b * b % mod;
        }
        return (int) ans;
    }

    static int inv(int x) {
        return pow(x, mod - 2);
    }



    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}

Measured memory_bytes: 37372
# coding: utf-8
h,w = gets.chomp.split(" ").map(&:to_i)
s = h.times.map{"#"+gets.chomp+"#"}.unshift("#"*(w+2)).push("#"*(w+2))
q = [[0,0]]
depth = 0
n = []
n[0] = 0
while !(q.include?([h-1,w-1]))
  depth += 1
  n[depth] = q.size
  if n[depth-1] == n[depth]
    puts -1
    exit
  end
  for i in n[depth-1]..n[depth]-1
    if s[q[i][0]+1][q[i][1]] == "."
      q.push([q[i][0],q[i][1]-1])
    end
    if s[q[i][0]+2][q[i][1]+1] == "."
      q.push([q[i][0]+1,q[i][1]])
    end
    if s[q[i][0]+1][q[i][1]+2] == "."
      q.push([q[i][0],q[i][1]+1])
    end
    if s[q[i][0]][q[i][1]+1] == "."
      q.push([q[i][0]-1,q[i][1]])
    end
  end
  q.uniq!
end
count = 0
s.each do |str|
  count += str.count("#")
end
puts (w+2)*(h+2)-count-depth-1

Measured memory_bytes: 2300
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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

using ll = long long;
using Graph = vector<vector<int>>;

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN3(n,s,t);
  int ans = 0;
  FOR(i,n,2*n+1){
    if(s.substr(n-2*n+i,2*n-i)==t.substr(0,2*n-i)){
      ans = i;
      break;
    }
  }
  OUT(ans);
}

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

typedef long long ll;

int main() {
	int r, d, x;
	cin >> r >> d >> x;
	for (int i = 0; i < 10; ++i) {
		int a = r * x - d;
		cout << a << endl;
		x = a;
	}
}



















Measured memory_bytes: 256
#include<iostream>
using namespace std;
int k,s,cnt=0;
int main(){
    cin>>k>>s;
    for(int x=0;x<=k;x++){
        for(int y=0;y<=k;y++){
            if(s-x-y>=0&&s-x-y<=k) cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;//the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the endthe end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end.the end..the end.the end.the end.the end.the end.the end.
}

Measured memory_bytes: 256
//It's time to be who I am, rather than who I am supposed to be.
#include<bits/stdc++.h>
#define int long long
#define sz(x) (int)(x.size())
using namespace std;

const int N = 1e5+10;
const int mod = 998244353;
const int inf = 1e12;
int n, k, h[N], dp[N];

int solve(int currPos){
	if(currPos <= 0)
		return inf;

	int &ans = dp[currPos];
	if(ans != inf)
		return ans;

	for(int i = 1; i <= k; i++){
		int prev = currPos - i;
		if(prev >= 1){
			ans = min(ans, solve(prev) + abs(h[prev] - h[currPos]));
		}
	}
	return ans;

}

int32_t main(){
	ios::sync_with_stdio(false);
   cin.tie(NULL); cout.tie(NULL);


    fill(dp, dp + N, inf);
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
    	cin >> h[i];

    dp[1] = 0;
    dp[2] = abs(h[2] - h[1]);

    cout << solve(n) << '\n';

}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int a[2000100],p[2000100],n;
int calc(int lim)
{
	for (int i=1;i<=2*n-1;i++) p[i]=(a[i]>lim);
	if ((p[n]==p[n-1])||(p[n]==p[n+1])) return p[n];
	int l=n-1,r=n+1;
	while ((l)&&(p[l]!=p[l+1])) l--;
	while ((r<=2*n-1)&&(p[r]!=p[r-1])) r++;
	if ((!l)&&(r!=2*n)) return p[r];
	if ((r==2*n)&&(l)) return p[l];
	if ((!l)&&(r==2*n)) return p[n]^(n&1)^1;
	if ((n-l)<(r-n)) return p[l];
	if ((n-l)>(r-n)) return p[r];
	if (p[l]==p[r]) return p[l];
	assert(0);
}	
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=2*n-1;i++) scanf("%d",&a[i]);
	int l=0,r=2*n-1;
	while (l+1!=r)
	{
		int mid=(l+r)>>1;
		if (calc(mid)==0) r=mid;else l=mid;
	}
	printf("%d\n",r);
}

Measured memory_bytes: 5120
a = [0,0,0,0,0,0]
b = [0,0,0,0]
for i in range(3):
  a[2*i],a[2*i+1] = map(int, input().split())
for i in range(6):
  for j in range(4):
    if a[i] == j+1:
      b[j] += 1
flag = 0
for i in range(4):
  if b[i] > 2:
    print("NO")
    flag = 1
if flag == 0:
  print("YES")

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<utility>
#include<set>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#define maxn 1010
#define INF 0x3f3f3f3f
#define LL long long
#define ULL unsigned long long
#define E 1e-8
#define mod 1000000007
#define P pair<int,int>
using namespace std;
//n个  长度是L
int main()
{
    int n,l;
    while(cin>>n>>l)
    {
        string s[105];
        int a[105];
        for(int i = 0 ; i < n ; i++ )
        {
            cin>>s[i];
            a[i] = (int)s[i][0];
            //cout<<a[i]<<endl;
        }
        sort(s+0,s+n);
        for(int j = 0 ; j < n ; j++ )
        cout<<s[j];
        }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
	// #ifndef ONLINE_JUDGE
	// 	// for getting input from input.txt
	// 	freopen("input.txt", "r", stdin);
	// 	// for writing output to output.txt
	// 	freopen("output.txt", "w", stdout);
	// #endif
		ll n,res=1;
		cin>>n;
		ll v[100005];
		for (int i = 0; i <n; i++)
		{	
			cin>>v[i];
			// res = res*v[i];
		}
		sort(v,v+n);
		if(v[0]==0){
		cout<<0;
		return 0;
		}

		for (int i = n-1; i >= 0; i--)
		{
			if(1000000000000000000/v[i]>=res){
				res *= v[i];
			}
			else{
				cout<<-1;
				return 0;
			}
		}
		
		cout<<res;
		
		return 0;
	}	

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

using namespace std;

typedef long long LL;

const int INF=0x3f3f3f3f;

map<int,bool> vis;

int main(){
	int n;
	scanf("%d",&n);
	bool flag=0;
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		if(vis.count(x))flag=1;
		vis[x]=1;
	}
	if(!flag)puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 9600
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
#include<set>
using namespace std;
#define ll long long int
#define all(v) begin(v), end(v)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;
using namespace std;



int main(void) {
	ll n;
	cin >> n;
	vector<ll> d(n);
	for (int i = 0; i < n; i++){
		cin >> d[i];
	}
	sort(d.begin(), d.end());
	cout << d[n/2]-d[(n/2)-1] << endl;
	return 0;
}

Measured memory_bytes: 1024
using System;

namespace abc107_c
{
	class Program
	{
		static void Main(string[] args)
		{
			string s = Console.ReadLine();
			long n = long.Parse(Console.ReadLine());
			bool onlyone = true; char first = ' ';
			for (int i = 0; i < Math.Min(s.Length, n); i++)
			{
				if (s[i] != '1')
				{
					if (first == ' ') first = s[i];
					onlyone = false;
				}
			}
			Console.WriteLine(onlyone ? '1' : first);
		}
	}
}

Measured memory_bytes: 11092
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    int N;
    cin >> N;
    VEC(int) A(N);
    READVEC(A);

    int ret = 0;
    while (true) {
        bool good = true;
        for (int& a : A)
            if (a % 2 == 0)
                a /= 2;
            else good = false;
        if (!good)
            break;
        ret++;
    }

    cout << ret << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    A = LI()

    # [0, i)の累積GCD
    gcd_cum_l = [0] * (N + 1)
    for i in range(N):
        gcd_cum_l[i+1] = math.gcd(A[i], gcd_cum_l[i])
    # [i, N)の累積GCD
    gcd_cum_r = [0] * (N + 1)
    for i in range(N - 1, -1, -1):
        gcd_cum_r[i] = math.gcd(A[i], gcd_cum_r[i+1])
    # print(gcd_cum_l)
    # print(gcd_cum_r)

    ans = 0
    for i in range(N):
        ans = max(math.gcd(gcd_cum_l[i], gcd_cum_r[i+1]), ans)

    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 22016
n=int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

ans = 0

for i in range(len(a)):
    ans +=b[a[i]-1]

    
    if(i != 0):

        if(a[i]-1 == a[i-1]):
            ans += c[a[i-1]-1]


print(ans)

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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

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

  vector<ll> a(n);
  for (auto &x : a) {
    cin >> x;
  }

  ll count = 0;
  bool loop = true;
  while (loop) {
    for (auto &x : a) {
      if (x % 2 != 0) {
        loop = false;
        break;
      }
      x /= 2;
    }
    if (loop) {
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n, m;
int a[1000];
int b[1000];

int main() {
	while (cin >> n >> m&&n + m) {
		int suma = 0, sumb = 0;
		rep(i, n) {
			cin >> a[i];
			suma +=a[i];
		}
		rep(i, m) {
			cin >> b[i];
			sumb += b[i];
		}
		ll sum = INF;
		ll ansa = -1, ansb = -1;
		rep(i, n) {
			rep(j, m) {
				if (suma - a[i] + b[j] == sumb - b[j] + a[i]) {
					if (sum > a[i] + b[j]) {
						sum = a[i] + b[j];
						ansa = a[i];
						ansb = b[j];
					}
				}
			}
		}
		if (ansa == -1)cout << -1 << endl;
		else cout << ansa << " " << ansb << endl;
	}
}


Measured memory_bytes: 3100
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static void Main(string[] args)
        {
            int N = ReadInt();
            var S = Read();
            int cnt = 0;
            for (int i = 0; i + 3 <= N; ++i)
            {
                if (S.Substring(i, 3) == "ABC") { ++cnt; }
            }
            Console.WriteLine(cnt);
        
        }
    }
}


Measured memory_bytes: 13140
import sys
input = sys.stdin.readline


def read():
    S = input().strip()
    return S,


def solve(S):
    N = len(S)
    ans = 1000
    for i in range(N-2):
        s = int(S[i:i+3])
        ans = min(ans, abs(s - 753))
    return ans


if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(obj) (obj).begin(),(obj).end()
typedef long long ll;
ll mod=2e12;
ll cnt=0;
#define max 100005
#define nil -1
//8.4
struct data{int l,r,p;};
struct data T[max];
void Preorder(int r){
  if(r==nil) return;
  cout<<" "<<r;
  Preorder(T[r].l);
  Preorder(T[r].r);
  return;
}

void Inorder(int r){
  if(r==nil)return;
  Inorder(T[r].l);
  cout<<" "<<r;
  Inorder(T[r].r);
  return;
}

void Postorder(int r){
  if(r==nil) return;
  Postorder(T[r].l);
  Postorder(T[r].r);
  cout<<" "<<r;
}
int main(){
    int n,d,r,l;
    cin>>n;
    for(int i=0;i<n;i++) T[i].p=T[i].l=T[i].r= nil;
    for(int j=0;j<n;j++){
        cin>>d>>l>>r;
        T[d].l=l;
        T[d].r=r;
        if(l!=nil)T[l].p=d;
        if(r!=nil)T[r].p=d;
    }
    for(int i=0;i<n;i++){
        if(T[i].p==nil) r=i;
    }
    cout<<"Preorder"<<endl;
    Preorder(r);
    cout<<endl<<"Inorder"<<endl;
  Inorder(r);
  cout<<endl<<"Postorder"<<endl;
  Postorder(r);
  cout<<endl;
   return 0;
}



Measured memory_bytes: 3084
n = int(input())
a = list(map(int,input().split()))
c = 0
s = 0
ma = 10**6
for i in a:
    if i<0:
        c+=1
        c%=2
    s += abs(i)
    ma = min(ma,abs(i))
if c == 1:
    print(s-2*ma)
else:
    print(s)


Measured memory_bytes: 20000
#include <iostream>
#include <cstring>


using namespace std;

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

 if((s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2])||(s[0]==s[2]&&s[1]==s[3]&&s[0]!=s[1])||(s[0]==s[3]&&s[2]==s[1]&&s[0]!=s[2])){  
 cout << "Yes" << endl;
 }else{
 cout << "No" << endl;  
 }  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep for(int i = 0;i<n;i++)
#define ll long long
 
//const int INF = 1e8;
const int MOD = 1000000007;
int dx[4] = {1,0,-1,0};int dy[4] = {0,1,0,-1};

int main(){
  int n;string s;cin >> n >> s;
  vector<int> al(26,0);
  vector<int> bl={};
  rep{
    int q = s.at(i) - 'a';
    al[q] += 1;
  }
  for(int i = 0;i<26;i++){
    if(al[i]>0){
      bl.push_back(al[i]);
    }
  }
  /* for(int i = 0;i<bl.size();i++){
    cout << bl[i] << " ";
  }cout << endl;*/
  ll ans = 1;
  for(int i = 0;i<bl.size();i++){
    ans = (ans*(bl[i]+1))%MOD;
  }
  cout << ans-1<< endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long n;
    int i;
    cin>>n;
    for(i=(int)sqrt(n);i>=1;i--){
        if(n%i==0){
            cout<<max(to_string(i).size(),to_string(n/i).size())<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define mp make_pair
#define ll long long
#define pb push_back

void solve()
{
  long long s;
  cin>>s;

  vector<long long>dp(s+1,0LL);

  int i,j;

  long long hell = 1e9+7;
  
  if(s<=2)
  {
      cout<<0<<endl;
      return;
  }
  if(s<=5)
  {
      cout<<1<<endl;
      return;
  }

  dp[3] = 1;
  dp[4] = 1;
  dp[5] = 1;

  for(i=6;i<=s;i++)
  {
      for(j=i-3;j>=0;j--)
        dp[i] = (dp[i] + dp[j])%hell;

      dp[i] = (dp[i]+1LL)%hell;
  }
  cout<<dp[s]<<endl;

}

int main()
{
    int t = 1;
    //cin>>t;

    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pii pair<int,int>
const long long MOD=1000000007;

int main(){
    string s;
    cin>>s;
    bool ans=true;
    rep(i,s.size()){
        if(i%2==0 && s[i]=='L') ans=false;
        if(i%2==1 && s[i]=='R') ans=false;
    }
    if(ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

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

  map<int, int> counter;
  for(int i=0;i<N;i++) {
    int a;
    cin >> a;
    counter[a]++;
  }

  int ans = N;
  for(auto it=counter.begin();it!=counter.end();it++) {
    if(it->second % 2 == 0) ans -= it->second;
    else ans -= it->second - 1;
  }

  cout << ans << endl;
}

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

string str;

int main(void) {
    cin >> str;
    for (int i = 0; i < str.size(); i++) {
        if(i % 2 == 1) continue;
        cout << str[i];
    }
    cout << '\n';
    return 0;
}

Measured memory_bytes: 512
//Longest Common Subsequence
#include <iostream>
#include <string>

using namespace std;

static const int N = 1000;

int lcs(string s1, string s2) {
    int l1 = s1.length(), l2 = s2.length();
    int dp[l1+1][l2+1];
    for(int i=0; i<l1+1; i++) dp[i][0] = 0;
    for(int j=0; j<l2+1; j++) dp[0][j] = 0;

    for(int i=1; i<l1+1; i++) {
        for(int j=1; j<l2+1; j++) {
            if(s1[i-1] == s2[j-1]) dp[i][j] = dp[i-1][j-1]+1;
            else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }
    return dp[l1][l2];
}

int main() {
    string s1, s2;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> s1 >> s2;
        cout << lcs(s1, s2) << endl;
    }
}


Measured memory_bytes: 7064
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int n;
  cin >> n;
  int ac, wa, tle, re;
  ac = 0;
  wa = 0;
  tle = 0;
  re = 0;

  REP(i,n){
    string s;
    cin >> s;
    if(s == "AC") ++ac;
    if(s == "WA") ++wa;
    if(s == "TLE") ++tle;
    if(s == "RE") ++re;
  }
  cout << "AC" << " x " << ac << endl;
  cout << "WA" << " x " << wa << endl;
  cout << "TLE" << " x " << tle << endl;
  cout << "RE" << " x " << re << endl;


  return 0;
}


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

int n, m;
int ans[110][110];

int C;
int cc[10010];
int ci;

int fecth(){
	while(cc[ci] == 0) ++ci;
	--cc[ci];
	return ci;
}

int main()
{
	read(n, m, C);
	for(int i=1; i<=C; ++i) read(cc[i]);
	ci=1;
	for(int i=1; i<=n; ++i){
		if(i%2==1){
			for(int j=1; j<=m; ++j)
				ans[i][j] = fecth();
		} else {
			for(int j=m; j>=1; --j)
				ans[i][j] = fecth();
		}
	}
	for(int i=1; i<=n; ++i){
		for(int j=1; j<=m; ++j) printf("%d ", ans[i][j]);
		putchar(10);
	}
	return 0;
}


Measured memory_bytes: 384
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Program
{
    public class ABC085D
    {
        static public void Main(string[] args)
        {
            var N = NextInt;
            var H = NextLong;
            var count = 0;
            var sum = 0L;
            var aary = new long[N];
            var bary = new long[N];
            for (int i = 0; i < N; ++i)
            {
                aary[i] = NextLong;
                bary[i] = NextLong;
            }
            Array.Sort(bary);
            bary = bary.Reverse().ToArray();
            var maxa = aary.Max();
            foreach (var item in bary.Where(e => e > maxa))
            {
                sum += item;
                ++count;
                if (sum >= H)
                {
                    Console.Write(count);
                    return;
                }
            }
            Console.WriteLine(count + (H - sum - 1) / maxa + 1);
        }

        static class Console_
        {
            private static Queue<string> param = new Queue<string>();
            public static int NextInt() => int.Parse(NextString());
            public static long NextLong() => long.Parse(NextString());
            public static string NextString()
            {
                if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item);
                return param.Dequeue();
            }
        }
        static int NextInt => Console_.NextInt();
        static long NextLong => Console_.NextLong();
        static string NextString => Console_.NextString();

        static IEnumerable<int> Prime(int x)
        {
            if (x < 2) yield break;
            yield return 2;
            var halfx = x / 2;
            var table = new bool[halfx + 1];
            var max = (int)(Math.Sqrt(x) / 2);
            for (int i = 1; i <= max; ++i)
            {
                if (!table[i])
                {
                    var add = 2 * i + 1;
                    yield return add;
                    for (int j = 2 * i * (i + 1); j <= halfx; j += add)
                    {
                        table[j] = true;
                    }
                }
            }
            for (int i = max + 1; i <= halfx; ++i)
            {
                if (!table[i]) yield return 2 * i + 1;
            }
        }
    }
}


Measured memory_bytes: 20428