akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n;
vector<int> et[50];
int m;
int u[20], v[20];
int p2[51];

vector<bool> isFill[50];
int depth[50];
int parent[50];
int parentId[50];

void dfs(int p, int v, int dep) {
	depth[v] = dep;
	parent[v] = p;
	
	for (int i = 0; i < et[v].size(); i++) {
		int nv = et[v][i];
		if (nv == p) continue;
		parentId[nv] = i;
		dfs(v, nv, dep + 1);
	}
}

void Reset() {
	int i, j;
	rep(i, n) { rep(j, isFill[i].size()) isFill[i][j] = false; }
}

void Fill(int u, int v) {
	if (depth[u] < depth[v]) swap(u, v);
	
	int du = depth[u];
	int dv = depth[v];
	
	//cout << "Fill(" << u << ", " << v << ")" << endl;
	//cout << "du = " << du << ", dv = " << dv << endl;
	
	while (du > dv) {
		isFill[parent[u]][parentId[u]] = true;
		//cout << "u, parent[u], parentId[u] = " << u << ", " << parent[u] << ", " << parentId[u] << endl;
		u = parent[u];
		du--;
	}
	
	while (u != v) {
		isFill[parent[u]][parentId[u]] = true;
		isFill[parent[v]][parentId[v]] = true;
		u = parent[u];
		v = parent[v];
	}
}

signed main() {
	int i, j, k;
	
	cin >> n;
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		et[a].push_back(b);
		et[b].push_back(a);
	}
	cin >> m;
	rep(i, m) {
		cin >> u[i] >> v[i];
		u[i]--;
		v[i]--;
	}
	
	dfs(-1, 0, 0);
	
	p2[0] = 1;
	rep(i, n) p2[i + 1] = p2[i] * 2;
	
	rep(i, n) isFill[i].resize(et[i].size());
	
	int ans = 0;
	rep(i, (1 << m)) {
		Reset();
		
		int bcnt = 0;
		rep(j, m) {
			if ((i >> j) & 1) {
				Fill(u[j], v[j]);
				bcnt++;
			}
		}
		
		int fillCnt = 0;
		rep(j, n) {
			rep(k, isFill[j].size()) {
				if (isFill[j][k]) fillCnt++;
			}
		}
		
		//cout << "i = " << i << ", fillCnt = " << fillCnt << endl;
		if (bcnt % 2 == 0) ans += p2[n - 1 - fillCnt];
		else ans -= p2[n - 1 - fillCnt];
	}
	
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll fexp (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = fexp (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return fexp (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/gcd(num1,num2))*num2;}
// end of Template

str s;
bool trylen(int x){
    if(x%2==0){
        str a,b;a="";b="";
        for(int i=0;i<x/2;i++){
            a+=s[i];
        }
        for(int i=x/2;i<x;i++){
            b+=s[i];
        }
        if(a==b)return true;
        else return false;
    }
    else return false;
}
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

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

    cin>>s;
    for(int i=s.size()-1;i>=0;i--){
        if(trylen(i)){cout<<i<<newl;break;}
    }
}


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

class MainClass : Scanner
{
    static void Main()
    {
        var (N, K) = ReadStream<int, int>();
        string S = RString();

        var stand = new List<int>() { 0 ,0};
        var flip = new List<int>() { 0,0 };

        int now = 0;
        while (now < N)
        {
            int cnt = 0;
            while (now < N && S[now] == '0') { now++;cnt++; }
            stand.Add(stand.Last()+cnt);

            cnt = 0;
            while (now < N && S[now] == '1') { now++;cnt++; }
            flip.Add(flip.Last()+cnt);
        }
        stand.Add(stand.Last());
        flip.Add(flip.Last());

        long ans = 0;
        if (stand.Count <= K) K =stand.Count-3;
        for (int i = 1; i < stand.Count-K-1; i++)
        {
            ans = Max(ans, stand[i + K] - stand[i] + flip[i + K] - flip[i-1]);
        }
        
        WriteLine(ans);
    }
}

class Scanner
{
    public static int RInt() => int.Parse(Console.ReadLine());
    public static long RLong() => long.Parse(Console.ReadLine());
    public static string RString() => Console.ReadLine();
    public static double RDouble() => double.Parse(Console.ReadLine());

    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static string[] RStrings() => Console.ReadLine().Split();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static T1 ReadStream<T1>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadStream<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadStream<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadStream<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[0], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[0], typeof(T4));
        return (r1, r2, r3, r4);
    }
}

Measured memory_bytes: 29248
let break p lst =
  let rec doit acc = function
    | [] -> (List.rev acc, [])
    | x :: xs as l ->
      if p x then (List.rev acc, l)
      else doit (x :: acc) xs in
  doit [] lst

let split_n n lst =
  let rec doit n acc l =
    if n = 0 then (List.rev acc, l)
    else
      match l with
      | [] -> assert false
      | hd :: tl -> doit (n - 1) (hd :: acc) tl in
  doit n [] lst

