akhauriyash/Code-Regression huggingface dataset:
class Graph:
    class Edge:
        def __init__(self, to, cost):
            """
            :param to:  終点ノード
            :param cost: 辺の重み
            """
            self.to, self.cost = to, cost

    def __init__(self, n, directed=False, decrement=True, edges=[]):
        self.n = n
        self.directed = directed
        self.decrement = decrement
        self.edges = [[] for _ in range(self.n)]
        self.edges2 = []                            # ワーシャルフロイド用
        self.parent = [-1]*self.n
        self.info = [-1]*self.n
        for x, y, cost in edges:
            self.add_edge(x, y, cost)

    def add_edge(self, x, y, cost):
        if self.decrement:
            x -= 1
            y -= 1
        self.edges[x].append(self.Edge(y, cost))
        self.edges2.append((x, y, cost))
        if self.directed == False:
            self.edges[y].append(self.Edge(x, cost))
            self.edges2.append((y, x, cost))     # ワーシャルフロイド用

    def warshall_folyd(self, INF=1<<30):
        """
        :param INF: INF = 10**18 にすると、負のコストがある場合に少し面倒になる
        :return: 頂点 i, j 間の距離を行列として返す
        """
        dist = [[INF] * self.n for _ in range(self.n)]

        for i, j, cost in self.edges2:
            dist[i][j] = cost
        for i in range(self.n):
            dist[i][i] = 0  # 自身のところに行くコストは０

        for k in range(self.n):
            for i in range(self.n):
                for j in range(self.n):
                    if dist[i][j] > dist[i][k] + dist[k][j]:
                        dist[i][j] = dist[i][k] + dist[k][j]
        return dist

    def warshall_folyd2(self, INF=1<<30):
        """
        :param INF: INF = 10**18 にすると、負のコストがある場合に少し面倒になる
        :return: 頂点 i, j 間の距離を行列として返す
        """
        dist = [[INF] * self.n for _ in range(self.n)]

        for i, j, cost in self.edges2:
            dist[i][j] = cost
            if dist[i][j] <= L:
                data.append((i, j))
        for i in range(self.n):
            dist[i][i] = 0

        for k in range(self.n):
            for i in range(self.n):
                for j in range(self.n):
                    if dist[i][j] > dist[i][k] + dist[k][j]:
                        dist[i][j] = dist[i][k] + dist[k][j]
                        if dist[i][j] <= L:
                            data.append((i, j))
        return dist

def max2(x,y):
    return x if x > y else y

from itertools import combinations

N, M, L = map(int, input().split())
graph = Graph(N, directed=False, decrement=True)
for _ in range(M):
    x, y, cost = map(int, input().split())
    graph.add_edge(x, y, cost)

data = []
d = graph.warshall_folyd2()

graph2 = Graph(N, directed=False, decrement=False)
for i, j in combinations(range(N), 2):
    if d[i][j] <= L:
        graph2.add_edge(i, j, 1)


d = graph2.warshall_folyd()

for _ in range(int(input())):
    s, t, = map(int, input().split())
    s, t = s-1, t-1
    print(d[s][t]-1 if d[s][t] < 1<<20 else -1)

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll n, a;

	cin >> n;

	vector<pair<ll, ll>> v;

	REP(i, n) {
		cin >> a;
		v.push_back(make_pair(a, i + 1));
	}

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

	REP(i, n) {
		if (i != n - 1) {
			cout << v[i].second << " ";
		}
		else {
			cout << v[i].second << endl;
		}
	}
}

Measured memory_bytes: 2544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  string s;
  cin >> s;
  int n = 3;
  int ans = 0;
  int cnt = 0;
  REP(i, n) {
    if (s[i] == 'R') cnt++;
    else {
      ans = max(cnt, ans);
      cnt = 0;
    }
  }
  ans = max(cnt, ans);
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 3660
#include<iostream>
#include<cctype>
#include<queue>
#include<cstdio>
#include<cmath>
#include<sstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<ctime>
#include<cstdlib>
#include<map>
#include<utility>
#include<iomanip>
#include<set>
#include<stack>
//#include<Windows.h>
using namespace std;
typedef long long ll;typedef pair<int,int> pii;
typedef pair<ll,ll> pll;typedef vector<string> vss;
typedef vector<int> vii;typedef vector<pii> vpi;
typedef vector<ll> vll;typedef vector<pll> vpl;
typedef unsigned long long ul;typedef queue<int> qii;typedef queue<pii> qpi;
int k,dis[100005];
priority_queue<pii,vector<pii>,greater<pii> > q;
int main()
{
	cin>>k;
	fill(dis,dis+k,1e9+7);
	q.push({1,1});dis[1]=1;
	while(!q.empty()){
		pii t=q.top();q.pop();
		if(dis[t.second]!=t.first) continue;
		for(int i=0;i<10;i++){
			int a=(t.second*10+i)%k;
			if(dis[a]>t.first+i){
				dis[a]=t.first+i;
				q.push(make_pair(dis[a],a));
			}
		}
	}
	cout<<dis[0]<<'\n';
	return 0;
}


