akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
bool chk[1002];
long long a[1002],k=0;
void seive()
{
    int i,j;
    for(i=3;i<=1000;i+=2) chk[i]=true;
    for(i=3;i*i<=1000;i+=2)
    {
        if(chk[i]==true)
        {
            for(j=i*i;j<=1000;j+=i+i) chk[j]=false;
        }
    }
    a[k++]=2;
    for(i=3;i<=1000;i+=2) if(chk[i]==true) a[k++]=i;
   // for(i=0;i<10;i++) cout<<a[i]<<" "; cout<<endl;
}
int main()
{
    seive();
    long long i,j,p,q,n,pp,fact[1002];
    while(cin>>n)
    {
        pp=1;
        memset(fact,0,sizeof(fact));
        for(i=2;i<=n;i++)
        {
            p = i;
            for(j=0;a[j]*a[j]<=p;j++)
            {
                while(p%a[j]==0)
                {
                    fact[a[j]]++;
                    p/=a[j];
                }
            }
            if(p!=1) fact[p]++;
        }
        for(i=2;i<=n;i++) pp=(pp*(fact[i]+1))%mod;
        cout<<pp<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;} 
int main(void)
{
  int k,n[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  scanf("%d",&k);
  
  printf("%d",n[k-1]);
}

Measured memory_bytes: 128
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};



int main() {
    int N, H;
    scanf("%d%d", &N, &H);
    vector<int> A, B;
    int amax = 0;
    for(int i = 0; i < N; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        amax = max(amax, a);
        A.push_back(a);
        B.push_back(b);
    }

    priority_queue<int> P;
    for(int i = 0; i < N; i++) {
        if (B[i] > amax) {
            P.push(B[i]);
        }
    }

    long long sum = 0;
    int now = 0;
    bool flag = false;
    while(!P.empty()) {
        sum += P.top();
        P.pop();
        now++;
        if (H <= sum) {
            flag = true;
            break;
        }
    }
    if (flag) {
        cout << now << endl;
        return 0;
    }

    cout << (((H - 1) - sum) / amax + 1) + now << endl;

    return 0;
}

Measured memory_bytes: 1780
import numpy as np
N= int(input())
s_list = []
p_list = []
for _ in range(N):
    s, p = input().split()
    s_list.append(s)
    p_list.append(int(p))

s_unique = list(set(s_list))
s_unique.sort()
for s in s_unique:
    ps = []
    indexs = [i for i,x in enumerate(s_list) if x==s]
    for index in indexs:
        ps.append(p_list[index])
    ps_sorted_index = np.argsort(ps)[::-1]
    for i in ps_sorted_index:
        print(indexs[i]+1)

Measured memory_bytes: 21536
#include"bits/stdc++.h"
using namespace std;

int main(){

  long int N;
  cin >> N;

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

  vector <int> indices(N);
  iota(indices.begin(), indices.end(), 0);

  sort(indices.begin(), indices.end(), [&A](int x, int y){return A[x] < A[y];});
  
  for (int i=0; i<N; i++) {
    cout << indices[i]+1 << ' ';
  }

  cout << endl;

  return 0;

}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*
    s.find_by_order(k) ---> returns iterator to the element at index(from 0) k
    s.order_of_key(val) ---> number of elements that are strictly smaller than the given value
*/
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int tc; cin >> tc; cin.ignore(); while(tc--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}
 
int main() {
	fast();
 
    /*NA – JEONG – MO – SA – JI – MI – DA – CHAE – TZU*/
    
    inp(n);
    cout << n - (n/2) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define gcd(x,y) __gcd(x,y)
#define PI 3.14159265
#define endl "\n"
#define count_ones __builtin_popcountl
#define piii pair<int,pair<int,int>>
const int N=1e5+20,MOD=(int)(1e9)+7;
const int oo = 0x3f3f3f3f;
typedef long long ll;
using namespace std;
ll modPower(ll x, ll y,ll p){
    ll res=1;
    x%=p;
    while(y>0){
        if(y&1) res=(res*x)%p;
        y=y>>1; 
        x=(x*x)%p;
    }
    return res;
}
inline void boost(){
	ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
}
ll GCD(ll a, ll b){
	if(a==0)return b;
	return GCD(b%a,a);
}
/* -------------------------------------- */

/* -------------------------------------- */

int main() {
	boost();
	int a;string s;
	cin>>a>>s;
	if(a>=3200) cout<<s;
	else cout<<"red";
}

Measured memory_bytes: 256
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

int used[10];
int a[10][10];
int ans,n;

void search(int x)
{
  int i,b1;
  b1=0;
  for (i=0;i<n;i++)
    if (used[i]==0) b1=1;
  if (b1==0)
  {
    ans++;
    return;
  }
  for (i=0;i<n;i++)
    if ((used[i]==0)&&(a[x][i]==1))
    {
      used[i]=1;
      search(i);
      used[i]=0;
    }
}

int main()
{
  int i,m,x,y;
  scanf("%d%d",&n,&m);
  memset(a,0,sizeof(a));
  for (i=0;i<m;i++)
  {
    scanf("%d%d",&x,&y);
    x--;y--;
    a[x][y]=1;
    a[y][x]=1;
  }
  memset(used,0,sizeof(used));
  used[0]=1;
  ans=0;
  search(0);
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N;
    cin >> N;
    vector<long> h(N);
    for(size_t i=0;i<N; i++)
    {
        cin >> h[i];
    }
    long prev=0;
    long counter=0;
    for(size_t i=0;i<N; i++)
    {
        if(h[i] > prev)
        {
            counter += h[i] - prev;
        }
        prev = h[i];
    }
    cout << counter << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 256
#[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 ) * } } ; }
#[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" ) } ; }

fn main() {
    input! {
        h: usize, w: usize,
        s: [chars; h]
    }

    for y in 0..h {
        for x in 0..w {
            let mut cnt = 0;
            for (ny, nx) in adjacent8(y, x, h, w) {
                if s[ny][nx] == '#' {
                    cnt += 1;
                }
            }
            if s[y][x] == '.' {
                print!("{}", cnt);
            } else {
                print!("#");
            }
        }
        println!("");
    }
}

#[doc = " https://github.com/hatoo/competitive-rust-snippets"]
#[allow(dead_code)]
fn adjacent8(y: usize, x: usize, h: usize, w: usize) -> Box<Iterator<Item = (usize, usize)>> {
    static DYDX: [(isize, isize); 8] = [
        (-1, 0),
        (1, 0),
        (0, -1),
        (0, 1),
        (-1, -1),
        (-1, 1),
        (1, -1),
        (1, 1),
    ];
    Box::new(DYDX.iter().filter_map(move |&(dy, dx)| {
        let ny = y as isize + dy;
        let nx = x as isize + dx;
        if nx >= 0 && nx < w as isize && ny >= 0 && ny < h as isize {
            Some((ny as usize, nx as usize))
        } else {
            None
        }
    }))
}

Measured memory_bytes: 4352
import sys
a,b = list(map(int, input().split()))

if a<=0 and b>= 0:
  print("Zero")
  sys.exit()
elif a < 0 and b < 0:
  if (-(a-b)+1)%2 == 0:
    print("Positive")
    sys.exit()
  else:
    print("Negative")
    sys.exit()
elif a==0 or b==0:
  print("Zero")
  sys.exit()
elif a>0 and b>0:
  print("Positive")
  sys.exit()
else:
  if (-a)%2 == 0:
    print("Positive")
  else:
    print("Negative")

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

int main() {
  int N;
  cin >> N;
  
  map<string,int> mapp;
  string str;
  for (int i = 0; i < N; i++) {
    cin >> str;
    mapp[str]++;
  }
  
  int M;
  cin >> M;
  for (int i = 0; i < M; i++) {
    cin >> str;
    mapp[str]--;
  }

  int ans = 0;
  for( auto i = mapp.begin(); i != mapp.end() ; ++i ) {
    ans = max(ans,i->second);
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=4005,mod=998244353;
int n,k,C[N][N],pw2[N];
int c(int n,int m){
    if (m>n||m<0)
        return 0;
    return C[n][m];
}
int calc(int m,int n){return c(n+m-1,m-1);}
int Get(int v,int n,int k){
    int ans=0;
    int lim=max(0,v/2-max(0,v-1-k));
    for (int i=0;i<=lim;i++)
        ans=(1LL*pw2[i]*C[lim][i]%mod*calc(k-lim*2+i,n-i)+ans)%mod;
    return ans;
}
int main(){
    pw2[0]=1;
    for (int i=1;i<N;i++)
        pw2[i]=pw2[i-1]*2%mod;
    for (int i=0;i<N;i++)
        C[i][0]=C[i][i]=1;
    for (int i=1;i<N;i++)
        for (int j=1;j<i;j++)
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
    scanf("%d%d",&k,&n);
    for (int i=2;i<=2*k;i++)
        if (i&1)
            printf("%d\n",Get(i,n,k));
        else
            printf("%d\n",(Get(i-1,n,k-1)+Get(i-1,n-1,k-1))%mod);
    return 0;
}


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

int main (){
    string S;
    cin >> S;
    if(S=="Sunny"){
        S="Cloudy";
    }else if(S=="Cloudy"){
        S="Rainy";
    }else{
        S="Sunny";
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input()) 
x=list(map(int, input().split()))

box = []
d= 0
for i in range(min(x),max(x)+1):
    d = map(lambda y: (y-i)**2, x)
    d_t = sum(d)
    box.append(d_t)
print(min(box))
    
    

Measured memory_bytes: 2940
n, m = map(int, input().split())

x = []
y = []
z = []

for i in range(n):
    X, Y, Z = map(int, input().split())
    x.append(X)
    y.append(Y)
    z.append(Z)

sign = [1, -1]

ans = []

for j in sign:
    for k in sign:
        for l in sign:
            a = []
            for i in range(n):
                a.append(x[i] * j + y[i] * k + z[i] * l)
            a.sort(reverse=True)
            ans.append(sum(a[:m]))
print(max(ans))


Measured memory_bytes: 41328
// url: http://abc075.contest.atcoder.jp/tasks/abc075_b

import std.algorithm, std.conv, std.range, std.stdio, std.string;

alias point = Point!int;
alias grid = Grid!(char, int);

void main()
{
  auto rd = readln.split.to!(int[]), h = rd[0], w = rd[1];
  auto g = grid(h, w);

  foreach (i; 0..h) {
    auto s = readln.chomp;
    foreach (j; 0..w) {
      g[i][j] = s[j];
    }
  }

  foreach (i; 0..h) {
    foreach (j; 0..w) {
      auto p = point(j, i);
      if (g[p] == '.')
        g[p] = cast(char)('0' + g.sibPoints8(p).count!(np => g[np] == '#'));
    }
  }

  foreach (i; 0..h)
    writeln(g[i]);
}

struct Point(T)
{
  T x, y;
  pure auto opBinary(string op: "+")(Point!T rhs) const { return Point!T(x + rhs.x, y + rhs.y); }
  pure auto opBinary(string op: "-")(Point!T rhs) const { return Point!T(x - rhs.x, y - rhs.y); }
  pure auto opBinary(string op: "*")(Point!T rhs) const { return x * rhs.x + y * rhs.y; }
  pure auto opBinary(string op: "*")(T a) const { return Point!T(x * a, y * a); }
  pure auto opBinary(string op: "/")(T a) const { return Point!T(x / a, y / a); }
  pure auto hypot2() const { return x ^^ 2 + y ^^ 2; }
}

struct Grid(T, U)
{
  import std.algorithm, std.conv, std.range, std.traits, std.typecons;

  const sibs4 = [Point!U(-1, 0), Point!U(0, -1), Point!U(1, 0), Point!U(0, 1)];
  const sibs8 = [Point!U(-1, 0), Point!U(-1, -1), Point!U(0, -1), Point!U(1, -1),
                 Point!U(1, 0), Point!U(1, 1), Point!U(0, 1), Point!U(-1, 1)];

  T[][] m;
  const size_t rows, cols;

  mixin Proxy!m;

  this(size_t r, size_t c) { rows = r; cols = c; m = new T[][](rows, cols); }
  this(T[][] s) { rows = s.length; cols = s[0].length; m = s; }

  pure auto dup() const { return Grid(m.map!(r => r.dup).array); }
  ref pure auto opIndex(Point!U p) { return m[p.y][p.x]; }
  ref pure auto opIndex(size_t y) { return m[y]; }
  ref pure auto opIndex(size_t y, size_t x) const { return m[y][x]; }
  static if (isAssignable!T) {
    auto opIndexAssign(T v, Point!U p) { return m[p.y][p.x] = v; }
    auto opIndexAssign(T v, size_t y, size_t x) { return m[y][x] = v; }
    auto opIndexOpAssign(string op, V)(V v, Point!U p) { return mixin("m[p.y][p.x] " ~ op ~ "= v"); }
    auto opIndexOpAssign(string op, V)(V v, size_t y, size_t x) { return mixin("m[y][x] " ~ op ~ "= v"); }
  }
  pure auto validPoint(Point!U p) { return p.x >= 0 && p.x < cols && p.y >= 0 && p.y < rows; }
  pure auto points() const { return rows.to!U.iota.map!(y => cols.to!U.iota.map!(x => Point!U(x, y))).joiner; }
  pure auto sibPoints4(Point!U p) { return sibs4.map!(s => p + s).filter!(p => validPoint(p)); }
  pure auto sibPoints8(Point!U p) { return sibs8.map!(s => p + s).filter!(p => validPoint(p)); }
}


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

using namespace std;
int main() {

	int N, L;
	cin >> N >> L;

	int sum = 0;
	for (int i = 0; i < N; i++) {
		sum += L + i;
	}
	int sum_minus[110] = { 0 };
	int ans = 1000000;
	int k = 0;

	for (int i = 0; i < N; i++) {
		sum_minus[i] = sum - (L + i);
		if (ans > abs(sum - sum_minus[i])) {
			ans = abs(sum - sum_minus[i]);
				k = i;
		}

	}

	cout << sum_minus[k] << endl;




	return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
import std.conv;

void main() {
	auto N = r;
	auto ip = readln.split.to!(int[]), D = ip[0], X = ip[1];
	int count;
	foreach(_; 0..N) {
		count += ceil(D / r.to!real).to!int;
		//count++;
	}
	(count + X).writeln;
}

int r() {
	return readln.chomp.to!int;
}

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



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

	int N; cin >> N;
	int u, k, v;
	bool ad[110][110];
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			ad[i][j] = 0;
		}
	}
	for (int i = 0; i < N; i++) {
		cin >> u >> k;
		for (int i = 0; i < k; i++) {
			cin >> v;
			ad[u-1][v-1] = true;
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (ad[i][j]==true) cout << 1;
			else cout << 0;
			if (j == N - 1) {
				cout << endl;
			}
			else cout << " ";
		}
	}
}


Measured memory_bytes: 3176
class UnionFind(object):
    def __init__(self, n):
        self.parent={i:i for i in range(1,n+1)}
        self.size={i:1 for i in range(1,n+1)}
    def find(self, a):
        if self.parent[a]!=a:
            self.parent[a]=self.find(self.parent[a])
        return self.parent[a]
    def getsize(self, a):
        return self.size[self.find(a)]
    def unite(self, a, b):
        a=self.find(a)
        b=self.find(b)
        if a==b:return
        if self.size[a]>self.size[b]:
            self.size[a]+=self.size[b]
            self.parent[b]=a
        else:
            self.size[b]+=self.size[a]
            self.parent[a]=b
    def isunited(self, a, b):
        return self.find(a)==self.find(b)


N = int(input())
l = []
q = []
for i in range(N):
    x, y = map(int, input().split())
    l.append((x, y, i+1))

l.sort()
for i in range(N-1):
    x1, y1, s = l[i]
    x2, y2, t = l[i+1]
    q.append((abs(x1-x2), s, t))

l.sort(key=lambda x:x[1])
for i in range(N-1):
    x1, y1, s = l[i]
    x2, y2, t = l[i+1]
    q.append((abs(y1-y2), s, t))

uft = UnionFind(N)
ans = 0
q.sort()

for cost, s, t in q:
    if not uft.isunited(s, t):
        ans += cost
        uft.unite(s, t)

print(ans)


Measured memory_bytes: 153220
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int x[n], y[n];
    for (int i = 0; i < n; i++)
        cin >> x[i];
    for (int i = 0; i < n; i++)
        cin >> y[i];
    for (int p = 1; p <= 3; p++)
    {
        double sum = 0.0;
        for (int j = 0; j < n; j++)
        {
            sum += pow(abs(x[j]-y[j]), p);
        }
        printf("%lf\n", pow(sum, 1.0/p));
    }
    double d = 0.0;
    for (int i = 0; i < n; i++)
    {
        d = d < fabs(x[i]-y[i])?fabs(x[i]-y[i]):d;
    }
    printf("%lf\n", d);
    return 0;
}


Measured memory_bytes: 3300
#include <iostream>
#include <queue>
#define P pair<int,int>
#define PP pair<int,P>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
#define int long long

int ox[1005],oy[1005],oz[1005];
int x[1005],y[1005],z[1005];
int dp[1005][1005];


signed main() {
int n,m;cin>>n>>m;
rep(i,n) cin>>ox[i]>>oy[i]>>oz[i];

int ans = 0;

rep(loop,(1<<3))
{
    rep(i,n)
    {
        x[i] = (((loop>>0)&1)?ox[i]:-ox[i]);
        y[i] = (((loop>>1)&1)?oy[i]:-oy[i]);
        z[i] = (((loop>>2)&1)?oz[i]:-oz[i]);
    }
    rep(i,n+1) dp[i][0] = 0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=i && j<=m ;j++)
        {
            if(i==j)  dp[i][j] = dp[i-1][j-1] + x[i-1]+y[i-1]+z[i-1];  
            else dp[i][j] = max(dp[i-1][j-1]+x[i-1]+y[i-1]+z[i-1],dp[i-1][j]);
        }
    }
    ans = max(ans,dp[n][m]);
}
cout << ans << endl;

return 0;
}


Measured memory_bytes: 7424
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main()
{
  int R[MAX], n;

  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> R[i];
  int maxv = -1000000000; // 最大利益
  int minv = R[0];        // 最小値
  for (int i = 1; i < n; i++)
  {
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }
  cout << maxv << endl;
  return 0;
}


Measured memory_bytes: 3892
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
#include<queue>
#include<utility>
#include<tuple>
#include<set>
using namespace std;

int main(void)
{
	int X, Y, Z, K;
	cin >> X >> Y >> Z >> K;

	vector<long long> A(X), B(Y), C(Z);
	for (int i = 0; i < X; i++)
		cin >> A[i];
	for (int i = 0; i < Y; i++)
		cin >> B[i];
	for (int i = 0; i < Z; i++)
		cin >> C[i];

	const long long minf = -1E9;
	A.push_back(minf);
	B.push_back(minf);
	C.push_back(minf);

	sort(A.rbegin(), A.rend());
	sort(B.rbegin(), B.rend());
	sort(C.rbegin(), C.rend());

	set<int> dic;
	priority_queue < pair<long long, tuple<int, int, int>>> task;
	dic.insert(0);
	task.push(make_pair(A[0] + B[0] + C[0], make_tuple(0, 0, 0)));

	vector<long long> abc;
	//while (abc.size() < K) {
	for (int i = 0; i < K; i++) {
		auto p = task.top();
		task.pop();

		abc.push_back(p.first);

		for (int j = 0; j < 3; j++) {
			int a, b, c;
			tie(a, b, c) = p.second;

			if (j == 0)
				a++;
			else if (j == 1)
				b++;
			else
				c++;

			int hash = (a << 20) + (b << 10) + c;
			if (dic.count(hash) == 1)
				continue;

			dic.insert(hash);
			task.push(make_pair(A[a] + B[b] + C[c], make_tuple(a, b, c)));
		}
	}
	
	sort(abc.rbegin(), abc.rend());

	for (int i = 0; i < K; i++) {
		cout << abc[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
constexpr int MOD = 1000000007;
constexpr ll INF = 50000000000000000;
typedef std::pair<int,int> P;
constexpr ll SIZE= 100010;

    ll N,A[2*SIZE];
    ll ans=0;
    bool F[2*SIZE]={};
int main() {
    std::ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N){
        cin>>A[i];
        if((i>0&&A[i]-A[i-1]>1)||A[0]!=0){
            cout<<-1;
            return 0;
        }
    }
    REP(i,N){
        if(A[i]==0||i==0)continue;
        if(A[i]-A[i-1]!=1)ans+=A[i];
        else ans++;

        DEB(ans)
    }
    cout<<ans<<endl;
    return 0;
}


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


struct Pair
{
int i;
string S;
int P;

	bool operator < ( const Pair &X ) const
	{
		return S == X.S ? P > X.P : S < X.S;
	}
};


int main()
{
int i;
int N;
string S;
int P;

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

	cin >> N;
	
	
vector<Pair> R;

	for( i = 1; i <= N; i++ )
	{
		cin >> S;
		cin >> P;

		R.emplace_back( Pair { i, S, P } );
	}

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


	for( i = 0; i < R.size(); i++ )
	{
		cout << R[ i ].i << endl;
	}

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int[] input = new int[2];

		if (N == 2)
		{
			input[0] = int.Parse(Console.ReadLine());
			input[1] = int.Parse(Console.ReadLine());
			Console.WriteLine(input[0] + input[1]);
		}
		else { Console.WriteLine("Hello World"); }
	}
}

Measured memory_bytes: 11092
s=list(input())
d=0
for i in range(len(s)):
  a=i%2
  if a==0:
    if s[i]=="L":
      print("No")
      break
  else:
    if s[i]=="R":
      print("No")
      break
  d=d+1
if d==len(s):
  print("Yes")

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
using namespace std;

#define rep(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define SZ(x) ((int) (x).size())
typedef long long ll;

const int N = 100000 + 5;
vector<pair<int,int>> vp;
struct Node{
	int x, y, id;
}node[N];
bool cmp1(const Node &a, const Node &b) {
	return a.x < b.x;
}
bool cmp2(const Node &a, const Node &b) {
	return a.y < b.y;
}
struct Edge{
	int u, v, dis;
	bool operator < (const Edge &e) const {
		return dis < e.dis;
	}
}G1[N],G2[N];

int f[N];
int find(int u) {
	return u == f[u] ? u : f[u] = find(f[u]);
}
void merge(int u, int v) {
	u = find(u);
	v = find(v);
	f[u] = v;
}
int main(){
	int n, cnt = 0;
	cin >> n;
	rep(i,0,n) {
		int x, y;
		cin >> node[cnt].x >> node[cnt].y;
		node[cnt++].id = i;
	}
	sort(node, node+n, cmp1);

	rep(i,1,n) {
		int dis = abs(node[i].x - node[i-1].x);
		G1[i-1] = Edge{node[i].id, node[i-1].id, dis};
	}
	sort(node, node+n, cmp2);
	rep(i,1,n) {
		int dis = abs(node[i].y - node[i-1].y);
		G2[i-1] = Edge{node[i].id, node[i-1].id, dis};
	}
	sort(G1, G1+n-1);
	sort(G2, G2+n-1);
	//rep(i,0,n-1) cout << G1[i].u <<" " << G1[i].v <<" " << G1[i].dis<< endl;
	//rep(i,0,n-1) cout << G2[i].u <<" " << G2[i].v << " " << G2[i].dis << endl;
	rep(i,0,N) f[i] = i;
	cnt = 0;
	int s1 = 0, s2 = 0;
	long long ans = 0;
	while(cnt < n - 1) {
		int u, v, t;
		if(G1[s1].dis < G2[s2].dis) {
			u = G1[s1].u;
			v = G1[s1].v;
			t = G1[s1].dis;
			s1++;
		} else {
			u = G2[s2].u;
			v = G2[s2].v;
			t = G2[s2].dis;
			s2++;
		}
		if(find(u) != find(v)) cnt++, merge(u, v), ans += t;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4096
import heapq

def dijkstra(m, s, t):
    INF = 1e10
    D = [INF] * N
    D[s] = 0
    Q = [(0 if s == v else INF, v) for v in range(N)]
    heapq.heapify(Q)

    while Q:
        c, u = heapq.heappop(Q)
        if D[u] < c:
            continue
        for v, w in m[u]:
            if D[v] > D[u] + w:
                D[v] = D[u] + w
                heapq.heappush(Q, (D[u]+w, v))
    return D[t] 

N, M = map(int, input().split())

# N < 100
m = [[] for i in range(N)]
E = [0] * M
for i in range(M):
    a, b, w = map(int, input().split())
    E[i] = a-1, b-1, w
    m[a-1].append((b-1,w))
    m[b-1].append((a-1,w))

count = 0
for a, b, w in E:
    d = dijkstra(m, a, b)
    #print((a+1, b+1), d, "w=%d"%w)
    if d < w:
        count += 1

print(count)


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

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define REP(i, n) for(LL i = 0; i < n; ++i)
#define FOR(i, a, n) for(LL i = a; i < n; ++i)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

//#define int long long

class UnionFind {
    private:
        vector<int> parent;  // 親
        vector<int> rank;    // 木の深さ
    public:
        UnionFind(int n);          // n要素で初期化
        int Find(int x);           // 木の根を返す
        void Unite(int x, int y);  // xとyの属する集合を併合
        bool Same(int x, int y);   // xとyが同じ集合に属するか否か
};

UnionFind::UnionFind(int n) : parent(vector<int>(n)), rank(vector<int>(n)) {
    for (int i = 0; i < n; i++) {
        parent[i] = i;
        rank[i] = 0;
    }
}

int UnionFind::Find(int x) {
    if (parent[x] == x) {
        return x;
    } else {
        return parent[x] = Find(parent[x]);
    }
}

void UnionFind::Unite(int x, int y) {
    x = Find(x);
    y = Find(y);
    if (x == y) return;

    if (rank[x] < rank[y]) {
        parent[x] = y;
    } else {
        parent[y] = x;
        if (rank[x] == rank[y]) rank[x]++;
    }
}

bool UnionFind::Same(int x, int y) { return Find(x) == Find(y); }

template <typename T>
struct Edge {
    int src, to;
    T cost;
    Edge(int to, T cost) : src(-1), to(to), cost(cost) {}
    Edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
};

template <typename T>
class Kruskal {
    private:
        int V; // 頂点数
        vector<Edge<T>> edges;
        vector<vector<Edge<T>>> minimumSpanningTree;
    public:
        Kruskal(int n);
        void AddEdge(int from, int to, T cost);
        T Run();
        vector<vector<Edge<T>>> GetMinimumSpanningTree();
};

template <typename T>
Kruskal<T>::Kruskal(int n) : V(n), minimumSpanningTree(n) {}

template <typename T>
void Kruskal<T>::AddEdge(int from, int to, T cost) {
    edges.push_back(Edge<T>(from, to, cost));
}

template <typename T>
T Kruskal<T>::Run() {
    sort(edges.begin(), edges.end(), [](const Edge<T> &a, const Edge<T> &b){
        return a.cost < b.cost;
    });
    UnionFind tree(V);
    T total = 0;
    
    for(auto &e : edges){
        if(!tree.Same(e.src, e.to)){
            tree.Unite(e.src, e.to);
            total += e.cost;
            minimumSpanningTree[e.src].push_back(Edge<T>(e.to, e.cost));
            minimumSpanningTree[e.to].push_back(Edge<T>(e.src, e.cost));
        }
    }

    return total;
}

template <typename T>
vector<vector<Edge<T>>> Kruskal<T>::GetMinimumSpanningTree(){
    return minimumSpanningTree;
}

/*************** using variables ***************/

/**********************************************/

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    Kruskal<int> kruskal(n);
    REP(i, n){
        REP(j, n){
            int x;
            cin >> x;
            if(x != -1) kruskal.AddEdge(i, j, x);
        }
    }

    cout << kruskal.Run() << endl;
}



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

int main()
{
  string S;cin>>S;
  int N=0,W=0,s=0,E=0;
  for(int i=0;i<S.size();i++)
  {
    if(S[i]=='N'&&N==0)N++;
    if(S[i]=='W'&&W==0)W++;
    if(S[i]=='S'&&s==0)s++;
    if(S[i]=='E'&&E==0)E++;
  }
  if(N==s&&W==E)printf("Yes\n");
  else printf("No\n");
}

Measured memory_bytes: 3596
n = int(raw_input())
a = map(int, raw_input().split())

ans = 0
temp = 0
for i in xrange(n-1):
    if a[i] >= a[i+1]:
        temp = temp + 1
    else:
        ans = max(ans, temp) 
        temp = 0

print max(ans, temp)

Measured memory_bytes: 11340
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 1e9+7;
void Digvijay()
{
   int n;
   cin>>n;
   vector<int> a(n);
   for(auto& it:a)cin>>it;
   map<int,int> mp;
   for(auto it:a)mp[it]++;
   if(mp[0]>1)
   {
       cout<<0<<"\n";
   }
   else
   {
       bool ok=true;
       for(auto it:a)
       {
           if(it==0)continue;
           if(mp[it]!=2)ok=false;
       }
       if(ok)
       {
           int ans=1;
           for(auto it:mp)
           {
               //cout<<ans<<"\n";
               if(it.second)
               ans*=it.second;
               ans%=mod;
           }
           cout<<ans<<"\n";
       }
       else cout<<0<<"\n";
   }
}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int _=1;
    //cin>>_;
    for(int __=0;__<_;__++)
    {
        Digvijay();
    }
}

Measured memory_bytes: 7892
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#define eps 1e-6
using namespace std;
typedef long long ll;

template <typename Tp> inline void getint(Tp &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

inline ll fastpow(ll bas, ll ex){
	register ll res = 1;
	for(; ex; ex >>= 1, bas = bas * bas) if(ex & 1) res = res * bas;
	return res;
}

ll N, P;

int main(){
	getint(N), getint(P);
	if(N == 1) return printf("%lld\n", P), 0;
	for(register int i = (int)(pow(P, 1.0 / N) + eps); i > 1; i--){
		const ll v = fastpow(i, N);
		if(P % v == 0) return printf("%d\n", i), 0;
	}
	return puts("1"), 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _h cout<<"here"<<endl;
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;i+=1)
#define prarr(a,n) rep(i,n) cout<<a[i]<<" \n"[i==n-1];// printf("%s\n"," " );
#define ff first
#define ss second
#define pu push_back
const int inf = 1e9+10;
const ll INF = 1e16+10;
const int MOD = 1e9+7;
const int MAXN = 2e5+10;

int main(){
    ll n,k,q;
    cin>>n>>k>>q;
    map<int ,int> v;
    rep(i,n){
        v[i+1]=0;
    }
    rep(i,q){
        int in;
        cin>>in;
        v[in]++;
    }
    rep(i,n){
        if(k+v[i+1]-q<=0){
            cout<<"No"<<endl;
        }
        else{
            cout<<"Yes"<<endl;
        }
    }
}

Measured memory_bytes: 5376
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

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


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))

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; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

int main() {
    SS(int,n,m)
    vector<int> s(m);
    vector<char >c(m);

    rep(i,m)cin>>s[i]>>c[i]; //左からs桁目がc
    if(n==1){
        for(int i=0;i<10;i++){
            string ans=to_string(i);
            bool flag=true;
            rep(j,m){
                if(ans[s[j]-1]!=c[j])flag=false;
            }
            if(flag==true){
                p(i);
                return 0;
            }
        }
    }
    if(n>1){
    for(int i=pow(10,n-1);i<pow(10,n);i++){
        debug(i);
        string ans=to_string(i);
        bool flag=true;
        rep(j,m){
            if(ans[s[j]-1]!=c[j])flag=false;
        }
        if(flag==true){
            p(i);
            return 0;
        }

    }
    }
    p(-1);
}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();
    long[] a = new long[n];
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextLong();
    }
    Arrays.sort(a);

    long lo = a[0];
    long hi = a[n - 1];
    long ans = hi - lo;

    for (int i = 1; i < n / 2; i++) {
      int l = i;
      int r = n - 1 - i;
      ans += hi - a[l];
      ans += a[r] - lo;
      lo = a[l];
      hi = a[r];
    }
    if (n % 2 != 0) {
      int m = n / 2;
      ans += Math.max(hi - a[m], a[m] - lo);
    }
    os.println(ans);
  }

  private static class Scanner {

    private final InputStream is;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    Scanner(InputStream is) {
      this.is = is;
    }

    private boolean hasNextByte() {
      if (ptr < buflen) {
        return true;
      } else {
        ptr = 0;
        try {
          buflen = is.read(buffer);
        } catch (IOException e) {
          e.printStackTrace();
        }
        if (buflen <= 0) {
          return false;
        }
      }
      return true;
    }

    private int readByte() {
      if (hasNextByte()) {
        return buffer[ptr++];
      } else {
        return -1;
      }
    }

    private static boolean isPrintableChar(int c) {
      return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
      while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
        ptr++;
      }
      return hasNextByte();
    }

    public String next() {
      if (!hasNext()) {
        throw new NoSuchElementException();
      }
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while (isPrintableChar(b)) {
        sb.appendCodePoint(b);
        b = readByte();
      }
      return sb.toString();
    }

    public long nextLong() {
      if (!hasNext()) {
        throw new NoSuchElementException();
      }
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
        minus = true;
        b = readByte();
      }
      if (b < '0' || '9' < b) {
        throw new NumberFormatException();
      }
      while (true) {
        if ('0' <= b && b <= '9') {
          n *= 10;
          n += b - '0';
        } else if (b == -1 || !isPrintableChar(b)) {
          return minus ? -n : n;
        } else {
          throw new NumberFormatException();
        }
        b = readByte();
      }
    }

    public int nextInt() {
      long nl = nextLong();
      if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
        throw new NumberFormatException();
      }
      return (int) nl;
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }
  }
}