let make_postorder preorder inorder =
  let rec doit = function
    | ([], []) -> []
    | (xs, ys) ->
      begin match xs with
      | [] -> assert false
      | x :: xs ->
        begin match break (fun e -> e = x) ys with
        | (yl, yr) ->
          begin match yr with
          | [] -> assert false
          | _ :: yr ->
            let (xl, xr) = split_n (List.length yl) xs in
            doit (xl, yl) @ doit (xr, yr) @ [x]
          end
        end
      end in
  doit (preorder, inorder)

let () =
  let n = read_int () in
  let rec read_tree i acc =
    if i = n then List.rev acc
    else read_tree (i + 1) ((Scanf.scanf "%d " (fun i -> i)) :: acc) in
  let read_tree i = read_tree i [] in
  let preorder = read_tree 0 in
  let inorder = read_tree 0 in
  make_postorder preorder inorder
  |> List.iteri (fun i e -> if i <> 0 then print_string " "; print_int e);
  print_newline ()

Measured memory_bytes: 2404
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
 
int main(){
  int n;
  string s;
  cin >> n >> s;
  string ans;
  int a=0;
  if (n%2==1){
    ans="No";}
  else{
    rep(i,n/2){
      if(s[i]!=s[n/2+i]) a++;
    }
    if (a==0) ans="Yes";
    else ans = "No";
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    ll a,b,n,ans;
    cin >> n >> a >> b;

    ans = n/(a+b)*a;
    ans += min(n%(a+b),a);

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}



Measured memory_bytes: 256
#abc143d
import bisect

n=int(raw_input())
l=map(int,raw_input().split())
l.sort()
res=0
for i in range(n):
 for j in range(i+1,n):
  k=l[i]+l[j]
  res+=max(0,bisect.bisect_left(l,k)-j-1)
print res


Measured memory_bytes: 2812
from collections import deque

S = deque(input())
Q = int(input())
Qs = [list(input().split()) for i in range(Q)]

is_reverse = False
for query in Qs:
    if query[0] == '1' and len(S) != 1:
        is_reverse = not is_reverse
    else:
        f = int(query[1])
        c = query[2]
        if (f == 1 and is_reverse) or (f == 2 and not is_reverse):
            S.append(c)
        else:
            S.appendleft(c)

if is_reverse:
    S.reverse()

print(''.join(S))

Measured memory_bytes: 35188
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX

signed main(){
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, M, s, t, min_ = 0;
	int a, b;
	vector<int> d;
	vector<vector<int>> graph;
	priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> Q;
	
	cin>>N>>M>>s>>t;
	
	d.resize(N+1);
	graph.resize(N+1);
	
	for(int i = 1; i <= N; i++){
		cin>>d[i];
	}
	
	for(int i = 0; i < M; i++){
		cin>>a>>b;
		graph[a].push_back(b);
	}
	
	for(int i = 0; i < t; i++){ //cout<<i<<endl;
		min_ = 0;
		if(i >= s && Q.size()){
			pair<int,int> temp = Q.top();
			
			while(temp.second <= i){ //cout<<"roop "<<endl;
				Q.pop();
				 temp = Q.top();
			}
			min_ = temp.first;
		}
		//cout<<"END "<<endl;
		for(int j = 0; j < graph[i+1].size(); j++){
			Q.push(make_pair(min_+d[graph[i+1][j]], graph[i+1][j]));
			// cout<<"push "<<min_+d[graph[i+1][j]]<<" "<<graph[i+1][j]<<endl;
		}
	}
	
	cout<<min_<<endl;
	
	return 0;
}


Measured memory_bytes: 9048
#include <iostream>
using namespace std;
void display(int N, int* arr) {
    for(int i = 1; i < N; i++) cout << arr[i] << " ";
    cout << arr[N] << endl; 
}
void insertionSort(int N, int* arr) {
    display(N, arr);
    for(int i = 2, v; i <= N; i++) {
        v = arr[i];
        for(int j = i-1; j >= 0; j--) {
            if(v >= arr[j]) {
                arr[j+1] = v;
                break;
            }
            arr[j+1] = arr[j];
        }
        display(N, arr);
    }
}
int main(void){
    int N; cin >> N;
    int arr[N+1]; arr[0] = 0;
    for(int i = 1; i <= N; i++) cin >> arr[i];
    insertionSort(N, arr);
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
long long int arr[1000000];
int main()
{
    int n,m,q;
    cin>>n>>m>>q;
    for(int i=0; i<q; i++)
    {
        int x;
        cin>>x;
        arr[x]++;
    }

    for(int i=1; i<=n; i++)
    {
        if((m+arr[i])-q > 0)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    return 0;
}



Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main(){
    int N, K;
    int d;
    int A;
    cin >> N >> K;
    vector<int> flag(N,1);
    for(int i=0; i<K; i++){
        cin >> d;
        for(int j=0; j<d; j++){
            cin >> A;
            flag.at(A-1)=0;
        }
    }
    int cnt = 0;
    for (int i=0; i<N; i++ ){
        cnt += flag.at(i);
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3628
#if __has_include("noamoa_atcoder_lib.h")
#include "noamoa_atcoder_lib.h"
#else
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define endl '\n'
#define all(x) (x).begin(),(x).end()
namespace atcoder {
	using namespace std;
	using ll = long long;
	using intv = vector<int>;
	using charv = vector<char>;
	using boolv = vector<bool>;
	using floatv = vector<float>;
	using doublev = vector<double>;
	using stringv = vector<string>;

	constexpr ll MOD  = 1000000007;
    constexpr ll MOD9 = 1000000009;

	template<typename T>
	void sort(vector<T>& v){
		sort(all(v));
	}
	template<typename T>
	void sortInv(vector<T>& v){
		sort(all(v), greater<T>());
	}

	template<typename T>
	T sum(const vector<T>& v){
		T ret = 0;
		for(const auto& e : v) ret += e;
		return ret;
	}

	template<typename T>
	inline vector<T>& operator+=(vector<T>& v, const T& e){
		v.push_back(e);
		return v;
	}

	template<typename T>
	void in(vector<T>& v){
		for(auto& e : v) cin >> e;
	}

	template<typename T>
	istream& operator>>(istream &stream, vector<T>& v){
		for(auto& e : v) stream >> e;
		return stream;
	}

	template<typename T>
	void out(const vector<T>& v){
		for(const auto& e : v) cout << e << ' ';
		cout << endl;
	}

	template<typename T>
	void outln(const vector<T>& v){
		for(const auto& e : v) cout << e << endl;
	}

	void init(){
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}
using namespace atcoder;
#endif

int main(){
	init();

	int a,b,c,d;cin>>a>>b>>c>>d;

	while(true){
		c-=b;
		if(c<=0){
			cout<<"Yes";break;
		}
		a-=d;
		if(a<=0){
			cout<<"No";break;
		}
	}
}

Measured memory_bytes: 3652
<?php
	list( $r, $c ) = explode( ' ', trim( fgets( STDIN ) ) );
	$output = array();
	$total = array_fill( 0, $c+1, 0 );
	while( $r-- ) {
		$rc = explode( ' ', trim( fgets( STDIN ) ) );
		
		$sum = 0;
		for( $i=0; $i<$c; $i++ ) {
			$sum += $rc[ $i ];
			$total[ $i ] += $rc[ $i ];
		}
		$total[ $c ] += $sum;
		array_push( $rc, $sum );
		array_push( $output, implode( " ", $rc ) );
    }
	array_push( $output, implode( " ", $total ) );
	print implode( "\n", $output );
?>

Measured memory_bytes: 6732
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] list = new int[String.valueOf( N ).length()]; 
        for (int i= 0;i < String.valueOf( N ).length();i++) {
            list[i] = N % 10;
            N /= 10;
        }
        int a = list[0];
        String b = null;
        if (a == 2 || a == 4 || a == 5 || a == 7 || a == 9) {
            b = "hon";
        } else if (a == 0 || a == 1 || a == 6 || a == 8){
            b = "pon";
        } else {
            b = "bon";
        }
        System.out.println(b);
    }
}

Measured memory_bytes: 35796
#define _GLIBCXX_DEBUG
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iterator>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define FOR(i,a,b) for(int i =(a) ; i <= (b); i++)
#define rep(i,n)  FOR( i, 0, (n) - 1 )
typedef long long ll;

#define mod 1000000007

ll madd(ll a, ll b){
    return (a + b) % mod;
}
ll msub(ll a, ll b){
    return (a + mod - b) % mod;
}
ll mmul(ll a, ll b){
    return ((a % mod) * (b % mod)) % mod;
}
ll mpow(ll a, ll b){
    if(b == 0) return 1;
    else if(b == 1) return a % mod;
    else if(b % 2 == 0){
        ll hlf = mpow(a,b/2);
        return (hlf * hlf) % mod;
    }
    else {
        ll hlf = mpow(a,b/2);
        return ( mmul(hlf , hlf) * a ) % mod;
    }
}
ll mdiv(ll a, ll b){
    return mmul(a, mpow(b, mod-2));
}

// AGC ... 021
bool isAGC(int a,int b,int c,int d){
    if(a == 0 && b == 2 && c == 1)return true;
    if(b == 0 && c == 2 && d == 1)return true;
    return false;
}

// A 0 C 1 G 2 T 3
bool islegal(int a,int b,int c, int d){
    if(isAGC(a,b,c,d))return false;
    if(isAGC(b,a,c,d))return false;
    if(isAGC(a,c,b,d))return false;
    if(isAGC(a,b,d,c))return false;
    return true;
}

ll ans[103][256];

int main(){
    int N;
    cin >> N;
    if(N == 3){cout << "61" << endl;return 0;}
    if(N == 4){cout << "230"<< endl;return 0;}
    // tmpの初期化
    rep(i,256){
        int a,b,c,d;
        a = i / 64;
        b = (i - a * 64) / 16;
        c = (i - a * 64 - b * 16) / 4;
        d = (i - a * 64 - b * 16 - c * 4);
        if(islegal(a,b,c,d)) ans[4][i] = 1;
        else ans[4][i] = 0;
    }
    FOR(j,5,N+1){
        rep(i,256){
            int a,b,c,d;
            a = i / 64;
            b = (i - a * 64) / 16;
            c = (i - a * 64 - b * 16) / 4;
            d = (i - a * 64 - b * 16 - c * 4);
            ans[j][i] = 0;
            if(ans[4][a*64+b*16+c*4+d] == 1){
                rep(k,4){
                    ans[j][i] = madd(ans[j][i] , ans[j-1][k*64+a*16+b*4+c]);
                }
            }
        }
    }
    ll ans2 = 0;
    rep(i,256) ans2 = madd(ans2,ans[N][i]);
    cout << ans2 << endl;
    return 0;
}

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

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

const ll MAX_N=131072;
int bit[MAX_N*2-1];
ll n;
int main(){
  string s;
  cin >>s;
  string t;
  rep(i,s.size()){
    if (s[i]==',') t+=' ';
    else t+=s[i];
  }
  cout <<t<<endl;
}


Measured memory_bytes: 256
N, X = list(map(int, input().split()))

ans = N
N, X = X, N - X
while N and X:
  if X > N:
    d, m = divmod(X, N)
    if m == 0:
      ans += (d * 2 - 1) * N
    else:
      ans += d * 2 * N
    N, X = N, m
  else:
    d, m = divmod(N, X)
    if m == 0:
      ans += (d * 2 - 1) * X
    else:
      ans += d * 2 * X + m * 2
    N, X = m, X - m

print(ans)

Measured memory_bytes: 61972
#include<bits/stdc++.h>
using namespace std;
signed main(){
	int n;scanf("%d",&n);n--;
	int t,q;scanf("%d",&t);
	long long ans=t/2;t%=2;
	while(n--){
		scanf("%d",&q);
		ans+=min(q,t)+(q-min(q,t))/2;
		t=(q-min(q,t))&1;
	}
	printf("%lld\n",ans);
	return 0;
}

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

#define fr                first
#define se                second
#define int               long long
#define pb                push_back
#define mp                make_pair
#define pii               pair<int,int>
#define vi                vector<int>
#define mi                map<int,int>
#define pqb               priority_queue<int>
#define set_bits(x)       __builtin_popcountll(x)
#define mod               1000000007
#define inf               1e18                        //Defining infinity the overflow of int
#define ps(x,y)           fixed<<setprecision(y)<<x   //fir defining the precision int the decimal upto y places. 
#define zrosetbits(x)     __builtin_ctzll(x)         //it will give no of 0's before the first 1 from the right.
#define mk(a,n,type)     type *a=new type[n];
#define test(t)            int t; cin>>t; while(t--)


void io()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin.tie(0);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}



int32_t main()
{
	io();
	clock_t begin = clock();

	//int te = 1;

	// test(t)
	// {
	// int r, g, b;
	string s;
	cin >> s;

	int ctr = 0;
	int res = INT_MIN;

	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] == 'R')
			ctr++;
		if (s[i] == 'S')
        {
			res = max(ctr, res);
          ctr=0;
        }
	}

	res = max(res,ctr);

	cout << res << "\n";





	// cout << concat(4, 1) << "\n";
	//te++;