Measured memory_bytes: 2804
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String A = sc.next();
            String B = sc.next();

            if ( A.equals(B) ) {
                System.out.println("EQUAL");
            } else if ( A.length() < B.length() || A.length() == B.length() && A.compareTo(B) < 0 ) {
                System.out.println("LESS");
            } else {
                System.out.println("GREATER");
            }
        }
    }
}


Measured memory_bytes: 23380
'''بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ'''
#codeforces
gi = lambda : list(map(int,input().split()))
s = input()
if s[-1] == 's':
  print(s + 'es')
else:
  print(s + 's')

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
typedef pair<int, int> the;

const int INF = 1 << 29;
const ll LINF = 1LL << 60;

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int>a(n);
	rep(i, n)  cin >> a[i];
	sort(a.begin(), a.end(), greater<int>());
	
	int ans = 0;
	rep(i, k)  ans += a[i];
	cout << ans << endl;
}

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

int main(){
    ll H; cin >> H;
    ll cnt = 1;
    while(H>1){
        H = H / 2;
        cnt++;
    }
    cout << ll(1*pow(2, cnt)-1) << endl;
}


Measured memory_bytes: 256
#![allow(unused)]

use std::{cell, cmp, collections, convert, fmt, io, iter, ops, str};

use cell::{Cell, RefCell};
use cmp::Ordering::{Equal, Greater, Less};
use collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
use io::{Read, Write};

#[cfg(feature = "debug")]
macro_rules! debug {
    ($($args: tt)*) => { eprint!($($args)*) };
}

