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

using namespace std;

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int, int > ii;
#define repi(i, a, b)    for(int i = a; i < b; i++)
#define repd(i, a, b)    for(int i = b-1; i >= a; i--)   
#define rep(i, n)        for(int i = 0; i < n; ++i)
#define ll               long long int
#define I                iterator
#define lf               long double
#define pb               push_back
#define pq               priority_queue
#define all(c)           (c).begin(), (c).end()
#define tr(c, it)        for(auto it = c.begin(); it != c.end(); ++it)

int main(){
    string str;
    getline(cin , str);
    int ans = 0, len = str.length();
    ans = 15 - len;

    tr(str, it){
        if(*it == 'o'){
            ans ++;
        }
    }
    if(ans >= 8){
        cout << "YES"<<endl;
    }else{
        cout << "NO"<<endl;
    }
    return 0;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  bool b = false;
  rep(i,s.size()) {
    string tmps = s;
    tmps[s.size() - 1] = s[0];
    for (int j = 1; j < s.size(); j++) {
    tmps[j - 1] = s[j]; 
    }
    s = tmps;
    if (s == t) b = true;
  }
  if(b) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

void Slide(int a, int b, char code[]){
    int i,length;
    
    length=strlen(code);
    
    for(i=0;i<length;i++){
        code[i]=toupper(code[i]);
        if(code[i]>'Z' || code[i]<'A') continue;
        code[i]=(a*(code[i]-'A'+1)+b)%26+'A';
        if(code[i]>'Z'){
            //code[i]+=('a'-'z'-1)*((code[i]-'a')/26);
            code[i]-=26;
        }
        code[i]=tolower(code[i]);
    }
    
}

int main(void){
    int a,b,i,n;
    char code[256],p[256];
    
    scanf("%d",&n);
    gets(code);
    
    for(i=0;i<n;i++){
        gets(code);
        strcpy(p,code);
        
        for(a=1;a<26;a++){
            if(a%2==0 || a%13==0)continue;
            for(b=0;b<26;b++){
                //puts(code);
                Slide(a,b,code);
                //puts(code);
                //puts("");
                if(strstr(code,"this") == '\0' && strstr(code,"that")=='\0'){
                    strcpy(code,p);
                    continue;
                }
                else break;
            }
            if(strstr(code,"this") != '\0' || strstr(code,"that")!='\0'){
                break;
            }
        }
        puts(code);
    }
    return 0;
}

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



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

    int n,m;
    cin>>n>>m;
    int a[n][m];
    for(int i=0;i<n;i++)for(int j=0;j<m;j++){
        cin>>a[i][j];
        a[i][j]--;
    }

    int low=-1,up=301,mid;
    while(up-low>1){
        mid = (low+up)/2;
        int p[n]={};
        bool pos = true;
        int use=0;
        bool ng[m]={};

        while(use<m){
            pos = true;
            int cnt[m]={};
            for(int i=0;i<n;i++){
                while(p[i]<m && ng[a[i][p[i]]]){
                    p[i]++;
                }
                cnt[a[i][p[i]]]++;
            }
            for(int i=0;i<m;i++){
                if(cnt[i] > mid){
                    if(!ng[i]) use++;
                    ng[i] = true;
                    pos = false;
                }
            }
            
            
            if(pos) break;
        }
        if(pos){
            up = mid;
        }
        else low = mid;
    }
    cout<<up<<endl;
    
}

Measured memory_bytes: 640
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader bf = 
            new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(bf.readLine());
        String[] str = bf.readLine().split(" ");
        int[] h = new int[N];
        for(int i = 0; i < N; i++){
            h[i] = Integer.parseInt(str[i]);
        }
        int answer = h[0];
        for(int i = 0; i < N-1; i++){
            int value = h[i+1] -h[i];
            if(value > 0){
                answer += value;
            }
        }
        System.out.println(answer);
    }
}