// double c_time = (double) (clock() - begin) / CLOCKS_PER_SEC;
// cout << ps(c_time, 4) << " seconds\n";
	//}

	return 0;
}


Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
    int N;

    cin >> N;

    vector<string> s(N);
    vector<int> t(N);

    for(int i = 0; i < N; i ++){
        cin >> s[i] >> t[i];
    }
    string X;

    cin >> X;

    int ans = 0;
    int i;

    for(i = 0; i < N; i ++){
        if(s[i] == X){
            i ++;
            break;
        }
    }
    for(; i < N; i ++){
        ans += t[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n ,x) for (int i = x; i < (int)(n); ++i)
#define repBack(i, n) for (int i = n; i >= 0; --i)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int r,D;
    vector<int>x(11);
    cin >> r >> D >> x[0];
    repX(i,11,1){
        x[i] = r * x[i-1] - D;
        cout << x[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb                push_back
#define int               long long
#define M                 1000000007
#define MM                998244353
#define popf              pop_front
#define popb              pop_back
#define fi                first
#define se                second
#define vc                vector
#define pii               pair<int,int>
#define msi               map<string,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define piii              pair<int,pii>
#define mx                -1000000007
#define f(i,a,b)           for(int i=a;i<b;i++)
#define rf(i,a,b)          for(int i=a;i>=b;i--)

	signed main() {
	
		   int t=1;
		  //cin>>t;
		   while(t--)
		   {
		   		
		   	int n,k,w,sum=0,d=0,c=0;
		             string  s,r;
		             int a1=0,b1=0,xx=0;
		             int n0=0,n1=0,n2=0;
		int a,b;
		cin>>a>>b>>c>>k;
		if(k>a+b){
			cout<<a-(k-a-b)<<endl;
		}
		else {cout<<min(k,a)<<endl;}
		                         
}


	} 

Measured memory_bytes: 3628
package main
import(
  "fmt"
)
func main(){
  var n, i, num int
  fmt.Scan(&n)
  ans:=n-1
  for i=1;i<=1000000;i++{
    if n%i==0{
      num=i+n/i-2
      if ans>num{
        ans=num
      }
    }
  }
  fmt.Println(ans)
}


Measured memory_bytes: 512
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
	    Scanner s=new Scanner(System.in);
	    int n=s.nextInt();
	    long k=s.nextLong();
	    long a[]=new long[n];
	    long sum=0;
	    for(int i=0;i<n;i++)
	    {a[i]=s.nextLong();}
	    Arrays.sort(a);
	    for(int i=0;i<n-k;i++)
	    {sum+=a[i];}
	    System.out.println(sum);
	}}

Measured memory_bytes: 82912
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <tuple>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}

