akhauriyash/Code-Regression huggingface dataset:
<?php
class Dice{
  public $label=[1,2,3,4,5,6];#index+1????????¢?????????
  public $pos=[0,1,2];#?????¢,?????¢,??\??¢???index ???????????¢???5-index
  function __construct($sLabel){$this->label=explode(' ',$sLabel,6);}
  function move($s){
    $x=$this->pos[0];
    if($s=='E'){
      $this->pos[0]=5-$this->pos[2];
      $this->pos[2]=$x;
    }
    elseif($s=='W'){
      $this->pos[0]=$this->pos[2];
      $this->pos[2]=5-$x;
    }
    elseif($s=='N'){
      $this->pos[0]=$this->pos[1];
      $this->pos[1]=5-$x;
    }
    elseif($s=='S'){
      $this->pos[0]=5-$this->pos[1];
      $this->pos[1]=$x;
    }
  }
  function spin($s){
    $x=$this->pos[1];
    if($s=='L'){
      $this->pos[1]=$this->pos[2];
      $this->pos[2]=5-$x;
    }
    elseif($s=='R'){
      $this->pos[1]=5-$this->pos[2];
      $this->pos[2]=$x;
    }
  }
  function toTop($label){
    $move=array('','N','W','W','W','N');#1 2 3 5 4 6
    for($i=0;$i<6;$i++){
      $this->move($move[$i]);
      if($this->top()==$label) return 1;
    }
    return 0;
  }
  function toSpin($label){
    for($j=0;$j<4;$j++){
      if($this->front()==$label) return 1;
      $this->spin('L');
    }
    return 0;
  }
  function isSame($dice){
    $move=array('','N','W','W','W','N');#1 2 3 5 4 6
    $end=[];
    for($i=0;$i<6;$i++){
      $this->move($move[$i]);
      $top=$this->top();
      if(isset($end[$top])) continue;
      $end[$top]=1;
      if(!$dice->toTop($top)) continue;
      if(!$dice->toSpin($this->front())) continue;
      if($dice->right()!=$this->right()) continue;
      if($dice->bottom()!=$this->bottom()) continue;
      if($dice->back()!=$this->back()) continue;
      if($dice->left()!=$this->left()) continue;
      return 1;
    }
    return 0;
  }
  function top(){return $this->label[$this->pos[0]];}
  function front(){return $this->label[$this->pos[1]];}
  function right(){return $this->label[$this->pos[2]];}
  function bottom(){return $this->label[5-$this->pos[0]];}
  function back(){return $this->label[5-$this->pos[1]];}
  function left(){return $this->label[5-$this->pos[2]];}
}

$d0=new Dice(trim(fgets(STDIN)));
$d1=new Dice(trim(fgets(STDIN)));
echo ($d0->isSame($d1))?'Yes':'No';
?>

Measured memory_bytes: 15600
#include <stdio.h>

int hill[10];

int main(void) {
    int i, j;
    for(i = 0; i < 10; i++) {
        scanf("%d", &hill[i]);
    }

    for(i = 1; i < 10; i++) {
        int a = i;
        int b = hill[i];

        while(a > 0 && hill[a - 1] > b) {
            hill[a] = hill[a - 1];
            a--;
        }
        hill[a] = b;
    }

    for(i = 9; i >= 7; i--) {
        printf("%d\n", hill[i]);
    }

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int Alice = 0, Bob = 0;
  vector<int> point(N);
  for (int i = 0; i < N; i++) {
    cin >> point.at(i);
  }
  sort(point.begin(), point.end());
  reverse(point.begin(), point.end());
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      Alice += point.at(i);
    }
    else {
      Bob += point.at(i);
    }
  }
  cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)


#define SZ(x) ((int)(x).size())


typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
struct Vec{
    double x, y;
};

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

template<class T>
T min(T a, T b)
{
    if (a < b) return a;
    return b;
}

template<class T>
T max(T a, T b)
{
    if (a > b) return a;
    return b;
}

using namespace std;

int board[3][3];
int main()
{
    vector <int> num(100);
    rep(i, 3)rep(k, 3){
        int A;
        cin >> A;
        board[i][k]=A;
        num[A] = 1; 
    }
    int N;
    cin >> N;
    rep(i,N) {
        int m;
        cin >> m;
        if (num[m] == 1){
            rep(i, 3) rep(k, 3) if (board[i][k] == m) board[i][k] = 0;
        }
    }
    
    int row = 0, col = 0, rcross = 0, lcross = 0; 
    rep(i, 3){
        rep(k, 3){
            col += board[i][k];
            row += board[k][i];
            if (i == k) rcross += board[i][k];
            if (i == (2 - k)) lcross += board[i][k];
        }
        if (col == 0 || row == 0) {
            cout << "Yes" << endl;
            return 0;
        }
        col = 0; row = 0;
    }
    if (lcross == 0 || rcross == 0) {
            cout << "Yes" << endl;
            return 0;
    }
    cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define INF = 1000000100;

int main(){
    int n;
    string s;
    cin >> n >> s;
    //cout << 'A' + 2 << endl;
    for(int i=0;i<s.size();i++){
        putchar((s[i]-'A'+n)%26+'A');
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
// by syu
package main

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

var in = NewScanner(os.Stdin, 0)

func main() {
	K := in.Int()
	if K&1 == 0 {
		Pln(K / 2 * K / 2)
	} else {
		Pln((K/2 + 1) * (K / 2))
	}
}

type Scanner struct {
	*bufio.Scanner
}

func NewScanner(r io.Reader, max int) *Scanner {
	s := bufio.NewScanner(r)
	s.Split(scanWords)
	if max <= 0 {
		max = 1048576
	}
	s.Buffer([]byte{}, max)
	return &Scanner{s}
}
func (s *Scanner) Int() int {
	s.Scan()
	i, e := strconv.ParseInt(s.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return int(i)
}
func isSpace(b byte) bool {
	return b == ' ' || b == '\n' || b == '\r' || b == '\t'
}
func scanWords(data []byte, atEOF bool) (advance int, token []byte, err error) {
	start := 0
	for start < len(data) && isSpace(data[start]) {
		start++
	}
	for i := start; i < len(data); i++ {
		if isSpace(data[i]) {
			return i + 1, data[start:i], nil
		}
	}
	if atEOF && len(data) > start {
		return len(data), data[start:], nil
	}
	return start, nil, nil
}
func Pln(s ...interface{}) {
	fmt.Println(s...)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  int d=0,e=999999;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i]<e)e=a[i];
    if(a[i]>d)d=a[i];
  }
  cout << d-e;
}

Measured memory_bytes: 256
#include<stdio.h>
int solve (int d)
 {
		 int ans = 0;
		 int i=d;
		 while(i<600)
         {
             ans+=d*i*i;
             i=i+d;
         }
		 return ans;
 }
int main()
{
    int d;
    while(scanf("%d",&d)==1)
    {
        printf("%d\n",solve(d));
    }
    return 0;
}

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

struct fast_io {
    fast_io() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
    }
} __fast_io;