#[cfg(feature = "debug")]
macro_rules! debugln {
    ($($args: tt)*) => { eprintln!($($args)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! debug {
    ($($args:tt)*) => {};
}

#[cfg(not(feature = "debug"))]
macro_rules! debugln {
    ($($args:tt)*) => {};
}

macro_rules! vmax {
    ($x: expr, $y: expr) => { cmp::max($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::max($x, vmax!($($args),*)) };
}

macro_rules! vmin {
    ($x: expr, $y: expr) => { cmp::min($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::min($x, vmin!($($args),*)) };
}

fn main() {
    let n = parse_word::<usize>();
    let k = parse_word::<usize>();
    let a = parse_vec::<i32>();

    let min_pos = a.iter()
        .enumerate()
        .filter_map(|(i, &e)| if e == 1 { Some(i) } else { None })
        .next()
        .unwrap();

    // N (> 0) ranges cover (K + (N - 1) * (K - 1)) length.
    // Thus, N = ceil((len - K) / (K - 1)) + 1.
    let cover_cnt = |len| {
        if len == 1 {
            0
        } else if len <= k {
            1
        } else {
            (len - k - 1) / (k - 1) + 2
        }
    };

    println!("{}", cover_cnt(n));

    // let left_cnt = cover_cnt(min_pos + 1);
    //
    // let len_rem = n - if left_cnt == 0 {
    //     0
    // } else {
    //     k + (left_cnt - 1) * (k - 1) - 1
    // };
    // let right_cnt = cover_cnt(len_rem);
    //
    // println!("{}", left_cnt + right_cnt);
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        //
    }
}

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_owned()
}

fn read_word() -> String {
    const CAPACITY: usize = 16;

    let mut stdin = io::stdin();
    let mut byte: [u8; 1] = [0];

    loop {
        let mut buf = Vec::with_capacity(CAPACITY);

        loop {
            let res = stdin.read(&mut byte);

            if res.unwrap_or(0) == 0 || byte[0] <= b' ' {
                break;
            } else {
                buf.push(byte[0]);
            }
        }

        if !buf.is_empty() {
            return String::from_utf8(buf).unwrap();
        }
    }
}

fn parse_line<T: str::FromStr>() -> T {
    read_line().parse().ok().unwrap()
}

fn parse_word<T: str::FromStr>() -> T {
    read_word().parse().ok().unwrap()
}

fn parse_vec<T: str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn flush() {
    io::stdout().flush();
}


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

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

  int n, k;
  cin >> n >> k;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x > k/2) {
      sum += (k-x)*2;
    }
    else {
      sum += x*2;
    }
  }
  cout << sum << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

char change_color (char c1, char c2 )
{
	map<char, bool> used_color;
	used_color['r'] = false;
	used_color['g'] = false;
	used_color['b'] = false;

	used_color[c1] = true;
	used_color[c2] = true;

	map<char, bool>::iterator it = used_color.begin();
	for (; it != used_color.end(); ++it){
		if ( (*it).second == false ){
			return (*it).first;
		} // end if
	} // end for
} 
bool same_color (string s )
{
	int len = s.length();
	int n = (int)count (s.begin(), s.end(), s[0] );

	if (n == len ){
		return true;
	} // end if

	return false;
}	
	

int bfs (string str )
{
	int len = str.length();
	int i;

	queue <string> Q;
	string s = str;
	Q.push (s );
	set <string> S;
	multimap <string, string> D;

	while (!Q.empty() ){
		s = Q.front(); Q.pop();
//		cout << s << endl;
		if (same_color (s ) ){
			break;
		} // end if

		map<int, int> change_part;

		for (i = 0; i < len - 1; ++i){
			if (s[i] != s[i+1] ){
				change_part[i] = i+1;
			} // end if
		} // end for
		
		if (!change_part.empty() ){
			map<int, int>::iterator it = change_part.begin();
			for (; it != change_part.end(); ++it){
				string t = s;
				t[(*it).first] = change_color (s[(*it).first], s[(*it).second] );
				t[(*it).second] = change_color (s[(*it).first], s[(*it).second] );
				if (!S.count (t ) ){
					S.insert (t );
					Q.push (t );
					D.insert ( make_pair (t, s ) );
				} // end if
			} // end for
		} // end if
	} // end while

	if (Q.empty() && !same_color (s ) ){
		return -1;
	} // end if

	int res = 0;
	if (!D.empty() ){
		++res;
		multimap <string, string>::iterator it = D.begin();
		for (; it != D.end(); ++it){
			if ((*it).first == s ){
				 break;
			} // end if
		} // end for
		string from = (*it).second;
		while (from != str ){
			for (it = D.begin(); it != D.end(); ++it){
				if ( (*it).first == from ){
					from = (*it).second;
					++res;
					break;
				} // end if
			} // end for
		} // end while
	} // end if

	return res;	
}							 

int main()
{
//	cut here before submit 
//	freopen ("testcase.Mworm", "r", stdin );
	string str = "";
	int n;

	while (getline (cin, str ) ){
		int len = str.length();
		if (len == 1 && str[0] == '0'){
			break;
		} // end if
		int i;
		int res = 0;
		
		res = bfs (str );
		if (res == -1){
			cout << "NA" << endl;
		}else{
			cout << res << endl;	
		} // end if
	} // end loop
		
	return 0;
}

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

vector<bool> visited;
int len = 0;

void dfs(vector<vector<int>> &graph, int i){
    len++;
    visited[i] = true;
    for(int v : graph[i]){
        if(!visited[v]){
            dfs(graph, v);
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    visited.assign(n+1, false);
    vector<vector<int> > graph(n+1, vector<int>());
    for(int i=0;i<m;++i){
        int u, v;
        cin >> u >> v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    int res = 0;
    for(int i=1;i<=n;++i){
        if(!visited[i]){
            dfs(graph, i);
            res = max(res, len);
            len = 0;
        }
    }
    cout << res << '\n';
    return 0;
}

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

int main() {
int A;
  int B;
  cin>>A>>B;
  if(A%2==0&&B%2==0){
    cout<<(A+B)/2<<endl;
  }
  else if(A%2==1&&B%2==1){
    cout<<(A+B)/2<<endl;
  }
  else{
    cout<<"IMPOSSIBLE"<<endl;
  }
}

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

#define MAX 10000

int c[MAX+1][MAX+1];

int max( int a, int b );

int lcs( char *X, char *Y );

int main()
{
  int i, q;
  char X[1001], Y[1001];

  scanf("%d", &q);

  for( i=0; i<q; i++ )
    {
      scanf("%s%s", X, Y);
      printf("%d\n", lcs(X,Y));

    }

  return 0;
}
int max( int a, int b )
{
  if( a > b ) return a;
  else return b;
}

int lcs( char *X, char *Y )
{
  int i, j, m, n, maxl=0;
  char x[MAX], y[MAX];

  m = strlen(X);
  n = strlen(Y);

  x[0] = ' ';
  y[0] = ' ';
  strcpy(&x[1],X);
  strcpy(&y[1],Y);


  for( i=1; i<=m; i++ ) c[i][0] = 0;
  for( j=0; j<=n; j++ ) c[0][j] = 0;

  for( i=1; i<=m; i++ )
    {
      for( j=1; j<=n; j++ )
	{
	  if( x[i] == y[j] )
	    {
	      c[i][j] = c[i-1][j-1] + 1;
	    }
	  else if( c[i-1][j] >= c[i][j-1] )
	    {
	      c[i][j] = c[i-1][j];
	    }
	  else
	    {
	      c[i][j] = c[i][j-1];
	    }
	  maxl = max(maxl,c[i][j]);
	}
    }
  return maxl;
}



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


#define ll long long
#define ld long double
#define ull unsigned long long
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long ,long long>
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x,0,sizeof(x))
#define mod 1000000007LL
#define INF 1000000000007


 
//     long long power(long long x, long long y, long long p) 
// { 
//     long long res = 1;      
  
//     x = x % p;  
  
//     while (y > 0) 
//     { 
      
//         if (y & 1) 
//             res = (res*x) % p; 

//         y = y>>1; 
//         x = (x*x) % p; 
//     } 
//     return res; 
// } 
  

// long long modInverse(long long n, long long p) 
// { 
//     return power(n, p-2, p); 
// }  

// long long ncrp(long long n, long long r, long long p) 
// { 
   
//    if (r==0) 
//       return 1; 
  
    
//     long long fac[n+1]; 
//     fac[0] = 1; 
//     // for (long long i=1 ; i<=n; i++) 
//     //     fac[i] = fac[i-1]*i%p; 
  
//     return (fac[n]* modInverse(fac[r], p) % p * 
//             modInverse(fac[n-r], p) % p) % p; 
// }




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


   if (fopen("input.txt", "r")) {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }

    ll n,k;
    cin>>n>>k;

    ll a[n];


    ll i,j;

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

    // ll b[n];
    // clr(b);
    ll dp[k+1];
    clr(dp);


   for(i=0;i<=k;i++)
   {
       ll w=0;
       
       for(j=0;j<n;j++)
       {
           
           if(i-a[j]>=0)
           {
               if(dp[i-a[j]]==0)
               {
                 w++;
               }
           }
           
       }   
       if(w>0)
       {
           dp[i]=1;
       } 
   }

    cout<<(dp[k]==1?"First":"Second")<<endl;



 



  

    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int a = Integer.parseInt(scan.nextLine());
        int b = Integer.parseInt(scan.nextLine());
        int c = Integer.parseInt(scan.nextLine());
        int x = Integer.parseInt(scan.nextLine());

        int res = 0;
        for (int i = 0; i <= a; i++) {
            for (int y = 0; y <= b; y++) {
                for (int z=0; z <= c; z++) {
                    int total = 500*i + 100*y + 50*z;
                    if (x == total)
                        res++;
                }
            }
        }
        System.out.print(res);

    }
}


Measured memory_bytes: 21716
#include <algorithm>
#include <iostream>
#include <string>
#include <unordered_map>

using namespace std;

int main() {
  long N;
  cin >> N;
  
  unordered_map<string, size_t> strs;
  strs.reserve(N);
  long res = 0;
  for (long n = 0; n < N; ++n) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    res += strs[s];
    ++strs[s];
  }
  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 10496
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		int[] array = new int[n * n];
		int[] ref = new int[n * n];
		for (int i = 0; i < n; ++i) {
			x[i] = sc.nextInt();
			array[x[i] - 1] = i + 1;
			ref[x[i] - 1] = i + 1;
		}

		int pos = 0;
		for (int i = 0; i < n * n; ++i) {
			if (ref[i] > 0) {
				int cnt = 0;
				while (cnt < array[i] - 1) {
					if (array[pos] == 0) {
						array[pos] = array[i];
						++cnt;
					}
					++pos;
				}
			}
		}
		pos = n * n - 1;
		for (int i = n * n - 1; i >= 0; --i) {
			if (ref[i] > 0) {
				int cnt = 0;
				while (cnt < n - array[i]) {
					if (array[pos] == 0) {
						array[pos] = array[i];
						++cnt;
					}
					--pos;
				}
			}
		}

		for (int i = 0; i < n * n; ++i) {
			if (ref[i] > 0) {
				int cnt = 0;
				for (int j = 0; j < i; ++j) {
					if (array[j] == ref[i]) {
						++cnt;
					}
				}
				if (cnt != ref[i] - 1) {
					System.out.println("No");
					return;
				}
				for (int j = i + 1; j < n * n; ++j) {
					if (array[j] == ref[i]) {
						++cnt;
					}
				}
				if (cnt != n - 1) {
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
		for (int i = 0; i < n * n; ++i) {
			System.out.print(array[i] + (i == n * n - 1 ? "\n" : " "));
		}

	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 32348
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vll2 = vector<vector<ll>>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    if (n == m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Maxn 200007
using namespace std;
int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,m,cnt,tot;
int pre[Maxn],other[Maxn],last[Maxn],path[Maxn];
bool vis[Maxn];
void insert(int u,int v)
{
	other[++cnt]=v,pre[cnt]=last[u],last[u]=cnt;
}
void dfs(int u)
{
	bool check=false;
	path[++tot]=u;
	for (int q=last[u];q;q=pre[q])
	{
		int v=other[q];
		if (!vis[v])
		{
			vis[v]=true;
			dfs(v);
			check=true;
		}
		if (check) break;
	}
}
int main()
{
	n=read(),m=read(),tot=0;
	for (int i=1;i<=m;i++)
	{
		int u=read(),v=read();
		insert(u,v),insert(v,u);
	}
	memset(vis,false,sizeof(vis));
	vis[1]=true;
	dfs(1);
	for (int i=1;i+i<=tot;i++) swap(path[i],path[tot+1-i]);	
	--tot;
	dfs(1);
	cout << tot << endl;
	for (int i=1;i<=tot;i++) cout << path[i] << ' ' ;
	cout << endl;
	return 0;
}


Measured memory_bytes: 3328
function main()
  
  N = parse(Int, readline())

  check = 0
  dict = Dict()
  
  for i in 1:N
    num = i
    for j in 2:i
      while num % j == 0
        check += 1
        num = div(num, j)
      end
      if check > 0
        dict[j] = get(dict, j, 0) + check
        check = 0
      end
    end
  end
  
  ans = 1
  
  for i in values(dict)
    ans *= (i + 1)
    ans %= (10^9 + 7)
  end
  
  println(ans)
  
end

main()

Measured memory_bytes: 164740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    string s; cin >> s;
    ll n = s.size();
    ll l = 1, r = n+1;
    while(r - l > 1) {
        ll mid = (l + r) / 2;
        bool fl = true;
        Rep(i, n - mid, mid - 1) if(s[i] != s[i+1]) fl = false;
        if(fl) l = mid;
        else r = mid;
    }
    cout << l << endl;
}


Measured memory_bytes: 3724
#include<cstdio>
#include<cstring>
 
bool valid(int y, int x) {
    return (0 <= x && x<8) && (0 <= y && y<8);
}
 
void markdir(char map[8][8], int r, int c, int dy, int dx) {
    if(valid(r+dy, c+dx)) {
        map[r+dy][c+dx] = 'x';
        markdir(map, r+dy, c+dx, dy, dx);
    }
}
 
void mark(char map[8][8], int r, int c) {
    markdir(map, r, c, 1, 1);
    markdir(map, r, c, 1, 0);
    markdir(map, r, c, 1, -1);
    markdir(map, r, c, 0, 1);
    markdir(map, r, c, 0, -1);
    markdir(map, r, c, -1, 1);
    markdir(map, r, c, -1, 0);
    markdir(map, r, c, -1, -1);
}
 
 
void copy(char dst[8][8], const char src[8][8]) {
    memcpy(dst, src, 64);
}
 
bool dfs(const char map[8][8], int k) {
    if(k==8) {
        for(int i=0; i<8; i++) {
            for(int j=0; j<8; j++)
                printf("%c", map[i][j] == 'x' ? '.' : map[i][j]);
            puts("");
        }
        return true;
    }
 
    char mymap[8][8];
    for(int i=0; i<8; i++)
        for(int j=0; j<8; j++)
            if(map[i][j] == '.') {
                copy(mymap, map);
                mymap[i][j] = 'Q';
                mark(mymap, i, j);
                if(dfs(mymap, k+1)) return true;
            }
    return false;
}
int main(void) {
    char map[8][8];
    memset(map, '.', sizeof(map));
 
    int k;
    scanf("%d",&k);
    for(int i=0; i<k; i++) {
        int r,c;
        scanf("%d%d",&r,&c);
        map[r][c] = 'Q';
        mark(map,r,c);
    }
    dfs(map,k);
    return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}

using Graph = vector<vector<int>>;

int N;
int node(int i, int j){
  if (i < j) swap(i, j);
  return i*(i-1)/2 + j;
}


int main() {
  cin >> N;
  VV A(N, V(N-1));
  rep(i, N) rep(j, N-1) {
    cin >> A[i][j];
    A[i][j]--;
  }

  int NN = N*(N-1)/2;
  Graph G(NN, V());
  V indeg(NN);

  rep(i, N) rep(j, N-2) {
    G[node(i, A[i][j])].push_back(node(i, A[i][j+1]));
    indeg[node(i, A[i][j+1])]++;
  }

  queue<int> que;
  rep(u, NN) {
    if (indeg[u] == 0) que.push(u);
  }

  vector<int> order;
  while (!que.empty()) {
    auto u = que.front(); que.pop();
    order.push_back(u);
    for (auto v : G[u]) {
      indeg[v]--;
      if (indeg[v] == 0) que.push(v);
    }
  }

  if (order.size() < G.size()) {
    cout << -1 << endl;
    return 0;
  }

  V dp(NN);
  for (auto u : order) {
    for (auto v : G[u]) {
      chmax(dp[v], dp[u]+1);
    }
  }

  int ans = *max_element(ALL(dp)) + 1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 37492
n=list(map(int,input().split()))
a= str(n[0])+str(n[1])+str(n[2])
maiden=0;z=0;iguales=4504501;iguales_2=1127251;iguales_3=2253001
if(n[0]==1 and n[1]==1 and n[2]==1):
    for k in range(3000-n[3]):
        iguales = iguales-(3001-k)
    print(iguales)
elif(n[0]==2 and n[1]==2 and n[2]==2):
    if(n[3]%2==0):
        for k in range(int((3000-n[3])/2)):
            iguales_2 = iguales_2-(1501-k)
        print(iguales_2)
    else:
        print(0)
elif(a=='121'or a=='112' or a=='211' and n[3]>=2997):
    for k in range(int(3000 -n[3])):
            iguales_3 = iguales_3-(1501-k)
    print(iguales_3)
else:
    for i in range((n[3]//n[0])+1):
        for j in range((n[3]//n[1])+1):
            z=(n[3]-i*n[0]-j*n[1])/n[2]
            if(z%1==0 and z>=0):
                maiden=maiden+1    
    print(maiden)

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

using namespace std;

#define N 300000

int n,m,S,T,tot,ans,q[N],head[N],iter[N],a[N],b[N],visa[N],visb[N],lvl[N];
struct edge{int v,r,c,nxt;}e[N<<3];

void add(int x,int y,int z){
	e[++tot].v=y; e[tot].r=tot+1; e[tot].c=z; e[tot].nxt=head[x]; head[x]=tot;
	e[++tot].v=x; e[tot].r=tot-1; e[tot].c=0; e[tot].nxt=head[y]; head[y]=tot;
}

void bfs(int S,int T){
	memset(lvl,-1,sizeof lvl); lvl[S]=0;
	int tt=0,ww=1; q[ww]=S;
	while (tt<ww){
		int u=q[++tt];
		for (int i=head[u],v;i;i=e[i].nxt)
			if (e[i].c&&lvl[v=e[i].v]==-1){
				q[++ww]=v;
				lvl[v]=lvl[u]+1;
			}
	}
}

int dfs(int u,int T,int mx){
	if (u==T) return 1;
	for (int &i=iter[u],v;i;i=e[i].nxt)
		if (e[i].c&&lvl[v=e[i].v]==lvl[u]+1){
			int d=dfs(v,T,1);
			if (d){
				e[i].c-=d; e[e[i].r].c+=d;
				return d;
			}
		}
	return 0;
}

int dinic(){
	int flow=0;
	while (1){
		bfs(S,T);
		if (lvl[T]==-1) break;
		memcpy(iter,head,sizeof iter);
		for (int ff=dfs(S,T,1);ff;ff=dfs(S,T,1)) flow+=ff;
	}
	return flow;
}

int main(){
	scanf("%d",&n);
	for (int i=0;i<n;++i) scanf("%d",a+i);
	for (int i=0;i<n;++i) scanf("%d",b+i);
	S=++m; T=++m;
	ans=n*2;
	for (int i=0;i<n;++i){
		if (!visa[i]){
			++m;
			for (int j=i;!visa[j];j=a[j]) visa[j]=m;
			if (a[i]==i) --ans;
		}
	}
	for (int i=0;i<n;++i){
		if (!visb[i]){
			++m;
			for (int j=i;!visb[j];j=b[j]) visb[j]=m;
			if (b[i]==i) --ans;
		}
	}
	for (int i=0;i<n;++i){
		if (a[i]!=i) add(S,visa[i],1);
		if (b[i]!=i) add(visb[i],T,1);
		if (a[i]!=i&&b[i]!=i){
			add(visa[i],visb[i],1);
			if (a[i]==b[i]) add(visa[i],visb[i],1);
		}
	}
	printf("%d\n",ans-dinic());
	
	return 0;
}
			

Measured memory_bytes: 23040
#include<iostream>
using namespace std;
int t[200][200],u[200][200];
int main(){
  while(1){
    int n,h,w,H,W,ans=0;
    cin>>n;
    if(n==0)break;
    cin>>W>>H;
    for(int i=0;i<200;i++)
      for(int j=0;j<200;j++)
	t[i][j]=u[i][j]=0;

    for(int i=0;i<n;i++){
      int x,y;
      cin>>x>>y;
      t[x][y]=1;
    }

    for(int i=1;i<200;i++)
      for(int j=1;j<200;j++)
	u[i][j]=t[i][j]+u[i-1][j]+u[i][j-1]-u[i-1][j-1];

    

    cin>>w>>h;
    w--,h--;
    for(int i=1;i+w<=W;i++){
      for(int j=1;j+h<=H;j++){
	int cnt=u[i+w][j+h]-u[i-1][j+h]-u[i+w][j-1]+u[i-1][j-1];
	ans=max(ans,cnt);
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1472
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int a,b;
  cin >> a >> b;
  COUT(max(max(a+b, a-b), a*b));
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
#define stackReplaceBegin(size)\
	void* p=malloc(size);\
	esp_new=(lint)p+size-1;\
	void * stack_extend_memory_ = malloc(size);\
	void * stack_extend_origin_memory_;\
	char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);\
	*stack_extend_dummy_memory_ = 0;\
	asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI = 3.141592653589793238462643383279;
lint esp_new;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	T res(1),now(a);
	while(b){
		if(b&1)res*=now;
		b>>=1;
		now*=now;
	}
	return res;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, (int)vec.size() - 1)std::cout << vec[i] << " ";
	if(!vec.empty())std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
int n,d;
int x[15][15];
int main() {
	std::cin>>n>>d;
	for(int i=0;i<n;i++){
		for(int j=0;j<d;j++)std::cin>>x[i][j];
	}
	int ans=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			lint sum=0;
			for(int k=0;k<d;k++){
				sum+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
			}
			int r=sqrt(sum)+0.1;
			if(r*r==sum)ans++;
		}
	}
	std::cout<<ans<<std::endl;
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <stdio.h>
#include <string.h>
#include <numeric>
#include <cstdlib>

#define rep(i, n) for (int i = 0; i < n; ++i)
typedef unsigned long long ll;

using namespace std;

bool dfs(int i,int n, vector<int> rest, int cnt, int k, int res_idx){
    if(rest[i] == 'x')
        return false;
    if (i == n)
        return false;
    if (i == res_idx)
        return false;
    cnt += 1;
    if ( cnt >= k )
        return true;
    else {
        dfs(i + 1, n, rest, cnt, k, res_idx);
    }
}

int main()
{
    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    vector<int> front(k), back(k);
    int cnt = 0;
    int i = 0;
    while (true)
    {
        if(s[i] == 'o'){
            front[cnt] = i;
            i = i + c+1;
            cnt += 1;
        }
        else
        {
            i += 1;
        }
        if (i > n-1 || cnt >= k)
            break;
    }
    cnt = k-1;
    i = n-1;
    while (true)
    {
        if (s[i] == 'o')
        {
            back[cnt] = i;
            i = i - c-1;
            cnt -= 1;
        }
        else
        {
            i -= 1;
        }
        if (i < 0 || cnt < 0)
            break;
    }
    rep(i,k){
        if(front[i] == back[i]){
            cout << front[i] + 1 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3332
import os

import sys
import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

# MOD = 998244353


DIGIT = (10 ** 18).bit_length()


def solve_f2(mat, last_col, rank):
    # 掃き出し法
    for col in range(last_col, mat.shape[1] - 1):
        if rank >= DIGIT:
            break
        last_col = col
        row = mat[rank:, col].argmax() + rank
        if not mat[row, col]:
            continue
        pivot = mat[row].copy()
        mat[mat[:, col]] ^= pivot
        mat[row] = mat[rank]
        mat[rank] = pivot
        rank += 1

    if rank < DIGIT and mat[rank:].any():
        # 解無し
        return False, last_col, rank
    else:
        return True, last_col, rank


def solve(N, A, S):
    if S[-1] == '1':
        return 1

    # すべての1を、それより後ろの0で打ち消せればOK
    S = (np.array(list(S), dtype=int) == 1)[::-1]
    A = np.array(A, dtype=int)[::-1]

    a_mat = []
    for d in reversed(range(DIGIT)):
        a_mat.append(A >> d & 1)
    mat = np.array(a_mat).astype(bool)

    rank = 0
    for col in range(N):
        if S[col]:
            # check
            if mat[rank:, col].any():
                # 1のかち
                return True
        if rank >= DIGIT:
            return False
        row = mat[rank:, col].argmax() + rank
        if not mat[row, col]:
            continue
        pivot = mat[row].copy()
        mat[mat[:, col]] ^= pivot
        mat[row] = mat[rank]
        mat[rank] = pivot
        rank += 1
    return False


T = int(sys.stdin.buffer.readline())
for _ in range(T):
    N = int(sys.stdin.buffer.readline())
    A = list(map(int, sys.stdin.buffer.readline().split()))
    S = sys.stdin.buffer.readline().decode().rstrip()
    ans = solve(N, A, S)
    print(int(ans))


Measured memory_bytes: 27376
use std::fs;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let k: usize = parse!(it);
    let n = 50;
    let r = k / n;
    let mut a = vec![n - 1 + r; n];
    for i in 0..(k % n) {
        a[i] += n;
        for j in 0..n {
            if i != j {
                a[j] -= 1;
            }
        }
    }
    println!("{}", n);
    println!(
        "{}",
        a.iter()
            .map(|&x| x.to_string())
            .collect::<Vec<String>>()
            .join(" ")
    );
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define pii pair<int,int>
using namespace std;
const int N = 1e5+5;
pii a[N],b[N];int fa[N],n;
int main(){
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i].first,a[i].second=i;
    for(int i=1;i<=n;i++)cin>>b[i].first,b[i].second=i;
    sort(a+1,a+1+n);sort(b+1,b+1+n);
    for(int i=1;i<=n;i++)if(a[i].first>b[i].first){cout<<"No";return 0;}
    for(int i=1;i<=n;i++)fa[b[i].second]=a[i].second;
    for(int i=1;i<n;i++)if(a[i+1].first<=b[i].first){cout<<"Yes";return 0;}//至少有一个满足了
    int x=1,num=0;
    do{
        x=fa[x];
        num++;
    }while (x!=1);//一样
    if(num==n)cout<<"No"; else cout<<"Yes";
}

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

int main() {
    int h, w;
    cin >> h >> w;
    string s[2 * h];
    for (int i = 0; i < 2 * h; i+=2)
        cin >> s[i];
    for (int i = 1; i < 2 * h; i+=2)
        s[i] = s[i - 1];
    for (int i = 0; i < 2 * h; i++)
        cout << s[i] << endl;
    return 0;
}

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

long long mod = 1e9+7;
long long r = 0, g = 0, b = 0;

long long solve(long long sum, long long a){
    long long count = 0;
    if(a == r) count++;
    if(a == g) count++;
    if(a == b) count++;

    if(a == r){
        r++;
    }
    else{
        if(a == g){
            g++;
        }
        else{
            b++;
        }
    }

    sum = (sum*count)%mod;
    return sum;
}

int main(){
    long long n;
    cin >> n;
    vector<long long> a(n);

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

    
    long long sum = 1;

    for(long long i = 0; i < n; i++){
        sum = solve(sum, a[i]);
    }

    cout << sum << endl;
    return 0;
}

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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int IINF = 2002002002;
constexpr ll LINF = 9009009009009009009LL;

//===




int main()
{
	int N, K;
	cin >> N >> K;

	string S;
	cin >> S;

	int ans = 0;
	for (int i = 0; i < N - 1; ++i) {
		if (S[i] == 'L' && S[i + 1] == 'L') ++ans;
		else if (S[i] == 'R' && S[i + 1] == 'R') ++ans;
	}

	int numLR = 0, numRL = 0;
	for (int i = 0; i < N - 1; ++i) {
		if (S[i] == 'L' && S[i + 1] == 'R') {
			++numLR;
		}
		else if (S[i] == 'R' && S[i + 1] == 'L') {
			++numRL;
		}
	}

	if (numLR < numRL) swap(numLR, numRL);
	if (numRL >= K) ans += K * 2;
	else {
		ans += numRL * 2;
		numLR -= numRL;
		K -= numRL;
		if (numLR >= K) ans += K;
		else {
			ans += numLR;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int time = a + b;
        if(time >= 24){
            time = time - 24;
        }
        System.out.println(time);
    }
}

Measured memory_bytes: 23764
//      https://youtu.be/X_hMZYDMps4

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

typedef long long ll;
typedef long double ld;
typedef long long unsigned llu;
typedef pair<long long, long long> pll;
const long long inf = 2000000000000000000LL;    // 2e18
#define pi                  acos(-1.0)
#define fast                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define nl                  "\n"
#define ff                  first
#define ss                  second
#define pb                  push_back
#define pf                  push_front
#define all(x)              x.begin(),x.end()
#define debug(x)            cout<<"debug "<<x<<"\n"

int main()
{
    fast;
    ll t,i,j,k,l,m,n,o,p,q,temp,ans=0,flag=0,mod=1000000007,odd=0,even=0;
    cin>>n;
    ll a[(3*n)];
    for(i=0;i<3*n;i++) cin>>a[i];
    sort(a,a+(3*n));
    for(i=0,j=(n*3)-2;i<n;i++,j-=2){
        ans+=a[j];
    }
    cout<<ans;
}


Measured memory_bytes: 5968
import scala.collection.mutable._
import io.StdIn.readLine

object Main extends App {
  val map = new HashMap[String,Int]
  val s = readLine.split(" ")
  s.foreach(e => {
    if(!map.contains(e)) map.put(e,1)
    else map.put(e,map(e)+1)
  })
  val maxF = map.maxBy(_._2)._1
  val maxL = s.map(e => (e.length, e)).max._2

  println(maxF + " " + maxL)
}


Measured memory_bytes: 43988
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//

    #define pb push_back
    #define MP make_pair
    #define F first
    #define S second
    #define int long long
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define deb(x) cout<<#x<<" "<<x<<endl;
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int MOD =  1000000007 ;
    const int MAX = 2e6 + 7;
    const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    // int v[MAX];
    int mod = 1e9+7;
    int mul(int a,int b)
    {
        return ((a%mod)*(b%mod))%mod;
    }
    int add(int a,int b)
    {
        return ((a%mod)+(b%mod))%mod;
    }
    int power(int a,int b)
    {
        int res = 1;
        while(b>0)
        {
            if(b&1)
            {
                res = res*a;
            }
            b = b/2;
            a = a*a;
        }
        return res;
    }
    int sub(int a,int b)
    {
        return ((a%mod)-(b%mod)+mod)%mod;
    }
    int divi(int a,int b)
    {
        return mul(a,power(b,mod-2));
    }

    int sum;
    void solve()
    {
        cin>>n;
        while(power(2,k)<=n)k++;
        k--;
        sum=2*power(2,k)-1;
        cout<<sum<<endl;

    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          GAME STARTS FROM HERE                            //

    int32_t main() 
      {
        
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);
        
        // cin>>t;while(t--)
        solve();
        
      return 0;
      }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    string a,S;cin>>a>>S;
    cout<<"A"<<S[0]<<"C"<<endl;
}

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

using namespace std;

int main() {
	ll n;
	cin >> n;
	vector<ll> l(n);
	REP(i, n) {cin >> l[i];}
	ll max = *max_element(l.begin(), l.end());
	ll sum = 0;
	REP(i, n) {sum += l[i];}
	sum -= max;
	if (max < sum) {cout << "Yes" << endl;}
	else { cout << "No" << endl;}
}

Measured memory_bytes: 384
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -std=c++11 */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int maxn = 1e6;
LL sum1[maxn];

int main()
{
    int n,k;
    while (cin >> n >> k) {
        LL ans = 0, cnt = 0;
        if (k&1) {
            FOR(i,1,n+1) if (i%k == 0)
                cnt++;
            ans = cnt*cnt*cnt;
        }
        else {
            FOR(i,1,n+1) if (i%k == 0)
                cnt++;
            ans += cnt*cnt*cnt;
            cnt = 0;
            FOR(i,1,n+1) if (i%k == k/2)
                cnt++;
            ans += cnt*cnt*cnt;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256