Measured memory_bytes: 22356
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
using namespace std;
int gcd(int a, int b) {
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
signed main() {
	int a, b; cin >> a >> b;
	cout << a * b / gcd(a, b) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,a[100010],f[100010]; 
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=1;i<n;i++)
	{
		if(i==1)
			f[i]=f[i-1]+abs(a[i]-a[i-1]);
		else
			f[i]=min(f[i-1]+abs(a[i]-a[i-1]),f[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<f[n-1]<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(){
    int n,i,j;
    int a[200001];
    long long ans = 0;
    
    scanf("%d",&n);
    for(i = 0; i < n; i++) scanf("%d",&a[i]);
    
    for(i = 1; i < n; i++){
        if(a[i-1] > a[i]){
            ans += (a[i-1]-a[i]);
            a[i] += (a[i-1]-a[i]);
        }else{
            // 何もしない
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 2516
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}

int main()
{
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
    ll n;
    cin>>n;
    ll arr[n];
    for(ll i=0;i<n;i++)
        cin>>arr[i];
    sort(arr,arr+n);
    ll st=arr[0];
    ll en=arr[n-1];
    ll ans=INT_MAX;
    for(ll i=st;i<=en;i++)
    {
        ll maxi=0;
        for(ll j=0;j<n;j++)
        {
            maxi=maxi+pow(arr[j]-i,2);
        }
        ans=min(ans,maxi);
    }
    cout<<ans;
}


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


int main(){
  LL x, y;

  scanf("%lld %lld", &x, &y);

  int ans = 1;
  while (x <= y / 2) {
    ans++;
    x *= 2;
  }

  printf("%d\n", ans);
}


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

typedef long long ll;
ll n, s, a[100];
int main()
{
	ll i, j;
	cin >> n;
	for (i = 0; i < n; i++) {
		scanf ("%lld", &a[i]);
	}
	for (i =0; i < n; i++) {
		for (j = i + 1; j < n; j++){
			s += a[i] * a[j];
		}
	}
	cout << s <<endl;

    return 0;
}


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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

#include <valarray>
#include <cmath>

double calc(valarray<double> p1, valarray<double> p2) {
    double res = 0.0;
    REP (i, 0, 3) {
        res += pow(p1[i] - p2[i], 2);
    }
    return sqrt(res);
}

void subMain() {
    valarray<double> len(3);
    REP(i, 0, 3) {
        cin >> len[i];
    }
    int n;
    cin >> n;
    vector<valarray<double>> point(n, valarray<double>(3));
    REP(i, 0, n) {
        REP(j, 0, 3) {
            cin >> point[i][j];
        }
    }
    REP(i, 0, n) {
        REP(j, 0, n) {
            REP(k, 0, n) {
                if (i == j || j == k || k == i) continue;
                valarray<double> res = {
                    calc(point[i], point[j]),
                    calc(point[j], point[k]),
                    calc(point[k], point[i]),
                };
                res /= len;
                double eps = 1e-3;
                if (abs(res[0] - res[1]) <= eps && abs(res[0] - res[2]) <= eps && abs(res[1] - res[2]) <= eps) {
                    cout << k + 1 << " " << i + 1 << " " << j + 1 << endl;
                    return;
                }
            }
        }
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int T;
    cin >> T;
    REP(t, 0, T) {
        subMain();
    }
    return 0;
}



Measured memory_bytes: 3284
#include<stdio.h>
#include<math.h>
int main()
{
    long long int num1,num2,num;
    while (scanf("%lld %lld",&num1,&num2) !=EOF){
        num = num1*num2;
        while(num1 != num2)
        {
            if(num1 > num2){
              num1 = num1-num2;
            }
            else{
                num2 = num2-num1;
            }
        }
        printf("%lld %lld\n",num1,num/num1);
    }
    return 0;
}

Measured memory_bytes: 596
from itertools import product


D,G = map(int, input().split())
p = [0] * D
c = [0] * D

for i in range(D):
    p[i],c[i] = (list(map(int,input().split())))


#print(p)
#print(c)

states = list(product([i for i in range(2)], repeat=D))

#print(states)

res = float('inf')

for state in states:
    score = 0
    num = 0

    for i in range(D):
        if state[i] == 1:
            score += p[i] * (i+1) * 100 + c[i]
            num += p[i]

    #print('num1',num)

    if score < G:
        for i in range(D):
            if state[D-i-1] != 1 and score < G:
                add_count = 0
                while score < G and add_count < p[D-i-1]:
                    add_count += 1
                    num += 1
                    score += (D-i) * 100

        if score < G:
            num = float('inf')
    
    #print('num2',num)
    res = min(res,num)

print(res)

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

using namespace std;

#define pb push_back
#define mp make_pair
constexpr int INF = 1 << 29;
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;

constexpr int dx[4] = {1, 0, -1, 0};
constexpr int dy[4] = {0, 1, 0, -1};

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if ((a * 100 + b * 10 + c) % 4 == 0) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  string s,t;
  cin >> s >> t;
  int a,b;
  cin >> a >> b;
  string u;
  cin >> u;
  if(s==u) cout << a-1 << " " << b << endl;
  else cout << a << " " << b-1 << endl;
  
  return 0;
    

}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }
        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var K = cin.ReadInt;
            var max = (N - 1) * (N - 2) / 2;
            if (K > max)
            {
                WriteLine(-1);
                return;
            }
            var M = (N - 1) + max - K;
            WriteLine(M);
            for (int i = 0; i < N - 1; i++)
            {
                WriteLine("1 " + (i + 2).ToString());
            }
            var u = 2;
            var v = 3;
            for(int i = 0; i < max - K; i++)
            {
                if(v > N)
                {
                    u++;
                    v = u + 1;
                }
                WriteLine(u + " " + v);
                v++;
            }
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13268
using System;
using System.Collections.Generic;

namespace ITP_4_D{
    public class Program{
        public static void Main(string[] args){
            //???????????¨?????????
            Console.ReadLine();
            
            string[] temp = Console.ReadLine().Split(' ');
            List<int> number = new List<int>();
            long sum = 0;
            //????????????????????????????????????????´??????????
            for(int i=0; i < temp.Length; i++){
                int value = int.Parse(temp[i]);
                number.Add(value);
                sum += value;
            }
            number.Sort();
            Console.WriteLine(number[0] +" "+ number[temp.Length-1] +" "+ sum);
        }
    }
}

Measured memory_bytes: 10144
//ABC145
#include <stdio.h>
#include <math.h>

int main(int argc, char const *argv[]) {
    double a,b,x,y;
    double rad,deg;
    scanf("%lf",&a);
    scanf("%lf",&b );
    scanf("%lf",&x );

    if (2*x > a*a*b ) {
        y = (2*((a*a*b)-x))/(a*a*a);
        rad = atanl(y);
    } else if (2*x < a*a*b) {
        y = (a*b*b)/(2*x);
        rad = atanl(y);
    } else {
        rad = atanl(1);
    }
    deg = (rad * 180) / (4*atanl(1));

    printf("%2.8lf\n",deg);

    return 0;
}

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

#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a.first << "\n"; }); cout << endl;

const int INF = INT_MAX;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

using PII = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

int N, M;
V<PII> v;

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cin >> N;
    cin >> M;
    REP(i, N) {
        LL a, b;
        cin >> a; cin >> b;
        v.emplace_back(PII(a,b));
    }
    std:sort(ALL(v), [](const PII& a, const PII& b){ return a.first < b.first; });
    LL ans = 0;
    int ct = 0;
    REP(i, N) {
        if(ct == M) break;
        if(M < ct+v[i].second) {
            ans += v[i].first * (M-ct);
            break;
        }
        ans += v[i].first * v[i].second;
        ct += v[i].second;
    }
    cout << ans << "\n";
}

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

int main(){
  int n; cin >> n;
  vector<int> a(n), b(n);
  
  for(int i = 0; i < n; i++){
    cin >> a[i];
    b[i] = a[i];
  }
  
  sort(b.begin(), b.end());
  int m1 = b[n/2 - 1], m2 = b[n/2];
  
  for(int i = 0; i < n; i++){
    if(a[i] <= m1) cout << m2 << endl;
    else cout << m1 << endl;
  }
  
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld  = long double;
using pll = pair<ll, ll> ;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=1LL<<60;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-9; //微調整用（EPSより小さいと0と判定など）
 
#define gcd __gcd //llは受け取ってくれない
int lcm(int a, int b){return a / gcd(a, b) * b;}
#define ALL(a) a.begin(),a.end() //sort(ALL(vec));
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define PB push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに
 
//最大値、最小値を更新する。aよりbのが大きい（小さい）か等しければaを更新してtrueを返す。そうでなければ何もせずfalseを返す chmax(nowmax,x);
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
// ----- template end ---- //
 
// ------- library ------- //



// ----- library end ----- //



int main() {

  ll A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;

  //0~10^5全探索
  ll min = LINF;
  ll zero = 0;
  rep(i, pow(10,5)+1){
    chmin(min, i*2*C + A*max(X-i, zero) + B*max(Y-i, zero));
  }

  cout << min << endl;

// -- main() end -- //
}


 

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

int main(int argc, char const* argv[])
{
  string s;
  cin >> s;
  if(s.size() == 2)cout << s << endl;
  else cout << s[2] << s[1] << s[0] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main(void) {

    int x[5]; rep(i,5) cin >> x[i];
    int ans;
    rep(i,5) {
        if (x[i] == 0) {
            ans = i+1;
        }
    }
    out(ans);

    
    return 0;
}









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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

signed main(){

  string s; cin >> s;
  int n = s.size();
  vector<int> pos;
  for(int i = 0; i < n-1; i++){
    if(s[i] == 'R' && s[i+1] == 'L'){
      pos.push_back(i);
    }
  }

  map<int,int> mp;
  for(int p : pos){
    int l = 0,r = 0;
    int pos = p;
    while(s[pos] == 'R'){
      if((p - pos)%2 == 1) l++;
      if((p - pos)%2 == 0) r++;
      pos--;
    }

    pos = p+1;
    while(s[pos] == 'L'){
      if((pos - (p+1))%2 == 0) l++;
      if((pos - (p+1))%2 == 1) r++;
      pos++;
    }
    mp[p] = r;
    mp[p+1] = l;
  }

  for(int i = 0; i < n; i++){
    cout << mp[i] << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 7160
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    string s;
    cin >> s;
    bool t = true;
    for(int i = 0; i < 3; i++){
        if(s[i] == s[i+1]){
            cout << "Bad";
            t = false;
            break;
        }
    }
    if (t){
        cout << "Good";
    }
    cout << endl;
}


Measured memory_bytes: 256
H,W=list(map(int,input().split()))

S=[]
fence='.'*W
S.append(fence)
for i in range(H):
    S.append('.'+input()+'.')
S.append(fence)

number_of_bombs=[]
for i in range(H+2):
    number_of_bombs.append([0*i for i in range(W+2)])

for i in range(1,H+1):
    for j in range(1,W+1):
        if S[i][j]=='#':
            number_of_bombs[i][j]=1000000


for i in range(1,H+1):
    for j in range(1,W+1):
        if S[i][j]=='#':
            number_of_bombs[i][j-1]+=1
            number_of_bombs[i][j+1]+=1
            for k in range(j-1, j+2):
                number_of_bombs[i-1][k]+=1
                number_of_bombs[i+1][k]+=1

for i in range(1,H+1):
    line=''
    for j in range(1,W+1):
        if number_of_bombs[i][j]>=1000000:
            line+='#'
        else:
            line+=str(number_of_bombs[i][j])
    print(line)


Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const long long MAXN=100005;
long long fa[MAXN],jl[MAXN];
long long n,m;
long long find(long long x)
{
	if(fa[x]==x)
		return x;
	long long f=find(fa[x]);
	jl[x]=jl[fa[x]]+jl[x];
	fa[x]=f;
	return f;
}
int main()
{
	scanf("%lld %lld",&n,&m);
	for(long long i=1;i<=n;i++)
		fa[i]=i,jl[i]=0;
	for(long long i=1;i<=m;i++)
	{
		long long l,r,d;
		scanf("%lld %lld %lld",&l,&r,&d);
		long long a=find(l),b=find(r);
		if(a==b)
		{
			if(jl[l]-jl[r]!=d)
			{
				printf("No\n");
				return 0;
			}
		}
		else
		{
			fa[b]=a;
			jl[b]=-d+jl[l]-jl[r];
		}
	}
	printf("Yes\n");
}

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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
int chara[100005];
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,t,m,a[2],len=2;
    while(1){
    cin >> m;if(m==0)break;
    cin >> n;
    str s;
    cin >> s;
    stack<int> q;
    q.push(0);
    rep(i,0,n){
        if(s[i]=='I'){
            char ma='O';
            int len=0;
            i++;
            for(;i<n+1;i++){
               // cout << s[i] <<"=" << ma;
                if(i==n){
                    if(ma=='I')len--;
                    if(len>0)q.push(len);
                }else if(ma==s[i]){
                    if(ma=='O')len++;
                    ma=(ma=='O')?'I':'O';
                }else{
                    if(ma=='O')i--;
                    if(ma=='I')len--;
                    if(len>0)q.push(len);
                    break;
                }
               // ma=(ma=='O')?'I':'O';
            }
        }
    }
    int ans=0;
    while(!q.empty()){
        int res=q.top();q.pop();
        if(res>=m)ans+=(res+1-m);
    }
    cout << ans <<endl;
    }
    return 0;
}

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

long long ans = 0;
int n, m, q;
int a[50], b[50], c[50], d[50];

void fn(vector<int> &v, int current) {

    if(v.size() == n) {
        long long temp = 0;

        for(int i=0;i<q;i++) {
            if(v[b[i]-1] - v[a[i]-1] == c[i]) {
                temp += d[i];
            }
        }

        ans = max(temp, ans);
        return;
    }

    if(current > m || v.size() > n) {
        return;
    }


    fn(v, current+1);

    v.push_back(current);
    fn(v, current+1);
    fn(v, current);
    v.pop_back();

}



int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);

    cin>>n>>m>>q;


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

    vector<int> v;


    fn( v, 1);

    cout<<ans;


    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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 EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll M;
ll ans = 0;
ll rest = 0;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> M ;
    ans = -1;
    while(M--) {
        ll d, c;
        cin >> d >> c;
        ans += c;
        rest += d * c;
    }
    while(rest >= 10) {
        ans += rest / 10;
        rest = rest % 10 + (rest / 10);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		if(C >= A && C <= B) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


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

using namespace std;

int a,b;

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

  if(a > 0) {
    cout << "Positive" << endl;
    return 0;
  }

  if(b < 0) {
    if((b - a) % 2 == 0) cout << "Negative" << endl;
    else cout << "Positive" << endl;
    return 0;
  }

  if(a <= 0 && b >= 0) {
    cout << "Zero" << endl;
    return 0;
  }
}
  
  


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int u32;
typedef pair<int, int> p;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int Inf = 1000000000;
ll inf = 1000000000000;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		cout << 'x';
	}
	return(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define MP make_pair
#define pb push_back
#define PI 3.1415926535897932384626433832795
typedef long long ll;
#define MOD 1000000007
ll gcd(ll a,ll b){if (b == 0)return a;return gcd(b, a % b);} 
#define cases int t;cin>>t;while(t--) 

ll power(ll x, ll y, ll p)  
{  
    ll res = 1LL;
  
    x = x % p;
   
    if (x == 0) return 0;
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
   
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res%MOD;  
}  




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

    ll res[100003];
    ll ans = 0;
    ll cnt = 0;
    for(ll g = k;g>=1;g--){
       
        res[g] = power(k/g ,n,MOD);

        ll m = 2;
        while(m*g <= k){
            res[g] -= res[m*g] %MOD;
            if(res[g] < 0)res[g] += MOD;
            m++;
        }

        ans += (g * res[g]) %MOD;
        ans %= MOD;
    }
    cout<<ans<<endl;

}


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

const int MAX = 200005;
const ll MOD = 1000000007;
vector<int> E[MAX];
pair<ll, ll> dp[MAX];
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long pow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1) res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}

void dfs(int u, int p=-1) {
  for (int v: E[u]) {
    if (v == p) continue;
    dfs(v, u);
    dp[u].first *= (COM(dp[u].second+dp[v].second, dp[v].second) * dp[v].first) % MOD;
    dp[u].first %= MOD;
    dp[u].second += dp[v].second;
  }
  ++dp[u].second;
}

void bfs(int u, int p=-1) {
  for (int v: E[u]) {
    if (v == p) continue;
    ll c = COM(dp[u].second-1, dp[v].second);
    c = pow(c, MOD-2);
    ll d = pow(dp[v].first, MOD-2);
    ll e = (dp[u].first * c) % MOD * d % MOD;
    dp[v].first *= COM(dp[u].second-1, dp[v].second-1) * e % MOD;
    dp[v].first %= MOD;
    dp[v].second = dp[u].second; 
    bfs(v, u);
  }
}

int main() {
  int n;
  cin >> n;
  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    E[a].push_back(b);
    E[b].push_back(a);
  }
  COMinit();
  
  rep(i, n) dp[i] = make_pair(1ll, 0ll);
  dfs(0);
  bfs(0);
  rep(i, n) cout << dp[i].first << endl;
  
  return 0;
}

Measured memory_bytes: 22640
#include <algorithm>
#include <array>
#include <functional>
#include <iostream>
#include <math.h>
#include <vector>
#define ll long long int
#define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n)

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    REP1(i, 1099) {
        if (int(i * 0.08) != a || int(i * 0.1) != b)
            continue;
        cout << i << endl;
        return 0;
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  for(int i=0;i<4;i++){
    cout << s.at(i);
  }
  cout << " ";
  for(int i=4;i<12;i++){
    cout << s.at(i);
  }
  cout << endl;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

int main() {
  string S, T; cin >> S >> T;
  ll ans = 0;
  for(int i = 0; i < S.size(); ++i) {
    if(S[i] != T[i]) ans++;
  }
  cout << ans << endl;
}

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

int main() {
  int n, q, m;
  cin >> n;
  vector<int> a(n);
  for (auto& e : a) cin >> e;
  cin >> q;
  while (q--) {
    cin >> m;
    vector<int> dp(m + 1);
    dp[0] = 1;
    for (auto& n : a) {
      for (int i = m; i >= 0; i--) {
        if (dp[i] && i + n <= m) {
          dp[i + n]++;
        }
      }
    }
    cout << (dp[m] ? "yes\n" : "no\n");
  }
}


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

int main() {
    while (1) {
        int N, R;
        cin >> N >> R;
        if (N == 0 && R == 0)
            break;
        vector<int> A(N);
        rep(i, N) A[i] = N - i;

        rep(i, R) {
            int p, c;
            cin >> p >> c;
            --p;
            vector<int> utmp(p), dtmp(c);
            rep(i, p) utmp[i] = A[i];
            for (int i = p; i < p + c; ++i)
                dtmp[i - p] = A[i];

            rep(i, c) A[i] = dtmp[i];
            for (int i = c; i < c + p; ++i)
                A[i] = utmp[i - c];
        }
        cout << A[0] << "\n";
    }

    return 0;
}


Measured memory_bytes: 3080
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll   long long
#define ld long double
#define endl '\n'
#define INF 10000000000000000
#define pll pair<ll,ll>
#define ff first
#define ss second

using namespace std;
const ll N = 405;
const ll MOD = 1e9+7;
ll dp[N][N];
int main()
{
 //freopen("input.txt","r",stdin);
 //  freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k;
    cin>>n;
    vector<ll> a(n+1);
    for(ll i =1;i<=n;i++) {
        cin>>a[i];
    }
    ll sum[n+1];
    for(ll i =1;i<=n;i++ ){
        sum[i]=sum[i-1]+a[i];
    }
    for(ll L=n;L>=1;L--) {
        for(ll R=L;R<=n;R++) {
            if(L==R) dp[L][R]=0;
            else {
                dp[L][R]=INF;
                for(ll j =L;j<=R-1;j++) {
                    dp[L][R]=min(dp[L][j]+dp[j+1][R]+sum[R]-sum[L-1],dp[L][R]);
                }
            }
        }
    }
    cout<<dp[1][n];

    // ������ ������

}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i;
    cin>>n;
    int h[n];
    long long dp[n];
    for(i=0;i<n;i++)
        cin>>h[i];
    dp[0]=0;dp[1]=fabs(h[1]-h[0]);
    for(i=2;i<n;i++)
    {
        if((dp[i-1]+fabs(h[i]-h[i-1]))<(dp[i-2]+fabs(h[i]-h[i-2])))
            dp[i]=dp[i-1]+fabs(h[i]-h[i-1]);
        else
            dp[i]=dp[i-2]+fabs(h[i]-h[i-2]);
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ll long long;
#define dbg(x) cout<<#x<<"--------------"<<x<<endl;
#define dl cout<<"LINE"<<__LINE__<<endl;
using namespace std;
int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	
	char s[3];
	cin>>s;
	for(int i=0;i<=2;i++){
		if(s[i]=='7'){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	
	
		
	return 0;
}

Measured memory_bytes: 3648
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
d = int(readline())

if d == 22:
    print('Christmas Eve Eve Eve')
elif d == 23:
    print('Christmas Eve Eve')
elif d == 24:
    print('Christmas Eve')
else:
    print('Christmas')

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

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);

        scanner.nextLine();
        final int[] numbers = Arrays
                .stream(scanner.nextLine().split(" "))
                .mapToInt(Integer::parseInt)
                .toArray();

        int sum = 0;
        for (int i = 0; i < numbers.length; i++) {
            sum += numbers[i];
        }

        int diff = sum;
        for (int i = 0; i < numbers.length; i++) {
            int sumPart = 0;
            for (int j = 0; j <= i; j++) {
                sumPart += numbers[j];
            }
            diff = Math.min(diff, Math.abs((sum - sumPart) - sumPart));
        }

        System.out.println(diff);
    }
}

Measured memory_bytes: 29396
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *
from copy import *

s, t = input(), input()
ls, lt = len(s), len(t)
dp = [[0] * (lt+1) for i in range(ls+1)]
for i, x in enumerate(s, 1):
    for j, y in enumerate(t, 1):
        if x == y:
            dp[i][j] = dp[i-1][j-1]+1
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])
ans = ''
while 0 < dp[i][j]:
    if dp[i-1][j] == dp[i][j]:
        i -= 1
    elif dp[i][j-1] == dp[i][j]:
        j -= 1
    else:
        i -= 1
        j -= 1
        ans += s[i]
