akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cassert>
#include<set>
#include<sstream>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)
#define MAX 20

using namespace std;

string parse;
char  cparse[MAX];
int N,sweets[MAX],n;

set<vector<char> > ans;
char opr[] = {'&','|','^'};

int exp(int&,int&,vector<char>&);

int fact(int &cur,int &ocnt,vector<char> &vec)
{
  int p;
  if(parse[cur] == '(')
    {
      cur++;
      p = exp(cur,ocnt,vec);
      cur++;
      return p;
    }
  else
    {
      p = parse[cur]-'0';
      cur++;
      return sweets[p-1];
    }
}

int exp(int &cur,int &ocnt,vector<char> &vec)
{
  int p;
  p = fact(cur,ocnt,vec);
  if(ocnt < vec.size())
    {
      int q = fact(cur,ocnt,vec);
      int ret;
      if(vec[ocnt] == '&')ret = p & q;
      if(vec[ocnt] == '|')ret = p | q;
      if(vec[ocnt] == '^')ret = p ^ q;
      ocnt++;
      return ret;
    }
  return p;
}


bool check(vector<char> &vec)
{
  int cur = 0;
  int ocnt = 0;
  int res = exp(cur,ocnt,vec);
  return res == (1<<4)-1;
}

void dfs(int cur,vector<char> &vec)
{
  if(cur >= vec.size())
    {
      if(check(vec))ans.insert(vec);
      return;
    }

  rep(i,3)
    {
      vec[cur] = opr[i];
      dfs(cur+1,vec);
    }

}

void change()
{
  stringstream ss;
  ss << parse;
  string content = "";
  while(!(ss>>parse).fail())content += parse;
  parse = content;
}

int main()
{
  while(getline(cin,parse),parse != "END")
    {
      n = 0;
      rep(i,parse.size())if(parse[i] == '(')n++;
      change();
      ans.clear();


      cin >> N;
      rep(i,N)
	{
	  sweets[i] = 0;
	  rep(j,4)
	    {
	      int bit;
	      cin >> bit;
	      if(bit)
		{
		  sweets[i] |= (1<<j);
		}
	    }
	}

      vector<char> vec(n);
      dfs(0,vec);

      cout << ans.size() << endl;
      cin.ignore();
    }
  return 0;
}

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

using namespace std;
using ll = long long;

const ll INF = 1LL << 60;
ll s;

pair<ll, ll> num(ll x) {
  return pair<ll, ll>(x/3 + x/5 - 2*(x/15), x/15);
}

ll sumOfLen(ll x) {
  if (x == 0) return 0;
  int d = 0;
  ll L = 1, R = 10;
  ll len = 0;
  ll i, j, k, l;
  for (; !(L <= x && x < R); d++, L *= 10, R *= 10) {
    tie(i, j) = num(R-1);
    tie(k, l) = num(L-1);
    i -= k; j -= l;
    len += i*4 + j*8;
    len += (R-L-i-j)*(d+1);
    if (len > s) return s+1;
  }
  tie(i, j) = num(x);
  tie(k, l) = num(L-1);
  i -= k; j -= l;
  len += i*4 + j*8;
  len += (x+1-L-i-j)*(d+1);
  return len;
}

int calcLen(ll x) {
  if (x % 15 == 0) return 8;
  if (x % 3 == 0 || x % 5 == 0) return 4;
  ll res = 0;
  while (x) {
    x /= 10;
    res++;
  }
  return res;
}

int main() {
  cin >> s;
  s--;
  
  ll ok = 0, ng = INF;
  while (ng - ok > 1) {
    ll m = (ok + ng) / 2;
    if (sumOfLen(m) <= s) ok = m;
    else ng = m;
  }
  s -= sumOfLen(ok);
  int lim = 20;
  string t;
  if (ng % 3 == 0 || ng % 5 == 0) {
    if (ng % 3 == 0) t += "Fizz";
    if (ng % 5 == 0) t += "Buzz";
    t = t.substr(s);
    lim -= t.size();
    cout << t;
  } else {
    t = to_string(ng).substr(s);
    lim -= t.size();
    cout << t;
  }
  for (ng++; lim - calcLen(ng) >= 0; ng++) {
    if (ng % 15 == 0) cout << "FizzBuzz";
    else if (ng % 3 == 0) cout << "Fizz";
    else if (ng % 5 == 0) cout << "Buzz";
    else cout << ng;
    lim -= calcLen(ng);
  }
  if (ng % 15 == 0) t = "FizzBuzz";
  else if (ng % 3 == 0) t = "Fizz";
  else if (ng % 5 == 0) t = "Buzz";
  else t = to_string(ng);
  cout << t.substr(0, lim) << endl;
  
  return 0;
}


