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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  while (n--) {
    string ord, s;
    cin >> ord >> s;
    reverse(begin(ord), end(ord));
    for (char c : ord) {
      if (c == 'J') {
        rotate(begin(s), prev(end(s)), end(s));
      } else if (c == 'C') {
        rotate(begin(s), next(begin(s)), end(s));
      } else if (c == 'E') {
        if (s.size() & 1) {
          for (int i = 0; i < (int)s.size() / 2; ++i) {
            swap(s[i], s[(s.size() + 1) / 2 + i]);
          }
        } else {
          rotate(begin(s), begin(s) + s.size() / 2, end(s));
        }
      } else if (c == 'A') {
        reverse(begin(s), end(s));
      } else if (c == 'P') {
        for (auto&& e : s) {
          if (isdigit(e)) {
            e = e == '0' ? '9' : e - 1;
          }
        }
      } else {
        assert(c == 'M');
        for (auto&& e : s) {
          if (isdigit(e)) {
            e = e == '9' ? '0' : e + 1;
          }
        }
      }
    }
    cout << s << '\n';
  }
}



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

#define DIM 200007
typedef long long ll;
typedef long double ld;
using namespace std;

struct ev{
    ll k,b;
};
ll n,i,j,m,nlines;
ev lines[DIM];
ll a[DIM];
ll benz[DIM];
ll dp[DIM];


ll check(ev l1, ev l2, ev l3){
    return (ld)(l3.b - l1.b) / (ld)(l1.k - l3.k) >= (ld)(l3.b - l2.b) / (ld)(l2.k-l3.k) ;
}

void add(ll k, ll b){
    ev l={k,b};
    while(nlines>1 && check(lines[nlines-1],lines[nlines],l)) nlines--;
    nlines++;
    lines[nlines]=l;
}

ll f(ll num, ll x){
    return lines[num].k*x+lines[num].b;
}

ll getm(ll x){
    ll l=0,r=nlines,m;
    while(r-l>1){
        m=(l+r)/2;
        if(f(m,x)<f(m+1,x)) r=m;
        else l=m;
    }
    return f(r,x);
}

int main()
{
    ll sss;
    cin >> n >> sss;
    for(i=1; i<=n; i++) cin >> a[i];
    add(-2*a[1],a[1]*a[1]);
    for(i=2; i<=n; i++){
        dp[i]=getm(a[i])+a[i]*a[i]+sss;
        add(-2*a[i],dp[i]+a[i]*a[i]);
    }
    cout << dp[n] << endl;
    return 0;
}


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

int main() {
    uint64_t r, D, x;
    std::cin >> r >> D >> x;

    for (int i = 0; i < 10; ++i) {
        x =  r * x - D;
        std::printf("%lu\n", x);
    }

    return 0;
}


Measured memory_bytes: 256
<?php
  list($N) = explode(" ", trim(fgets(STDIN)));
  list($K) = explode(" ", trim(fgets(STDIN)));
  list($X) = explode(" ", trim(fgets(STDIN)));
  list($Y) = explode(" ", trim(fgets(STDIN)));

  $ans = 0;
  if($N > $K){
    $ans += $K * $X;
    $ans += ($N-$K) * $Y;
  }else{
    $ans += $N * $X;
  }
  echo $ans;

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

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

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

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

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

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

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

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

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

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

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

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

fn main() {
    input!{
      mut n: usize,
    }
    if n == 0 {
        return println!("{}", "2");
    } else if n == 1 {
        return println!("{}", "1");
    }
    n -= 2;

    let mut l0 = 2 as u64;
    let mut l1 = 1;
    let mut luca = l1 + l0;
    while n > 0 {
        l0 = l1;
        l1 = luca;
        luca = l1 + l0;
        n-=1;
    }
    println!("{}", luca);
}


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

public class Program{
    public static void Main(){
        var input = Console.ReadLine().Split().ToArray();
        var a = int.Parse(input[0]);
        var b = int.Parse(input[2]);
        if(input[1]=="+")Console.WriteLine(a+b);
        else Console.WriteLine(a-b);
    }
}


Measured memory_bytes: 13268
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
#define gcd(a,b) __gcd(a,b)
using namespace std;
int extgcd(int a,int b,int &x,int&y){
  int d=a;
  if(b!=0){
    d=extgcd(b,a%b,y,x);
    y-=(a/b)*x;
  }else{
    x=1;y=0;
  }
  return d;
}
int main(){
  int a,b,x,y;
  cin>>a>>b;
  int d=gcd(a,b);
  a/=d;b/=d;
  extgcd(a,b,x,y);
  cout<<x<<" "<<y<<endl;;

}

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

using namespace std;
string s;
int main()
{
  cin>>s;
  for(int i=0;i<s.size();i++)
  {
    if(s[i]==',')cout<<" ";
    else cout<<s[i];
  }
  cout<<endl;
 return 0;
}

Measured memory_bytes: 256
Num = int(input())
Num_Array = []
count = 0
result = 0

for i in range(Num):
    Num_Array.append(int(input()))
Num_Array.sort()

while count < Num:

    if Num_Array.count(Num_Array[count]) == 1:
        result += 1
    else:
        Num_Array.pop(count)
        count -= 1
        Num -= 1
    count += 1

print(result)

Measured memory_bytes: 3064
/// Coded by Dhiman Sarker Bappi (Dhimanda) - RMSTU