template <class T>
T clampMax(const T& a, const T& b) { return min(a, b); }

template <class T>
T clampMin(const T& a, const T& b) { return max(a, b); }

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

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

#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

const int MAX_N = 110;
const int MAX_V = 1010 * MAX_N;
int N;
int W;
int w[MAX_N];
LL v[MAX_N];
LL dp[MAX_N][MAX_V];

int main()
{
    cin >> N >> W;
    REP(i, N) cin >> w[i] >> v[i];
    REP(i, MAX_N) REP(j, MAX_V) dp[i][j] = 1000000000000LL;
    dp[0][0] = 0;
    REP(i, N)
    {
        REP(j, MAX_V)
        {
            if (j - v[i] >= 0)
            {
                updateMin(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
            }
            updateMin(dp[i + 1][j], dp[i][j]);
        }
    }
    int ans = 0;
    REP(i, MAX_V)
    {
        if (dp[N][i] <= W)
        {
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 95872
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

vector<ll> uft;

ll parent(ll a){
    if(uft[a]==a){return a;}
    return uft[a]=parent(uft[a]);
}




int main(){
    ll n,q;
    while(cin>>n>>q){
        if(n==0){break;}
    uft.resize(n);
    for(int i=0;i<n;i++){uft[i]=i;}
    vector<ll> color(n,0);
    vector<ll> P(n,0);
    for(int i=1;i<n;i++){cin>>P[i]; P[i]--;}
    color[0]=1;
    vector<pll> com(q);
    for(auto &i:com){
        char c;
        cin>>c>>i.S;
        i.F=(c=='M'?1:0);
        i.S--;
        if(c=='M'){color[i.S]++;}
    }
    reverse(com.begin(),com.end());
    for(ll i=n-1;i>0;i--){
        if(color[i]==0){uft[parent(i)]=parent(P[i]);}
    }
    ll ans=0;
    for(auto &i:com){
        if(i.F==1){
            color[i.S]--;
            if(color[i.S]==0){uft[parent(i.S)]=parent(P[i.S]);}
        }
        else{
            ans+=parent(i.S)+1;
        }
    }
    cout<<ans<<endl;
    }
    
    
    return 0;
}



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

int main(){
	int n;  cin >> n;
	map<string, int> cnt;
	for(int i=0; i<n; i++){
		string s;  cin >> s;
		cnt[s]++;
	}
	for(string s : {"AC", "WA", "TLE", "RE"}){
		cout << s << " x " << cnt[s] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3640
import math
n = int(input())
lis = list(map(int,input().split()))
if n == 1:
  print("0")
  exit()
for i in range(n):lis[-(i+1)] += i
lis.sort()
cou = 0
co = 0
num = lis[math.ceil(n/2)]
nu = lis[math.floor(n/2)]
for i in range(n):
  cou += abs(lis[i]-num)
  co += abs(lis[i]-nu)
print(min(cou,co))

Measured memory_bytes: 26832
#include <bits/stdc++.h> 
 
#define INF (1<<31) - 1 //INT_MAX/2
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;
using P = std::pair<int, int>;

int main(int argc, char *argv[])
{
    int N;
    std::cin >> N;

    std::vector<int> a(N);
    for (int i = 0; i < N; i++) {
        std::cin >> a[i];
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        ans += a[i] - 1;
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN=100000+10;
int ans;
char s[MAXN];
int main()
{
	scanf("%s",s+1);
	for(int i=1;i<strlen(s+1);++i)
		ans+=(s[i]!=s[i+1]);
	printf("%d\n",ans);
	return 0;
}

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

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

class Prime{
public:
	vector<int> prime;
	vector<bool> is_prime;
	Prime(int n){
		prime = vector<int>(n);
		is_prime = vector<bool>(n+1,true);
		is_prime[0] = is_prime[1] = false;
		int p = 0;
		for (int i = 2;i <= n;i++){
			if(is_prime[i]){
				prime[p++] = i;
				for (int j = 2*i;j <= n;j += i)is_prime[j] = false;
			}
		}
	}
};

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

	int N; cin >> N;

	Prime p(55555);

	int idx = 0;
	for (int i = 0;i < N;i++){
		while(p.prime[idx]%5 != 1) idx++;
		cout << p.prime[idx] << " ";
		idx++;
	}

	cout << endl;

	return 0;

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> v(n,0);
  r(i,n)cin >> v.at(i);
  vector<int> v2(n,0);
  v2=v;
  int a,m,time,count=0;
  cin >> m;
  while(m--){
    cin >> a >> time;
    v2.at(a-1)=time;
    r(i,n)count+=v2.at(i);
    cout << count << endl;
    count = 0;
    v2 = v;
  }
}

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

#define LL long long

const int maxN = 305;

int n, m;
LL mod;
LL C[maxN + 1][maxN + 1], f[maxN + 1][maxN + 1], sum[maxN + 1][maxN + 1];

int main()
{
	scanf("%d %d %lld", &n, &m, &mod);
	C[0][0] = 1;
	for(int i = 1; i <= n; i++)
	{
		C[i][0] = 1;
		for(int j = 1; j <= i; j++) C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;
	}
	f[1][0] = sum[1][0] = 1;
	for(int i = 1; i <= m; i++) f[1][i] = 1, sum[1][i] = (sum[1][i - 1] + 1) % mod;
	for(int i = 2; i <= n + 1; i++)
		for(int j = 0; j <= m; j++)
		{
			for(int k = 1; k < i; k++)
				f[i][j] = (f[i][j] + C[i - 2][k - 1] * f[i - k][j] % mod * (sum[k][m] - sum[k][j]) % mod) % mod;
			if(j) sum[i][j] = (sum[i][j - 1] + f[i][j]) % mod;
		}
	printf("%lld", (f[n + 1][0] % mod + mod) % mod);		
	return 0;
}

Measured memory_bytes: 2432
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  let a=nin()
  out(48-a)
}
main()


Measured memory_bytes: 7372
def main():
    num, start_a, start_b, goal_a, goal_b = map(int, input().split())
    data = input()
    data_a = data[start_a - 1 : goal_a]
    data_b = data[start_b - 1 : goal_b]

    if '##' in data_a or '##' in data_b:
        flg = 0
    elif start_a < start_b and goal_a < goal_b:
        flg = 1
    elif start_b < start_a and goal_b < goal_a:
        flg =  1
    elif start_a < start_b and goal_a > goal_b:
        data_now = data[start_b - 2 : goal_b + 1]
        if '...' in data_now:
            flg = 1
        else:
            flg = 0
    elif start_b < start_a and goal_b > goal_a:
        data_now = data[start_a - 2 : goal_a + 1]
        if '...' in data_now:
            flg = 1
        else:
            flg = 0

    if flg:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    map<int,int> count;
    rep(i,n) {
        count[a[i]]++;
    }
    ll sum = 0;
    for (auto itr = count.begin(); itr != count.end(); itr++) {
        ll value = itr->second;
        sum += value*(value-1)/2;
    }
    rep(i,n) {
        ll ans = sum;
        ans -= count[a[i]]-1;
        printf("%lld\n",ans);
    }
}

Measured memory_bytes: 8320
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readfloat64() float64 {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return float64(i)
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

const Mod = 1000000007

func ModComb(n, k int) int {
	if k == 0 {
		return 1
	}
	x, y := n, k
	for i := 1; i < k; i++ {
		x = x * (n - i) % Mod
		y = y * (k - i) % Mod
	}
	inv := ModInv(y)
	return x * inv % Mod
}

func ModFact(x int) int {
	fact := 1
	for i := 1; i <= x; i++ {
		fact = fact * i % Mod
	}
	return fact
}

func ModInv(x int) int {
	return ModPow(x, Mod-2)
}

func ModPow(a, n int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % Mod
		}
		a = a * a % Mod
		n /= 2
	}
	return res
}

func pow(a, n int) int {
	if n == 0 {
		return 1
	}

	ans := 0
	if n%2 == 0 {
		ans = pow(a*a, n/2)
	} else {
		ans = a * pow(a*a, (n-1)/2)
	}
	return ans
}

func intSliceReverse(slice []int) []int {
	for i, j := 0, len(slice)-1; i < j; i, j = i+1, j-1 {
		slice[i], slice[j] = slice[j], slice[i]
	}
	return slice
}

func stringReverse(str string) string {
	runes := []rune(str)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func main() {
	sc.Split(bufio.ScanWords)

	a, b := readInt(), readInt()

	fmt.Println(a * b)
}


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

int main()
{
    int t=1;


    while(t--){
        int n;
        cin >> n;

         map<string, int>mp;
         for(int i = 0; i<n; i++){
            string s;
            cin >> s;
            mp[s]++;
         }
        // AC, WA, TLE, or RE.
         cout << "AC x "<<mp["AC"]<<endl;
         cout << "WA x "<<mp["WA"]<<endl;
         cout << "TLE x "<<mp["TLE"]<<endl;
         cout << "RE x "<<mp["RE"]<<endl;

    }

    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>

using namespace std;

int main(){

  int width, height, n, x = 0, y = 0, xi, yi, a;
  cin >> width >> height >> n;

  for (int i = 0; i < n; i++){
    cin >> xi >> yi >> a;
    if (a == 1){
      x = max(x, xi);
    }

    else if (a == 2){
      width = min(width, xi);
    }

    else if (a == 3){
      y = max(y, yi);
    }
  
    else{
      height = min(height, yi);
    }
  }

  if (x >= width|| y >= height) cout << 0 << endl;
  else cout << (width - x) * (height - y) << endl;
  
  return 0;

}


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

//保存用
const int limit = 50;

int n, m;
int a[limit], b[limit];

bool graph[limit][limit];
bool visited[limit];

void dfs(int v) {
	visited[v] = true;
	for (int v2 = 0; v2 < n; ++v2) {
		if (graph[v][v2] == false) continue;
		if (visited[v2] == true) continue;
		dfs(v2);
	}
}

int main(void) {

	cin >> n >> m;

	for (int i = 0; i < m; ++i) {
		cin >> a[i] >> b[i];
		a[i]--, b[i]--;
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;

	}
	int ans = 0;

	for (int i = 0; i < m; ++i) {
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

		for (int j = 0; j < n; ++j) visited[j] = false;

		dfs(0);

		bool bridge = false;
		for (int j = 0; j < n; ++j) if (visited[j] == false) bridge = true;
		if (bridge) ans += 1;

		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;

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

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

#define ll long long

using namespace std;
 


int main() {
	ll N, M;
 
	cin >> N >> M;
	ll p[8][N];

	for (int i = 0; i < N ;i++) {
		ll a,b,c;
		cin >> a >> b >> c;
		p[0][i] =   a + b + c;
		p[1][i] = - a + b + c;
		p[2][i] =   a - b + c;
		p[3][i] = - a - b + c;
		p[4][i] =   a + b - c;
		p[5][i] = - a + b - c;
		p[6][i] =   a - b - c;
		p[7][i] = - a - b - c;
	} 
	ll ans = -10000000000LL;

	for (int i = 0; i < 8; i++) {
		sort(p[i], p[i] + N, std::greater<ll>() );
		ll sum = 0;
		for (int j = 0; j < M; j ++) {
			sum += p[i][j];
		}
		if (sum > ans) {
			ans = sum;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>

double calcDistanceBetween(int sourceX, int sourceY, int targetX, int targetY) {
    const unsigned int diffX = std::abs(targetX - sourceX);
    const unsigned int diffY = std::abs(targetY - sourceY);
    return std::sqrt(diffX * diffX + diffY * diffY);
}

int main() {


    const int N_MAX = 8; // the upper bound of the N;

    int N; // the number of towns
    std::cin >> N;

    int x[N_MAX]; // stores the x coordinate for each town
    int y[N_MAX]; // stores the y coordinate for each town

    for (int i=0; i<N; ++i) {
        std::cin >> x[i] >> y[i];
    }

    double sum = 0.; // is the sum of the distance for each pair of the towns.

    for (int i=0; i<N; ++i) { // from the i-th town
        for (int j=i; j<N; ++j) { // to the j-th town
            sum += calcDistanceBetween(x[i], y[i], x[j], y[j]);
        }
    }

    sum *= 2;
    const double average = sum / N;

    std::cout << std::fixed << std::setprecision(10);
    std::cout << average << std::endl;

    return 0;

}


Measured memory_bytes: 3756
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair

int main(){
  int H,W;
  cin>>H>>W;
  VVI X(H,VI(W));
  rep(i,H) rep(j,W) cin>>X[i][j];
  vector<pair<PII,PII>> P;
  rep(i,H){
    rep(j,W-1){
      if(X[i][j]%2){
        P.pb(mp(mp(i+1,j+1),mp(i+1,j+2)));
        X[i][j+1]++;
      }
    }
  }
  rep(i,H-1){
    if(X[i][W-1]%2){
      P.pb(mp(mp(i+1,W),mp(i+2,W)));
      X[i+1][W-1]++;
    }
  }
  cout<<P.size()<<endl;
  rep(i,P.size()) cout<<P[i].first.first<<" "<<P[i].first.second<<" "<<P[i].second.first<<" "<<P[i].second.second<<endl;
}

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

int main() {
    string s;
    cin >> s;
    if ((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

using namespace std;

string s;	
int k;


int main(){
	int x;
	char y;
	cin >> s >> k;
	for(int i=0;i<s.size();i++){
		if(k==0)break;
		if(i==s.size()-1){
			y=s[i];
			if(y+(k%26)>'z'){
				y=y+(k%26)-26;
			}else{
				y+=(k%26);
			}
			
			s[i]=y;
		}else{
			y=s[i];
			x=s[i];
			if(s[i]=='a')continue;
			else{
				if(x+k>122){
					s[i]='a';
					k-=123-x;
				}
			}
		}
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 640
N = int(input())
pointR = []
pointB = []
for i in range(N):
    pointR.append(list(map(int, input().split())))
for i in range(N):
    pointB.append(list(map(int, input().split())))
pointR.sort(key = lambda t: t[0], reverse = True)
pointB.sort(key = lambda t: t[1])
ans = 0

Aok = [True] * N

for i in range(N):
    for j in range(N):
        if Aok[j]:
            if pointR[j][0] < pointB[i][0] and pointR[j][1] < pointB[i][1]:
                ans += 1
                Aok[j] = False
                break
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;
int main(void)
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 1;
    rep(i, 1, n)
    {
        if (s[i] != s[i - 1])
        {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    int n; cin >> n;
    vector<int> checker(n);
    vector<int> rabbit(n);
    rep(i,n) {
        cin >> rabbit[i];
        rabbit[i]--;
    }
    int ans = 0;
    rep(i,n){
        if(checker[i]!=0) continue;
        if(rabbit[rabbit[i]]==i){
            ans++;
            checker[i]++;
            checker[rabbit[i]]++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> arr;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		arr.push_back(a);
	}
	if (n == 1) {
		cout << 0;
		return 0;
	}int i = 0;
	int j = 1;
	int ans = 0;
	while (i < arr.size()) {
		if (arr.at(i) != j) {
			arr.erase(arr.begin() + i);
			ans++;
		}
		else {
			i++;
			j++;
		}
	}if (n == ans) {
		ans = -1;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 4296
a, b, c, l_list = 0, 0, 0, []


def dfs(l_key, a_sum, b_sum, c_sum):
    if l_key == len(l_list):
        if min(a_sum, b_sum, c_sum) > 0:
            return abs(a - a_sum) + abs(b - b_sum) + abs(c - c_sum) - 30
        else:
            return 1 << 20

    l_value = l_list[l_key]
    ret0 = dfs(l_key + 1, a_sum, b_sum, c_sum)
    ret1 = dfs(l_key + 1, a_sum + l_value, b_sum, c_sum) + 10
    ret2 = dfs(l_key + 1, a_sum, b_sum + l_value, c_sum) + 10
    ret3 = dfs(l_key + 1, a_sum, b_sum, c_sum + l_value) + 10

    return min(ret0, ret1, ret2, ret3)


def main():
    global a, b, c, l_list

    n, a, b, c = map(int, input().split())
    l_list = [int(input()) for _ in range(n)]

    ans = dfs(0, 0, 0, 0)
    print(ans)


main()


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll n, m;
    cin >> n >> m;
    vector<ll> x(n), y(m);
    REP(i, n) cin >> x[i];
    REP(i, m) cin >> y[i];

    // 答えを立式したら、計算量を落とす工夫をする
    ll xSum = 0, ySum = 0;
    REP(i, n)
    {
        xSum += i * x[i] - (n - 1 - i) * x[i];
    }
    REP(i, m)
    {
        ySum += i * y[i] - (m - 1 - i) * y[i];   
    }
    xSum = xSum % MOD;
    ySum = ySum % MOD;
    ll ans = xSum * ySum;
    ans = ans % MOD;

    cout << ans << endl;
}


Measured memory_bytes: 1792
# coding: utf-8
DATA = """
1000000000000000000 1
""".split("\n")

def get_debug_line():
	for i in DATA:
		yield i

if 1:
	get_line = input
else:
	get_line = get_debug_line().__next__
	get_line()

N, K = [int(i) for i in get_line().strip().split(" ")]

N %= K
_min = N
while(1):
	if N > K:
		N -= K
	else:
		N = K - N
	
	if _min == N:
		break

	if N < _min:
		_min = N

print (_min)

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

typedef long long ll;

vector<int> to[200005];
vector<int> ans;

void dfs(int v, int p = -1) {
    for (int u: to[v]) {
        if (u == p) continue;
        ans[u] += ans[v];
        dfs(u,v);
    }
}

int main() {
    int N, Q;
    cin >> N >> Q;
    for (int i=0;i<N-1;i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    ans.resize(N);
    for (int j=0;j<Q;j++){
        int p, x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }
    dfs(0);
    for (int i=0;i<N;i++) {
        cout << ans[i];
        if (i!=N-1) { cout << " "; }
        else { cout << endl; }
    } 

    return 0;
}

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


using namespace std;

int main() {
  vector<int> v;
  int counter, tmp;
  bool b;
  cin >> counter;
  b = false;
  
  for(int i=0;i<counter;i++){
    cin >> tmp;
    v.push_back(tmp);
  }
  
  for(int i=counter-1;i>0;i--){
    if(v[i-1]>v[i]){
      v[i-1] = v[i-1]-1;
    }
  }
  
  for(int i=counter-1;i>0;i--){
    if(v[i-1]>v[i]){
      b = true;
    }
  }
  
  if(b){
    cout << "No";
  }else{
    cout << "Yes";
  }
}

Measured memory_bytes: 892