Measured memory_bytes: 24540
s=input()[::-1]
p=["maerd","remaerd","resare","esare"]
while True:
  if s[:5]==p[0]:s=s[5:]
  elif s[:5]==p[3]:s=s[5:]
  elif s[:7]==p[1]:s=s[7:]
  elif s[:6]==p[2]:s=s[6:]
  else:
    if s=="":print("YES");break
    else:print("NO");break


Measured memory_bytes: 135072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

constexpr auto INF = INT_MAX/2;
constexpr auto MOD = 1000000007;

int main() {

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

	bool taka = true;

	while (true) {
		c -= b;
		if (c <= 0) { taka = true;break; }
		a -= d;
		if (a <= 0) { taka = false;break; }
	}

	cout << (taka ? "Yes" : "No") << endl;

}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] cnt = new int[M];
		for(int i = 0; i < N; i++) {
			int K = sc.nextInt();
			for(int j = 0; j < K; j++) {
				int A = sc.nextInt() - 1;
				cnt[A]++;
			}
		}
		int k = 0;
		for(int i : cnt) {
			if(i == N) {
				k++;
			}
		}
		System.out.println(k);
	}
}

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

int main(){
	while(1){
		int n, m;
		int f[21][21]; //field
		
		for(int i=0; i<=20; ++i)
		for(int j=0; j<=20; ++j)
		f[i][j]=0;
		
		scanf(" %d", &n);
		if(n==0) break;
		for(int i=0; i<n; ++i){
			int x, y;	
			scanf(" %d %d", &x, &y);
			f[y][x]=1; //宝石あり
		}
		
		int count=0, nx=10, ny=10;
		if(f[ny][nx]==1){
			++count;	
			f[ny][nx]=0;
		}
		
		scanf(" %d", &m);
		for(int i=0; i<m; ++i){
			char d; //direction
			int value;
			scanf(" %c %d", &d, &value);
			
			if(d=='N' || d=='S'){
				int t=-1;
				if(d=='N') t=1;
				
				for(int j=0; j<value; ++j){
					ny+=t;				
					if(f[ny][nx]==1){
						++count;	
						f[ny][nx]=0;
					}			
				}
			}
			else if(d=='E' || d=='W'){
				int t=1;
				if(d=='W') t=-1;
				
				for(int j=0; j<value; ++j){
					nx+=t;				
					if(f[ny][nx]==1){
						++count;	
						f[ny][nx]=0;
					}			
				}
			}
			
		}
		
		if(count==n) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1168
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	double n,t,a;
	cin>>n>>t>>a;
	double h[1001];
	for(int i=0;i<n;i++)
	{
		cin>>h[i];
	}
	double b[1001];
	for(int i=0;i<n;i++)
	{
		b[i]=abs(a-(t-h[i]*0.006));
	}
	double mix=9999,ans;
	for(int i=0;i<n;i++)
	{
		if(b[i]<mix)
		{
			mix=b[i];
			ans=i+1;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
ll n,W,w[101],v[101],dp[101][100001];
void solve()
{
	fill(dp[0],dp[0]+100001,INF);
	dp[0][0]=0;
	for (int i=0;i<n;i++)
		for (int j=0;j<=100000;j++)
			if (j<v[i]) dp[i+1][j]=dp[i][j];
			else dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i]);
	int res=0;
	for (int i=0;i<=100000;i++) if (dp[n][i]<=W) res=i;
	cout<<res;
}
int main()
{
	cin>>n>>W;
	for (int i=0;i<n;i++) cin>>w[i]>>v[i];
	solve();
	return 0;
}
/*#include<bits/stdc++.h>
using namespace std;
const long long INF=0x3fffffff;
typedef long long LL;
int n;
LL w[101],v[101],W;
pair <LL, LL> pi[1 << (100 / 2)];
void solve() {
    int n2 = n / 2;
    for(int i = 0; i < (1 << n2); i++) {
        LL sw = 0, sv = 0;
        for(int j = 0; j < n2; j++) {
            if((i >> j) & 1) {
                sw += w[j];
                sv += v[j];
            }
        }
        pi[i] = make_pair(sw, sv);
    }
    sort(pi, pi + (1 << n2));
    int m = 1;
    for(int i = 1; i < (1 << n2); i++) {
        if(pi[m-1].second < pi[i].second) {
            pi[m++] = pi[i];
        }
    }
    LL res = 0;
    for(int i = 0; i < (1 << (n - n2)); i++) {
        LL sw = 0, sv = 0;
        for(int j = 0; j < n - n2; j++) {
            if((i >> j) & 1) {
                sw += w[n2 + j];
                sv += v[n2 + j];
            }
        }
        if(sw <= W) {
            LL tv = (lower_bound(pi, pi + m, make_pair(W - sw, INF)) - 1)->second;
            res = max(res, sv + tv);
        }
    }
    printf("%lld", res);
}
int main()
{
    scanf("%d%lld", &n, &W);
    for(int i=0;i<n;i++) scanf("%lld%lld", &w[i], &v[i]);
    solve();
    return 0;
}*/

Measured memory_bytes: 79104
n = int(input())
h = list(map(int,input().split()))
h = h[::-1]

for i in range(n-1):
    if h[i+1] - h[i] == 1:
        h[i+1] = h[i+1] - 1
    elif h[i+1] - h[i] > 1:
        print("No")
        exit()
else:
    print("Yes")

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

#define INF 1e9
using namespace std;

#define REPR(i, n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265359

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

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

typedef long long ll;


int main() {
    int a, b, x;
    cin >> a >> b >> x;
    double filled = (double) x / (a * a * b);
    double deg;
    if (filled >= 0.5) {
        double sub = b * (1.0 - filled);
        double rad = atan((2 * sub) / a );
        deg = rad * ((double)180 /  PI);
    } else {
        double rad = atan((double) (a * b * b) / (2 * x ) );
        deg = rad * ((double)180 /  PI);

    }
    cout << fixed << setprecision(10) << deg << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin >> a>>b;
    string ans;
    if(a==b)
    ans="Draw";
    else if(a>b){
        if(b==1)
        ans="Bob";
        else
        ans="Alice";
    }
    else{
        if(a==1)
        ans="Alice";
        else
        ans="Bob";
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
 
int main(){
    ll D,N; cin>>D>>N;
    if(D==0){
        if(N!=100)cout<<N<<endl;
        else cout<<101<<endl;
    }
    if(D==1){
        if(N!=100)cout<<N*100<<endl;
        else cout<<10100<<endl;
    }
    if(D==2){
        if(N!=100)cout<<N*10000<<endl;
        else cout<<1010000<<endl;
    }
    return 0;
}

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	sort(a.begin(), a.end());
	if (n % 2) cout << 0 << endl;
	else {
		cout << a[n/2]-a[n/2-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 3696
from collections import *
from functools import *
from itertools import *

def main():
    n = int(input())
    #a, p = map(int, input().split())
    #xs = list(map(int, input().split()))
    xs = [ input().split() for _ in range(n) ]
    xs = [ (a[0], int(a[1])) for a in xs ]
    def cmp(a, b):
        if a[0] > b[0]:
            return 1
        if a[0] < b[0]:
            return -1
        return b[1] - a[1]
    xs = [ (x[0], x[1], i+1) for i, x in enumerate(xs) ]
    xs.sort(key=cmp_to_key(cmp))
    for s, p, i in xs:
        print(i)
        pass
    pass


if __name__ == "__main__":
    main()
    pass


Measured memory_bytes: 3572