#include<bits/stdc++.h>
using namespace std;
#define    in_file     freopen("input.txt", "r", stdin)
#define    out_file    freopen("output.txt", "w", stdout)
#define    fast        ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define    F           first
#define    S           second
#define    pb          push_back
#define    popb        pop_back
#define    pf          push_front
#define    popf        pop_front
#define    lcm(a,b)    (a*b)/gcd(a,b)
#define    gcd(a,b)    __gcd(a,b)
#define    pi          2*acos(0)
#define    elif        else if
#define    ll          long long
#define    nl          '\n'
#define    endl        '\n'
#define    fori(i,b,e) for(int (i)=(b); (i) <= (e); (i)++)
#define    for0(i,n)   for(int (i)=0; (i) < (n); (i)++)
#define    sp          fixed << setprecision
#define    all(x)      x.begin(),x.end()

// ===================== DEBUG  ==========================

vector<string>vec_spltr(string s){s+=',';vector<string>res;while(!s.empty())
res.push_back(s.substr(0, s.find(','))),s=s.substr(s.find(',')+1);return res;}
void dbg_out(vector<string>__attribute__((unused))args,__attribute__((unused))int idx,
__attribute__((unused))int LINE_NUM){cerr<<endl;}template<typename Head,typename... Tail>
void dbg_out ( vector <string> args, int idx, int LINE_NUM, Head H, Tail... T)
{if(idx>0)cerr<<", ";else cerr << "Line(" << LINE_NUM << ") ";stringstream ss;ss<<H;
cerr<<args[idx]<<" = "<<ss.str();dbg_out(args,idx+1,LINE_NUM, T...);}
#define debug(...) dbg_out(vec_spltr(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)

// ===================== custom function ==========================
ll pow_mod(ll nn, ll pp, ll mm) { ll res = 1; while(pp > 0) { if(pp&1) res = (res * nn) % mm; pp = pp >> 1; nn = (nn * nn) % mm; } return res; }
void dhimanda();
// ===================== Main function ==========================
int main()
{
    //in_file;
    //out_file;
    int t=1;
    //cin >> t;
    fori(i,1,t){
        //printf("Case %d: ", i);
        dhimanda();
    }
    return 0;
}
void dhimanda(){
    ll n,k;
    cin >> n>>k;
    ll a[n];
    for0(i,n) cin >> a[i];
    sort(a,a+n);
    ll sum = 0;
    for0(i,k) sum += a[i];
    cout <<sum<<endl;
}

// Contact : chessdhiman@gmail.com


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 2005000000
#define MOD 1000000007
#define N 100005
#define M 100000000
#define LOG 22
#define KOK 4000000
using namespace std;

int n,m,x,y,t[N];

int main() {

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

	scanf("%d %d",&n,&m);

	for(int i=1;i<=m;i++) {

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

		t[x]++;
		t[y]++;

	}

	for(int i=1;i<=n;i++) {

		if(t[i]&1) {

			printf("NO");

			return 0;

		}

	}

	printf("YES");

}

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

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  string S;
  cin >> S;

  int ans=0;
  rep(i,sz(S))  if(S.at(i)=='R')  ans++;
  if(S.at(1)=='S')  chmin(ans,1);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3652
import java.util.Scanner;

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

		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		long cd = gcd(c, d);

		long cdd = c / cd * d;

		long e = b / c - a / c + b / d - a / d - b / cdd + a / cdd;

		if (a % c == 0)
			e++;
		if (a % d == 0)
			e++;
		if (a % cdd == 0)
			e--;

		System.out.println(b - a + 1 - e);

	}

	static long gcd(long l, long m) {
		long n = l;
		if (l < m) {
			l = m;
			m = n;
		}

		while (m != 0) {
			n = m;
			m = l % m;
			l = n;
		}

		return l;
	}

}


Measured memory_bytes: 21972
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>

using namespace std;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()



