akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> C(N);
  vector<vector<int>> A(N, vector<int>(M));
  for (int i = 0; i < N; ++i) {
    cin >> C[i];
    for (int j = 0; j < M; ++j) {
      cin >> A[i][j];
    }
  }

  int ans = 1000000001;
  for (int bit = 0; bit < 1 << N; ++bit) {
    int p = 0;
    vector<int> u(M);
    for (int i = 0; i < N; ++i) {
      if (bit & 1 << i) {
        p += C[i];
        for (int j = 0; j < M; ++j) {
          u[j] += A[i][j];
        }
      }
    }

    bool flag = true;
    for (int j = 0; j < M; ++j) {
      if (u[j] < X) {
        flag = false;
      }
    }

    if (flag) {
      ans = min(p, ans);
    }
  }

  if (ans == 1000000001) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
}

Measured memory_bytes: 3636
from collections import defaultdict

n = int(input())

total = None
for i in range(n):
    S = defaultdict(int)
    for s in input():
        S[s] += 1

    if i == 0:
        total = S
        continue

    keys = list(total.keys())
    for k in keys:
        if k in S:
            total[k] = min(total[k], S[k])
        else:
            total.pop(k)

chars = []
for k, c in total.items():
    chars.extend([k]*c)

print(''.join(sorted(chars)))

Measured memory_bytes: 3316
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		
		int[] H = new int[N];
		int[] countH = new int[N];
		
		
		for(int i = 0 ; i < N ; i++) {
			H[i] = Integer.parseInt(sc.next());
		}
		
		for(int i = 0 ; i < N-1 ; i++) {
			if (H[i] >= H[i+1]) {
				countH[i] = 1;
			}
		}
		/*
		for(int i = 0 ; i < N ; i++) {
			System.out.print(countH[i] + " ");
		}
		System.out.println();
		*/
		int ans = 0;
		int count = 0;
		
		for(int i = 0 ; i < N ; i++) {
			if(countH[i] == 1) {
				count++;
			}else{
				if(count > ans) {
					ans = count;
				}
				count = 0;
			}
			// System.out.print(ans + " ");
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 51208
#include<cstdio>
#include<iostream>
#include<ctype.h>
#include<string>
using namespace std;
int main(){
	int A, B;
	cin >> A >> B;
	if(A + B >= 10){
		cout << "error" << endl;
	} 
	else{
		cout << A + B;
	}
	return 0;
}

Measured memory_bytes: 256
class Problem
  attr_accessor *(?a..?z).to_a.map(&:to_sym)
  def initialize
    @a,@b,@c=gets.to_s.split.map{ |v| v.to_i }
  end

  def solve
    q1 && q2
  end

  def q1
    4 * a * b < (c - a - b) ** 2
  end

  def q2
    0 < c - a - b
  end

  def show(ans)
    puts ans ? "Yes" : "No"
  end
end

Problem.new.instance_eval do
  show(solve)
end

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

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

  const int MOD = 1000000007;

  int64_t ans = 0;
  for(int64_t i=k; i<=n+1; i++) {
    int64_t min = i*(i+1)/2;
    int64_t max = (n+1)*(n+2)/2 - (n+1-i)*(n+2-i)/2;
    ans += (max-min+1);
    ans = ans%MOD;
  }

  cout<<ans<<endl;

  return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine(Main2());
    }

    static string Main2()
    {
        var X = long.Parse(Console.ReadLine());
        var a = new Dictionary<long, long>();

        for (var i = 1L; i < 8192; i++)
        {
            var k = i * i * i * i * i;
            a.Add(k, i);
            a.Add(-k, -i);
        }
        a.Add(0, 0);

        for (var b = 0L; b < 8192; b++)
        {
            var b5 = b * b * b * b * b;
            if (a.ContainsKey(+X + b5))
                return (+a[X + b5]) + " " + (+b);
            if (a.ContainsKey(+X - b5))
                return (+a[X - b5]) + " " + (-b);
        }

        return null;
    }

    static long func1(long a, long b)
    {
        return a * b;
    }
}


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


    class Progrm
{
   static void Main()
    {
        while(true){
            int t=int.Parse(Console.ReadLine());
            if(t==0)break;
            int n=int.Parse(Console.ReadLine());
            int sum=0;
            for(int i=0;i<n;++i){
               	
                string[] input = Console.ReadLine().Split(' ');
                int s=int.Parse(input[0]);
                int f=int.Parse(input[1]);
                sum+=f-s;
            }
            if(sum>=t){
                Console.WriteLine("OK");
            }else{
                Console.WriteLine(t-sum);
            }
        }
    }

}