int main() {
    int H, W; cin >> H >> W;
    int CH, CW; cin >> CH >> CW;
    CH--; CW--;
    int DH, DW; cin >> DH >> DW;
    DH--; DW--;

    vector<string> grid(H);
    for (string &row : grid)
        cin >> row;

    vector<vector<int>> spells(H, vector<int>(W, INT_MAX));
    spells[CH][CW] = 0;
    deque<pair<int, int>> q;
    q.push_front({CH, CW});
    while (!q.empty()) {
        auto [r, c] = q.front(); q.pop_front();
        for (int rr = r - 2; rr <= r + 2; rr++) {
            for (int cc = c - 2; cc <= c + 2; cc++) {
                if ((rr < 0 or rr >= H or cc < 0 or cc >= W) or
                    (rr == r and cc == c) or (grid[rr][cc] == '#'))
                    continue;
                int w = abs(rr - r) + abs(cc - c) > 1;
                if (spells[r][c] + w < spells[rr][cc]) {
                    spells[rr][cc] = spells[r][c] + w;
                    if (w == 1) q.push_back({rr, cc});
                    else        q.push_front({rr, cc});
                }
            }
        }
    }

    cout << (spells[DH][DW] == INT_MAX ? -1 : spells[DH][DW]) << endl;
}


Measured memory_bytes: 8636
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int N,M;
  cin>>N>>M;
  int A[N],sum=0;
  for(int i=0;i<N;i++){
    cin>>A[i];
    sum+=A[i];
  }
  sort(A,A+N);
  reverse(A,A+N);
  double base=sum*1.0/(4.0*M);
  int count=0;
  for(int i=0;i<N;i++){
    if(A[i]*1.0>=base){
      count++;
    }
  }
  if(count>=M){
    printf("Yes");
  }else{
    printf("No");
  }
}

Measured memory_bytes: 256
import numpy as np

st = lambda n: bin(n)[2:]
N,K = map(int,input().split())
a = np.array([int(i) for i in input().split()])

MAX = 10**12
mm = MAX.bit_length()
chk = [((a >> K) & 1).sum() for K in range(mm)]

ll = []
q = 0
for num,cc in enumerate(chk):
  if cc < N/2:
    q += 2**(num)
  ll.append((num,2**num*(N-cc),2**num*cc))
    
max_V = 0
KK = (K+1).bit_length()
sk = st(K+1).zfill(mm)
sq = st(q).zfill(mm)

for i in range(KK):
  if (K+1)>>i&1 == 1:
    op = q
    if q>>i&1 == 1:
      op -= 2**i
    I = KK-i
    for j in range(mm-KK+I):
      if sq[j] == '1' and sk[j] == '0':
        op -= 2**(mm-1-j)
    V = 0
    for nm,v_1,v_0 in ll:
      if op>>nm & 1 == 1:     
        V += v_1
      else:
        V += v_0
    max_V = max(max_V, V)
    
print(max_V)

Measured memory_bytes: 38608
/*
 *      ┌─┐       ┌─┐ + +
 *   ┌──┘ ┴───────┘ ┴──┐++
 *   │                 │
 *   │       ───       │++ + + +
 *   ███████───███████ │+
 *   │                 │+
 *   │       ─┴─       │
 *   │                 │
 *   └───┐         ┌───┘
 *       │         │
 *       │         │   + +
 *       │         │       Code is far away from bug with the animal protecting
 *       │         └──────────────┐
 *       │                        │
 *       │                        ├─┐
 *       │                        ┌─┘
 *       │                        │
 *       └─┐  ┐  ┌───────┬──┐  ┌──┘  + + + +
 *         │ ─┤ ─┤       │ ─┤ ─┤
 *         └──┴──┘       └──┴──┘  + + + +
 *                神兽保佑
 *               代码无BUG!
 */

#include<bits/stdc++.h>
using namespace std;
class IN{
public:
    template<typename T>
    IN& operator >>(T &x){read(x);return *this;}
    IN& operator >>(double &x){scanf("%lf",&x);return *this;}
    IN& operator >>(char *s){scanf("%s",s);return *this;}
    IN& operator >>(char &c){c=getchar();return *this;}
private:
    template<typename T>
    void read(T &x){
        T f=1;int c=getchar();x=0;
        while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
        while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();
        x*=f;
    }
}in;
class NL{}nl;
class BK{}bk;
class OUT{
public:
    template<typename T>
    OUT& operator <<(T x){write(x);return *this;}
    OUT& operator <<(const char *s){printf("%s",s);return *this;}
    OUT& operator <<(char c){putchar(c);return *this;}
    OUT& operator <<(BK x){putchar(' ');return *this;}
    OUT& operator <<(NL x){putchar('\n');return *this;}
private:
    template<typename T>
    void write(T x){
        if(x<0)putchar('-'),x=-x;
        if(x>=10)write(x/10);
        putchar(x%10+48);
    }
}out;