int main()
{
	int n; cin >> n;
	if (n == 1)cout << "Hello World" << endl;
	else
	{
		int a, b; cin >> a >> b;
		cout << a + b << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(i = 1; i <= n; i++)
//2D::rep(i,j)rep(j,j)cin>>bin[i][j];
//vector<int> a(n)
#define Graph vector<vector<int>>
#define A1 cout<<"No"<<endl
#define A2 cout<<"Yes"<<endl
#define A3 cout<<ans<<
#define AA(i) cout<<i<<endl;
const int U=2e5+5;
const ll MOD=1000000007;
const int INF = 1001001001;

int main(){
    int N,K; cin >> N >> K;
    vector<ll> A(N+1);
    int i;
    ll ans=0;
    rep(i,N) cin>>A[i];
    for(i=K;i<N;i++){
        if(A[i-K+1] < A[i+1]){
            A2;
        }
        else A1;
    }
    return 0;
}

Measured memory_bytes: 4836
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#define INF 1000000000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;


int main(){
    int n,m;
    cin >> n>> m;
    vector<int> c(m), d(n);
    rep(i, n) cin >> d[i];
    rep(i, m) cin >> c[i];
    vector<int> dp((m-n+1)*(n+1));//???????????°?????\??????????????´????°?
    rep(i, m-n+1) dp[i*(n+1)] = 0;
    for(int i =1 ; i <= n ; i++) dp[i] = dp[i-1]+d[i-1]*c[i-1];
    for(int i=1;i<m-n+1 ;i++){
        for (int j=1 ; j<=n ; j++) {
            dp[i*(n+1)+j] = min(dp[(n+1)*(i-1)+j],dp[i*(n+1)+j-1]+c[i+j-1]*d[j-1]);
        }
    }
    int ans = INF;
    rep(i, m-n+1) ans = min(ans,dp[i*(n+1)+n]);
    cout << ans << endl;
}

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

typedef long long ll;

int main() {
  ll W, H, x, y;
  std::cin >> W >> H >> x >> y;

  double S = (double) W * H / 2;
  int multi = (2 * x == W and 2 * y == H) ? 1 : 0;
  std::cout << std::fixed << std::setprecision(9)
            << S << " " << multi << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
const ll MOD = 1e9+7;

signed main(){
	int n; 
	std::cin >> n;
	std::vector<int> ans(n + 1);
	for(int i = 1; i <= n; i++){
		int num = 0;
		for(int x = 1; x <= sqrt(i); x++){
			for(int y = 1; y <= sqrt(i); y++){
				int p = (x + y) * (x + y) + 4 * (i - x*x - y*y - x*y);
				if(p < 0) continue;
				int q = sqrt(p);
				if(q * q == p){
					int r = -(x + y) + q;
					if(r >= 2 && r % 2 == 0) num++;
				}
			}
		}
		ans[i] = num;
	}
	for(int i = 1; i <= n; i++){
		std::cout << ans[i] << '\n';
	}
}

Measured memory_bytes: 3560
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <new>
#define ESP (1e-13)
#define INF 2000000000
/*
#define FOR(i,m,n)    for(int i=m;i<n;i++)
#define FORB(i,m,n)    for(int i=m;i>=n;i--)
#define INF 999999999
*/

#define ll long long
/*
#define PUSH(a) push_back(a)
#define POP() pop_back()
#define SORT(v,n) sort(v,v+n)
#define VSORT(v) sort(v.begin(),v.end())
*/

using namespace std;

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

typedef struct {
	long int A;
	long int B;
}Item ;

Item item[100000];
int N, W,K;
int C[100001][32], G[100001][32];

void compute(int &maxValue, vector<int> &selection) {
	for (int w = 0;w <= W;w++) {
		C[0][w] = 0;
		G[0][w] = 1;
	}
	for (int i = 1;i <= N;i++) C[i][0] = 0;
	for (int i = 1;i <= N;i++) {
		for (int w = 1;w <= W;w++) {
			C[i][w] = C[i - 1][w];
			G[i][w] = 0;
			if (item[i].A > w) continue;
			if (item[i].B + C[i - 1][w - item[i].A] > C[i - 1][w]) {
				C[i][w] = item[i].B + C[i - 1][w - item[i].A];
				G[i][w] = 1;
			}
		}
	}
	maxValue = C[N][W];
	selection.clear();
	for (int i = N, w = W;i >= 1;i--) {
		if (G[i][w] == 1) {
			selection.push_back(i);
			w -= item[i].A;
		}
   }
	reverse(selection.begin(), selection.end());
}

void input() {
	cin >> N >> W;
	for (int i = 0;i < N;i++) {
		cin >>item[i].A; cin >> item[i].B;
	}

}

int main() {
	int H,W;
	cin >> H;
	cin >> W;
	char S[52][52] = { {" "} };
	for (int i = 1;i <= H;i++)
		for (int j = 1;j <= W;j++)
			cin >> S[i][j];
	for (int i = 1;i <= H;i++)
	{
		for (int j = 1;j <= W;j++)
		{
			int count = 0;
			if (S[i][j - 1] == '#') count++;
			if (S[i-1][j - 1] == '#') count++;
			if (S[i+1][j - 1] == '#') count++;
			if (S[i][j + 1] == '#') count++;
			if (S[i+1][j + 1] == '#') count++;
			if (S[i-1][j + 1] == '#') count++;
			if (S[i-1][j] == '#') count++;
			if (S[i+1][j] == '#') count++;
			if (S[i][j]!='#') S[i][j] = (char)(count+48);
		}
	}

	for (int i = 1;i <= H;i++)
	{
		for (int j = 1;j <= W;j++)
		{
			cout << S[i][j];
		}
		cout << endl;
	}

}










Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
  
#define N 5000
  
typedef struct list
{
  int x, y;
  char ground;
  struct list *prev;
  struct list *next;
} list;
  
list head;
list tail;
      
void Insert(char);
list *FarSide(list *);
int PubbleArea(list *, list *);
  
int main()
{
  int i;
  char c;
  list *p;
  list *farSide;
  int pubbleCount = 0;
  int pubble[N];
  int sumPubble = 0;
      
  head.next = &tail;
  tail.prev = &head;
      
  // Input
  while(1)
    {
      c = getchar();
      if(c == '\n') break;
  
      Insert(c);
    }
  
  for(p = head.next; p != &tail; p = p->next)
    {
      if(p->ground == '\\' &&
     (farSide = FarSide(p)) != NULL)
        {
      pubble[pubbleCount] = PubbleArea(p, farSide);
      sumPubble += pubble[pubbleCount];
      p = farSide;
      pubbleCount++;
        }
          
    }
  
  printf("%d\n%d", sumPubble, pubbleCount);
  for(i = 0; i < pubbleCount; i++)
    {
      printf(" %d", pubble[i]);
    }
  printf("\n");
      
  return 0;
}
  
void Insert(char c)
{
  static int xCount = 0;
  static int yCount = 0;
  list *p;
  
  p = (list*)malloc(sizeof(list));
  p->prev = tail.prev;
  tail.prev->next = p;
  p->next = &tail;
  tail.prev = p;
  
  xCount++;
  if(c == '\\') yCount--;
  if(c == '/' ) yCount++;
  p->x = xCount;
  p->y = yCount;
  p->ground = c;
}
  
list *FarSide(list *s)
{
  list *i_p;
  int height;
  height = s->y + 1;
  
  for(i_p = s->next; i_p != &tail; i_p = i_p->next)
    {
      if(i_p->y == height) return i_p;
    }
  return NULL;
}
  
int PubbleArea(list *pS, list *pE)
{
  list *i_p;
  list *farSide;
  int area = 0;
      
  for(i_p = pS; i_p != pE; i_p = i_p->next)
    {
      if(i_p->ground == '\\')
        {
      farSide = FarSide(i_p);
      area += farSide->x - i_p->x;
        }
    }
  return area;
}

Measured memory_bytes: 1488
#include <stdio.h>
#include <stdlib.h>

int get_int() {
    int n = 0;
    int c = getchar_unlocked();
    if(c == 45) {
        c = getchar_unlocked();
        while(47 < c && c < 58) n = 10 * n + (c & 0xf), c = getchar_unlocked();
        return -n;
    } else if(c < 48 || 57 < c) return c;
    while(47 < c && c < 58) n = 10 * n + (c & 0xf), c = getchar_unlocked();
    return n;
}
int get_str(char *str) {
    int c;
    while((c = getchar_unlocked()) > 32) *str++ = (char)c;
    *str = 0;
    return c;
}
void put_int(int n) {
    if(!n) {
        putchar_unlocked('0');
        return;
    }
    if(n < 0) n = -n, putchar_unlocked('-');
    char buf[11];
    int i = 0;
    while(n) buf[i++] = (char)(n % 10 + '0'), n /= 10;
    while(i--)putchar_unlocked(buf[i]);
}

typedef struct Node {
    int key;
    struct Node *left, *right;
} Node;
typedef struct BST {
    Node *root;
    size_t size;
} BST;
void bst_init(BST *BST) {
    BST->root = NULL;
    BST->size = 0;
}
void bst_insert(BST *BST, int key) {
    Node *new_node = malloc(sizeof(Node));
    new_node->key = key;
    new_node->left = NULL;
    new_node->right = NULL;
    Node *tmp;
    Node *root = BST->root;
    while(root != NULL) {
        tmp = root;
        if(key < root->key) root = root->left;
        else root = root->right;
    }
    if(BST->size == 0) BST->root = new_node;
    else if(key < tmp->key) tmp->left = new_node;
    else tmp->right = new_node;
    BST->size++;
}
void bst_inorder(Node *root) {
    if(root == NULL) return;
    bst_inorder(root->left);
    putchar_unlocked(' '), put_int(root->key);
    bst_inorder(root->right);
}
void bst_preorder(Node *root) {
    if(root == NULL) return;
    putchar_unlocked(' '), put_int(root->key);
    bst_preorder(root->left);
    bst_preorder(root->right);
}
int main(int argc, char **argv) {
    BST BST;
    bst_init(&BST);
    int m = get_int();
    char c[8];
    for(int i = 0; i < m; ++i) {
        get_str(c);
        if(*c == 'i') {
            int key = get_int();
            bst_insert(&BST, key);
        } else {
            bst_inorder(BST.root);
            putchar_unlocked('\n');
            bst_preorder(BST.root);
            putchar_unlocked('\n');
        }
    }
    return 0;
}



Measured memory_bytes: 17184
#include<stdio.h>

/* 配列の要素を順番に出力 */
void trace(int A[],int N){
	int i;
	for(i = 0; i < N; i++){
		if(i > 0)printf(" ");
		printf("%d",A[i]);
	}
	printf("\n");
}

/* 挿入ソート */
void insertionSort(int A[],int N){
	int i,j,v;
	for(i = 1; i < N; i++){
		v = A[i];
		j = i - 1;
		while(j >= 0 && A[j] > v){
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;
		trace(A,N);
	}
}

int main(){
	int N,i,j;
	int A[100];

	scanf("%d",&N);
	for(i = 0; i < N; i++){
		scanf("%d",&A[i]);
	}

	trace(A,N);
	insertionSort(A,N);

	return 0;
}


Measured memory_bytes: 2000
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int p = int.Parse(input[0]);
		int q = int.Parse(input[1]);
    int r = int.Parse(input[2]);
		int answer = Math.Min(p+q,p+r);
    answer = Math.Min(answer,q+r);

		Console.WriteLine(answer);
	}
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

int n;
vector<int> ko[200010];
int dep[200010];
int par[20][200010];
vector<int> dlst[200010];

const ll M = 1'000'000'007;
ll Pow(ll b, ll e){
	ll ret=1;
	while(e){
		if(e&1) (ret*=b)%=M;
		(b*=b)%=M; e>>=1;
	}
	return ret;
}

int tin[200010];
int tou[200010];
int nt;
void dfs(int x){
	dlst[dep[x]].pb(x);
	tin[x] = ++nt;
	for(int y:ko[x]){
		dep[y]=dep[x]+1;
		dfs(y);
	}
	tou[x] = nt;
}

int deep[200001], dn;

int lca(int a, int b){
	for(int i=17; 0<=i; --i) if(par[i][a] != par[i][b]) a=par[i][a], b=par[i][b];
	if(a!=b) a=par[0][a];
	return a;
}

ll aru[200010];
ll nai[200010];

int main()
{
	read(n);
	for(int i=1; i<=n; ++i){ int p; read(p); par[0][i]=p; ko[p].pb(i); }
	for(int i=1; i<=17; ++i) for(int j=0; j<=n; ++j) par[i][j]=par[i-1][par[i-1][j]];
	dfs(0);
	ll ans = 0;
	for(int d=0; d<=n; ++d){
		auto& lst = dlst[d];
		int ln = lst.size();
		if(!ln) continue;
		
		dn=0;
		for(int i=0; i+1 < ln; ++i) deep[dn++] = lca(lst[i], lst[i+1]);
		sort(deep, deep+dn, [&](const int& a, const int& b){ return dep[a]>dep[b]; });
		dn=unique(deep, deep+dn)-deep;
		
		set<pp> S;
		for(int x:lst) aru[x]=1, nai[x]=1, S.emplace(tin[x], x);
		
		for(int di=0; di<dn; ++di){
			int x = deep[di];
			int l = tin[x], r = tou[x];
			
			ll all_way = 1;
			ll prod_nai = 1;
			ll sum_arini = 0;
			
			while(true){
				auto it = S.lower_bound(pp{l, 0});
				if(it == S.end() || it->first > r) break;
				ll p=it->second, A=aru[p], N=nai[p];
				(all_way *= A+N) %= M;
				(prod_nai *= N) %= M;
				(sum_arini += A*Pow(N, M-2)) %= M;
				S.erase(it);
			}
			S.emplace(tin[x], x);
			
			aru[x] = prod_nai * sum_arini % M;
			nai[x] = (all_way + M - aru[x]) % M;
		}
		
		(ans += aru[S.begin()->second] * Pow(2, n+1-ln)) %= M;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 53376
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>

typedef long long ll;
typedef unsigned long long ull;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()ss		
#define debug system("pause")				//デバッグ用

int saiki(string, int, int);

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

	string s;
    cin>>s;
    s[3]='8';
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

ll mod_pow(ll a, ll n, ll m = mod) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
const int max_n = 10000;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

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


void solve() {
	string n; cin >> n;
	for (char c : n) {
		if (c == '7') {
			cout << "Yes\n"; return;
		}
	}
	cout << "No\n";
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init_f();
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	stop
		return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 5;

int main() {
  int n;
  cin >> n;
  vector<P> list(n);
  vector<int> keys(n);
  for (int i = 0; i < n; i++) {
    cin >> list[i].first >> list[i].second;
    keys[i] = i;
  }

  double sum = 0;
  int cnt = 0;
  do {
    for (int i = 0; i < n - 1; i++) {
      int x = (list[keys[i]].first - list[keys[i + 1]].first);
      int y = (list[keys[i]].second - list[keys[i + 1]].second);
      sum += sqrt(x * x + y * y);
    }
    cnt++;
  } while (next_permutation(keys.begin(), keys.end()));
  double ans = (double) (sum / cnt);
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    
    while(n > 1000){
      n = n - 1000;
  }
    int ans = 1000 - n;
    System.out.println(ans);
  }
}

Measured memory_bytes: 35840
# これはエスパーですがMが素数ならNが何であってもできなさそう？未証明
# で 合成数のみっぽいので定石的に素因数分解すると
# 各項に因数をどれだけ割り振れるかみたいになる？
# -> サンプル1をみるとならなそう
# 最大公約数をgcdとすると、a*gcd*(N-1)+b*gcd = M となるのが都合よさそう こうなると右辺もgcdで割れるのでやはり約数のどれかになりそう
n, m = map(int, input().split())


def make_divisors(n):
    lower_divisors = []
    upper_divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)

    upper_divisors.reverse()
    return lower_divisors + upper_divisors


if m % n == 0:
    print(m // n)
    exit()
else:
    x = m // n
    divisors = make_divisors(m)[::-1]
    for d in divisors:
        if d <= x:
            print(d)
            exit()

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

//debug: f[0] process nearly equall f[j] process
//Ai+..Aj = sum[i]-sum[j]
ll N;
int A[210000];

void solve() {
	ll i,j,k,l,r,x,y; string s;
	
	cin>>N;
    FOR(i,N){
        ll input;
        cin>>A[i];
    }
    ll sum[N+1];
    ll sumxor[N+1];
    sum[0]=0;
    FOR(i,N)
        sum[i+1]=sum[i]+A[i];
    sumxor[0]=0;
    FOR(i,N)
        sumxor[i+1]=(sumxor[i]^A[i]);
    ll f[N];
    ZERO(f);
    ll next =0; 
    /*FOR(i,N){
        if(sumxor[i+1]==sum[i+1]){
            f[0] += 1;
        }
        else{
            next=i;
            break;
        }
    }*/
    FOR(j,N){
        //cout<<f[j];
        if(j>0) f[j]=f[j-1]-1;
        else f[j] = 0;

        for(i=next;i<N;i++){
            ll sum1 = sum[i+1]-sum[j];
            ll sumxor1 = (sumxor[i+1]^sumxor[j]);
            //cout<<"j+1:"<<j+1<<"i:"<<i<<"sum:"<<sum1<<"xor:"<<sumxor1<<endl;

            if(sum1 == sumxor1){
                f[j] += 1;
                if(i==N-1){
                    next = N;
                }
            }else{
                next=i;
                break;
            }
        }
    }
    
    ll ret=0;
    FOR(i,N){
        //cout<<f[i]<<endl;
        ret += f[i];
    }
    cout<<ret<<endl;

}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

Measured memory_bytes: 5760
/**
 *  author: mahfuzz
 *  created: 01.05.2020
**/
 
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;
 
int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
    string a, b; cin >> a >> b;
    
    int x = stoi(a+b);
    int d = sqrt(x);
    
    if(d * d == x)
        cout << "Yes\n";
    else
        cout << "No\n";
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 100055
#define ll long long
ll v[N],w[N],dp[N];
int main() {
    for(auto &i : dp)
        i = 1e18;
    int n,W;
    scanf("%d%d",&n,&W);
    for(int i=1; i<=n; ++i)
        scanf("%lld %lld",&w[i],&v[i]);
    ll ans = 0;
    dp[0] = 0;
    for(int i=1; i<=n; ++i) {
//        dp[v[i]] = min(dp[v[i]] , w[i]);
        for(int j = N - v[i] - 1 ; j>=0;--j){
            dp[j+v[i]] = min( dp[j+v[i]] , dp[j] + w[i] );
            if( dp[j+v[i]] <= W )
                ans = max(ans , j+v[i]);
        }
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <unistd.h>
#define ll long long
#define inf 1000000007
#define inf16 0x3f3f3f3f
#define INF 1000000000000000007LL
#define VI vector<int>
#define VPII vector<pair<int, int> >
#define VLL vector<ll>
#define PII pair<int, int>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
using namespace std;

#define int long long
const int N = 1e5+7;
const int MOD = 1e9+7;

int n, m, s, t, curr;

VPII G[N];

VI DAG[N];

int dist[2][N];

struct comp
{
	bool operator()(int a, int b)
	{
		return mp(dist[curr][a], a)<mp(dist[curr][b], b);
	}
};

set<int, comp> S;

queue<int> Q;

int deg[N];

VI topo;

int dp[N];
int dpt[N];

void dijkstra(int s)
{
	for(int i = 1; i <= n; ++i)
	{
		dist[curr][i] = INF;
	}

	dist[curr][s] = 0;
	S.insert(s);

	while(!S.empty())
	{
		int v = *S.begin();
		S.erase(S.begin());

		for(auto it:G[v])
		{
			if(dist[curr][it.st]>dist[curr][v]+it.nd)
			{
				S.erase(it.st);
				dist[curr][it.st] = dist[curr][v]+it.nd;
				S.insert(it.st);
			}
		}
	}
}

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	cin >> n >> m >> s >> t;

	while(m--)
	{
		int a, b, c;
		cin >> a >> b >> c;
		G[a].eb(b, c);
		G[b].eb(a, c);
	}

	curr = 0;
	dijkstra(s);
	curr = 1;
	dijkstra(t);

	for(int i = 1; i <= n; ++i)
	{
		for(auto it:G[i])
		{
			if(dist[0][i]+it.nd+dist[1][it.st]==dist[0][t])
			{
				DAG[i].pb(it.st);
				++deg[it.st];
			}
		}
	}

	for(int i = 1; i <= n; ++i)
	{
		if(!deg[i])
			Q.push(i);
	}

	while(!Q.empty())
	{
		int v = Q.front();
		Q.pop();
		topo.pb(v);

		for(auto it:DAG[v])
		{
			if(--deg[it]==0)
				Q.push(it);
		}
	}

	dp[s] = 1;

	for(auto v:topo)
	{	
		for(auto it:DAG[v])
		{
			dp[it] += dp[v];
			dp[it] %= MOD;
		}
	}

	reverse(ALL(topo));

	dpt[t] = 1;

	for(auto v:topo)
	{	
		for(auto it:DAG[v])
		{
			dpt[v] += dpt[it];
			dpt[v] %= MOD;
		}
	}

	int ans = dp[t]*dp[t]%MOD;

	for(int i = 1; i <= n; ++i)
	{
		if(dist[0][i]+dist[1][i]==dist[0][t] && dist[0][i]==dist[1][i])
		{
			ans -= dp[i]*dp[i]%MOD*dpt[i]%MOD*dpt[i]%MOD;
			ans %= MOD;
		}
	}

	for(int v = 1; v <= n; ++v)
	{
		for(auto u:G[v])
		{
			if(dist[0][v]+u.nd+dist[1][u.st]==dist[0][t] && dist[0][v]+u.nd>dist[1][u.st] && dist[1][u.st]+u.nd>dist[0][v])
			{
				ans -= dp[v]*dp[v]%MOD*dpt[u.st]%MOD*dpt[u.st]%MOD;
				ans %= MOD;
			}
		}
	}

	ans %= MOD;
	ans += MOD;
	ans %= MOD;

	cout << ans << endl;
}

Measured memory_bytes: 22772
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;

int n, k;
string s;



int main() {
	cin >> n>>k>>s;
	int num = 0;
	vector<int> vec(n+2, 0);
	num = 2 * k + 1;
	int val;
	if (s[0]=='0')
	{
		val = 0;
	}
	else {
		val = 1;
	}
	int temp = s[0];
	int iter = 0;
	vec[iter]++;
	for (int i = 1; i < n; i++)
	{
		if (s[i]==s[i-1])
		{
			vec[iter]++;
		}
		else {
			iter++;
			vec[iter]++;
		}
	}
	vector<int> nvec(n + 3, 0);
	for (int i = 1; i <= iter+1; i++)
	{
		nvec[i] = nvec[i - 1] + vec[i-1];
	}
	int a = 0;
	if (num%2==0)
	{
		for (int i = 0; i <= iter + 1 ; i++)
		{
			a = max(a, nvec[i] - nvec[max(0,i-num)]);
		}
	}
	else {
		for (int i = 0; i <=iter+1; i++)
		{
			if (val==1&&(int)( pow(-1,i) + 1)/2|| val == 0 && (int)(pow(-1, i) + 1) / 2==0)
			{
				a = max(nvec[i] - nvec[max(0, i - num+1)],a);
			}
			else {
				a = max(nvec[i] - nvec[max(0, i - num)], a);
			}
		}
	}
	cout << a << endl;
}

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

int main(){
  int64_t N,K,sum = 0;
  cin >> N >> K;
  vector<int> H(N);
  for (int i= 0; i < N; i++){
    cin >> H.at(i);
  }
  if (N > K){
    sort(H.begin(),H.end());
    for (int i = 0; i < N - K; i++) sum += H.at(i);
  }
  cout << sum << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n)cin >> a[i];

    int now=1;
    rep(i,n){
        if(a[i]==now) now++;
    }

    if (now==1) cout << -1 << endl;
    else cout << n-now+1 << endl;


    return 0;
}

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


Measured memory_bytes: 1024
n = int(input())
arr = [[0 for _ in range(10)] for _ in range(10)]

for i in range(1,n+1):
    bot=i%10
    if bot==0:
        continue
    top=i
    while top>=10:
        top=top//10
    arr[top][bot]+=1

ans=0
for i in range(10):
    for j in range(10):
        ans+=arr[i][j]*arr[j][i]
print(ans)

Measured memory_bytes: 40812
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,m,idx,tmp,md;
  cin >> n >> m;
  int a[n],b[n],c[m],d[m];
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
  }
  for(int j=0;j<m;j++){
    cin >> c[j] >> d[j];
  }
  for(int i=0;i<n;i++){
    md = 10000000000;
    idx = 0;
    for(int j=0;j<m;j++){
      tmp = abs(c[j]-a[i])+abs(d[j]-b[i]);
      if(tmp<md){
        md = tmp;
        idx = j;
      }
    }
    cout << idx+1<<endl;
  }
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,cnt;
string s;

signed main() {
    cin >> n >> s;
    rep(i,n) {
        if (s[i] == 'R') cnt++;
    }
    if (cnt > n-cnt) cout << "Yes" << endl;
    else cout << "No" << endl;
}




Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<queue>
using namespace std;
int d[6];
int m[300];
int bfs[300];
int main(){
	int a;
	scanf("%d",&a);
	for(int i=0;i<6;i++)scanf("%d",d+i);
	int s,g;
	scanf("%d%d",&s,&g);
	s--;g--;
	for(int i=0;i<a;i++)scanf("%d",m+i);
	int at=s;
	while(1){
		int t;
		scanf("%d",&t);
		t--;
		t=d[t];
		for(int i=0;i<a;i++)bfs[i]=-1;
		bfs[at]=0;
		queue<int>Q;
		Q.push(at);
		while(Q.size()){
			int now=Q.front();
		//	printf("%d\n",now);
			Q.pop();
			for(int i=0;i<6;i++){
				if(0<=now-d[i]){
					if(bfs[now-d[i]+m[now-d[i]]]==-1){
						bfs[now-d[i]+m[now-d[i]]]=bfs[now]+1;
						Q.push(now-d[i]+m[now-d[i]]);
					}
				}
				if(now+d[i]<a){
					if(bfs[now+d[i]+m[now+d[i]]]==-1){
						bfs[now+d[i]+m[now+d[i]]]=bfs[now]+1;
						Q.push(now+d[i]+m[now+d[i]]);
					}
				}
			}
		}
	//	printf("%d ",bfs[g]);
		int V=0;
		int K=0;
		if(bfs[g]==-1)V=99999999;
		else V=bfs[g];
		if(at+t<a){
			for(int i=0;i<a;i++)bfs[i]=-1;
			bfs[at+t+m[at+t]]=0;
			Q.push(at+t+m[at+t]);
			while(Q.size()){
				int now=Q.front();
				Q.pop();
				for(int i=0;i<6;i++){
					if(0<=now-d[i]){
						if(!~bfs[now-d[i]+m[now-d[i]]]){
							bfs[now-d[i]+m[now-d[i]]]=bfs[now]+1;
							Q.push(now-d[i]+m[now-d[i]]);
						}
					}
					if(now+d[i]<a){
						if(!~bfs[now+d[i]+m[now+d[i]]]){
							bfs[now+d[i]+m[now+d[i]]]=bfs[now]+1;
							Q.push(now+d[i]+m[now+d[i]]);
						}
					}
				}
			}
	//	printf("%d ",bfs[g]);
			if(~bfs[g]&&V>bfs[g]){
				K=1;
				V=bfs[g];
			}
		}
		if(at-t>=0){
			for(int i=0;i<a;i++)bfs[i]=-1;
			bfs[at-t+m[at-t]]=0;
			Q.push(at-t+m[at-t]);
			while(Q.size()){
				int now=Q.front();
				Q.pop();
				for(int i=0;i<6;i++){
					if(0<=now-d[i]){
						if(!~bfs[now-d[i]+m[now-d[i]]]){
							bfs[now-d[i]+m[now-d[i]]]=bfs[now]+1;
							Q.push(now-d[i]+m[now-d[i]]);
						}
					}
					if(now+d[i]<a){
						if(!~bfs[now+d[i]+m[now+d[i]]]){
							bfs[now+d[i]+m[now+d[i]]]=bfs[now]+1;
							Q.push(now+d[i]+m[now+d[i]]);
						}
					}
				}
			}
	//	printf("%d ",bfs[g]);
			if(~bfs[g]&&V>bfs[g]){
				K=-1;
				V=bfs[g];
			}
		}
	//	printf("\n");
		printf("%d\n",K);
		fflush(stdout);
		at=at+t*K+(K?m[at+t*K]:0);
		if(at==g)return 0;
	}
}

Measured memory_bytes: 1304
n = gets.to_i
a = gets.chomp.split(' ').map(&:to_i)

m = 0
tmp = 0
(0...(a.size-1)).each do |i|
  if a[i] >= a[i+1]
    tmp += 1
  else
    tmp = 0
  end
  m = tmp if m < tmp
end

puts m

Measured memory_bytes: 9732
#include<bits/stdc++.h>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iostream>
#define ios   ios_base::sync_with_stdio(false);  cin.tie(0);    cout.tie(0);
typedef long long int ll;
typedef long double  ld;
using namespace std;
const int M=1e9+7;
ll bm[300005],bM[300005],cm[300005],cM[300005];
int main() {
    ios;
    ll n,k;cin>>n>>k;
    ld a[n];
   for(ll i=0;i<n;++i)
   {
        cin>>a[i];
         a[i]=(a[i]+1)/2;
   //cout<<a[i]<<" ";
   }
   
   ld sum=0,ans=0;
   for(ll i=0;i<n;++i)
   {
       if(i<k)
       sum+=a[i];
       else
       {
          ans=max(sum,ans);
          sum=sum-a[i-k]+a[i];
       }
   }
   ans=max(sum,ans);
  cout<<fixed;
  cout<<setprecision(6)<<ans;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define ll long long
#define endl "\n"
#define vi vector<int>
#define vl vector<ll>
#define all(v) (v).begin(),(v).end()
#define mst(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define mt make_tuple
#define eb emplace_back
using namespace std;
const int N=1e5+5;
int n,m,ans;
vi v[N];
bool vis[N];
int h[N];
void dfs(int s){
    vis[s]=1;
    int mx=0;
    for(int j:v[s]){
        mx=max(mx,h[j]);
        if(!vis[j])
            dfs(j);
    }
    if(mx<h[s]) ans++;
}
void solve(){
    mst(vis,0);
    cin>>n>>m;
    for(int i=0;i<n;i++)
        cin>>h[i];
    for(int i=0;i<m;i++){
        int l,r;
        cin>>l>>r;
        v[l-1].pb(r-1);
        v[r-1].pb(l-1);
    }
    ans=0;
    for(int i=0;i<n;i++){
        if(!vis[i])
            dfs(i);
    }
    cout<<ans<<endl;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll t,p;
    t=1;
    //cin>>t;
    for(p=1;p<=t;p++){
        solve();
    }
    return 0;
}


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

int main(){
  int a,h,m,s,sum,r;
  char c;
  vector<pair<int,int> > vp;
  pair<int,int> p;
  while(1){
    cin>>a;
    vp.clear();
    if(a==0)break;
    for(int i=0;i<a;i++){
      cin>>h>>c>>m>>c>>s;
      h=h*3600+m*60+s;
      p.first=h;p.second=1;
      vp.push_back(p);
      cin>>h>>c>>m>>c>>s;
      h=h*3600+m*60+s;
      p.first=h;p.second=-1;
      vp.push_back(p);
    }
    sort(vp.begin(),vp.end());
    r=0;
    sum=0;
    for(int i=0;i<vp.size();i++){
      r+=vp[i].second;
      if(r>sum)sum=r;
    }
    cout<<sum<<endl;
  }
  return 0;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n; cin>>n;
    vector<int> p(n);
    rep(i,n) cin>>p[i];
    int a=0, b=0;
    sort(etob(p));
    rep(i,n){
        if(i%2==0){
            a+=p[i];
        }else{
            b+=p[i];
        }
    }
    cout<<a-b<<endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int main()
{
    int n; cin >> n;
    vector<string> a(n);
    map<string, int> mp;
    rep(i,n) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }

    ll ans = 0;
    for (auto& x : mp) {
        int s = x.second;
        ans += (ll)s*(s-1)/2;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11904
from itertools import combinations, product


def gcd(a, b):
    if a < b:
        a, b = b, a
    while b != 0:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)


def get(fmt):
    ps = input().split()
    r = []
    for p, t in zip(ps, fmt):
        if t == "i":
            r.append(int(p))
        if t == "f":
            r.append(float(p))
        if t == "s":
            r.append(p)
    if len(r) == 1:
        r = r[0]
    return r

def put(*args, **kwargs):
    print(*args, **kwargs)


def rep(n, f, *args, **kwargs):
    return [f(*args, **kwargs) for _ in range(n)]
    
def rep_im(n, v):
    return rep(n, lambda: v)
    
YES_NO = ["NO", "YES"]


v = sorted(get("iii"))
put(YES_NO[v == [5, 5, 7]])


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

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 210000

int C[MAX];
int temp[MAX];

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N;
	int ans = 0;
	
	cin>>N;
	
	for(int i = 0; i < N; i++){
		cin>>C[i];
	}
	
	for(int i = 0, b = 0; i < N; i++){
		if(i && C[i] == C[i-1]) continue;
		ans += temp[C[i]];
		temp[C[i]] += b;
		temp[C[i]]++;
		
		temp[C[i]] %= MOD;
		ans %= MOD;
		b = ans;
	}
	
	cout<<(ans+1)%MOD<<endl;
	
	return 0;
}

Measured memory_bytes: 3328
import functools
import fractions

def gcd_list(numbers):
    return functools.reduce(fractions.gcd, numbers)


N = int(input())
a_list = [int(i) for i in input().split(' ')]

gcd = gcd_list(a_list)
div = sum(map(lambda x: (gcd / x), a_list))
print (gcd / div )



Measured memory_bytes: 5128