print(ans[::-1])


Measured memory_bytes: 113372
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d[40][40], tmp, m, h, w, x, y, sum[5][100], k, q;

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

  cin >> n >> c;
  rep(i, c) rep(j, c) cin >> d[i][j];

  rep(i, n) {
    rep(j, n) {
      cin >> a;
      a--;
      sum[(i + j) % 3][a]++;
    }
  }

  ans = LINF;
  rep(fir, c) {
    rep(sec, c) {
      rep(thi, c) {
        if (fir == sec || fir == thi || sec == thi) continue;
        cnt = 0;
        rep(i, c) {
          cnt += d[i][fir] * sum[0][i];
          cnt += d[i][sec] * sum[1][i];
          cnt += d[i][thi] * sum[2][i];
        }
        ans = min(ans, cnt);
      }
    }
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>

#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using namespace std;

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    vector<uint64_t> A(N+1);
    vector<uint64_t> B(M+1);
    A[0] = 0;
    rep(i, N) {
        cin >> A[i+1];
        A[i+1] += A[i];
    }
    B[0] = 0;
    rep(i, M) {
        cin >> B[i+1];
        B[i+1] += B[i];
    }

    uint64_t ret = 0;
    if(A.size() > B.size()) {
        swap(A, B);
    }

    rep(i, A.size()) {
        if(A[i] > K) {
            break;
        }
        uint64_t cost = i;
        auto rem = K - A[i];
        auto itr = lower_bound(B.begin(), B.end(), rem);
        if(itr == B.begin() && *itr > K) {
////            cout << "cost=" << i <<  "+" << 0  << endl;
            ret = max(cost, ret);
            continue;
        }
        if(itr == B.end()) {
            itr--;
        }
        if(*itr > rem) {
            itr--;
        }
        if(itr != B.end() && *itr <= rem) {
            cost += itr - B.begin();
//            cout << "cost=" << i <<  "+" << itr - B.begin()  << endl;
        }
        ret = max(ret, cost);
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 5988
#include<bits/stdc++.h>
#define ll long long int
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl '\n'

using namespace std;

int main() {
    fast;
    ll n;
    cin>>n;
    string str;
    cin>>str;
    int left = 0, right = n-1,ctr=0;  
  
    while (left < right)  
    {  
        while (str[left] == 'R' && left < right)  
            left++;  
  
        while (str[right] == 'W' && left < right)  
            right--;  
  
        if (left < right)  
        {  
            str[left] = 'W';  
            str[right] = 'R';  
            left++;  
            right--;  
            ctr++;
        }  
    }  
    cout<<ctr<<endl;
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
#define For(i,a,b) for(i=(a);i<=(b);++i)
#define Forward(i,a,b) for(i=(a);i>=(b);--i)
using namespace std;
template<typename T>inline void read(T &x)
{
	T s=0,f=1;char k=getchar();
	while(!isdigit(k)&&(k^'-'))k=getchar();
	if(!isdigit(k)){f=-1;k=getchar();}
	while(isdigit(k)){s=s*10+(k^48);k=getchar();}
	x=s*f;
}
void file()
{
	#ifndef ONLINE_JUDGE
	freopen("a.in","r",stdin);
	freopen("a.out","w",stdout);
	#endif
}
const int MAXN=700010;
int n,ans;
char a[MAXN];
int main()
{
	scanf("%s",a);
	n=strlen(a)-1;
	int i=0,j=n,ans=0;
	while(i<j)
	{
		int k=0,lj=j;
		while(a[i]=='x'&&i<=n)++i,++k;
		while(a[j]=='x'&&j>=i)--j,--k;
		if(i>j&&j==lj)break;
		ans+=abs(k);
		if(i>j)break;
		if(a[i]!=a[j])
		{
			printf("-1\n");
			return 0;
		}
		++i;--j;
		if(i>j)break;
	}
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 384
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        t: usize,
    }
    for _ in 0..t {
        input! {
            n: usize,
            klr: [(usize, i64, i64); n]
        }

        let mut ls = BinaryHeap::new();
        let mut rs = BinaryHeap::new();
        let mut sum = 0;
        for (k, l, r) in klr {
            if l > r {
                ls.push((Reverse(k), l - r));
            } else {
                rs.push((Reverse(n - k), r - l));
            }
            sum += min(l, r);
        }

        let mut lpq = BinaryHeap::new();
        while let Some((Reverse(k), v)) = ls.pop() {
            lpq.push(Reverse(v));
            sum += v;
            if lpq.len() > k {
                sum -= lpq.pop().unwrap().0;
            }
        }

        let mut rpq = BinaryHeap::new();
        while let Some((Reverse(k), v)) = rs.pop() {
            rpq.push(Reverse(v));
            sum += v;
            if rpq.len() > k {
                sum -= rpq.pop().unwrap().0;
            }
        }
        println!("{}", sum);
    }



}


Measured memory_bytes: 13780
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, k; cin >> n >> k;
    int cnt[105] = {};
    for (int i = 0; i < k; i++) {
        int d; cin >> d;
        for (int j = 0; j < d; j++) {
            int x; cin >> x;
            cnt[x]++;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) ans += cnt[i] == 0;
    cout << ans;
}


Measured memory_bytes: 3632
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
tmp = 1
lst = []
s = 1
while tmp * 26 < n:
    tmp *= 26
    s += tmp
n -= s
while tmp >= 1:
    lst.append(n // tmp)
    n %= tmp
    tmp //= 26
alpha = 'abcdefghijklmnopqrstuvwxyz'
ans = []
for i in lst:
    if i >= 0:
        ans.append(alpha[i])
print(''.join(ans))


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

int n,m,x,y;
int maxx, miny;

int main() {
	cin >> n >> m >> x >> y;
	maxx = x;
	miny = y;
	for (int i = 0 ; i < n ; i++) {
		int tmp;
		cin >> tmp;
		maxx = max(maxx, tmp);
	}
	for (int i = 0 ; i < m ; i++) {
		int tmp;
		cin >> tmp;
		miny = min(miny, tmp);
	}
	if ( maxx < miny) {
		cout << "No War" << endl;
	} else {
		cout << "War" << endl;
	}
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, C = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(N)]
t = [[0] * (10 ** 5 + 1) for _ in range(C + 1)]
for i in range(N):
  for j in range(c[i][0], c[i][1] + 1):
    t[c[i][2]][j] = 1
res = 0
for i in range(10 ** 5 + 1):
  p = 0
  for j in range(C + 1):
    p += t[j][i]
  res = max(p, res)
print(res)

Measured memory_bytes: 82780
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.pop(0)
A = set(A)
for i in range(N-1):
    B = list(map(int,input().split()))
    B.pop(0)
    B = set(B)
    A = A.intersection(B)
print(len(A))

Measured memory_bytes: 3060