akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,m;
    cin>>n>>m;
    if(!n)return;
    vi ca(n),cb(m);
    rep(i,n)cin>>ca[i];
    rep(i,m)cin>>cb[i];
    int sa=0,sb=0;
    rep(i,n)sa+=ca[i];
    rep(i,m)sb+=cb[i];
    int mi=inf;
    int ansa,ansb;
    rep(i,n){
        rep(j,m){
            if(sa-ca[i]+cb[j]==sb-cb[j]+ca[i]){
                if(mi>ca[i]+cb[j]){
                    mi=ca[i]+cb[j];
                    ansa=ca[i];
                    ansb=cb[j];
                }
            }
        }
    }
    if(mi==inf)cout<<-1<<endl;
    else cout<<ansa<<sp<<ansb<<endl;
    run();
}


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

bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd11(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int ab(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
int main(){
  string s;
  cin >>s;
  int count =0,ans =0;
  for(int i =0 ; i<s.size() ; i++){
    if(s[i]=='A' || s[i]=='G' || s[i]=='C' || s[i]=='T'){
      count ++;
    }
    else{
      count =0;
    }
    
    ans = max(ans ,count);
  }
  cout <<ans <<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>
#include <numeric>

using namespace std;
typedef long long int ll;
typedef long double ld;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }                   // 最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); };                      // 最小公倍数
ll getDigit(ll num) { return log10(num) + 1; }                         // 桁数
ll digitSum(ll n) { return (n < 10) ? n : digitSum(n / 10) + n % 10; } // 各桁の和
#define pb push_back
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repn(i, n) for (ll i = 1; i <= n; i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define all(x) (x).begin(), (x).end()

void Main()
{
    int n;
    cin >> n;
    vector<int> t(n);
    rep(i, n) cin >> t[i];
    int m;
    cin >> m;
    vector<int> p(m);
    vector<int> x(m);
    rep(i, m) cin >> p[i] >> x[i];

    rep(i, m)
    {
        vector<int> tmp = t;
        tmp[p[i] - 1] = x[i];
        cout << accumulate(all(tmp), 0) << endl;
    }

    return;
}

signed main(void)
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
Scanf.scanf "%d" (fun n ->
    let t = Array.init n (fun _ -> Scanf.scanf " %d" (fun t -> t)) in
    let rec gcd a b = if b = 0 then a else gcd b (a mod b) in
    let lcm a b = a / gcd a b * b in

    let rec loop i acc =
        if i = n then acc else loop (i + 1) (lcm acc t.(i))
    in
    loop 1 t.(0) |> Printf.printf "%d\n"
)

Measured memory_bytes: 3824
#include <iostream>
#include <string>
#include <queue>

struct TProcess
{
    std::string Name;
    int Time;
};
typedef std::queue<TProcess> TProcessList;
TProcessList InputProcessList(std::istream& Input, int N)
{
    TProcessList List;
    for(int i = 0; i < N; ++i){
        TProcess P;
        Input >> P.Name >> P.Time;
        List.push(P);
    }
    return List;
}
int main()
{
    int N, Q;
    std::cin >> N >> Q;
    int Time = 0;
    TProcessList List = InputProcessList(std::cin, N);
    while(List.empty() == false){
        TProcess P = List.front(); List.pop();
        if(P.Time <= Q){
            Time += P.Time;
            std::cout << P.Name << " " << Time << std::endl;            
        }else{
            Time += Q;
            P.Time -= Q;
            List.push(P);
        }
    }
}

Measured memory_bytes: 4404
import numpy as np

x, y, a, b, c = map(int, input().split())
p = np.array(list(map(int, input().split())))
q = np.array(list(map(int, input().split())))
r = np.array(list(map(int, input().split())))

p = np.sort(p)[::-1][:x]
q = np.sort(q)[::-1][:y]
a = np.hstack((p, q, r))
a = np.sort(a)[::-1][:(x+y)]

print(np.sum(a))

Measured memory_bytes: 24840
#include <iostream>
#define ll long long
using namespace std;
int main(){
    ll N; scanf("%lld", &N);
    // 26 26 * 26 26 * 26 * 26
    ll pre[12] = {0};
    ll sum = 26;
    for(int i = 1; i <= 11; i++){
        pre[i] = pre[i - 1] + sum;
        sum = sum * 26;
    }
    int cur = 11;
    // pre[i - 1] + 1 ~ pre[i]
    // a = 0
    while(N < pre[cur] + 1){
        cur--;
    }
    N -= pre[cur];
    --N;
    int stk[13];
    for(int i = 1; i <= cur + 1; i++){
        stk[i] = N % 26;
        N /= 26;
    }
    for(int i = cur + 1; i >= 1; i--){
        printf("%c", (char)('a' + stk[i]));
    }
    return 0;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
    string s;  cin >> s;
    int Q;  cin >> Q;
    vector<char> h, b;
    bool is_reverse = false;
    for(int i = 0 ; i < Q ; i++){
      int T;  cin >> T;
      if(T == 1){  is_reverse = ((is_reverse) ? false : true);  continue;  }
      else if(T == 2){
        
        int F;  char C;  cin >> F >> C;
        if(is_reverse == false){
          if(F == 1)  h.insert(h.begin(), C);
          else        b.push_back(C);
        }else{
          if(F == 1)  b.push_back(C);
          else        h.insert(h.begin(), C);
        }
      }

    }

    if(is_reverse == false){
      for(int i = 0 ; i < h.size() ; i++)  cout << h[i];
      cout << s;
      for(int i = 0 ; i < b.size() ; i++)  cout << b[i];
      cout << endl;
    }else{
      for(int i = b.size() - 1 ; 0 <= i ; i--) cout << b[i];
      for(int i = s.length() - 1 ; 0 <= i ; i--)  cout << s[i];
      for(int i = h.size() - 1 ; 0 <= i ; i--) cout << h[i];
      cout << endl;
    }

	return 0;
}

Measured memory_bytes: 976
// 要復習

#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG

int main()
{
    int64_t n;
    cin >> n;
    int64_t a[n], b[n];
    for (int64_t i = 0; i < n; i++)
    {
        cin >> a[i];
        b[i] = a[i];
    }
    //positive-negative-positive... case
    int64_t case1, total;
    if (a[0] > 0)
    {
        case1 = 0;
        total = a[0];
    }
    else //if (a[0] <= 0)
    {
        case1 = abs(1 - a[0]);
        total = 1;
    }
    for (int64_t i = 1; i < n; i++)
    {
        int64_t ttmp = total + a[i];
        int64_t atmp = a[i];
        if ((ttmp * total) < 0 && ttmp != 0)
        {
            total = ttmp;
        }
        else
        {
            if (total > 0)
            {
                a[i] = -total - 1;
            }
            else
            {
                a[i] = -total + 1;
            }
            total += a[i];
        }
        case1 += abs(a[i] - atmp);
    }

    //negative-positive... case
    int64_t case2;
    if (b[0] < 0)
    {
        case2 = 0;
        total = b[0];
    }
    else //if (a[0] >= 0)
    {
        case2 = abs(-1 - b[0]);
        total = -1;
    }
    for (int64_t i = 1; i < n; i++)
    {
        int64_t ttmp = total + b[i];
        int64_t atmp = b[i];
        if ((ttmp * total) < 0 && ttmp != 0)
        {
            total = ttmp;
        }
        else
        {
            if (total > 0)
            {
                b[i] = -total - 1;
            }
            else
            {
                b[i] = -total + 1;
            }
            total += b[i];
        }
        case2 += abs(b[i] - atmp);
    }
    cout << min(case1, case2) << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long int ll;

ll a, b, c, d, e;
ll N, H, K, W;
ll dp[100001];
ll h[100001];
void input()
{
    cin >> N;

    for (int i = 0; i <= N; i++)
    {
        if (i == 0)
        {
            h[i] = 0;
        }
        else
        {
            int hi;
            cin >> hi;
            h[i] = hi;
        }
    }
}
void solve()
{

    for (int i = 1; i <= N; i++)
    {
        if (i == 1)
        {
            dp[i] = 0;
        }
        else if (i == 2)
        {
            dp[i] = abs(h[i] - h[i - 1]);
        }
        else
        {
            ll cost1 = abs(h[i] - h[i - 1]);
            ll cost2 = abs(h[i] - h[i - 2]);
            dp[i] = min(dp[i - 1] + cost1, dp[i - 2] + cost2);
        }
    }
}

int main()
{
    input();
    solve();
    cout << dp[N] << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;  
#include <bits/stdc++.h> 
using namespace std; 

int comp(const void* a, const void* b) 
{ return *(int*)a > *(int*)b ; } 
 
int findNumberOfTriangles(int arr[], int n) 
{ 
	qsort(arr, n, sizeof( arr[0] ), comp); 

	int count = 0; 

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

		for (int j = i + 1; j < n; ++j) 
		{  
			while (k < n && arr[i] + arr[j] > arr[k]) 
			++k; 
			if(k > j) 
			count += k - j - 1; 
		} 
	} 

	return count; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    int n;
    cin>>n;
    int a[n];
    for(int i=0; i<n; i++)cin>>a[i];
    cout<<findNumberOfTriangles(a, n)<<endl;
    
    return 0;
}

Measured memory_bytes: 380
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();

            int N = int.Parse(line);
            line = Console.ReadLine();
            string[] strs = line.Split(' ');
            List<int> A = new List<int>(); //フレンドリーさ
            for(int i = 0; i < N; i++)
            {
                A.Add(int.Parse(strs[i]));
            }
            int[] ArrayA = A.OrderByDescending(x => x).ToArray();

            long sum = 0;

            int next = 0;
            for(int i = 0; i < N;i++)
            {
                if (i == 0) continue;
                sum += ArrayA[next];
                //偶数回目は見る場所を変える
                if (i % 2 == 1) next++;

            }

            Console.WriteLine(sum);
        }
    }
}


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

int main()
{
    int num, con;
    cin >> num >> con;
    vector<int> v;
    for (int i = 0; i < num; i++)
    {
        int a;
        cin >> a;
        v.push_back(a);
    }
    
    sort(v.begin(), v.end());
    
    int sum = 0;
    for (int i = 0; i < con; i++)
    {
        sum += v.back();
        v.pop_back();
    }
    
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
double D[80]; int d;

double pop_n(){
  return (D[--d]);}
void push_n(double a) {
  D[d]=a; d++;
}

int main() {
  char inbuf[99];
  while (gets(inbuf)) {
    char *tp = strtok(inbuf, " \n");
    while (tp != NULL) {
      double a,b;
      if ((tp[0] == '+') && (tp[1]==0)) {
        b = pop_n(); a = pop_n();
        push_n(a+b);
      }
      else if (tp[0] == '*') {
        b = pop_n(); a = pop_n();
        push_n(a*b);
      }
      else if ((tp[0] == '-') && (tp[1]==0)) {
        D[d-2]=D[d-2]-D[d-1];
        d--;
        //      b = pop_n(); a = pop_n();
        //      push_n(a-b);
      }
      else if (tp[0] == '/') {
        b = pop_n(); a = pop_n();
        push_n(a/b);
      }
      else {
        D[d++]=atof(tp);
      }
      tp = strtok(NULL, " \n");
    }
    printf("%.6lf\n",pop_n());
  }
  return 0;
}

Measured memory_bytes: 580
import sys
from collections import defaultdict


sys.setrecursionlimit(10 ** 6)


def main():
    MOD = 10 ** 9 + 7
    N = int(input())
    adj_nodes = defaultdict(list)
    for _ in range(N - 1):
        x, y = list(map(int, input().split(' ')))
        x -= 1
        y -= 1
        adj_nodes[x].append(y)
        adj_nodes[y].append(x)
    dp_b = [0 for _ in range(N)]
    dp_w = [0 for _ in range(N)]

    def bfs(node, parent):
        black = 1
        white = 1
        for child in adj_nodes[node]:
            if child == parent:
                continue
            bfs(child, node)
            black *= dp_w[child]
            white *= dp_b[child] + dp_w[child]
            black %= MOD
            white %= MOD
        dp_b[node] = black
        dp_w[node] = white

    bfs(0, None)
    print((dp_b[0] + dp_w[0]) % MOD)


if __name__ == '__main__':
    main()

Measured memory_bytes: 131124
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from functools import *
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def Golf():
    *a,=map(int,open(0))
def S_():
    return input()
def IS():
    return input().split()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2)
    found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()
 
def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a
 
show_flg=False
show_flg=True
 
ans=0

n,k=LI()
a=[(1+i)/2 for i in LI()]
ac=[0]
for i in range(n):
    ac+=[ac[-1]+a[i]]

for i in range(n-k+1):
    ans=max(ac[i+k]-ac[i],ans)

print(ans)

Measured memory_bytes: 79364
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

a = -(-N//A)
b = -(-N//B)
c = -(-N//C)
d = -(-N//D)
e = -(-N//E)

ans = 5 + max(a,b,c,d,e) - 1

print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			String a = sc.next();
			String b = sc.next();
			String c = sc.next();

			if (a.endsWith(b.substring(0, 1)) && b.endsWith(c.substring(0, 1))) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}

		} finally {
			sc.close();
		}
	}
}

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

int main() {
  
  bool bingo = 0;
  
  int N;

  
vector<int> vec(9);
for (int i = 0; i < 9; i++) {
  cin >> vec.at(i);
}
  cin >> N;   
  int b;

 for (int j = 0; j < N; j++) {
  cin >> b;
         //cout << b << endl;
  for (int i = 0; i < 9; i++) {
 	if ( b == vec.at(i) ) {
  	vec.at(i) = 0; 
//      cout << b << endl;
 	}
 	//else continue;
    //      cout << b << endl;
  	} 
 }

  if (vec.at(1) == 0 && vec.at(4)== 0 && vec.at(7) == 0) {
   bingo = true; 
  }
  else if (vec.at(2) == 0 && vec.at(5)== 0 && vec.at(8) == 0) {
   bingo = true; 
  }    
  else if (vec.at(0) == 0 && vec.at(3)== 0 && vec.at(6) == 0) {
   bingo = true; 
  }     
  else if (vec.at(0) == 0 && vec.at(1)== 0 && vec.at(2) == 0) {
   bingo = true; 
  }      
  else if (vec.at(3) == 0 && vec.at(4)== 0 && vec.at(5) == 0) {
   bingo = true; 
  }    
  else if (vec.at(6) == 0 && vec.at(7)== 0 && vec.at(8) == 0) {
   bingo = true; 
  }      
  else if (vec.at(0) == 0 && vec.at(4)== 0 && vec.at(8) == 0) {
   bingo = true; 
  }     
  else if (vec.at(2) == 0 && vec.at(4)== 0 && vec.at(6) == 0) {
   bingo = true; 
  }     
  else bingo = false;
  
//for (int i = 0; i < 9; i++) {
//  cout << vec.at(i) << " ";
//}  
  
 if (bingo) { 
  cout << "Yes" << endl;
 }
  else cout << "No" << endl;
}


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

int main() {
    long long n;
    cin>>n;
    int arr[26];
    for(int i=0;i<26;i++){
    arr[i]=0;
        
        
    }
    for(int i=0;i<n;i++)
    {
        
        string s;
        cin>>s;
        arr[s[0]-65]++;
        
    
    }
     long long ar[5];
     ar[0]=arr['M'-65];
      ar[1]=arr['A'-65];
       ar[2]=arr['R'-65];
        ar[3]=arr['C'-65];
            ar[4]=arr['H'-65];
        long long sum=0;
        for(int i=0;i<3;i++)
        {
           for(int j=i+1;j<4;j++)
        {
            
            for(int k=j+1;k<5;k++)
        {
            sum+=ar[i]*ar[j]*ar[k];
        }
        } 
            
        }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int i, N, a, b, c, A, B, C;

int print(void)
{
    if (C == A + B) {
        printf("YES\n");
    } else if (A == B + C) {
        printf("YES\n");
    } else if (B == C + A) {
        printf("YES\n");
    } else {
        printf("NO\n");
    }
}

int main(void)
{
    scanf("%d", &N);
    for (i = 0; i < N; i++) {
    scanf("%d %d %d\n", &a, &b, &c);
    A = a * a;
    B = b * b;
    C = c * c;
    print();
    }
    return 0;
}

Measured memory_bytes: 1012
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>

using namespace std;
typedef long long int ll;

int main(){

    string S;
    cin >> S;

    bool k = true;
     bool g = true;
    for(ll i = 1; i <= S.length(); i++){
        if(i % 2 == 0){
            if(S[i-1] == 'R'){
                g = false;
            }
        }else{
            if(S[i-1] == 'L'){
                k = false;
            }        
        }
    }

    if(k == true && g == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    


} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

class MergeSortTree {
    vector<vector<int>> tree;
    vector<int>& A;
    int idx_begin, idx_end;


    int left(int i) { return 2 * i; }
    int right(int i) { return 2 * i + 1; }

    void merge(int s1, int s2, int dest) {
        vector<int>& v1 = tree[s1];
        vector<int>& v2 = tree[s2];
        vector<int>& vdest = tree[dest];
        vdest.resize(v1.size() + v2.size());

        int j1 = 0, j2 = 0;
        for(int i = 0; i < vdest.size(); ++i) {
            if(j1 >= v1.size())       vdest[i] = v2[j2++];
            else if(j2 >= v2.size())  vdest[i] = v1[j1++];
            else if(v1[j1] <= v2[j2]) vdest[i] = v1[j1++];
            else                      vdest[i] = v2[j2++];
        }
    }

    void build(int node, int l, int r) {
        // [l, r] inclusive
        if(tree.size() <= node) tree.resize(node + 1);
        if(l == r) {
            tree[node] = { A[l] };
            return;
        }

        int mid = (l + r) / 2;
        build(left(node), l, mid);
        build(right(node), mid + 1, r);
        merge(left(node), right(node), node);
    }

    int hmlt(int x, int l, int r, int node, int start, int end) {
        // answer to the query of (x, l, r)
        if(l > end || r < start) return 0;
        if(l <= start && end <= r) {
            return (upper_bound(tree[node].begin(), tree[node].end(), x) - tree[node].begin());
        }

        int mid = (start + end) / 2;
        return hmlt(x, l, r, left(node), start, mid) + hmlt(x, l, r, right(node), mid + 1, end);
    }

public:
    MergeSortTree(vector<int>& A, int idx_begin, int idx_end)
    : A(A), idx_begin(idx_begin), idx_end(idx_end) {
        // create tree from idx_begin to idx_end in the array A
        // in other words create merge sort tree of this part of array
        assert(A.size() > 0);
        tree.resize(2);
        build(1, idx_begin, idx_end); // building 1 based tree
    }
    
    int greater(int x, int l, int r) {
        // with the assumption that l and r are in range of A
        // return how many numbers are greater than x in the range of [l, r] in O(lg(n) * lg(n))
        return hmlt(x, l, r, 1, idx_begin, idx_end);
    }
};

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, m, q;
    cin >> n >> m >> q;
    vector<pair<int, int>> a(m);
    for(int i = 0; i < m; ++i) {
        cin >> a[i].fi >> a[i].se;
    }
    sort(a.begin(), a.end());
    vector<int> b(m);
    for(int i = 0; i < m; ++i) {
        b[i] = a[i].se;
    }
    MergeSortTree mst(b, 0, m - 1);
    while(q--) {
        int ql, qr;
        cin >> ql >> qr;
        int i = lower_bound(a.begin(), a.end(), make_pair(ql, -1)) - a.begin();
        cout << mst.greater(qr, i, m - 1) << '\n';
    }
}


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

public class Main {
	static int mod = (int)1e9+7;
	static Comparator<Integer> lower_bound = (x, y) -> x.compareTo(y) >= 0 ? 1 : -1;
	static Comparator<Integer> upper_bound = (x, y) -> x.compareTo(y) > 0 ? 1 : -1;

	public static void main(String[] args){
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc,out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		out.println(Math.min(a+b, Math.min(b+c, a+c)));
	}

	public static long gcd(long a, long b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}

	public static long lcm(long a, long b) {
		return a / gcd(a, b) * b;
	}

	public static long factorial(int n) {
		long a;

		if(n > 0) {
			a = n * factorial(n - 1);
		}else{
			a = 1;
		}
		return a;
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(K key, V value) {
        super(key, value);
    }

    public Pair<V, K> swap() {
    	return new Pair<V, K>(getValue(), getKey());
    }
 }

class UnionFind {
	int[] par;

	public UnionFind(int n) {
		par = new int[n];

		Arrays.fill(par, -1);
	}

	int root(int x) {
		if(par[x] < 0) return x;
		return par[x] = root(par[x]);
	}

	boolean unite(int x,int y) {
		x = root(x);
		y = root(y);

		if(x == y) return false;

		if(size(x) < size(y)) {
			int tmp = x;
			x = y;
			y = tmp;
		}

		par[x] += par[y];
		par[y] = x;

		return true;
	}

	boolean same(int x,int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}

	int size(int a) {
		return -par[root(a)];
	}
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 26580
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    int ans=1e6+1;
    for(int i=0;i<=s.length()-t.length();i++)
    {
        int ind=i;
        int ind2=0;
        int cur=0;
        while(ind2<t.length())
        {
            if(s[ind]!=t[ind2])
                cur++;
            ind++;
            ind2++;
        }
        ans=min(ans,cur);
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3628
n = int(input())
l = [list(map(int, input().split())) for _ in range(n)]
m = 0
for i in range(n-1,-1,-1):
  l[i][0] += m
  m += (l[i][1]-(l[i][0]%l[i][1]))%l[i][1]
print(m)

Measured memory_bytes: 31348
#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(){
    string s;
    int q;
    cin >> s >>q;
    deque<char> ans;
    int flag = 0;
    rep(i,s.size()) ans.push_back(s[i]);
    rep(i,q){
        int com;
        cin >> com;
        if(com==1) flag=1-flag;
        else{
            int f; char c;
            cin >> f >> c;
            if(flag)if(f==1) ans.push_back(c);
                    else ans.push_front(c);
            else if(f==1) ans.push_front(c);
                    else ans.push_back(c);
        }
    }
    if (flag){
        while(!ans.empty()){
            cout << ans.back();
            ans.pop_back();
        }
    }
    else{
        while(!ans.empty()){
            cout << ans.front();
            ans.pop_front();
        }
    }
    cout << endl;

}

Measured memory_bytes: 896
/*
ITP1_11_B
Dice 2

*/

#include<stdio.h>
#include<string.h>

struct DICE
{
  int *state;
  int *label;
};

int main(){
  int inistate[6][6] = {{1,3,4,2,5,6},{4,1,6,2,5,3},{6,4,3,2,5,1},
  {3,6,1,2,5,4},{6,2,5,3,4,1},{6,5,2,4,3,1}};
  ///{上,E,W.S,N,下}
  int label[6] = {1,2,3,4,5,6};
  struct DICE dice = {inistate[0],label};
  int i,j,k,x,y,q,ans,temp;
  for(i=0;i<6;i++){
    scanf("%d",&dice.label[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d %d", &x,&y);
    for(j=0;j<6;j++){
      dice.state = inistate[j];
      for (k=0;k<4;k++){
        temp = dice.state[0];
        dice.state[0] = dice.state[4];
        dice.state[4] = dice.state[5];
        dice.state[5] = dice.state[3];
        dice.state[3] = temp;
        if (x==dice.label[dice.state[0]-1] && y==dice.label[dice.state[3]-1]){
          ans = dice.label[dice.state[1]-1];
        }
      }
    }
    printf("%d\n",ans);
  }

  return 0;
}


Measured memory_bytes: 2060
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};
long double eps = 1e-6;
long double pi = acos(-1);

template< int mod = 1000000007 >
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {
        if((x += p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p) {
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p) {
        x = (int) (1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const {
        ModInt ret(1), mul(x);
        while(n > 0) {
            if(n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }

    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt< mod >(t);
        return (is);
    }

    static int get_mod() { return mod; }
};

// const int mod = 998244353;
using mint = ModInt<>;
mint dp[51][51][2501];
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int n,k;
    cin>>n>>k;
    dp[0][0][0] = 1;
    for(int i=0;i<n;i++){
        for(int rem=0;rem<=i;rem++){
            for(int cost=0;cost<=k;cost++){
                mint x = dp[i][rem][cost];
                int ncost = cost+2*rem;
                if(rem&&(ncost-2)<=k) dp[i+1][rem-1][ncost-2] += mint(rem*rem)*x;
                if(ncost > k)continue;
                if((ncost+2)<=k && i!=n-1)dp[i+1][rem+1][ncost+2] += x;
                dp[i+1][rem][ncost] += x;
                if(i!=n-1 && rem) dp[i+1][rem][ncost] += mint(2*rem) * x;
            }
        }
    }
    mint ans = dp[n][0][k];
    cout << ans << endl;
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll N;
  cin >> N;
  bool ok = false;
  for (ll a=1; a<=9; a++)
    for (ll b=1; b<=9; b++)
      if (a*b == N)
        ok = true;
  cout << (ok ? "Yes" : "No") << endl;
}


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

using namespace std;

using ll = long long;

const long long MOD = 1e9 + 7;
const int INF = 1e9 + 7;

vector<int> koho;

void dfs(int n, const string& nums, string s) {
    if (n == 0) {
        if (s.size() > 0) koho.push_back(stoi(s));
        return;
    }
    dfs(n - 1, nums, s);
    for (char c : nums) dfs(n - 1, nums, s + c);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<bool> num(10, true);
    for (int i = 0; i < K; ++i) {
        int d;
        cin >> d;
        num[d] = false;
    }
    string nums;
    for (int i = 0; i < 10; ++i) {
        if (num[i]) nums += to_string(i);
    }
    dfs(5, nums, "");
    int ans = 0;
    for (int i : koho) {
        if (i >= N) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 892
local function range(b, e)
  if not e then
    e = b
    b = 1
  end
  local t = {}
  for i=1,e-b+1 do
    t[i] = b+i-1
  end
  return t
end

local function all(t, f)
  for k,v in pairs(t) do
    if not f(v) then
      return false
    end
  end
  return true
end

local function map(t, f)
  local nt = {}
  for k,v in pairs(t) do
    nt[k] = f(v)
  end
  return nt
end

local N = {}
N[1], N[2] = io.read("n", "n", "l")
local A = {}
for h=1,N[1] do
  A[h] = {}
  for w=1,N[2] do
    local a = io.read(1)
    A[h][w] = a
  end
  io.read("l")
end
local function a(p, q, s)
  if s == 1 then
    return A[p][q]
  else
    return A[q][p]
  end
end

local range = {range(N[1]), range(N[2])}
local function create_R(x)
  local y = x % 2 + 1
  local function filter(p)
    local function check(q)
      return a(p,q,x) == '.'
    end
    return all(range[y], check)
  end
  return map(range[x], filter)
end
local R = {}

R[1] = create_R(1)
R[2] = create_R(2)

for h=1,N[1] do
  if not R[1][h] then
    for w=1,N[2] do
      if not R[2][w] then
        io.write(a(h,w,1))
      end
    end
    print()
  end
end

Measured memory_bytes: 2920
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for(long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for(long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                                                            \
    (upper_bound((V).begin(), (V).end(), X) -                                  \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                                                               \
    {                                                                          \
        cerr << #v << ':';                                                     \
        for(auto xv : v) cerr << xv << ' ';                                    \
        cerr << endl;                                                          \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2> inline bool chmin(T1 &a, const T2 &b) {
    if(a > b) a = b;
    return a > b;
}
template <typename T1, typename T2> inline bool chmax(T1 &a, const T2 &b) {
    if(a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* liblary */

/* main */

bool hasSubSequence(const string &subseq, const string &s) {
    int index = 0;
    for(int i = 0; i < s.size() && index < subseq.size(); i++) {
        if(s[i] == subseq[index]) index++;
    }
    return index == subseq.size();
}

bool solve(const string &target, const string &first, const string &second) {
    string s = "", t = "";
    for(int i = 0; i < target.size(); i++) {
        (i % 2 ? s : t) += target[i];
    }
    return hasSubSequence(s, first) && hasSubSequence(t, second);
}

signed main() {
    string S, T;
    cin >> S >> T;
    int N = S.size();
    Yes(solve(S, S, T) || solve(S, T, S));
}


Measured memory_bytes: 3236
#include<cstdio>
int ans;
int main()
{
	int N;
	scanf("%d",&N);
	for(int i=1;i<=N;i++)
	{
		int t;
		scanf("%d",&t);
		while(t%2==0)
			ans++,t/=2;
	}
	printf("%d\n",ans);
}

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

int main()
{
	cin.sync_with_stdio(false);
	cin.tie(0);
	char sl;
	int N, M, R;
	while (cin >> N >> M, N | M) {
		vector<vector<ll>> umi(N, vector<ll>(N, INF)), riku(N, vector<ll>(N, INF));
		for (int i = 0; i < N; i++) {
			umi[i][i] = riku[i][i] = 0;
		}
		for (ll i = 0, x, y, t; i < M; i++) {
			cin >> x >> y >> t >> sl; x--; y--;
			if (sl == 'S') {
				umi[x][y] = umi[y][x] = min(umi[x][y], t);
			}
			else {
				riku[x][y] = riku[y][x] = min(riku[x][y], t);
			}
		}
		for (int k = 0; k < N; k++) {
			for (int i = 0; i < N; i++) {
				for (int j = 0; j < N; j++) {
					umi[i][j] = min(umi[i][j], umi[i][k] + umi[k][j]);
				}
			}
		}
		for (int k = 0; k < N; k++) {
			for (int i = 0; i < N; i++) {
				for (int j = 0; j < N; j++) {
					riku[i][j] = min(riku[i][j], riku[i][k] + riku[k][j]);
				}
			}
		}
		cin >> R;
		vector<ll> z(R);
		for (int i = 0; i < R; i++) {
			cin >> z[i]; z[i]--;
		}
		vector<vector<ll>> d(R, vector<ll>(N, INF));
		d[0][z[0]] = 0;
		for (int i = 0; i < N; i++) {
			if (umi[z[0]][i] != INF && riku[i][z[0]] != INF) {
				d[0][i] = min(d[0][i], umi[z[0]][i] + riku[i][z[0]]);
			}
		}
		for (int i = 1; i < R; i++) {
			for (int j = 0; j < N; j++) {
				d[i][j] = min(d[i][j], d[i - 1][j] + riku[z[i - 1]][z[i]]);
			}
			for (int j = 0; j < N; j++) {
				for (int k = 0; k < N; k++) {
					d[i][k] = min(d[i][k], d[i - 1][j] + riku[z[i - 1]][j] + umi[j][k] + riku[k][z[i]]);
				}
			}
		}
		ll res = INF;
		for (int i = 0; i < N; i++) {
			res = min(res, d[R - 1][i]);
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 5220
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <iomanip>

#define DEBUG 0
#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


int main(){

    int h,w;
    cin >> h >> w;
    vector <string> a(h);

    REP(i,h)
    {
        cin >> a[i];
    }

    REP(i,h+2)
    {
        REP(j,w+2)
        {
            if(i == 0 || i == h+1 || j == 0 || j == w+1)
            {
                cout << "#";
            }
            else
            {
                cout << a[i-1][j-1];
            }
        }
        cout << endl;
    }


    return 0;
}



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

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop0(i,n) for(int i=0; i<(n); i++)
#define loop1(i,n) for(int i=1; i<=(n); i++)
#define fori(a,b,i) for(int i=(a); i<=(b); i++)
#define ford(a,b,i) for(int i=(a); i>=(b); i--)
#define fast_io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define ign cin.ignore(numeric_limits<streamsize>::max(),'\n')

#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define endl "\n"
#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef map<int,int> MCI;
typedef unordered_map<int,int> UMII;
typedef unordered_map<char,int> UMCI;
typedef set<int> SI;
typedef long long int llint;

// Display Map
//~for (auto const& pair: m) {
//~std::cout << "{" << pair.first << ": " << pair.second << "}\n";
//~}

// Extract word(w) from sentence(s)
//~stringstream str(s);
//~string w;
//~while(str >> w){
//~// w is your word
//~}

//Memset Syntax
// memset(array, value,sizeof(array)) val is 0,-1 or bool only

// To get accurate precision
//~cout.precision(20);

int main() {
    fast_io;
	llint n;
	cin >> n;
	string ans = "";
	int rem;
	
	while(n > 0){
		n -= 1;
		rem = n % 26;
		rem += 97;
		ans = char(rem) + ans;
		n /= 26;
	}
	cout << ans << endl;
}


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

int main() {
  long long n; cin >> n;
  
  long long ans = 0;
  long long before; cin >> before;

  for(int i = 0; i < n - 1; i++) {
   long long temp; cin >> temp;
   if(before <= temp) {
     before = temp;
   } else {
     long long diff = before - temp;
   	 ans += diff;
   }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3628
class DisjointSet:
    def __init__(self,n):
        self.rank = [0]*n
        self.parent = [i for i in range(n)]

    def same(self,x,y): 
        return self.findSet(x) == self.findSet(y)

    def unite(self,x,y): 
        return self.link(self.findSet(x), self.findSet(y))

    def link(self,x,y):
        if self.rank[x] > self.rank[y]: 
            self.parent[y] = x
        else:
            self.parent[x] = y
            if self.rank[x] == self.rank[y]: self.rank[y] += 1

    def findSet(self,x):
        if x != self.parent[x]: 
            self.parent[x] = self.findSet(self.parent[x])
        return self.parent[x]

n,m = map(int,input().split())
ans = 0
edge = [[int(i)-1 for i in input().split()] for _ in range(m)]
for i in range(m):
    ds = DisjointSet(n)
    for j in range(m):
        if j == i: continue
        a,b = edge[j]
        ds.unite(a,b)
    for j in range(1,n):
        if not ds.same(0,j):
            ans += 1
            break
        
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
const int MAXN = 2e5 + 5, MAX = 3e4 + 5, MAXM = 4e5 + 5, BOUND = 2e5, MOD = 1e9+7, INF = 0x3f3f3f3f, base = 10000;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0), eps = 1e-9;
#define mid l + ((r-l)>>1)
#define lson o<<1,l,m
#define rson o<<1|1,m+1,r
#define lc(x) ch[x][0]
#define pii pair<int,int>
#define vi vector<int>
#define rc(x) ch[x][1]
#define rep(i,a,b) for(RR i=(a);i<=(b);++i)
#define random(a,b) ((a)+rand()%((b)-(a)+1))
#define fi first
#define se second
#define pil pair<int,ll>
inline int sign(db a){return a<-eps?-1:a>eps;}
inline int cmp(db a,db b){return sign(a-b);}

int n,tmp[MAXN],p[MAXN],l[MAXN],r[MAXN],s[MAXN],f[MAXN];
pii a[MAXN];
int main() {
	ios::sync_with_stdio(false); cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i].se>>a[i].fi;
    sort(a+1,a+1+n);
    for(int i=1;i<=n;i++)tmp[i] = a[i].se;
    sort(tmp+1,tmp+1+n);
    for(int i=1;i<=n;i++){
        a[i].se = lower_bound(tmp+1,tmp+1+n,a[i].se)-tmp;
        p[a[i].se] = i;
    }
    for(int i=1;i<=n;i++)r[i] = max(r[i-1],p[i]);
    l[n] = p[n];
    for(int i=n-1;i>=1;i--)l[i] = min(l[i+1],p[i]);
    int L = 0;
    s[0] = f[0] = 1;
    for(int i=1;i<=n;i++){
        while(r[L] < l[i]-1)L++;
        if(L)f[i] = (s[i-1] - s[L-1] + MOD)%MOD;
        else f[i] = s[i-1];
        s[i] = (s[i-1] + f[i])%MOD;
    }
    while(r[L] < n)L++;
    cout<< (s[n]-s[L-1]+MOD)%MOD<<'\n';
    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
const int N=1000010;
int i,j,k,n,m,x,y,t,num[N],d[N],p[N],f[N],de[N];
int fi[N*2],ne[N*2],la[N*2],a[N*2],ans=1013687232;
int read(){
	int x=0,f=1;
	char ch=getchar();
	while (ch<'0'||ch>'9'){f=ch=='-'?-f:f;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
	return x*f;
}
void add(int x,int y){
	k++;a[k]=y;
	if (fi[x]==0)fi[x]=k;else ne[la[x]]=k;
	la[x]=k;
}
int dp(int x,int fa){
	int used=0,tot=0;
	for (int i=fi[x];i;i=ne[i])if (a[i]!=fa)dp(a[i],x);
	for (int i=fi[x];i;i=ne[i])if (a[i]!=fa)p[++tot]=f[a[i]],used+=p[tot];
	if (tot<=1)return f[x]=used;
	else{
		for (int i=1;i<=tot;i++)if (!p[i])p[i]=1013687232;
		sort(p+1,p+1+tot);
		int tmp=0;
		for (int i=1;i<tot;i++)if (p[i]==1013687232)used++;
	}
	return f[x]=used;
}
void dfs(int x,int fa){
	for (int i=fi[x];i;i=ne[i])
		if (a[i]!=fa){
			de[a[i]]=de[x]+1;
			dfs(a[i],x);
		}
}
int main(){
	n=read();for (i=1;i<n;i++){x=read();y=read();add(x,y);add(y,x);d[x]++;d[y]++;}
	dfs(1,-1);
	for (i=1;i<=n;i++)if (de[i]>de[x])x=i;
	if (n<=5000)for (i=0;i<n;i++){ ans=min(ans,dp(i,-1)+1); }else ans=dp(x,-1)+1;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 27776
#include <bits/stdc++.h>
#define a first
#define b second
using namespace std;

const int maxn = 1e5+10;

int n, m, ans;
pair<int, int> x[maxn];
priority_queue<int> pq;

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; ++i)
		cin >> x[i].a >> x[i].b;
	sort(x, x+n);
	for (int i = 0, j = 1; j <= m; ++j) {
		for (; i < n && x[i].a <= j; ++i) pq.push(x[i].b);
		if (!pq.empty()) ans += pq.top(), pq.pop();
	}
	cout << ans;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define N 100005

using namespace std;
int n;
long long A[N][3], F[N][3];

long long Magic(int i, int col)
{
    if(i==n) return A[i][col];
    if(F[i][col]!=0) return F[i][col];
    return F[i][col] = A[i][col] + max(Magic(i+1, (col+1)%3), Magic(i+1, (col+2)%3));
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n;
    for(int i=1; i<=n; i++) cin>>A[i][0]>>A[i][1]>>A[i][2];
    cout<<max(max(Magic(1, 0), Magic(1, 1)), Magic(1, 2));
    return 0;
}


Measured memory_bytes: 12956
import fractions

def lcm(a, b):
    return a * b / fractions.gcd(a, b)

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

d_N = {}

for n in range(N):
    d = fractions.gcd(n, N)
    d_N[(n // d, N // d)] = n

for m in range(M):
    d = fractions.gcd(m, M)
    k = (m // d, M // d)
    if k in d_N:
        if S[d_N[k]] != T[m]:
            print(-1)
            exit()

L = int(lcm(N, M))
print(L)

Measured memory_bytes: 28524