Measured memory_bytes: 3300
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n, ans = 0;
    string s, s2 = "ABC";
    cin >> n >> s;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == s2[cnt]){
            cnt++;
            if(cnt == 3){
                ans++;
                cnt = 0;
            }
        }else if(s[i] == 'A'){
            cnt = 1;
        }else{
            cnt = 0;
        }
    }    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define long long long
using namespace std;
const long N=1e6;
long n,k,aa[N+2];
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  cin>>n>>k;vector<long>v;
  for(long i=1;i<=n;i++)
    cin>>aa[i];
  for(long i=1;i<=n;i++)
  {
    long sum=0;
    for(long j=i;j<=n;j++)
    {
      sum+=(aa[j]*1LL);
      v.push_back(sum);
    }
  }
  long ans=0;vector<long>tmp;
  for(long i=62;i>=0;i--)
  {
    tmp.clear();
    for(auto x:v)
    {
      if(x&(1LL<<i))
      {
        tmp.push_back(x);
      }
    }
    if(tmp.size()>=k)
    {
      ans|=(1LL<<i);v=tmp;
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif



void solve(){
    map<int,int> m;
    int N;
    cin >> N;
    rep(i,N){
        int A; cin >> A;
        m[A]++;
    }
    for(auto i=m.begin(); i!=m.end();i++){
        if(i->second!=1){ NO; return;}
    }
    YES;
}

signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}


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

long long sum(long long x){
    if(x == 0){
        return 0;
    }
    else if((x%3 == 0)||(x%5 == 0)){
        return sum(x - 1);
    }
    else{
        return x + sum(x - 1);
    }
}

int main(){
    long long n;
    cin >> n;
    cout << sum(n) << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <queue>
#include <stack>
#include <algorithm>
#define ll long long
using namespace std;

ll N,M;
char S[100010],T[100010];

ll gcd(ll a,ll b){
	return b==0?a:gcd(b,a%b);
}

int main() {
	
	scanf("%lld%lld",&N,&M);
	for(int i=0;i<N;++i)cin >> S[i];
	for(int j=0;j<M;++j)cin >> T[j];
	
	bool flag=true;
	ll GCD=gcd(N,M);
	ll LCM=N*M/GCD;
	ll n=N/GCD,m=M/GCD;
	for(int i=0;i<GCD;++i){
		if(S[i*n]!=T[i*m]){flag=false;break;}
	}
	if(flag)printf("%lld\n",LCM);
	else printf("-1\n");

	return 0;
}

Measured memory_bytes: 384
import java.util.*
import kotlin.math.acos
import kotlin.math.cos
import kotlin.math.round
import kotlin.math.sin

fun main(args: Array<String>) {
    val (n, m) = readIntList()
    val a = readIntList()

    val pq = PriorityQueue<Int>(Collections.reverseOrder())
    pq.addAll(a)
    repeat(m) {
        val max = pq.poll()
        pq.add(max / 2)
    }
    var sum = 0L
    pq.forEach { sum += it }
    println(sum)
}

// read
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

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

using namespace std;

int main()
{
    int a, b, ab, o;
    a = b = ab = o = 0;

    int id;
    char ch;
    string blood;
    while (cin >> id >> ch >> blood) {
        if (blood == "A") {
            a++;
        } else if (blood == "B") {
            b++;
        } else if (blood == "AB") {
            ab++;
        } else if (blood == "O") {
            o++;
        } else {
            cout << "ERROR" << endl;
        }
    }

    cout << a << endl << b << endl << ab << endl << o << endl;

    return 0;
}

Measured memory_bytes: 1204
import numpy as np
import itertools

num=list(map(int,input().split()))
a=0
ten=[]
for i in range(num[0]):
    ten.append(list(map(int,input().split())))

poi=list(itertools.combinations(ten, 2))

for i in range(len(poi)):
    c=np.array(poi[i][0])
    b=np.array(poi[i][1])
    l = np.linalg.norm(b-c)
    if l%1==0:
        a += 1

print(a)



Measured memory_bytes: 12424
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define printP(x) "(" << (x).first << ", " << (x).second << ")"
#define mod 1000000007
using namespace std;
typedef pair<llint, llint> P;

llint n, c;
llint a[405], b[405];
llint dp[2][405][405];

int main(void)
{
	cin >> n >> c;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) cin >> b[i];
	
	dp[0][0][0] = 1;
	for(int i = 0; i <= c; i++){
		for(int j = 1; j <= n; j++){
			for(int k = 1; k <= b[j]; k++){
				dp[i%2][j][k] = 0;
			}
		}
		for(int j = 1; j <= n; j++){
			llint sum = 0;
			for(int k = a[j-1]; k <= b[j-1]; k++) sum += dp[i%2][j-1][k], sum %= mod;
			for(int k = a[j]; k <= b[j]; k++){
				dp[i%2][j][k] = 0;
				if(i > 0) dp[i%2][j][k] += dp[(i-1)%2][j][k] * k % mod, dp[i%2][j][k] %= mod;
				dp[i%2][j][k] += sum, dp[i%2][j][k] %= mod;
			}
		}
		dp[0][0][0] = 0;
	}
	
	llint ans = 0;
	for(int k = 1; k <= 400; k++){
		ans += dp[c%2][n][k], ans %= mod;
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m,a,b;
	int h[100010];
	vector<int > v[100010];
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		cin >> h[i];
	}
	for(int i = 0; i < m; i++){
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	int cnt = 0;
	for(int i = 1; i <= n; i++){
		if(v[i].empty()){
			cnt++;
		}else{
			int flag = 1;
			for(auto x:v[i]){
				if(h[x] >= h[i]){
					flag = 0;
					break;
				}
			}
			if(flag)
				cnt++;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 9064
import java.util.*;
import java.io.*;
import java.util.stream.*;

public class Main{
	private static BufferedReader in;
	private static BufferedWriter out;
	
	public static void main(String[] args) throws IOException {
		open();

		StringTokenizer st;
		StringBuilder sb;
		
		String line=readString();
		int N=line.length();
		int mid=N/2;
		String r=line.substring(0,mid);
		String l=line.substring(mid+1,N);
		if(r.equals(l))
			out.write("Yes\n");
		else
			out.write("No\n");
		
		
		close();
	}
	
	private static int[] readInts() throws IOException {
		return Stream.of(in.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
	}

	private static int readInt() throws IOException {
		return Integer.parseInt(in.readLine());
	}

	private static long[] readLongs() throws IOException {
		return Stream.of(in.readLine().split(" ")).mapToLong(Long::parseLong).toArray();
	}

	private static long readLong() throws IOException {
		return Long.parseLong(in.readLine());
	}

	private static double[] readDoubles() throws IOException {
		return Stream.of(in.readLine().split(" ")).mapToDouble(Double::parseDouble).toArray();
	}

	private static double readDouble() throws IOException {
		return Double.parseDouble(in.readLine());
	}

	private static String readString() throws IOException {
		return in.readLine();
	}

	private static int setBit(int S, int j) {
		return S | (1 << j);
	}

	private static int isOn(int S, int j) {
		return S & (1 << j);
	}

	private static int clearBit(int S, int j) {
		return S & ~(1 << j);
	}

	private static int toggleBit(int S, int j) {
		return S ^ (1 << j);
	}

	private static int lowBit(int S) {
		return S & (-S);
	}

	private static int setAll(int n) {
		return (1 << n) - 1;
	}

	private static int modulo(int S, int N) {
		return ((S) & (N - 1));
	} // returns S % N, where N is a power of 2

	private static boolean isPowerOfTwo(int S) {
		return (S & (S - 1)) == 0 ? true : false;
	}

	private static int nearestPowerOfTwo(int S) {
		return ((int) Math.pow(2.0, (int) ((Math.log((double) S) / Math.log(2.0)) + 0.5)));
	}

	private static int turnOffLastBit(int S) {
		return ((S) & (S - 1));
	}

	private static int turnOnLastZero(int S) {
		return ((S) | (S + 1));
	}

	private static int turnOffLastConsecutiveBits(int S) {
		return ((S) & (S + 1));
	}

	private static int turnOnLastConsecutiveZeroes(int S) {
		return ((S) | (S - 1));
	}

	private static void open() {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new BufferedWriter(new OutputStreamWriter((System.out)));
	}

	private static void close() throws IOException {
		out.flush();
		out.close();
		in.close();
	}
}


Measured memory_bytes: 23124
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) (a < b ? b : a)
#define min(a,b) (a > b ? b : a)
#define AAA (1000000007)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


int main() {
	int x, y;
	cin >> x >> y;
	if (x == 2 || y == 2) {
		cout << "No";
		return 0;

	}
	if (x == 4 || x == 6 || x == 9 || x == 11) {
		if (y == 4 || y == 6 || y == 9 || y == 11) {
			cout << "Yes";
			return 0;
		}
		cout << "No";
		return 0;


	}
	if (y == 4 || y == 6 || y == 9 || y == 11) {
		cout << "No";
		return 0;
	}
	cout << "Yes";


	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  int a,i,s=0;
  for(i=0;i<m;i++)
  {
    cin>>a;
    s+=a;
  }
  if(s>n)
  cout<<"-1";
  else
  cout<<n-s;
  return 0;
}

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

#define INPUTMAX 9999

typedef struct listelem {
        int str[7];
}Dice;

int main(void)
{
  Dice a;
  char input_data[INPUTMAX], *word, compass[999];
  unsigned int i=1;
  int tmp;

  fgets(input_data, sizeof(input_data), stdin);
  word = strtok(input_data, " ");
  for(; word != NULL; i++){
    a.str[i] = atoi(word);
    word = strtok(NULL, " \n");
  }
  fgets(compass, sizeof(compass), stdin);
  for(i = 0; i < strlen(compass); i++){
    if (compass[i] == 'E'){
      tmp = a.str[1];
      a.str[1] = a.str[4];
      a.str[4] = a.str[6];
      a.str[6] = a.str[3];
      a.str[3] = tmp;
    } if (compass[i] == 'N'){
      tmp = a.str[1];
      a.str[1] = a.str[2];
      a.str[2] = a.str[6];
      a.str[6] = a.str[5];
      a.str[5] = tmp;
    } if (compass[i] == 'S'){
      tmp = a.str[1];
      a.str[1] = a.str[5];
      a.str[5] = a.str[6];
      a.str[6] = a.str[2];
      a.str[2] = tmp;
    } if (compass[i] == 'W'){
      tmp = a.str[1];
      a.str[1] = a.str[3];
      a.str[3] = a.str[6];
      a.str[6] = a.str[4];
      a.str[4] = tmp;
    }
  }
  printf("%d\n", a.str[1]);
  return 0;
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define all(a) (a).begin(), (a).end()

using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }

struct edge {
  int to; ll cost;
};

const int MAX_N = TEN(5);
int n,m;
vec<edge> g[MAX_N];
ll d[MAX_N];

void add_edge(int u, int v, ll c)
{
  g[u].push_back((edge){v,c});
}

int main()
{
  fastio();

  cin >> n >> m;
  forn(i,n-1) {
    add_edge(i+1, i, 0);
  }

  forn(i,m) {
    int l,r,c; cin >> l >> r >> c;
    add_edge(l-1,r-1,c);
  }

  fill_n(d, n, LLONG_MAX);
  priority_queue<pli, vector<pli>, greater<pli>> q;
  q.push(mp(0,0));
  d[0] = 0;

  while (!q.empty()) {
    int i; ll cost;
    tie(cost, i) = q.top(); q.pop();

    if (i == n-1) {
      cout << cost << endl;
      return 0;
    }

    if (d[i] < cost) continue;

    for (auto e : g[i]) {
      if (d[e.to] > d[i] + e.cost) {
        d[e.to] = d[i] + e.cost;
        q.push(mp(d[e.to], e.to));
      }
    }
  }

  cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 10232
A = [list(map(int,input().split())) for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]
c = [[0]*3 for _ in range(3)]
for x in b:
  for i in range(3):
    for j in range(3):
      if A[i][j] == x:
        c[i][j] = 1

if c[0] == [1,1,1] or c[1] == [1,1,1] or c[2] == [1,1,1]:
  print("Yes")
elif [c[0][0], c[1][0], c[2][0]] == [1,1,1] or [c[0][1], c[1][1], c[2][1]] == [1,1,1] or [c[0][2], c[1][2], c[2][2]] == [1,1,1]:
  print("Yes")
elif [c[0][0], c[1][1], c[2][2]] == [1,1,1] or [c[2][0], c[1][1], c[0][2]] == [1,1,1]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9148
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int>> a(H, vector<int>(W));
    rep(i, H) rep(j, W) cin >> a[i][j];
    
    vector<int> y, x, Y, X;
    rep(i, H) rep(j, W - 1) {
        if (a[i][j] % 2 == 1) {
            --a[i][j];
            ++a[i][j + 1];
            y.push_back(i);
            x.push_back(j);
            Y.push_back(i);
            X.push_back(j + 1);
        }
    }
    rep(i, H - 1) {
        if (a[i][W - 1] % 2 == 1) {
            --a[i][W - 1];
            ++a[i + 1][W - 1];
            y.push_back(i);
            x.push_back(W - 1);
            Y.push_back(i + 1);
            X.push_back(W - 1);
        }
    }
    
    cout << y.size() << endl;
    rep(i, y.size()) {
        cout << y[i] + 1 << " " << x[i] + 1 << " " << Y[i] + 1 << " " << X[i] + 1 << endl;
    }
    return 0;
}


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


int main(){
    int n;
    cin >> n;
    vector<ll> vx(n),vy(n),vh(n);
    int si = -1;
    rep(i,n){
        cin >> vx[i] >> vy[i] >> vh[i];
        if(vh[i] > 0) si = i;
    }
    ll rx,ry,rh;
    for(ll x=0;x<=100;x++){
        for(ll y=0;y<=100;y++){
            ll h = vh[si]+abs(x-vx[si])+abs(y-vy[si]);
            bool ok = true;
            rep(i,n){
                if(vh[i] > 0 && h-vh[i] !=abs(x-vx[i])+abs(y-vy[i])) ok = false;
                if (vh[i] == 0 && h > abs(x - vx[i]) + abs(y - vy[i]))
                    ok = false;
            }
            if(ok) rx=x,ry=y,rh=h;
        }
    }
    cout<<rx<<" "<<ry<<" "<<rh<<endl;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  auto s = readln.chomp;
  int res;
  switch (s) {
    case "SUN":
      res = 7;
      break;
    case "MON":
      res = 6;
      break;
    case "TUE":
      res = 5;
      break;
    case "WED":
      res = 4;
      break;
    case "THU":
      res = 3;
      break;
    case "FRI":
      res = 2;
      break;
    case "SAT":
      res = 1;
      break;
    default:
  }
  res.writeln;
}


Measured memory_bytes: 256
/**
*    created: 23.06.2020 23:32:09
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcount(bit)
#define mod 1000000007
#define pi acos(-1.0)
using namespace std;

signed main() {

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

    int a, b, c;
    cin >> a >> b >> c;
    cout << max({10*a+b+c,a+10*b+c,a+b+10*c}) << endl;
    return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> T1 pow_(T1 a, T2 b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  cin >> a;
  vector<vector<int> > G(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].eb(b);
    G[b].eb(a);
  }
  int cnt = 0;
  rep(v, n) {
    [&]() {
      for (int nv : G[v]) {
        if (a[nv] >= a[v]) return;
      }
      cnt++;
    }();
  }
  cout << cnt << endl;
}


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


int main()
{
	int n, b, f, r, v, house[4][3][10];
	
	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			for(int k = 0; k < 10; k++)
			{
				house[i][j][k] = 0;
			}
		}
	}
	
	string s = "####################";
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> b >> f >> r >> v;
		house[b-1][f-1][r-1] += v;
	}

	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			for(int k = 0; k < 10; k++)
			{
				cout << " " << house[i][j][k];
			}
			cout << "\n";
		}
		if (i < 3)
			cout << s << "\n";
	}
	return 0;
}




Measured memory_bytes: 3136
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};



int main(){
  int n; cin>>n;
  vector<int> a(26,50);
  rep(i,n){
    string s; cin>>s;
    vector<int> c(26,0);
    rep(j,s.size()){
      c[s[j]-'a']++;
    }
    rep(k,26){
      a[k]=min(a[k],c[k]);
    }
  }
  rep(i,26){
    rep(j,a[i]){
      char ans=i+'a';
      cout<<ans;
    }
  }
  cout<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forn(i, a, b) for(int i=(a); i<=(b); i++)
#define rforn(i, a, b) for(int i=(a); i>=(b); i--)
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define tests(t) int t; cin >> t; while(t--)
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define gcd __gcd
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define vi vector<int>
#define vpii vector<pii>
#define vvi vector<vi>
#define bitcount(x) __builtin_popcount(x)
#define PI acos(-1.0)
#define mod 1000000007
#define endl '\n'
#define int ll
using namespace std;
#define N 100005
#define inf 100000000000009LL


int w[100] , v[100];
int dp[101][100001];
int32_t main()
{   
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false), cin.tie(NULL);
    clock_t clk = clock();
    
    int n , W;
    cin >> n >> W;
    for(int i = 0 ; i < n ; i++){
        cin >> w[i] >> v[i];
    }

    dp[0][0] = 0;
    dp[0][w[0]] = v[0];

    for(int id = 1; id < n ; id++){
        dp[id][0] = 0;
        for(int j = 1; j <= W ; j++){

            dp[id][j] = dp[id-1][j];
            if(j >= w[id])
            dp[id][j] = max(dp[id][j]  , v[id] + dp[id-1][j - w[id]]);

        }
    }
    int ans = INT_MIN;
    for(int j = 0; j <= W ; j++){
        ans = max(dp[n-1][j] , ans);
    }

    cout << ans << endl;

    cerr<< "Time (in ms): " << double(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';
}

Measured memory_bytes: 81156
#include <bits/stdc++.h>
using namespace std;
#define int long long 
signed main() {
int n;
cin>>n;
int a[n+1],b[n];
int mn=0;
for(int i=0;i<n+1;i++)
{
  cin>>a[i];
}
for(int i=0;i<n;i++)
{
cin>>b[i];
}
long ans=0;
for(int i=0;i<n;i++)
{
  if(b[i]>a[i])
  {
          ans+=a[i];
        int temp= a[i+1]-(b[i]-a[i]);
        if(temp<=0)
        {
          ans+=a[i+1];
          a[i+1]=0;
        }
        else
        {
          ans+=a[i+1]-temp;
          a[i+1]-=(b[i]-a[i]);
        }
  }
  else
  {
    ans+=b[i];
  }
}
cout<<ans<<endl;



}


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

using namespace std;

inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0' || ch>'9') {if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*f;
}

int main()
{
	int n;
	n=read();
	int a=n%10,b=n/100;
	if(a==b) puts("Yes"); else puts("No");
	return 0;
}


Measured memory_bytes: 128
def main():

    N, M = map(int, input().split())
    solved = [0 for _ in range(N)]
    penal = [0 for _ in range(N)]
    for _ in range(M):
        p, S = input().split()
        p = int(p)
        if S == "AC":
            solved[p-1] = 1
        else:
            if solved[p-1] == 0:
                penal[p-1] += 1
    pt = 0
    for i in range(N):
        if solved[i] == 1:
            pt += penal[i]
    return " ".join(map(str, [sum(solved), pt]))

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

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  ll N;
  cin>>N;
  vector<ll> vec(N+1,0);

  ll x=0;
  FOR(i,1,N+1){
    cin>>x;
    vec[i]=vec[i-1]+x;
  }
  sort(vec.begin(),vec.end());

  ll res=0;
  x=1;
  FOR(i,1,N+1){
    if(vec[i]==vec[i-1]){
      x++;
    }
    else{
      res=res+x*(x-1)/2;
      x=1;
    }

  }
  res=res+x*(x-1)/2;
  //coutv(vec,0,N+1);
  cout<<res<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;

    vector<int> d(N);

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

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

    int ans=0;

    for(int i=0;i<d.size()-1;i++){
        if(d.at(i)>d.at(i+1)){
            ans++;
        }
    }

    cout << ans+1 << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define reverse(x) reverse(x.begin(), x.end())
#define pb push_back
#define pii pair<int, int>
#define pll pair<long long,long long>
#define f first
#define s second
typedef long long ll;
const int mod = 1e9+7;
using namespace std;
int n, m;

int main(){
	int x,a,b;
	cin >> x >> a >> b;
	if(-a+b <= 0){
		cout << "delicious";
	}else if(-a+b <= x){
		cout << "safe";
	}else {
		cout << "dangerous";
	}
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long double ld;
typedef long long ll;
const int MOD =  1000000007;
const int IINF = INT_MAX;
const ll INF = 1LL << 60;


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

    V<int> ans(10050);
    for(int x = 1; x <= 100; x++){
        for(int y = 1; y <= 100; y++){
            for(int z = 1; z <= 100; z++){
                int sum = x*x + y*y + z*z + x*y + y*z + z*x;
                if(sum < 10050) ans[sum]++;
            }
        }
    }
    for(int i = 1; i <= n; i++){
        cout << ans[i] << endl;
    }


    return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string Yes="Yes";
string YES="YES";
string NO="NO";
string No="No";
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
 
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;

map< ll, int > prime_factor(ll n) {//素因数分解
  map< ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}


int main(){
    ll n,p;
    std::cin >> n>>p;
    map<ll,int>mp=prime_factor(p);
    ll ans=1;
    erep(i,mp){
        i.se/=n;
        ans*=pow(i.fi,i.se);
    }
    std::cout << ans << std::endl;
}

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

int main(){
    int n;
    string s,tmp = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    while(cin >> n,n){
        vector <int> key(n+1);
        for(int i=0;i<n;i++) cin >> key[i];
        cin >> s;
        int len = 0;
        for(int i=0;i<s.size();i++){
            for(int j=0;j<tmp.size();j++){
                if(s[i] == tmp[j]) cout << ((j-key[len] < 0)? tmp[j-key[len]+tmp.size()]:tmp[j-key[len]]);
            }
            len++; if(len == n) len = 0;
        }
        cout << endl;
    }
}

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

int main(){
    ll i,n;
    cin >> n;
    ll start = (ll) sqrt((float)n);
    ll huga;

    for(i = 1; i * i <= n; i++){
      if(n % i == 0){
      huga = i;
      }
    }

    ll hoge = n / huga;
    ll ans = hoge + huga - 2;
    cout << ans << endl;
}

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

int main() {
    
    ll K;
    cin >> K;

    ll ans = 0;
    ll tmp;

    for (int i = 1; i <= K; i++) {
        for (int j = 1; j <= K; j++) {
            for (int k = 1; k <= K; k++) {
                tmp = gcd(i, j);
                ans += gcd(tmp, k);
            }
        }
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3632
def fact(n)
  return 1 if n === 0
  n * fact(n-1)
end
def pattern(n)
  if n>2
    return fact(n)/(2 * fact(n-2))
  else
    return fact(n)/2
  end
end

N,M = gets.split.map(&:to_i)
puts(pattern(N) + pattern(M))

Measured memory_bytes: 1788
#include<iostream>
using namespace std;
int main(){
	long long n,k,one;
	int temp,count=0;

	cin >>n >>k;
	for(int i=0;i<n;i++){
		cin >>temp;
		if(temp==1)one=i;
	}
	one+=0;
	//cout<<one<<endl;
	//for(int i=0;i<one;i+=(k-1))count++;
	//for(int i=one+1;i<n;i+=(k-1))count++;
	if((n-1)%(k-1)==0)count=(n-1)/(k-1);
	else {
		count=(n-1)/(k-1);
		count++;
	}

	cout<<count<<endl;
	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 = unsigned long long;
using p = pair<int, int>;

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

    int size = static_cast<int>(S.size());

    int count = 0;
    int maxCount = 0;

    rep(i, size)
    {
        if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T')
        {
            count++;
        }
        else
        {
            if (count > maxCount)
            {
                maxCount = count;
            }
            count = 0;
        }
    }

    if (count > maxCount)
    {
        maxCount = count;
    }

    std::cout << maxCount << endl;
    return 0;
}


Measured memory_bytes: 256
N = gets.to_i
G = Array.new(N){ [] }
C = Array.new(N)

(N - 1).times do 
  u,v,w = gets.split.map(&:to_i)
  G[u - 1] << [v - 1, w % 2]
  G[v - 1] << [u - 1, w % 2]
end

C[0] = 0
q = [0]

until q.empty?
  u = q.shift
  d = C[u]
  
  G[u].each do |v,w|
    unless C[v]
      C[v] = d + w
      q << v
    end
  end
end

puts C.map{|d| d % 2 }



Measured memory_bytes: 28284
#include <string>
#include <algorithm>
#include <vector> 
#include <math.h>
#include <iostream>
using namespace std;

int main()
{
	int a,b,k;
	cin >> a >> b >>k;
	int n = 0;
	int out = 0;

	int start = max(a, b);
	for (int i = start; i >0; i--) {
		if (a % i == 0 && b%i == 0) {
			n++;
			if (n == k) {
				out = i;
			}
		}
	}

	cout << out << endl;

	return 0;

}

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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

int main()
{
	i64 A,B,C;
	cin >> A >> B >> C;
	cout << min({ abs(A - B) + abs(A - C), abs(A - B) + abs(B - C), abs(A - C) + abs(B - C) }) << endl;
	return 0;
}


Measured memory_bytes: 256
<?php
  
  $input = trim(fgets(STDIN));

$length = strlen($input);


        for ($i = 0; $i < $length; $i+=2) {
            if ($input[$i] === 'L') {
                echo 'No';
                return;
            }
        }

        for ($i = 1; $i < $length; $i+=2) {
            if ($input[$i] === 'R') {
                echo 'No';
                return;
            }
        }


echo 'Yes';

Measured memory_bytes: 4984
N, M = map(int, input().split())
A_list = []
for i in range(M):
    A, B = map(int, input().split())
    if B > N:
          A_list.append(A)
list_num = len(A_list)
if list_num <= 1:
    print(0)
else:
    sort_list = sorted(A_list, reverse=True)
    add_list = sort_list[0:(list_num-1)]
    print_num = (list_num - 1) * N - sum(add_list)
    print(print_num)


Measured memory_bytes: 5608
import itertools
def listtoint(l, n):
    s = 0
    for i in range(n):
        s = s + l[i]*10**(n-1-i)
    return s
def main():
    N = int(input())
    P = list(map(int, input().split()))
    Q = list(map(int, input().split()))
    n = []
    for v in itertools.permutations(P):
        s = 0
        for i in range(N):
            s = s + v[i]*10**(N-1-i)
        n.append(s)
    p = listtoint(P, N)
    q = listtoint(Q, N)
    a, b = 0, 0
    for num in n:
        if num < p:
            a = a + 1
        if num < q:
            b = b + 1
    print(abs(a-b))
main()

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

int N,M;
string S[110],T[110];

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N; i++)cin >> S[i];
    scanf("%d",&M);
    for(int i = 0; i < M; i++)cin >> T[i];

    int ans = 0;
    for(int i = 0; i < N; i++)
    {
        int cnt = 0;
        for(int j = 0; j < N; j++)if(S[i] == S[j])cnt++;
        for(int j = 0; j < M; j++)if(S[i] == T[j])cnt--;
        ans = max(ans,cnt);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);

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

    vl v(1000010);  // v[i] : iがokなら1
    rep(i, n) {
        ll a;
        cin >> a;
        v[a]++;
    }

    ll ans = 0;
    exrep(i, 1, 1000000) {
        if(v[i] == 1) {
            ans++;
        }
        if(v[i] > 0) {
            for(ll j = 2*i; j <= 1000000; j += i) {
                v[j] = 0;
            }
        }
    }

    out(ans);
    re0;
}

Measured memory_bytes: 11176
#include<stdio.h>
#include<stdlib.h>
  int compare(const void *a, const void *b){
    return *(int*)a - *(int*)b;
      }
  int main(){
    int N,median,i;
    int A[200000];
    long long int mixsum = 0;
    scanf("%d",&N);
    for(i = 0; i < N;i++){
      scanf("%d",&A[i]);
      A[i] += -i;
    }
    qsort(A,N,sizeof(int),compare);

    median = A[N/2];
    for(i = 0;i < N;i++)mixsum += abs(A[i] - median);
    printf("%lld\n",mixsum);
    return 0;
  }


Measured memory_bytes: 1788
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include "bits/stdc++.h"
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,M;
	vpll VN;
	scan(N>>M);
	rep(i,N){
		ll a;
		scan(a);
		VN.push_back(mp(a,1));
	}
	rep(i,M){
		ll b,c;
		scan(b>>c);
		VN.push_back(mp(c,b));
	}
	sort(VN.rbegin(),VN.rend());
	ll ans=0;
	int kosu=0;
	rep(i,VN.size()){
		ll v=VN[i].first,n=VN[i].second;
		if(kosu+n<=N){
			ans+=v*n;
			kosu+=n;
		}
		else{
			ans+=(N-kosu)*v;
			kosu=N;
		}
		if(kosu>=N) break;
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 6564
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define int long long
#define st first
#define nd second
#define rd third
#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)
#define RE(i, n) FOR(i, 1, n)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define REP(i, n) for(int i = 0;i <(n); ++i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
template<typename TH> void _dbg(const char* sdbg, TH h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t) {
  while(*sdbg != ',')cerr<<*sdbg++; cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define cerr if(0)cout
#endif
#define next ____next
#define prev ____prev
#define left ____left
#define hash ____hash
typedef long long ll;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<pair<int, int> > VPII;
typedef vector<pair<ll, ll> > VPLL;

template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
template<class T1, class T2>
ostream& operator<< (ostream &out, pair<T1, T2> pair) { return out << "(" << pair.first << ", " << pair.second << ")";}
template<class A, class B, class C> struct Triple { A first; B second; C third;
  bool operator<(const Triple& t) const { if (st != t.st) return st < t.st; if (nd != t.nd) return nd < t.nd; return rd < t.rd; } };
template<class T> void ResizeVec(T&, vector<int>) {}
template<class T> void ResizeVec(vector<T>& vec, vector<int> sz) {
  vec.resize(sz[0]); sz.erase(sz.begin()); if (sz.empty()) { return; }
  for (T& v : vec) { ResizeVec(v, sz); }
}
typedef Triple<int, int, int> TIII;
template<class A, class B, class C>
ostream& operator<< (ostream &out, Triple<A, B, C> t) { return out << "(" << t.st << ", " << t.nd << ", " << t.rd << ")"; }
template<class T> ostream& operator<<(ostream& out, vector<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }

void Exit() {
  cout<<"First\n";
  exit(0);
}

const int N = 2e5 + 5;
VI slo[N];
int Dfs(int v, int p) {
  int free_sons = 0;
  for (auto nei : slo[v]) {
    if (nei == p) { continue; }
    free_sons += Dfs(nei, v);
  }
  if (free_sons >= 2) {
    Exit();
  }
  return 1 - free_sons;
}
    
int32_t main() {

  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  cerr << fixed << setprecision(10);
  cin.tie(0);
  //double beg_clock = 1.0 * clock() / CLOCKS_PER_SEC;
  
  int n;
  cin>>n;
  if (n % 2) {
    Exit();
  }
  RE (i, n - 1) {
    int a, b;
    cin>>a>>b;
    slo[a].PB(b);
    slo[b].PB(a);
  }
  Dfs(1, -1);
  cout<<"Second\n";
  
  
  
  return 0;
}


Measured memory_bytes: 8704
#include <iostream>
#include <algorithm>
#include <vector>
#define ll long long
#define ALL(x) (x.begin(),x.end())
using namespace std;

int main(){
ll n;
cin>>n;
ll sum=0;
for(ll i=1;i<n+1;i++){
if(10>i)
sum++;

if(1000>i&&i>=100)
sum++;

if(100000>i&&i>=10000){
  sum++;
}
}


cout<<sum<<endl;

}


Measured memory_bytes: 256