Measured memory_bytes: 9236
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from collections import defaultdict
import itertools
import numpy as np

n, m = LI()
ks = []
ss = []
for i in range(m):
    k, *s = LI()
    ks.append(k)
    ss.append(s)
ps = LI()

ans = 0
for comb in itertools.product((0,1), repeat=n):
    for j in range(m):
        o_e = 0 
        for i in ss[j]:
            o_e += comb[i-1]
        if o_e % 2 == ps[j]:
            continue
        else:
            break
    else:
        ans += 1

print(ans)

Measured memory_bytes: 12504
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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



int main(){
  int N, M;
  while(cin >> N >> M){
    vector<int> X(N); cin >> X;

    vector<vector<int>> g(M);
    for(auto x : X){
      g[x % M].push_back(x);
    }

    int ans = 0;

    dump(g);

    ans += g[0].size() / 2;
    if(M % 2 == 0) ans += g[M / 2].size() / 2;

    FOR(i,1,M){
      int j = M - i;
      if(i >= j) continue;

      auto &s = g[i];
      auto &t = g[j];

      dump(s, t);

      if(s.size() < t.size()) swap(s, t);

      sort(ALL(s));

      ans += t.size();

      int k = s.size() - t.size();

      while(s.size() >= 2){
        int a = s.back(); s.pop_back();
        int b = s.back();

        if(a == b and k >= 2){
          ans += 1;
          s.pop_back();
          k -= 2;
        }
        
      }
    }
    
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 6144
stdin = input().split()
n = int(stdin[0])
y = int(stdin[1]) / 1000

y_i = y % 5
n1 = n - y_i
y1 = y - y_i

ok = False
for num_x in range(int(y1/10) + 1):
    if num_x > n1:
        break
    y2 = y1 - 10*num_x
    for num_v in range(int(y2/5) + 1):
        if num_x + num_v > n1:
            break
        num_i = y2 - 5*num_v
        if num_x + num_v + num_i == n1:
            ok = True
            break
    if ok:
      break

if ok:
    print("{} {} {}".format(int(num_x), int(num_v), int(num_i + y_i)))
else:
    print("-1 -1 -1")

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int main()
{
	int N;
	int ans = 1;
	cin >> N;

	vector<int> d(N);

	for (int i = 0; i < N; i++)
	{
		cin >> d[i];
	}

	sort(d.begin(), d.end());

	int prev = d[0];
	for(int i = 1;i < N;i++)
	{
		if (d[i] > prev)
		{
			ans++;
		}

		prev = d[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define pb push_back
#define F first
#define S second
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
const int MOD = 1e9+7;
template <typename A>istream& operator>>(istream& input,vector<A>& x) {for(auto& i:x)input>>i;return input;}
template<typename A>ostream& operator<<(ostream& output,vector<A>& x) {for(auto& i:x)output<<i<<' ';return output;}
signed main()
{
    ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    int T=1;
   // cin>>T;
    while(T--)
    {
        int n;
        cin>>n;
        vi a(n+1);
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
        }
        int i=1;
        int cnt=1;
        while(a[i]!=2)
        {
            cnt++;
            i=a[i];
            if(cnt>2e5)
            {
                cout<<-1;
                return 0;
            }
        }
        cout<<cnt<<"\n";

    }

}


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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;
const double PI=3.1415926535897932;

ll R, C, K, ans=0, tmp=0;
vector<vector<ll>> V;
vector<vector<vector<ll>>> DP;

signed main(){
    cin >> R >> C >> K;
    V.resize(R+1);
    for(int i=0;i<R+1;i++) {
        V[i].resize(C+1, 0);
    }
    for(int i=0;i<K;i++) {
        ll r, c, v;
        cin >> r >> c >> v;
        V[r][c] = v;
    }
    DP.resize(R+1);
    for(int i=0;i<R+1;i++) {
        DP[i].resize(C+1);
        for(int j=0;j<C+1;j++) {
            DP[i][j].resize(4,0);
        }
    }

    for(int i=0;i<R+1;i++) {
        for(int j=0;j<C+1;j++) {
            for(int l=0;l<4;l++) {
                if(i>0) {
                    DP[i][j][0] = max(DP[i][j][0], DP[i-1][j][l]);
                    DP[i][j][1] = max(DP[i][j][1], DP[i-1][j][l]+V[i][j]);
                }
                if(j>0) {
                    DP[i][j][l] = max(DP[i][j][l], DP[i][j-1][l]);
                    if(l>0) DP[i][j][l] = max(DP[i][j][l], DP[i][j-1][l-1]+V[i][j]);
                }
            }
        }
    }
    ans = max(ans, DP[R][C][0]);
    ans = max(ans, DP[R][C][1]);
    ans = max(ans, DP[R][C][2]);
    ans = max(ans, DP[R][C][3]);
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007

int main()
{ FAST
    int n, k; cin >> n >> k;
    int arr[n];
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    sort(arr, arr+n);
    reverse(arr, arr+n);
    ll sum = 0;
    for(int i = 0; i < k && i < n; i++){
        arr[i] = 0;
    }
    for(int i = 0; i < n; i++){
        sum+= arr[i];
    }
    cout << sum << endl;
}


Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
        for (int i = 0; i < 3; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        System.out.println(a[0] + a[1]);
    }
}

Measured memory_bytes: 22868
import java.util.*; 
import java.lang.*; 


public class Main{
    
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                
                String S = scan.next();
                
                char t = S.charAt(S.length()-1);
                
                if(t=='s'){
                    System.out.println(S+"es");
                }else{
                    System.out.println(S+"s");
                }

        }
}

Measured memory_bytes: 38512
#include <bits/stdc++.h>
#define P pair<int,int>
#define All(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
typedef long long ll;
using namespace std;
const int INF = 1e9, MOD = 1e9 + 7;
const ll LINF = 1e18;
int main() {
	int n, x, sum, ans = INF;
	vector<int> v;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x;
		v.pb(x);
	}
	sort(All(v));
	int Min = v[0];
	reverse(All(v));
	int Max = v[0];
	for (int i = Min; i <= Max; i++) {
		sum = 0;
		for (int j = 0; j < n; j++) {
			sum += (v[j] - i) * (v[j] - i);
		}
		ans = min(ans, sum);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
  namespace program
  {
    class program
    {
        static void Main()
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int s = a * b;
            int r = 2 * (a + b);
            Console.WriteLine("{0} {1}",s, r);
        }
    }
}

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
string s; 
int a[30];
int k;
int main() {
	cin>>s;
	for(int i=0;i<4;i++) a[int(s[i])-64]++;
	for(int i=1;i<=26;i++) 
		if(a[i]==2) k++;
	if(k==2) cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
main()
{
  int x[3], i, j, tmp;
 
  scanf("%d %d %d", &x[0], &x[1], &x[2]);
   
  for (i = 0; i < 2; i++) {
    for (j = i + 1 ; j < 3 ; j++) {
      if (x[i] > x[j]) {
    tmp = x[i];
    x[i] = x[j];
    x[j] = tmp;
      }
    }
  }
       
 
  printf("%d %d %d\n", x[0], x[1], x[2]);
 
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
int main() {
    ll h;
    cin >> h;
    ll ans = 1;
    while(h) {
        h /= 2;
        ans *= 2;
    }
    cout << ans - 1 << endl;
}


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



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    int n,r;
    cin>>n>>r;
    if(n>=10){
        cout << r << endl;
        return 0;
    }
    int ans = r + 100 * (10 - n);
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>


long solve(long n) {
    long temp = 1;
    for (int i = 1; i <= ceil(sqrt(n)); ++i) {
        if (n % i == 0 && temp + n/temp > i + n/i) {
            temp = i;
        }
    }
    return temp;
}


int main () {
    long n;

    scanf("%ld", &n);
    long m = solve(n);
    printf("%ld\n", m + n/m - 2);
}

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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 201

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define print(v) for (auto i: v) cout << i << " ";

int main() {
    fast
    ll n;
    cin >> n;
    ll s = sqrt(n);
    ll ans = 0;
    while (s > 0) {
        if (n%s == 0) {
            cout << s + n/s - 2 << endl;
            break;
        }
        s--;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = (LL)1e9+7;
const int SIZE = 2e5+5;
const LL INF = 1LL<<60;
const double eps = 1e-4;
const double PI=3.1415926535897932;

LL a[209];
char s[209];

int clz(unsigned long long N) {
    return N ? 64 - __builtin_clzll(N) : -1e9;
}

LL reduce(vector<LL> &a,LL x){
	for(LL j:a){
		if(clz(j^x)<clz(x))return reduce(a,j^x);
	}
	return x;
}

int main(){
	CASET{
		DRI(n);
		REP(i,n){
			scanf("%lld",&a[i]);
		}
		RS(s);
		vector<long long> b;
		bool good = 1;
		for(int i=n-1;i>=0;i--){
			if(s[i]=='0'){// add to base!
				LL nx = reduce(b,a[i]);
				if(nx)b.PB(nx);
			}
			else{ // check!
				LL nx = reduce(b,a[i]);
				if(nx!=0){
					puts("1");
					good = 0;
					break;
				}
			}
		}
		if(good)puts("0");
		case_n++;
	}
}


Measured memory_bytes: 3660
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int check(char *str,int n){
  int i=0;
  for(i=0; i<n; i++){
    if(isalnum(str[i]) == 0){
      return 0;
      break;
    }
  }
  return 1;
}

int main(void) {
	char str[20],temp;
	int n;             //??\??????????????????????????????
	int i;

	do{
	scanf("%s",str);
	n = strlen(str);
	}while((n > 20) || (check(str,n) != 1));


	for (i = 0; i < n / 2; i++) {
		temp = str[i];
		str[i] = str[n - i-1];
		str[n - i-1] = temp;
	}

	printf("%s\n",str);

	return 0;
}

Measured memory_bytes: 524
#include<iostream>
using namespace std;
int main(){
    bool cards[4][14];
    int n,rank;
    char suit;
    for(int s=0;s<4;s++)
      for(int r=1;r<=13;r++)
        cards[s][r]=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>suit>>rank;
        if(suit == 'S')cards[0][rank]=1;
        if(suit == 'H')cards[1][rank]=1;
        if(suit == 'C')cards[2][rank]=1;
        if(suit == 'D')cards[3][rank]=1;
    }
    for(int s=0;s<4;s++){
        for(int r=1;r<=13;r++){
            if(cards[s][r])continue;
            if(s == 0)suit='S';
            if(s == 1)suit='H';
            if(s == 2)suit='C';
            if(s == 3)suit='D';
            cout<<suit<<" "<<r<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3084
def main():
    D, G = map(int, input().split())
    pc = []
    min_ct = 0
    for i in range(D):
        p, c = map(int, input().split())
        pc.append([p, c])
        min_ct += p

    bonus = [set()]
    for i in range(D):
        temp = []
        for st in bonus:
            temp.append(st | {i})
        bonus += temp
    # print(bonus)

    for comp in bonus:
        pt = sum([pc[i][0]*100*(i+1)+pc[i][1] for i in comp])
        ct = sum([pc[i][0] for i in comp])
        j = 0
        # print(comp, pt, j)
        for i in range(D-1, -1, -1):
            if i not in comp:
                while j < pc[i][0] and pt < G:
                    pt += 100 * (i+1)
                    j += 1
                break
        # print(comp, pt, j)
        if pt >= G:
            min_ct = min(min_ct, ct+j)

    return min_ct

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3316
def solve():
    N = int(input())
    dp = [[0] * 3 for i in range(N + 1)]
    for i in range(N):
        A = list(map(int, input().split()))
        for j in range(3):
            for k in range(3):
                if j != k:
                    dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + A[k])
    return max(dp[N])

print(solve())


Measured memory_bytes: 86344
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int N = sc.nextInt();
			int M = sc.nextInt();
			String[] nmap = new String[N];
			String[] mmap = new String[M];
			int nwcnt = 0;
			int nbcnt = 0;
			int mwcnt = 0;
			int mbcnt = 0;
			for (int i = 0; i < N; i++) {
				nmap[i] = sc.next();
				for (char c : nmap[i].toCharArray()) {
					if (c == '.') {
						nwcnt++;
					} else {
						nbcnt++;
					}
				}
			}
			for (int i = 0; i < M; i++) {
				mmap[i] = sc.next();
				for (char c : mmap[i].toCharArray()) {
					if (c == '.') {
						mwcnt++;
					} else {
						mbcnt++;
					}
				}
			}

			boolean ngflg = true;
			int index = 0;
			for (int r = 0; r < (N - M) + 1; r++) {
				for (int mr = 0; mr < M; mr++) {
					if (mr == 0) {
						index = 0;
					}
					index = nmap[r].substring(index).indexOf(mmap[mr]);
					if (index < 0 || !nmap[r].substring(index).startsWith(mmap[mr])) {
						break;
					}
					if (mr == M - 1) {
						ngflg = false;
					}
				}
			}

			if (!ngflg) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
}

Measured memory_bytes: 24916
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
ll ans;

void solve(ll a,ll b)
{
	if(a<b) swap(a,b);
	if(!b){ans+=a;return ;};
	ll cnt=a%b?a/b:a/b-1;
	ans+=cnt*b*2;
	solve(b,a%b);
}

int main()
{
	ll N,X;scanf("%lld %lld",&N,&X);
	ans+=N;
	solve(X,N-X);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a1,a2,a3;
  cin >> a1 >> a2 >> a3;
  if(a1 + a2 + a3 >= 22){
    cout << "bust" << endl;
  }else{
    cout << "win" << endl;
  }
}

Measured memory_bytes: 256
s = input()
a = s[0]
b = s[1]
c = s[2]
d = s[3]
op = ['+','-']

for v in op:
    for w in op:
        for x in op:
            l = str(a+v+b+w+c+x+d)
            if eval (l) == 7:
                print (l+"=7")
                exit ()


Measured memory_bytes: 9044
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include<map>
#include<type_traits>
using namespace std;

int main() {
	long long int N;
	cin >> N;
	if (N % 2 == 0) {
		cout << N << endl;
	}
	else {
		cout << N * 2 << endl;
	}
}



Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define triplerep(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

int main(void){
    int a, b, c, d;
    scnd4( a, b, c, d);
    
    if ( abs(c-a) <= d || (abs(b-a) <= d && abs(b-c) <= d) ) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>

using namespace std;
using ll = long long int;

int main(void){
    
   int n;
   cin>>n;
   int piv = 0;
   int ball_num = 0;
   int j;

   vector<int> a(n);
   vector<int> ans(n);

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

    
   for(int i=n;i>0;i--){
       j=i;
       int count = 2;
       int sum = 0;
        if(j*2<=n){
            while(j*count<=n){
                //cout<<"c : "<<count;
                sum += ans[j*count-1];
                //cout<<" "<<sum<<endl;
                count++;
            }
        }
       
       //cout<<"finish"<<endl;
       if(sum%2 == a[j-1]){
           //cout<<"a"<<endl;
            ans[j-1] = 0;
       }else{
          // cout<<"b"<<endl;
           ans[j-1] = 1;
           ball_num++;
        //    if(ans[j-1] != a[j-1]){
        //        cout<<"-1";
        //        piv = 1;
        //        break;
        //    }
       }
   }

   if(piv == 0){
       cout<<ball_num<<endl;
       for(int i=0;i<n;i++){
           if(ans[i]==1)  cout<<i+1<<" ";
       }
   }
   if(ball_num!=0) cout<<endl;
    return 0;

}

Measured memory_bytes: 2432
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      k: usize,
      a: usize,
      b: usize,
    }

    if k < a+1 {
        return println!("{}", 1+k);
    }
    if a+2 > b {
        return println!("{}", 1+k);
    }

    let mut ans = b;
    let k = k - (a + 1);
    ans += k/2 * (b - a) + k%2;
    println!("{}", ans);
}


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

 int main(){

 int a, b;
 cin>>a>>b;
 if( a < b ) cout<<"a < b"<<endl;
 if( a > b ) cout<<"a > b"<<endl;
 if( a== b ) cout<<"a == b"<<endl;
 return 0;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int x=abs(b-a);
  int y=abs(b-c);
  if(x<=d && y<=d){
    cout<<"Yes"<<endl;
  }else if(abs(a-c)<=d){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
def c_Tak_and_Cards(N, A, S):
    X = max(S + [A])
    y = [0] + [x - A for x in S]
    dp = [[0 for _ in range(2 * N * X + 1)] for _ in range(N + 1)]
    dp[0][N * X] = 1
    for j in range(N + 1):
        for t in range(2 * N * X + 1):
            if j == 0 and t == N * X:
                dp[j][t] = 1
            elif j >= 1 and (t - y[j] < 0 or t - y[j] > 2 * N * X):
                dp[j][t] = dp[j - 1][t]
            elif j >= 1 and 0 <= t - y[j] <= 2 * N * X:
                dp[j][t] = dp[j - 1][t] + dp[j - 1][t - y[j]]
            else:
                dp[j][t] = 0
    return dp[N][N * X] - 1
N,A = [int(i) for i in input().split()]
S = [int(i) for i in input().split()]
print(c_Tak_and_Cards(N, A, S))

Measured memory_bytes: 5732
n = int(input())
a = list(map(int, input().split()))
ans = 0
a_sum = [a[0]]

for i in range(n-1):
    a_sum.append((a_sum[i]+a[i+1])%1000000007)

    ans += a_sum[i]*(a[i+1]%1000000007)

print(ans%1000000007)


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

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


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

	stack<char> stk;
	int ret=0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i]=='g') {
			if (stk.empty()) {
				stk.push('g');
			} else {
				stk.pop();
				ret++;
			}
		} else {
			if (stk.empty()) {
				ret--;
				stk.push('g');
			} else {
				stk.pop();
			}
		}
	}
	cout << ret << endl;

}


Measured memory_bytes: 512
#include<stdio.h>

int main()
{
 int a[3],b[3],c[3],i;
 for (i=0;i<3;i++) {
  scanf("%d",&a[i]);
 }
 for (i=0;i<3;i++) {
  scanf("%d",&b[i]);
 }
 for (i=0;i<3;i++) {
  scanf("%d",&c[i]);
 }
 if (b[1]-b[0] != a[1]-a[0]) {
  printf("No");
  return 0;
 }
 if (b[2]-b[0] != a[2]-a[0]) {
  printf("No");
  return 0;
 }
 if (c[1]-c[0] != a[1]-a[0]) {
  printf("No");
  return 0;
 }
 if (c[2]-c[0] != a[2]-a[0]) {
  printf("No");
  return 0;
 }
 printf("Yes");
 return 0;
}



Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N, M, K;
  cin >> N >> M >> K;
  ll area = 0;
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= M; j++) {
      if (i * (M - j) + j * (N - i) == K) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	double t=0;
	for(int i=1;i<=n;i++){
		int a;
		cin >> a;
		t+=1.0/a;
	}
	cout << (double)1.0/t << endl;
}

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  vector<int> sum(N+1);
  int count = 0;
  vector<int> j(N+1);
  for (int i = 1; i <= N; i++) {
    j.at(i) = i;
    while(j.at(i) > 0){
  	sum.at(i) += j.at(i) % 10;	
    j.at(i) /= 10;
    }
    if (A <= sum.at(i) && sum.at(i) <= B){
      count += i;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <queue>
#include <stack>

using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
#define ll long long
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    int n,x,ans,a[105]={};
    cin >> n >> x;
    rep(i,n){
        cin >> a[i];
    }
    sort(a,a+n);
    int i=0;
    while(x>=a[i]&&i<n){
        if(i==n-1){
            if(x==a[i]){
                ++ans;
            }
            x-=a[i];
            ++i;
        }else{
            x-=a[i];
            ++i;
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int[] list = new int[n];
        for (int i = 0; i < n; i++) {
            list[i] = sc.nextInt();
        }
        Arrays.sort(list);
        int sum = 0;
        int index = 0;
        while (sum <= x && index != n) {
            sum += list[index++];
        }
        if (sum != x) {
            index--;
        }
        System.out.println(index);
    }
}

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

n = int(input())
edges = [list(map(int,input().split())) for _ in range(n-1)]
q,k = map(int,input().split())
xy = [list(map(int,input().split())) for _ in range(q)]

roots = [[] for _ in range(n)]
for a,b,c in edges:
    roots[a-1].append((b-1,c))
    roots[b-1].append((a-1,c))

dis = [-1] * n
dis[k-1] = 0
stack = [k-1]

while stack:
    label = stack.pop(-1)
    for i,c in roots[label]:
        if dis[i] == -1:
            dis[i] = dis[label] + c
            stack.append(i)

for x,y in xy:
    print(dis[x-1] + dis[y-1])


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

ifstream in ( "test.in"  );
ofstream out( "test.out" );

const int DIM = 5e2 + 5;

int mat[DIM][DIM];

int main( void ) {
    
    int n, m, h, w;
    cin >> n >> m >> h >> w;
    
    int cns = 1e9 / (h * w);
    
    long long sum = 0;
    for( int i = 1; i <= n; i ++ ) {
        for( int j = 1; j <= m; j ++ ) {
            if( i % h == 0 && j % w == 0 )
                mat[i][j] = -(h * w - 1) * cns - 1;
            else
                mat[i][j] = cns;
            
            sum += mat[i][j];
        }
    }
    
    if( sum >= 0 ) {
        cout << "Yes\n";
        
        for( int i = 1; i <= n; i ++ ) {
            for( int j = 1; j <= m; j ++ )
                cout << mat[i][j] << " ";
            cout << "\n";
        }
    } else
        cout << "No";
    
    return 0;
}

Measured memory_bytes: 3840
#include <iomanip>
#include <limits>
#include <thread>
#include <utility>
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <numeric>
#include <cassert>
#include <random>
#include <chrono>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <list>
#include <functional>
#include <bitset>
#include <complex>
#include <tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double D;
typedef complex<D> P;
const ll E = 1e18 + 7;
const ll MOD = 1000000007;
#define REP(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define fill(x, y) memset(x, y, sizeof(x))
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
template <class... A>
void prints() { cout << endl; }
template <class... A>
void prints_rest() { cout << endl; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }

template <class T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

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

    int N;
    cin >> N;

    int ans  = 0;
    rep(i, N) {
        int d = floor(log10(i+1)) + 1;
        if (d%2 == 1) ++ans; 
    }

    prints(ans);
    return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
from itertools import combinations
import sys
input = sys.stdin.readline

number = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
n = int(input())
s = input().rstrip()

ans = 0
for item in number:
    if item not in s:
        continue
    a = s.index(item)
    if a >= n-2:
        continue
    for item2 in number:
        if item2 not in s[a+1:]:
            continue
        b = a + 1 + s[a+1:].index(item2)
        if b >= n-1:
            continue
        for item3 in number:
            if item3 not in s[b+1:]: 
                continue
            c = b + 1 + s[b+1:].index(item3)
            ans += 1
print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

int main(){
 int n;
 double a,m,sum;
 while(1){
  cin >> n;
  int s[n+1]={};
  if(n==0) break;

  sum=0;
  for(int i=0;i<n;++i){
   cin >> s[i];
   sum+=s[i];
  }
  m=sum/n;

  a=0;
  for(int i=0;i<n;++i){
   a+=pow(s[i]-m,2);
  }
  a=sqrt(a/n);
  cout << fixed << setprecision(8) << a << endl ;
 }
 return 0;
}

Measured memory_bytes: 3276
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>
#include <string>
using namespace std;
int main(void) {
	for (;;) {
		string input,buf;
		cin >> input;
		if (input == ".")return 0;
		int cnt = 0;
		for (char a : input) {
			switch (a) {
			case '+':
				cnt++;
				break;
			case '-':
				cnt--;
				break;
			case '[':
			case ']':
				buf += a;
				break;
			case '?':
				buf += 'A';
				cnt = 0;
				break;
			default:
				a += cnt % 26;
				buf += (a<'A') ? a + 26 : (a>'Z') ? a - 26 : a;
				cnt = 0;
				break;
			}
		}
		bool update;
		do {
			input = buf;
			update = false;
			int start;
			for (int i = 0; i < input.size();i++) {
				if (input[i] == '[')start = i;
				if (input[i] == ']') {
					buf = string(input.begin(), input.begin() + start);
					buf.append(input.rend() - i, input.rend() - start - 1);
					buf.append(input.begin() + i + 1, input.end());
					update = true;
					break;
				}
			}
		} while (update);
		cout << buf << endl;
	}
}

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
using ull = unsigned long long;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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 (b < a) { a = b; return 1; } return 0; }

constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
constexpr double EPS = 1e-10;
constexpr int INF = 1001001001;
//constexpr ll INF = 1001001001001001001ll;


int main() {
    int n; cin >> n;
    deque<ll> q;
    bool f = true;
    rep(i, n) {
        ll a; cin >> a;
        if (f) {
            q.push_back(a);
            f = !f;
        }
        else {
            q.push_front(a);
            f = !f;
        }
    }

    if (!f) reverse(all(q));

    for (auto x : q) {
        cout << x << " ";
    }
    cout << endl;

}


Measured memory_bytes: 3840
s = input()
t = input()
index = 0
s = ''.join(list(reversed(s)))
t = ''.join(list(reversed(t)))
#まず、？とtの統合性が取れているかを確認
#後ろから調べてく
exit_flag = True
for i in range(len(s)):
    #逆から見ていき、一文字目が一致するかどうかの確認
    if s[i] == t[0] or s[i] == '?':
        if i + len(t) > len(s):
            break
        for j in range(len(t)):
            if not (s[i + j] == t[j] or s[i + j] == '?'):
                break
            if j == len(t) - 1:
                start_index = i
                exit_flag = False
        if not exit_flag:
            break
#条件に合わなかったら終わり

if exit_flag:
    print("UNRESTORABLE")
    exit()
ans = s[:start_index] + t + s[start_index + len(t):]
ans = ''.join(list(reversed(ans)))
ans = ans.replace("?", "a")
print(ans)


Measured memory_bytes: 3064
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
    
N,M = map(int,input().split())
s = input()
t = input()
g = gcd(N,M)
l = N*M//g

n = N//g
m = M//g

ans = l

for i in range(g):
    if s[i*n]!=t[i*m]:
        ans = -1
        break
print(ans)




Measured memory_bytes: 3316
#include <stdio.h> 
 
 
 int main(){ 
     int h, w; 
     int i, j; 
     while(1){ 
         scanf("%d %d ", &h, &w); 
         if(h==0&&w==0)break; 
         for(i=0;i<h;i++){ 
             for(j=0;j<w;j++){ 
                 if((i%2==0&&j%2==0)||(i%2==1&&j%2==1)){ 
                     printf("#"); 
                 }else{ 
                     printf("."); 
                 } 
             } 
             printf("\n"); 
         } 
         printf("\n"); 
     } 
 
 
     return 0; 
 } 



Measured memory_bytes: 2108
#include<iostream>
#include<string>

int main(){

	int n;
	std::cin >> n;

	std::string str;
	std::cin >> str;

	int res = 0;

	for (int i = 0; i < n; i++){
		std::string sign;
		std::cin >> sign;

		for (int j = 0; j < sign.size(); j++){
			if (sign[j] == str[0]){
				for (int k= j + 1; k < sign.size(); k++){
					if (sign[k] == str[1]){
						int aida = k - j;
						bool flg = true;
						for (int l = 1; l <= str.size() - 2; l++){
							if (k + aida*l >= sign.size() || sign[k + aida*l] != str[l + 1])flg = false;
						}

						if (flg){
							res++;
							goto next;
						}
					}
				}
			}
		}

	next:;
	}

	std::cout << res << std::endl;

	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <math.h>
#include <stdbool.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <chrono>
using namespace std;

int main(){
    #if 0
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
    #endif

    string S;
    cin >> S;

    bool yes = true;

    for (int i=0; i<S.size(); ++i){
        const char s = S[i];
        if ( i%2==0 && s == 'L'){
            yes = false;
            break;
        }
        if ( i%2==1 && s == 'R'){
            yes = false;
            break;
        }
    }

    if (yes){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
x,y,z,K = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

kouho = []

for i in range(x):
    for j in range(y):
        for k in range(z):
            if (i+1)*(j+1)*(k+1) > K:
                break
            kouho.append(a[i]+b[j]+c[k])


kouho.sort(reverse=True)

for i in range(K):
    print(kouho[i])

Measured memory_bytes: 8740
import java.util.*;

public class Main {
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		String ans = null;
		if (b > 0) {
			if (a > 0) {
				ans = "Positive";
			} else {
				ans = "Zero";
			}
		} else if (b == 0) {
			ans = "Zero";
		} else {
			int x = a - b;
			if (x % 2 == 0) {
				ans = "Negative";
			} else {
				ans = "Positive";
			}
		}
		System.out.print(ans);
	}
}


Measured memory_bytes: 23252
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	string S=in<string>(),T=in<string>();

	out(T+S);
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
import bisect
s, t = [x.strip() for x in open(0).readlines()]
if set(t) - set(s) != set():
    print(-1)
else:
    d = defaultdict(list)
    n = len(s)
    for i, c in enumerate(s, 1):
        d[c].append(i)
    for k in d:
        d[k].append(d[k][0] + n)
    ans = 0
    for c in t:
        q, r = divmod(ans, n)
        x = d[c][bisect.bisect(d[c], r)]
        ans = n*q + x
    print(ans)

Measured memory_bytes: 8052
// Enjoy your stay.

#include <bits/stdc++.h>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

typedef istringstream iss;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef stringstream sst;
typedef vector<ll> vi;

int n,m,y[5555],x[5555];
int sum[5555][5555];
vi zy,zx;

int f(int Y,int X){
	return sum[upper_bound(zy.begin(),zy.end(),Y)-zy.begin()]
		[upper_bound(zx.begin(),zx.end(),X)-zx.begin()];
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>n>>m;
	rep(i,n){
		cin>>y[i]>>x[i];
		zy.pb(y[i]);
		zx.pb(x[i]);
	}
	zy.pb(INF);zx.pb(INF);
	sort(zy.begin(),zy.end());
	sort(zx.begin(),zx.end());
	rep(i,n){
		sum[upper_bound(zy.begin(),zy.end(),y[i])-zy.begin()]
		[upper_bound(zx.begin(),zx.end(),x[i])-zx.begin()]++;
	}
	rep2(i,1,sz(zy)+1)rep2(j,1,sz(zx)+1){
		sum[i][j] += sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1];
	}
	rep(i,m){
		int y1,x1,y2,x2;
		cin>>y1>>x1>>y2>>x2;
		cout<<f(y2,x2) - f(y1-1,x2) - f(y2,x1-1) + f(y1-1,x1-1)<<endl; 
	}
}

Measured memory_bytes: 112004