#define pb(x) push_back(x)
#define fi first
#define se second
#define rep(i,a,n) for(int i=a;i<=n;++i)
#define per(i,n,a) for(int i=n;i>=a;--i)
#define mem(a,x) memset(a,x,sizeof(a))
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;
/*****************************************************************************************************/
ll Pow(ll a,ll b,ll mod){ll res=1;a%=mod;while(b){if(b&1)(res*=a)%=mod;(a*=a)%=mod;b>>=1;}return res%mod;}
ll inv(ll a,ll p){if(a==1)return 1;return (p-p/a)*inv(p%a,p)%p;}//p为素数,a<p
//ll C(ll n,ll m){ll res=1;for(ll i=1,j=n-m+1;i<=m;++i,++j){res=res*inv(i,p)%p*j%p;}return res;}
/*****************************************************************************************************/
/*ll ask(int x){ll res=0;while(x)res+=c[x],x-=x&-x;return res;}
void add(ll v,int x){while(x<=n)c[x]+=v,x+=x&-x;}*/
const int p=1e9+7;
const int N=2e5+10;
char s[N];
bool judge(int l,int r){
    while(l<r){
        if(s[l++]!=s[r--])return 0;
    }
    return 1;
}
int main(){
    in>>s+1;
    int n=strlen(s+1);
    if(judge(1,n)&&judge(1,(n-1)/2)&&judge((n+3)/2,n))
        out<<"Yes";
    else out<<"No";
    return 0;
}


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

int main(){
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    if(k != 0){
        for(ll i=1; i<=n; i++){
            if(i <= k) continue;
            ll a = n/i;
            ll b = n%i;
            ll c = i-k;
            ans += c*a;
            if(b-(k-1) > 0) ans += b-(k-1);
        }
        cout << ans << endl;
    }else{
        cout << n*n << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
namespace ORIGIN {
#define LL long long
#define VLL vector<long long>
#define SORT(x) sort(x.begin(),x.end())
#define REVE(x) reverse(x.begin(),x.end())
#define rep(i,n) for(int i=0;i<n;i++)
#define COUT(x) cout<<x<<endl
#define WHOLE(x) x.begin(),x.end()
	double pai = 3.1415926535;
	string atc = "atcoder";
	typedef pair<long long, long long> data_t;
	string strnum = "0123456789";
	string alpS = "abcdefghijklmnopqrstuvwxyz";
	string alpL = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	int sizealp = (int)(alpS.size());
	int mod = 1e9 + 7;
	bool test = false;
}
using namespace ORIGIN;

void Test(char a) {
	if (test) {
		printf("%c", a);
	}
}
int gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}

int main() {
	int n, m;
	cin >> n >> m;
	VLL l(m), r(m);
	rep(i, m)cin >> l[i] >> r[i];
	int right = *(min_element(WHOLE(r))), left = *(max_element(WHOLE(l)));
	COUT(max(0, right-left+1));
}

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


class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var h = Console.ReadLine().Split(' ').Select(int.Parse).ToList<int>();

        var max = 0;
        var count = 0;
        for (var i = 1; i < n; i++)
        {
            if (h[i] <= h[i - 1])
            {
                count++;
            }
            else
            {
                if (max < count) max = count;
                count = 0;
            }
        }
        if (max < count) max = count;

        Console.Write(max);
    }
}


Measured memory_bytes: 25692
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MAX 1000000007

using namespace std;

int main() {

	int a, b, c;

	cin >> a >> b >> c;
	vector<lli> vec(2000);
	vec[0] = c;
	rep1(i,10) {
		vec[i] = a * vec[i - 1] - b;
		cout << vec[i] << endl;
	}
	

}

Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    char[] chars=new char[s.length()];
    for(int i=0;i<s.length();i++){
      chars[i]=s.charAt(i);
    }
    Arrays.sort(chars);
    for(int i=0;i<s.length()-1;i++){
      if(chars[i]==chars[i+1]){
          System.out.println("no");
          return;
        
      }
    }
    System.out.println("yes");
  }
}


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

using namespace std;

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

    string s;
    cin >> s;
    string ans = "Yes";
    int c = 0;
    char c1=s[0], c2 = (s[1]!=c1)? s[1]: s[2];
    for(int i = 0; i < 4; ++i){
        if(s[i] != c1 && c2 != s[i]){
            ans = "No";
        }
        if(c1 == s[i])
            c++;
    }
    if(c != 2)
        ans = "No";

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<string>
using namespace std;
const int N =100010;
int n,l;
string p[N];
string s;

bool cmp(string a, string b)
{
    return a<b;
}
int main()
{
  scanf("%d%d",&n,&l);
  for(int i=1;i<=n;i++) cin>>p[i];
  sort(p+1,p+1+n,cmp);
  for(int i=1;i<=n;i++) cout<<p[i];
  return 0;
}




Measured memory_bytes: 1024
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

from collections import defaultdict, deque
g = defaultdict(list)
for a, b in ab:
    g[a-1].append(b - 1)

ans = None
for start in range(n):
    visited = [0] * n
    visited[start] = 1
    q = deque([start])
    prev = [None] * n

    f = False
    while q:
        cur = q.popleft()

        for target in g[cur]:
            if visited[target] == 0:
                visited[target] = 1
                q.append(target)
                prev[target] = cur

            if target == start:
                f = True
                break

        if f:
            break

    if f:
        loop = [target]
        while cur != None:
            loop.append(cur)
            cur = prev[cur]

        loop = loop[::-1]
        v = set(loop)

        f2 = True
        for i in range(len(loop) - 1):
            a, b = loop[i], loop[i+1]

            for target in g[a]:
                if target in v and target != b:
                    f2 = False
                    break

            if f2 == False:
                break

        if f2:
            ans = loop[:-1]
            break

if ans == None:
    print(-1)
else:
    print(len(ans))
    for _ans in ans:
        print(_ans + 1)


Measured memory_bytes: 46188
#include <bits/stdc++.h>
using namespace std;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
int main() {
  vector<int> a(3);
  for(int i=0;i<3;i++){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  if(a.at(0)==5&&a.at(1)==5&&a.at(2)==7){
    cout<<"YES";
  }
  else{
    cout<<"NO";
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
 
const int INF = 10000000;
 
int base16(char c) {
  if( 'a' <= c ) return c-'a'+10;
  else return c-'0';
}
 
int main() {
 
  string s;
 
  int coltabel[8][3] = { { 0, 0, 0 }, { 0, 0, 255 }, { 0, 255, 0 },
             { 0, 255, 255 }, { 255, 0, 0 }, { 255, 0, 255 },
             { 255, 255, 0 }, { 255, 255, 255 } };
 
  string nametable[8] = { "black", "blue", "lime", "aqua",
             "red", "fuchsia", "yellow", "white" };
 
  while(true) {
 
    cin>>s;
    if( s=="0" ) break;
 
    int r,g,b;
    r = base16(s[1])*16+base16(s[2]);
    g = base16(s[3])*16+base16(s[4]);
    b = base16(s[5])*16+base16(s[6]);
 
    int res,tmp=INF,t;
 
    for(int i=0; i<8; i++) {
      if( ( t = (r-coltabel[i][0])*(r-coltabel[i][0])
      + (g-coltabel[i][1])*(g-coltabel[i][1])
      + (b-coltabel[i][2])*(b-coltabel[i][2]) )
      < tmp ) {
    //cout<<t<<" "<<i<<endl;
    res = i;
    tmp = t;
      }
    }
 
    cout<<nametable[res]<<endl;
  }
}

Measured memory_bytes: 1188
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <string>
#include <functional>
#include <cassert>
#include <cmath>
#define SIZE 2005
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int A[SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	ll K;
	scanf("%lld",&K);
	for(int i=0;i<n;i++) scanf("%d",&A[i]);
	ll ret=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			if(A[i]>A[j])
			{
				ll mul=K*(K+1)/2LL;
				ret += mul;
                ret %= MOD;
			}
			else if(A[i]<A[j])
			{
				ll mul=K*(K-1)/2LL;
				ret += mul;
                ret %= MOD;
			}
		}
	}
	printf("%lld\n",ret);
	return 0;
}


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

int main(){
  string s;
  cin>>s;
  int cnt[30]={};
  for(int i=0;i<s.size();i++){
    cnt[s[i]-'A']=1;
  }
  if(cnt['N'-'A']^cnt['S'-'A']||cnt['W'-'A']^cnt['E'-'A'])cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
# include <cstdio>
# include <algorithm>

main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    int tmpa = std::min(a, b);
    int tmpb = std::max(a, b);
    a = tmpa;
    b = tmpb;
    if (b - a >= 1) {
        printf("%d\n", 2 * b - 1);
    } else {
        printf("%d\n", a + b);
    }
}

Measured memory_bytes: 256
import numpy as np
def resolve():
    N,K = map(int,input().split())
    ans = np.ones(N,dtype=int)
    for i in range(K):
        d = int(input())
        A = input().split()
        for j in range(d):
            ans[int(A[j]) - 1] = 0
    print(sum(ans))
resolve()

Measured memory_bytes: 27092
def solve(x: int) -> bool:
    n = min(1000, x // 100 + 1)  # at most 1000 items

    for a in range(x // 100 + 1):
        for b in range(n - a + 1):
            for c in range(n - a - b + 1):
                for d in range(n - a - b - c + 1):
                    for e in range(n - a - b - c - d + 1):
                        for f in range(n - a - b - c - d - e + 1):
                            if a * 100 + b * 101 + c * 102 + d * 103 + e * 104 + f * 105 == x:
                                return True
    return False


x = int(input().strip())
ans = solve(x)
if ans:
    print(1)
else:
    print(0)


Measured memory_bytes: 3064
#pragma GCC optimize("O3") 

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

typedef long long int           ll;
typedef unsigned long long int  ull;
typedef long double             ld;

typedef pair<int, int>          pii;
typedef pair<ll,ll>             pll;
typedef vector<int>             vi;
typedef vector<ll>              vll;
typedef vector<pii>             vpii;
typedef vector<pll>             vpll;

#define test(t)		        int t; cin >> t; while(t--)
#define f(i, a, b)	        for(int (i) = (a); (i) < (b); ++(i))
#define all(a)		        (a).begin(), (a).end()
#define endl 		        "\n"
#define maxvec(vec)             *max_element(all(vec))
#define minvec(vec)             *min_element(all(vec))
#define maxarr(arr)             *max_element(arr, arr + n)
#define minarr(arr)             *min_element(arr, arr + n)
#define deb(x)		        cout << #x << ": " << x << endl;
#define deb2(x,y)	        cout << #x << ": " << x << " ~ " <<  #y << ": " << y << endl;
#define deba(arr)	        cout << #arr << " ~ [ "; for(auto n: arr) cout << n << " "; cout << "]" << endl;
#define debap(arr)	        cout << #arr << " ~ [ "; for(auto n: arr) cout << n.first << "-" << n.second << " "; cout << "]" << endl;
#define fast 		        ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define mx9		1000000007
#define mx7		10000007
#define mx6		1000006
#define mx5		200005
#define inf		1<<30                                 
#define eps		1e-9
#define mod		1000000007
#define PI		3.141592653589793238462643383279502884L

void solve()
{
    ll x, k, d;
    cin >> x >> k >> d;
    ll temp = x / d;
    if(temp == 0)
    {
        if(k % 2 == 0)
            cout << abs(x) << endl;
        else
            cout << abs(abs(x) - d) << endl;
        return;
    }
    if(abs(temp) > k)
    {
        cout << abs(abs(x) - (k * d)) << endl;
    }
    else
    {
        k = abs(k - abs(temp));
        x = abs(abs(x) - (abs(temp) * d));
        if(k % 2 == 0)
            cout << abs(x) << endl;
        else
            cout << abs(abs(x) - d) << endl;
    }
  
}

int main()
{
    fast;
    //test(t)
        solve();
    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int n,m;
vi v[100001];
bool f[100001];
void dfs(int x){
	f[x]=true;
	rep(i,v[x].size()){
		if(!f[v[x][i]])
		dfs(v[x][i]);
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>m;
	rep(i,m){
		int z;
		int x,y;
		cin>>x>>y>>z;
		x--,y--;
		v[x].pb(y);
		v[y].pb(x);
	}
	int ans=0;
	rep(i,n){
		if(!f[i]){
			ans++;
			dfs(i);
		}
	}
	cout<<ans;
	re 0;
}


Measured memory_bytes: 12296
import math

A, B = input().split()
A, B = int(A), int(B)

Xb = [i for i in range(10*B, 10*(B+1))]
Xa = [i for i in range(math.ceil(A/0.08), math.ceil((A+1)/0.08))]

S  = set(Xb) & set(Xa)

if len(S) != 0:
    print(min(list(S)))
else:
    print('-1')

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

int main () {
	int N,M;
  	cin >> N >> M;
  	for(int i = 0;i<M;i++) {
    	int	a;
      	cin >> a;
      	N -= a;
    }
  	int answer = 0;
  	if (N < 0) answer = -1;
  	else answer = N;
  	cout << answer << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
// in-short-use macros
 
#define all(c) (c).begin(),(c).end()
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define PI 3.14159265
#define sizes 1000010
 
//main function here
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	// #ifndef ONLINE_JUDGE
	// freopen("C:/Users/saura/Desktop/cp/input.txt", "r", stdin);
	// freopen("C:/Users/saura/Desktop/cp/output.txt", "w", stdout);
	// #endif
	string s;
	cin>>s;
	ll sum=0;
	for(int i=0;i<s.size();i++)
		sum+=s[i] - '0';
	if(sum%9==0)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3768
N, M = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(M)]
ab.sort(key = lambda x : x[1])

ans = 0
last = -1
for a, b in ab:
    if a < last:
        continue
    else:
        ans += 1
        last = b

print(ans)

Measured memory_bytes: 18248
#include <stdio.h>
#include <math.h>
int main()
{
    int A,B;
    scanf("%d %d",&A,&B);
    if (B>A)
    {
    	printf("0");
	}
    if (A>2*B)
    {
    	printf("%d\n",A-2*B);
	}
	else
	{
		printf("0\n");
	}
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>


template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;


void solve() {
	ll n, d; cin >> n >> d; if (n == 0 and d == 0) exit(0);
	ll mn = INF;
	vector<vector<ll>> v(n);
	vector<ll> sm(n);
	for (int i = 0; i < n; i++) {
		ll m; cin >> m;
		v[i].resize(m);
		for (int j = 0; j < m; j++) cin >> v[i][j], sm[i] += v[i][j];
		chmin(mn, sm[i]);
	}
	for (int i = 0; i < n; i++) {
		if (sm[i] - mn > d) {
			cout << "No" << "\n";
			return;
		}
	}
	while (1) {
		bool ok = false;
		for (int i = 0; i < n; i++) {
			if (!v[i].empty() and sm[i] - v[i].back() >= mn) {
				ok = true;
				sm[i] -= v[i].back();
				v[i].pop_back();
				break;
			}
		}
		if (ok) continue;
		ll mx = -1;
		int idx = -1;
		for (int i = 0; i < n; i++) {
			if (!v[i].empty() and mx < sm[i] - v[i].back()) {
				ll t = sm[i] - v[i].back();
				bool ok = true;
				for (int j = 0; j < n; j++) {
					if (i == j) continue;
					if (llabs(sm[j] - t) > d) {
						ok = false;
						break;
					}
				}
				if (ok) {
					idx = i;
					mx = sm[i] - v[i].back();
				}
			}
		}
		if (mx == -1) break;
		mn = mx;
		sm[idx] -= v[idx].back();
		v[idx].pop_back();
		for (int i = 0; i < n; i++) {
			if (sm[i] - mn > d) {
				cout << "No" << "\n";
				return;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		if (!v[i].empty()) {
			cout << "No" << "\n";
			return;
		}
	}
	cout << "Yes" << "\n";
}

int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int kkt = 89;
	while (kkt) {
		solve();
	}
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  int x;
  int l = 0;
  
  cin >> N >> K;
  
  for (int i = 0; i < N; i++) {
    cin >> x;
    
    if (x < K - x) {
      l += 2 * x;
    }
    else {
      l += 2 * (K - x);
    }
  }
  
  cout << l << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <iomanip>

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

    int a, b;
    std::cin >> a >> b;
    std::cout << a/b << " " << a%b << " " << std::fixed << std::setprecision(6) << 1.0*a/b << "\n";
    return 0;
}

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

using namespace std;

#define ll long long
#define PI 3.14159265358979323846264338327950L

ll a,b,c,k;

void solve(){

    cin >> a >> b >> c >> k;

    ll ans = 0;

    if(k > a) ans += a;
    else{
        ans+= k;
        goto END;
    } 

    k = k-a;
    if(k > b) k-=b;
    else{
        goto END;
    }

    ans -= k;


    END:
    cout << ans << endl;

}





int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    solve();

}

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

import numpy as np

A = np.array(input().split(),np.int64)
B = np.array(input().split(),np.int64)

A.sort() ; B.sort() 
B=B[::-1]

right = max(A*B)   #時間の可能集合の端点
left = -1           #時間の不可能集合の端点

def test(t):
    
    C = A-t//B
    D= np.where(C<0,0,C)
    return D.sum()<=K

while left+1<right:
    mid = (left+right)//2
    if test(mid):
        right=mid
    else:
        left = mid

print(right)

Measured memory_bytes: 51896
import java.util.Scanner;
class Main{
	public static void main(String[]args) {
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	double ans=0;
	for(int i=0;i<a;i++) {
		double b=scan.nextDouble();
		String str=scan.next();
		if(str.charAt(0)=='J') {
			ans+=b;
		}
		else {
			ans+=b*380000;
		}
	}
	System.out.println(ans);
	}
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
    int s[3];
    cin >> s[0] >> s[1] >> s[2];
    sort(s,s+3);
    if(s[0]+s[1]==s[2]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {

	var S string

	fmt.Scan(&S)

	 a := SliceInt(len(S)+1)

	 for i:=0;i<len(S);i++{

		if S[i] == '<'{

			a[i+1]=a[i]+1

		}

	 }

	 for i := range S{

		i = len(S)-1-i

		c := S[i]

		if c== '>'{

			a[i] = max(a[i],a[i+1]+1)
		}
		
	 }

	 sum:=0

	 for _,temp:= range a{

		sum += temp
	 }

	 fmt.Println(sum)
}



//max 最大値を返す
func max(a,b int) int{

	if a >b{

		return a
	}

	return b

}

//SliceInt 引数サイズのSliceを返す
func SliceInt(a int) []int {

	IntSample := make([]int, a)

	return IntSample

}


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

int main(){
    int N;
    cin >> N;
    int a[100010]={0};
    int x;
    int i,j;
    int ans=1;
    int max=1;

    for(i=0; i<N; i++){
        cin >> x;
        if(x!=0){
            for(j=-1; j<2; j++){
                a[x+j]++;
            }
        }
        else{
            a[0]++;
            a[1]++;
        }
        if(x>max) max=x;
    }

    for(i=0; i<=100000; i++){
        if(ans<a[i]) ans=a[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
void Input(); void Prepare(); void Setup(); void Solve(); void Clean();

#ifdef DEBUG6500
int A = 2, B = 5;
int main(){ Prepare(); Solve(); return 0; }
#else
int A, B;
int main(){ Input(); Prepare(); Solve(); Clean(); return 0; }
#endif

void Solve()
{
	int ans;
	if ((A < 10) && (B < 10)) ans = A * B;
	else ans = -1;
	cout << ans << endl;
}

void Prepare()
{
}

#ifndef DEBUG6500
void Clean()
{
}

void Input()
{
	cin >> A >> B;
}
#endif


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define db double
#define ldb long double
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define ts puts("test  check")
#define xh1(a,b) for(int i=a;i<b;i++)
#define xh2(a,b) for(int j=a;j<b;j++)
#define stlbl(a) for(it=a.begin();it!=a.end();it++)
#define dzkt int T;cin>>T;while(T--)
#define mst(a,i) memset(a,i,sizeof(a))
#define iosks std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int N=2e5+10,M=3e4+10,inf=1e9+10,mod=1e9+7;
const db pi=atan(1)*4;
ll pow2(ll a,ll b) {ll s=1; while(b) {if(b&1) s=(s*a)%mod; a=(a*a)%mod; b/=2; } return s;}
int gcd(int a,int b) {return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) {return a/gcd(a,b)*b; }
ll prime(ll x) {for(ll i=2;i<=sqrt(x+0.5);i++) if(x%i==0) return 0; return 1; }
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'&&ch>'9') {if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9') {s=s*10+ch-'0'; ch=getchar();} return s*f;
}
set<ll> st;
vector<ll> vec;

ll pop(ll x)
{
    ll s=0;
    while(x){
        if(x&1) s++;
        x/=2;
    }
    return s;
}

ll n,c,x=1,f[N];

string s;

ll v1[N],v2[N],x1=1,x2=1,a1=0,a2=0;

int main()
{
    iosks;

    xh1(1,N) f[i]=f[i%pop(i)]+1;

    cin>>n>>s;
    xh1(0,n) if(s[i]=='1') c++;

    if(c>1){
        xh1(1,n+1) v1[i]=x1%(c-1),v2[i]=x2%(c+1),x1=(x1*2)%(c-1),x2=(x2*2)%(c+1);

        xh1(0,n) if(s[i]=='1') a1=(a1+v1[n-i])%(c-1),a2=(a2+v2[n-i])%(c+1);

        xh1(0,n){
            if(s[i]=='0') cout<<f[(a2+v2[n-i])%(c+1)]+1<<endl;
            else cout<<f[(a1-v1[n-i]+c-1)%(c-1)]+1<<endl;
        }
    }
    else if(c==0) xh1(0,n) cout<<1<<endl;
    else{
        xh1(1,n+1) v2[i]=x2%(c+1),x2=(x2*2)%(c+1);
        xh1(0,n) if(s[i]=='1') a2=(a2+v2[n-i])%(c+1);
        xh1(0,n){
            if(s[i]=='0') cout<<f[(a2+v2[n-i])%(c+1)]+1<<endl;
            else cout<<0<<endl;
        }
    }
    return 0;
}









Measured memory_bytes: 8496
#include <bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
#define ld long double
const int mod=1e9 + 7;
 
int dx[]={-1, 0, 1, 0};
int dy[]={0, -1, 0, 1};
 

int dp[3001][3001];



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

  
  string s,t;
  cin>>s>>t;
  int n= s.length(),m=t.length();
  for(int i=0;i<=n;i++)
  {
    for(int j=0;j<=m;j++)
    {
      dp[i][j]=0;
        if(i==0||j==0)dp[i][j]=0;
        else if(s[i-1]==t[j-1])
        {
          dp[i][j]=1+dp[i-1][j-1];
        }
        else
        {
          dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
        }
        
    }
  }
  int x=dp[n][m]; 

  char ans[x+1];
  ans[x]='\0';
  int i=n,j=m;
  while(i>0&&j>0)
  {
    if(s[i-1]==t[j-1])
    {
       ans[x-1]=s[i-1]; i--;j--; x--;
    }
    else if(dp[i-1][j]>dp[i][j-1])
    {
      i--;
    }
    else  j--;
  }
   
   cout<<ans<<"\n";

}

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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		String[] list = str.split(" ");
		int a = Integer.parseInt(list[0]);
		int b = Integer.parseInt(list[1]);
		int c = Integer.parseInt(list[2]);
		String answer = "";
		if(b-a == c-b){
			answer = "YES";
		}else{
			answer = "NO";
		}
		System.out.println(answer);

	}

}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
     
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007  
#define mod2 998244353  
#define pi 3.14159265358979323846 

int solve(){
    double k=1,a,x;
    int b=100;
    a=1.01;
    cin>>x;
    while(1){
        b=b*a;
        //cout<<b<<"\n";
        if(b>=x)
        return cout<<k<<"\n",0;
        k++;
    }
    return 0;
}   
     
signed main(){
    IOS;
    int t=1;
   // cin>>t;
    while(t--){
        solve();   
        cout<<"\n";
      // cout<<" * "<<t<<"\n";
    }
//    return 0;
} 

Measured memory_bytes: 3788
package main

import (
	"fmt"
	"strings"
	"strconv"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	A := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &A[i])
	}
	display(A)

	for i := 1; i < n; i++ {
		v := A[i]
		j := i - 1
		for j >= 0 && A[j] > v {
			A[j+1] = A[j]
			j--
		}
		A[j+1] = v

		display(A)
	}
}

func display(A []int) {
	var displays []string
	for _, k := range A {
		displays = append(displays, strconv.Itoa(k))
	}
	fmt.Println(strings.Join(displays, " "))
}


Measured memory_bytes: 1676
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template <class T>
bool chmax(T &a, const T &b) {if (a < b){ a = b; return 1;} return 0;}
template <class T>
bool chmin(T &a, const T &b) {if (a > b){ a = b; return 1;}return 0;}
template <class T>
void printv(vector<T> v) {for (T t : v) {cout << t << " ";}cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

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

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

    int r;
    cin >> r;
    cout << 3*r*r << endl;

    return 0;
}


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

int main(){
    int n,m; cin >> n >> m;
    pair<int, int> d[m];
    for(int i = 0; i < m; i++){
        int s,c; cin >> s >> c;
        d[i] = make_pair(s,c);
    }

    sort(d, d+m);


    char ans[n];
    for(int i = 0; i < n; i++) ans[i] = '0';
    if(n != 1 && d[0].first == 1 && d[0].second == 0){
        cout << -1 << endl; return 0;
    }
    for(int i = 0; i < m-1; i++){
        if(d[i].first == d[i+1].first && d[i].second != d[i+1].second){
            cout << -1 << endl; return 0;
        }
    }

    for(int i = 0; i < m; i++) ans[d[i].first-1] = d[i].second + '0';

    if(n != 1 && ans[0] == '0') ans [0] = '1';

    for(int i = 0; i < n; i++) cout << ans[i];
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int i,n;
char s[100];
scanf("%s",s);

for(i=0;i<100;i++){
    if(i%2==0){
        if(s[i]=='L'){
            printf("No");
            return 0;
        }
    }
    else if(s[i]=='R'){
        printf("No");
        return 0;
    }
  }
printf("Yes");
return 0;
}

Measured memory_bytes: 128
h = {}
gets.to_i.times do
    c, d = gets.chomp.split
    (h[c] ||= []) << d.to_i
end
h.values.map(&:sort!)
prev_d = -1
prev_c = nil
ok = true
gets.to_i.times do
    c = gets.chomp
    if !h[c]
        ok = false
        break
    end
    h[c].shift until h[c].empty? || h[c][0] > prev_d
    if h[c].empty?
        ok = false
        break
    end
    prev_c = c
    prev_d = h[c][0]
end
puts ok ? 'Yes' : 'No'



Measured memory_bytes: 25800
#include <cstdio>
#include <cctype>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define ll long long
#define reg register
#define rep(i, a, b) for (reg int i = (a), i##end = (b); i <= i##end; ++i)
#define dep(i, a, b) for (reg int i = (a), i##end = (b); i >= i##end; --i)

template <typename _typer> inline _typer read() {
    _typer init = 0;
    char ch = getchar(), k = 0;
    for ( ; !isdigit(ch); ch = getchar()) k = (ch == '-');
    for ( ; isdigit(ch); ch = getchar())
        init = (init << 3) + (init << 1) + (ch ^ 48);
    return k ? -init : init;
}
const ll N = 100005, INF = 1e9;

/*******************************************************************************
 *
 *
 *
 ******************************************************************************/

#define int ll

int n, m;
char s[N << 1], t[N << 1];
int nxt[N][30], h[30];

signed main() {
    scanf("%s%s", s + 1, t + 1);
    n = strlen(s + 1), m = strlen(t + 1);
    rep (i, 1, n) if (!h[s[i] - 'a']) h[s[i] - 'a'] = i;
    rep (i, 0, 25) nxt[n + 1][i] = h[i] ? h[i] : -1;
    dep (i, n, 0) {
        rep (j, 0, 25) nxt[i][j] = nxt[i][j] ? nxt[i][j] : nxt[i + 1][j];
        if (i) nxt[i - 1][s[i] - 'a'] = i;
    }
    int k = 0, l = 0;
    rep (i, 1, m) {
//         cout << i << " " << l << endl;
        int tp = nxt[l][t[i] - 'a'];
        if (tp == -1) return puts("-1"), 0;
        if (tp <= l) ++k;
        l = tp;
    }
    cout << k * n + l << endl;
    return 0;
}



Measured memory_bytes: 23936
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s="",k;
  cin>>k;
  for(int i=0;i<k.size();i++){
    if(k.at(i)=='B'){
      (s==""?s+="":s.erase(s.size()-1));
    }
    else
      s+=k.at(i);
  }
  cout<<s;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <map>
#include <limits>
#include <queue>
#include <set>
using namespace std;
typedef long long int lld;
int T;
int N, P;
int check[1000001];
int A, B, M;
vector<int> a; vector<int> b;
int m1 = 1e9; int m2 = 1e9;
int main(void){
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> A >> B >> M;

    for(int i = 0; i < A; i++){
        int t; cin >> t;
        m1 = min(t,m1);
        a.push_back(t);
    }
    for(int i = 0; i < B; i++){
        int t; cin >> t;
        m2 = min(t,m2);
        b.push_back(t);
    }
    m1 = m1 + m2;
    for(int i = 0; i < M; i++){
        int aa, bb, mm;
        cin >> aa >> bb >> mm;
        m1 = min(m1, a[aa-1]+b[bb-1]-mm);
    }
    cout << m1;
    return 0;
}


Measured memory_bytes: 1400
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  ll h[N];
  for(int i = 0; i < N; i++) cin >> h[i];

  int hight = h[0];
  for(int i = 0; i < N; i++){
    if(h[i] == hight){
      hight = h[i];
    }
    else if(h[i] > hight){
      hight = h[i] - 1;
    }
    else{
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


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

int main() {
  // 入力
  string S;
  cin >> S;

  for (int i=0; i<S.length(); i++) {
    S[i] = 'x';
  }

  // 出力
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
int main()
{
	int n ,i ,cha=999999999 ,ans ,ans1 ,t ,t1;
	scanf("%d",&n);
	int a[n];
	for(i = 0; i < n; i++)
		scanf("%d",&a[i]);
	std::sort(a,a+n);
	if(n==2)
	{
		printf("%d %d",a[1],a[0]);
		return 0;
	}
	t = a[n-1]/2;
	int now = n-1;
	if(a[n-1]%2)
	{
		t1 = t+1;
		for(i = 0; i < now; i++)
		{
			if(abs(a[i]-t) < cha)
			{
				cha = abs(a[i]-t);
				ans = i;
			}
			else if(abs(a[i]-t) == cha)
				ans1 = i;
			if(abs(a[i]-t1) < cha)
			{
				cha = abs(a[i]-t1);
				ans = i;
			}
			else if(abs(a[i]-t1) == cha)
				ans1 = i;
		}
	}
	else 
	{
		for(i = 0; i < now; i++)
		{
			if(abs(a[i]-t) < cha)
			{
				cha = abs(a[i]-t);
				ans = i;
			}
			else if(abs(a[i]-t) == cha)
				ans1 = i;
		}
	}
	printf("%d %d",a[n-1],a[ans]);
	//if((cha==abs(a[ans1]-t)) || (cha==abs(a[ans1]-t1)))
	//	printf("\n%d %d",a[n-1],a[ans1]);
	return 0;
}

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

int N, M;
int a[60], b[60];

void dfs(vector<int> G[], bool visited[], int v) {
    visited[v] = true;

    for (int i = 0; i < G[v].size(); i++) {
        if (!visited[G[v][i]]) {
            dfs(G, visited, G[v][i]);
        }
    }

    return;
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) cin >> a[i] >> b[i];

    int ans = 0;
    for (int i = 0; i < M; i++) {
        vector<int> G[N + 1];
        for (int j = 0; j < M; j++) {
            if (j != i) {
                G[a[j]].push_back(b[j]);
                G[b[j]].push_back(a[j]);
            }
        }
        bool visited[N + 1];
        memset(visited, false, sizeof(visited));
        dfs(G, visited, 1);

        for (int i = 1; i < N+1; i++) {
            if (!visited[i]) {
                ans++;
                break;
            }
        }
    }

    cout << ans << endl;
    
    return 0;
}


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

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

struct node *tree = NULL;

void insert(struct node **root, struct node *node)
{
  struct node *parent = NULL;
  struct node *current = *root;

  while (current != NULL) {
    parent = current;
    if (node->key < current->key) {
      current = current->left;
    } else {
      current = current->right;
    }   
  }
    
  node->parent = parent;
    
  if (parent == NULL) {
    *root = node;
  } else if (node->key < parent->key) {
    parent->left = node;
  } else {
    parent->right = node;
  }
}

void preorder_traverse(struct node* node)
{
  if (node != NULL) {
    printf(" %d", node->key);
    preorder_traverse(node->left);
    preorder_traverse(node->right);
  }
}

void inorder_traverse(struct node *node)
{
  if (node != NULL) {
    inorder_traverse(node->left);
    printf(" %d", node->key);
    inorder_traverse(node->right);
  }
}

void tree_destroy(struct node* node)
{
  if (node != NULL) {
    tree_destroy(node->left);
    tree_destroy(node->right);
    free(node);
  }
}

int main (int argc, char** argv)
{
  int i, num;
  char str[32] = {0};
  fgets(str, 32, stdin);
  num = atoi(str);
  for (i = 0; i < num; i++) {
    fgets(str, 32, stdin);
    if (str[0] == 'i') {
      struct node *node = (struct node *)malloc(sizeof(struct node));
      node->key = atoi(&str[7]);
      node->left = NULL;
      node->right = NULL;
      insert(&tree, node);
    } else if (str[0] == 'p') {
      inorder_traverse(tree);
      printf("\n");
      preorder_traverse(tree);
      printf("\n");
    }
  }
  tree_destroy(tree);
  return 0;
}

Measured memory_bytes: 24000