akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  int D, G;
  vector<int> vp, vc;

  cin >> D >> G;

  int ans = INF;

  for (int i = 0; i < D; i++) {
    int p, c; cin >> p >> c;
    vp.push_back(p);
    vc.push_back(c);
  }

  for (int bit = 0; bit < (1<<D); bit++) {
    int tmpsum = 0;
    int cnt = 0;
    for (int i = 0; i < D; i++) {
      if (bit & (1<<i)) {
        tmpsum += vc[i] + vp[i]*(i+1)*100;
        cnt += vp[i];
      }
    }

    for (int i = D-1; i >= 0; i--) {
      if (tmpsum >= G) {
        break;
      }
      if (!(bit & (1<<i))) {
        int point = (i+1)*100;
        int c = min((G-tmpsum+point-1)/point, vp[i]-1);
        cnt += c;
        tmpsum += c * point;
      }
    }
    if (tmpsum >= G) {
      ans = min(ans, cnt);
    }
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 3180
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin >> s;
    int counter = 700;
    if (s[0] == 'o') counter+= 100;
    if (s[1] == 'o') counter+= 100;
    if (s[2] == 'o') counter+= 100;
    cout << counter << endl;
}


Measured memory_bytes: 256
import numpy as np
import pdb


def main():
    mystring = list(raw_input())
    corrected = correction(mystring)
    print ''.join(corrected)
    pass

def correction(mystring):
    mystring[0:4]= ['2', '0','1', '8']
    return mystring

if __name__ == '__main__':
    main()

Measured memory_bytes: 16132
def main():
    N = int(input())
    A = [int()] * N
    x = [[] for i in range(N)]
    y = [[] for i in range(N)]
    for i in range(N):
        A[i] = int(input())
        for j in range(A[i]):
            xij, yij = map(int, input().split())
            x[i].append(xij - 1)
            y[i].append(yij)
    ans = 0
    for b in range(1 << N):
        flg = True
        for i in range(N):
            if not b & 1 << i:
                continue
            for j in range(A[i]):
                if 1 & b >> x[i][j] ^ y[i][j]:
                    flg = False
                    break
            if not flg:
                break
        if flg:
            ans = max(ans, bin(b).count("1"))
    print(ans)
    return


main()


Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>

int main(void) {
    int n, i;
    double t, l;

    while (scanf("%d", &n) != EOF && n != -1) {
        for (i = 2, t = 0; i <= n; i++) {
            t += atan2(1, sqrt(i - 1));
        }
        l = sqrt(n);
        printf("%.2lf\n%.2lf\n", l * cos(t), l * sin(t));
    }
    return 0;
}

Measured memory_bytes: 708
use std::io::{BufRead, Write, stdin, stdout};

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut s = String::new();
    input.read_line(&mut s).unwrap();
    let mut split = s.split_whitespace();
    let n: u16 = split.next().unwrap().parse().unwrap();
    let m: u16 = split.next().unwrap().parse().unwrap();
    let a: Vec<Vec<bool>> = (0..n)
        .map(|_| {
            let mut s = String::new();
            input.read_line(&mut s).unwrap();
            s.trim().chars().map(|c| c == '#').collect()
        })
        .collect();
    let b: Vec<Vec<bool>> = (0..m)
        .map(|_| {
            let mut s = String::new();
            input.read_line(&mut s).unwrap();
            s.trim().chars().map(|c| c == '#').collect()
        })
        .collect();
    let mut result = false;
    'x: for i in 0..n - m + 1 {
        for j in 0..n - m + 1 {
            let mut flag = true;
            'y: for k in 0..m {
                for l in 0..m {
                    if a[i as usize + k as usize][j as usize + l as usize] !=
                       b[k as usize][l as usize] {
                        flag = false;
                        break 'y;
                    }
                }
            }
            if flag == true {
                result = true;
                break 'x;
            }
        }
    }
    writeln!(output, "{}", if result { "Yes" } else { "No" }).unwrap();
}

fn main() {
    let stdin = stdin();
    solve(stdin.lock(), stdout());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v = Vec::<u8>::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }
    #[test]
    fn case1() {
        test("3 2
...
.#.
..#
#.
.#\n",
             "Yes\n");
    }
    #[test]
    fn case2() {
        test("4 1
....
....
....
....
#\n",
             "No\n");
    }
}

Measured memory_bytes: 4352
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define rep(i, l, r) for (ll i = (l); i < (r); ++i)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int> 
#define pdd pair<ld, ld> 
#define pb push_back
#define reset(x,v) memset(x,v,sizeof(x))
#define mod 1000000007
using namespace std;


int main() {
	FASTIO
	ll a, b , c , k;
	cin >> a >> b >> c >> k;
	ll s = 0;
	if(k > 0){
		s += min(a, k);
		k -= min(a, k);
	}
	if(k > 0){
		k -= min(b, k);
	}
	if(k > 0){
		s -= min(c, k);
		k -= min(c, k);
	}
	cout << s;
	return 0;
}




Measured memory_bytes: 3640
from collections import Counter

def comb(n, k):
    k = min(k, n - k)
    result = 1
    for i in range(n, n - k, -1):
        result *= i
    for i in range(1, k + 1):
        result //= i 
    return result

n = int(input())
A = [int(i) for i in input().split()]

S = [0] * (n + 1)
for i in range(1, n + 1):
    S[i] = S[i - 1] + A[i - 1]
    
S = Counter(S)
ans = 0
for v in S.values():
    if v > 1:
        ans += comb(v, 2)
        
print(ans)

Measured memory_bytes: 41484
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<set>
using namespace std;
int stoi(string x){stringstream ss;ss<<x;int tmp;ss>>tmp;return tmp;}
string itos(int x){stringstream ss;ss<<x;return ss.str();}
int main(){
int n,cnt=0;
	int out=0,ans=0,now=0;
cin>>n;
	for(;;){
	if(cnt==n)break;
	string tmp;
	cin>>tmp;
	if(tmp=="OUT")out++;
	else if(tmp=="HIT")now++;
	if(tmp=="HOMERUN")ans+=now+1,now=0;
	if(now==4)now=3,ans++;
	if(out==3){cout<<ans<<endl;cnt++;out=0,ans=0,now=0;}
	}
		return 0;
}

Measured memory_bytes: 1216
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i = Integer.parseInt(sc.next());
        
        if(i == 7 || i == 5 || i == 3){
                System.out.println("YES");
            }else{
                System.out.println("NO");
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int x,y,n,m; cin>>n>>m>>x>>y;
	int a=x,b=y;
	int c=MOD;
	rep(i,0,n){
		int p; cin>>p;
		chmax(a,p);
	}
	rep(i,0,m){
		int p; cin>>p;
		chmax(b,p);
		chmin(c,p);
	}
	if(a>=b){
		cout<<"War"<<endl;
		return 0;
	}
	rep(i,x+1,y+1){
		if(a<i && i<=c){
			cout<<"No War"<<endl;
			//cout<<i<<endl;
			return 0;
		}
	}
	cout<<"War"<<endl;
	
	
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    ll n;
    cin >> n;
    vector<ll> data(n);
    rep(i,0,n){
        cin >> data[i];
    }
    ll now_max = data[0];
    ll ans = 0;
    rep(i,0,n){
        if(now_max<=data[i]){
            now_max = data[i];
        }else{
            ans += now_max - data[i];
        }
    }
    cout<<ans<<endl;

}

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

int main()
{
  int A, B;
  cin >> A >> B;
  
  int time = A + B;
  if(time >= 24)
  {
    cout << time - 24 << endl;
  }
  else
  {
    cout << time << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

int main(void)
{
    string s[3];
    for (int i = 0; i < 3;i++){
        cin >> s[i];
    }
    cout << s[0][0] << s[1][1] << s[2][2] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define int long long
#define ll long long
#define pp pair<int,int>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
int max(int x, int y)
{
    return x>y ? x : y;
}
int min(int x, int y)
{
    return x<y ? x : y;
}
void _(int&a , int b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
ll cl(ll a,ll b)
{
    return (a/b)+(!(!(a%b)));
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll k,a,b;cin >> k >> a >> b;
    for(int i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            cout << "OK";return 0;
        }
    }
    cout << "NG";
    }

Measured memory_bytes: 3652
#include <stdio.h>

int up(int *a, int n){
  for(int i = 0; i < n - 1; i++){
    if(a[i + 1] - a[i] < 0){
      return 0;
    }
  }
  return 1;
}

int main(){
  int n;
  scanf("%d", &n);
  int p[n];
  for(int i = 0; i < n; i++){
    scanf("%d", &p[i]);
  }
  int flag = 0;
  if(up(p, n)){
    flag = 1;
  }
  int q[n];
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(i != j){
        for(int k = 0; k < n; k++){
          q[k] = p[k];
        }
        int sw = q[i];
        q[i] = q[j];
        q[j] = sw;
        if(up(q, n)){
          flag = 1;
        }
      }
    }
  }
  if(flag){
    printf("YES\n");
  }else{
    printf("NO\n");
  }
  return 0;
}


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

int main(void){
    string s; cin >> s;
    int y,m;

    y=stoi(s.substr(0,4));
    m=stoi(s.substr(5,2));

    bool heisei=true;
    if(y>=2020) heisei=false;
    if(y==2019 && m>=5) heisei=false;

    if(heisei) cout << "Heisei" << endl;
    else cout << "TBD" << endl;
}

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

using ll = long long;
using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(false)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YN(x)         cout << ((x) ? "YES" : "NO") << endl
#define Yn(x)         cout << ((x) ? "Yes" : "No") << endl
#define yn(x)         cout << ((x) ? "yes" : "no") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;

ll gcd(ll a, ll b) { return __gcd(a, b); }
ll lcm(ll a, ll b) { return (a == 0 || b == 0) ? 0 : (a / __gcd(a, b) * b); }

int main(int argc, const char* argv[]) {
	ll n, k, q;
	cin >> n >> k >> q;
	vector<ll> p(n, k-q);

	rep(i, q) {
		ll a;
		cin >> a;
		p.at(a-1) += 1;
	}

	rep(i, n) {
		Yn(p.at(i) > 0);
	}

	return 0;
}


Measured memory_bytes: 1408
// READ & UNDERSTAND
// ll, int overflow, array bounds
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n; string s;
	cin >> n >> s;
	for(int i=0; i<(int)s.length(); i++){
		int cur = s[i]-'A';
		cur = (cur+n)%26;
		s[i] = char('A'+cur);
	}
	cout << s << endl;
}	


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

int main(){
	int n,m;
	cin>>n>>m;
	int a[n];
	int b[n];
	for(int i=0;i<n;i++){
		a[i]=abs(i+m);
		b[i]=i+m;
	}
	sort(a,a+n);
	int sum=0,flag=0;
	for(int i=0;i<n;i++){
		if(flag==0&&b[i]==a[0]||b[i]==-a[0]){
			flag=1;
		}
		else sum+=b[i];
	}
	cout<<sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
#define all(x) x.begin(), x.end()
 
using namespace std;

int main() {
	int x;
	scanf ("%d", &x);
	int ans = 0, now = 0;
	while (!ans || now != 0) {
		(now += x) %= 360;
		ans++;
	}
	printf ("%d\n", ans);
	return 0;
}	


Measured memory_bytes: 3812
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll r;cin>>r;
  cout<<2*r*PI<<endl;
}
  
  
    


Measured memory_bytes: 3792
s =  int(input())
k =  int(input())
#print(pow(10, 12))
def main(string_s):
    for i, j in enumerate(str(string_s)):
#        print(i, j)
#        print(i, k)
        if j != '1':
            break
        if i+1 == k:
            print('1')
            return
    if str(s).lstrip('1') == '':
         print('1')
         return
    if str(s).lstrip('1')[0] == '2':
        print('2')
    elif str(s).lstrip('1')[0] == '3':
        print('3')
    elif str(s).lstrip('1')[0] == '4':
        print('4')
    elif str(s).lstrip('1')[0] == '5':
        print('5')
    elif str(s).lstrip('1')[0] == '6':
        print('6')
    elif str(s).lstrip('1')[0] == '7':
        print('7')
    elif str(s).lstrip('1')[0] == '8':
        print('8')
    elif str(s).lstrip('1')[0] == '9':
        print('9')
    else:
        print('1')

main(s)


Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll A, B;
  cin >> A >> B;
  cout << max(A + B, max(A - B, A * B)) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
char s[303][303];
int cnt[303][303];
int dp[303][303];
int main()
{
	int h,w,ans=0;
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;i++)
		scanf("%s",s[i]+1);
	for(int i=2;i<=w;i++)
	{
		for(int ii=0;ii<=h;ii++)
			for(int jj=0;jj<=h;jj++)
			{
				if(ii==0||jj==0)
					cnt[ii][jj]=0;
				else
					cnt[ii][jj]=cnt[ii-1][jj-1]+(s[ii][i-1]==s[jj][i]);
			}
		for(int ii=0;ii<=h;ii++)
			for(int jj=0;jj<=h;jj++)
			{
				if(ii==0||jj==0)
					dp[ii][jj]=0;
				else
					dp[ii][jj]=min(dp[ii-1][jj],dp[ii][jj-1])+cnt[ii][jj];
			}
		ans+=dp[h][h];
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{

	public static void main (String[] args) {

		Scanner sc = new Scanner (System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();
		int count = 0;

		for (int index=0; index<N; index++) {
			if (sc.nextInt()>=K) {
				count++;
			}
		}

		System.out.println(count);
	}
}

Measured memory_bytes: 48188
#include<stdio.h>
int main(void){
    
    int a=0;
    int c=0;
    int b;
    
    scanf("%d""%d",&c,&a);
   b=a+c;
if(b%2==0){
    printf("%d",b/2);
}else{
    printf("IMPOSSIBLE");
}
   
    
}

Measured memory_bytes: 128
import java.util.*;

class Main{
    static int inf = Integer.MAX_VALUE;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String S = sc.next();
        StringBuilder sb = new StringBuilder(S);
        char[] backRev = sb.reverse().toString().substring(0,n).toCharArray();
        char[] front = S.substring(0,n).toCharArray();
        //HashMap<String,ArrayList<Integer>> backDic = new HashMap<>();
        HashMap<String,HashMap<String,Long>> backDic = new HashMap<>();
        for(int i=0;i<(1<<n);i++){
            String cur = getSub(backRev,i);
            String remain = getRemainRev(backRev,i);
            if(!backDic.containsKey(cur)) {
                HashMap<String,Long> toAdd = new HashMap<>();
                toAdd.put(remain,1L);
                backDic.put(cur,toAdd);
            }
            else{
                HashMap<String,Long> toModify = backDic.get(cur);
                long now = toModify.getOrDefault(remain,0L)+1;
                toModify.put(remain,now);
            }
        }
        long cnt = 0;
        for(int i=0;i<(1<<n);i++){
            String redFront = getSub(front,i);
            String blueEnd = getRemainRev(front,i);
            if(!backDic.containsKey(redFront)) continue;
            HashMap<String,Long> toCheck = backDic.get(redFront);
            cnt += toCheck.getOrDefault(blueEnd,0L);
        }
        System.out.println(cnt);
    }
    static String getSub(char[] s, int idx){
        StringBuilder sb = new StringBuilder();
        for(int i=0;i<s.length;i++){
            if((idx&(1<<i))>0) sb.append(s[i]);
        }
        return sb.toString();
    }
    static String getRemainRev(char[] s, int idx){
        StringBuilder sb = new StringBuilder();
        for(int i=0;i<s.length;i++){
            if((idx&(1<<i))==0) sb.append(s[i]);
        }
        sb.reverse();
        return sb.toString();
    }
}


Measured memory_bytes: 169956
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main(){
    ll a,b,c,d;cin>>a>>b>>c>>d;
    //if(a>=0||c>=0)cout <<b*d;
    //else if(b<0||d<0)cout<<a*c;
    //if((a*b<0||d<0)&&(c*d<0||b<0)) cout <<0;
    cout<<max({a*c,a*d,b*c,b*d});
}

Measured memory_bytes: 3628
n,q = map(int,input().split())
s = input()
LR = [0]*q
for i in range(q):
    
    LR[i] = list(map(int,input().split()))
A = [0]*n
for i in range(n-1):
    if s[i] == "A" and s[i+1] == "C":
        A[i+1] = 1
    A[i+1] += A[i]
for i in range(q):
    print(A[LR[i][1]-1]-A[LR[i][0]-1])

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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    string ans = "YES";
    sort(A.begin(), A.end());
    for (int i = 0; i < N - 1; i ++) {
        if (A.at(i) == A.at(i + 1)) {
            ans = "NO";
            break;
        }
    }
    cout << ans << endl;
}

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

class Program
    {
        static void Main(string[] args){
            List<int> n = new List<int>();
            int r,i;
            string s;
            int[] v = new int[] { 2, 3, 5, 7 };
            while (true) {
                s = Console.ReadLine();
                if (string.IsNullOrEmpty(s)) break;
                n.Add(int.Parse(s));
            }
            foreach (int n1 in n)
            {
                r = 0;
                for (i = 1; i <= n1; i++)
                {
                    if (IsPrime(i,v)) r++;
                }
                Console.WriteLine(r);
            }
        }

        static bool IsPrime(int x,int[] v) {
            bool b=true;
            if (x < 2) return false;
            if (x % 2 == 0&&x!=2) return false;
            for (int i = 3; i < 1000; i+=2) {
                if (x % i == 0 && x / i > 1) { b = false; break; }
            }
            return b;
        }

    }

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

ll GetDigit(ll num)
{
  return log10(num) + 1;
}

//実行部
void Main()
{
  ll a, b, c; cin >> a >> b >> c;
  vll key;
  map <ll, ll> ans;
  for(ll i = a;i - a < c;i++)
  {
    if(i <= b)
    if(!ans.count(i)) { ans[i] = 0; key.pb(i); }
  }
  for(ll i = b;b - i < c;i--)
  {
    if(i >= a)
    if(!ans.count(i)) { ans[i] = 0; key.pb(i); }
  }
  sort(all(key));
  rep(i, key.size())
  {
    fin(key[i])
  }
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 256
function Main (S) {
  S = S.split("\n")[0].split("");
  var re = [];
  var ans = 0;
  for (var i of S) {
    re.unshift(i);
  }
  for (var i = 0; i < S.length; i++) {
    if (S[i] != re[i]) {
      ans++;
    }
  }
  console.log(ans/2);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import java.util.*;
import java.io.*;

class Main{
  static int n;
  static Card cards[];
  public static void main(String[] args){
      int i;
      try{
          InputStreamReader ir = new InputStreamReader(System.in);
           BufferedReader buffer = new BufferedReader (ir);
           String str1 = buffer.readLine();
           n = Integer.parseInt(str1);
           cards = new Card[n];
      for(i=0;i<n;i++){
  			String[] str2 = buffer.readLine().split(" ");
  			cards[i] = new Card(str2[0], Integer.parseInt(str2[1]), i);
  		}
    }catch(IOException e){
        System.out.println("error1");
    }
    quickSort(cards,0,n-1);
    if(isStable(cards,n)==true){
      System.out.println("Stable");
    }
    else{
      System.out.println("Not stable");
    }
    for(i=0;i<n;i++){
      System.out.println(cards[i].mark+" "+cards[i].number);
    }
  }
  private static void quickSort(Card c[],int p,int r){
    int q;
    if(p<r){
      q = partition(c,p,r);
      quickSort(c,p,q-1);
      quickSort(c,q+1,r);
    }
  }

  private static int partition(Card c[],int p,int r){
         int i,j,x;
         Card card;

         x = c[r].number;
         i = p-1;
         for(j=p;j<r;j++){
             if(c[j].number<=x){
                 i++;
                 card = c[i];
                 c[i] = c[j];
                 c[j] = card;
             }
         }
         card = c[i+1];
         c[i+1] = c[r];
         cards[r] = card;
         return i+1;
     }
     private static boolean isStable(Card[] c, int n){
       int i;
		for(i=1;i<n;i++){
			if(c[i-1].number == c[i].number && c[i-1].order > c[i].order){
				return false;
			}
		}
		return true;
	}
  public static class Card{
   public String mark;
   public int number;
   public int order;
   Card(String mark, int number, int order){
     this.mark = mark;
     this.number = number;
     this.order = order;
   }
  }

}



Measured memory_bytes: 78160
/* ex9_1
   moka223711 */

#include <stdio.h> 
#define SIZE 15

typedef struct stack{ // 文字列を格納するスタック
    int size;
    int count; // スタックに格納されたデータ数を表す変数
    char data[SIZE]; // スタックにデータを格納するための配列
    char *top; // スタックの先頭アドレスを表すポインタ
}stack;

void initialize_stack(stack *stk); // スタックを初期化するための関数
void print_stack(stack *stk); // スタックに格納されているデータを出力するための関数
void push(stack *stk, char input); // スタックの先頭にデータを格納するための関数
void pop(stack *stk); // スタックの先頭からデータを取り出すための関数

int main(void){
    stack stk;
    char input; // 入力を受け取るための変数
    initialize_stack(&stk); // スタックを初期化
    while((input = getchar()) != EOF){ // 入力ファイルの終端に達するまで文字を受け取る
        if(input != 'B')push(&stk, input); // 入力された文字が'0'か'1'だったときはスタックの先頭に文字を格納する
        else if(stk.count > 0)pop(&stk); // 入力された文字が'B'でありスタックの要素が空でなければ先頭から文字を削除する
    }
    print_stack(&stk); // スタックに格納されているデータを出力
    return 0;
}

// スタックを初期化するための関数
void initialize_stack(stack *stk){
    stk->count = 0; // スタックに格納されているデータの総数は0
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]); // スタックの先頭アドレスをstk->topに格納する
}

void print_stack(stack *stk){
    int i;
    for(i = 0; i < stk->count; i++) // 格納されているデータをすべて出力していく
        printf("%c", stk->data[stk->size-i-1]); // 古い要素から順番に出力していく
    printf("\n");// 最後に改行を出力して終了
}

// スタックの先頭にデータを格納するための関数
void push(stack *stk, char input){
    stk->top--; // スタックの先頭のアドレスを一つずらす
    *(stk->top) = input; // スタックの先頭に文字を格納する
    stk->count++; // スタックのデータの総数のカウントを一つ増やす
}

void pop(stack *stk){
    stk->top++; // スタックの先頭アドレスを一つずらす
    stk->count--; // スタックのデータの総数のカウントを一つ減らす
}


Measured memory_bytes: 1504
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long i = Math.round(Math.pow(n, 0.5));
        while (n % i != 0) i--;
        long ii = n/i;
        System.out.println(ii+i-2);
    }
}


Measured memory_bytes: 25044
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <limits>
#include <map>
#include <string>
using namespace std;

bool is_prime(int n){
for(int i=2;i*i<=n;i++){
if(n % i == 0) return false;
}
return n!=1;
}

int main(){
int n;
int* table =  new int[1000000];
while(~scanf("%d",&n)){

fill((int*)table,(int*)table+n+1,1);
table[0]=0;
table[1]=0;

for(int i=2;i<=n;i++){
if(table[i]) {
for(int j=i+i;j<=n;j+=i){
table[j] = 0;
}
}
}
printf("%d\n",count(table,table+n+1,1));
}
}

Measured memory_bytes: 0
#include <iostream>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <list>
#include <math.h>
#include <map>
using namespace std;
#define REP(i, k, n) for(int i = k;i < n; i++)
#define rep(i, n) REP(i,0,n)
#define ll long long int
int dx[4] = {0,-1,1,0};
int dy[4] = {-1,0,0,1};
#define eps 10e-6
#define mod 1000000007
int main(void){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	if(abs(a-c) <= d){
		cout << "Yes" << endl;
	}else if(abs(a-b) <= d && abs(b-c)<=d){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
INF = 1001001001
from collections import deque

def linput(ty=int, cvt=list):
	return cvt(map(ty,input().split()))

def pad(mxy, w="#"):
	gp = w*(len(mxy[0])+2)
	return [gp,]+[w+vx+w for vx in mxy]+[gp,]

vD = [(0,1),(1,0),(0,-1),(-1,0)]
vQ = deque([])
vQ_app, vQ_popl = vQ.append, vQ.popleft

def main():
	H,W = linput()
	sr,sc = 1,1
	gr,gc = H,W
	mM = [input().rstrip() for _ in "*"*H]
	walls = sum(s.count("#") for s in mM)
	mM = pad(mM,"#")
	#print(mM)#
	
	res = 0
	cnt = 0
	
	mV = [[INF,]*(W+2) for _ in "*"*(H+2)]
	#for sr in range(1,H+1):
	#	for sc in range(1,W+1):
	#		if mM[sr][sc]==".":
	#			continue
	mV[sr][sc] = 0
	vQ_app((sr,sc))
	
	while vQ:
		r,c = vQ_popl()
		now_cost = mV[r][c]
		for dr,dc in vD:
			nr,nc = r+dr, c+dc
			if mM[nr][nc]!=".":
				continue
			if now_cost + 1 < mV[nr][nc]:
				vQ_app((nr,nc))
				mV[nr][nc] = now_cost + 1
				#res = max(now_cost+1, res)
		
		cnt += 1
		#print(res,cnt,X,Y,H)
		if cnt>4999999: break
	
	res = mV[gr][gc]
	if res == INF:
		res = -1
	else:
		res = H*W - res - walls - 1
	print(res)

if __name__ == "__main__":
	main()


Measured memory_bytes: 74172
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep1(n) rep2(i,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
int main(){
    string s;
    cin>>s;
    int n;
    n=s.size();
    int count=0,max=0;
    for(int i=0;i<n;i++){
        if(s.at(i)=='A'||s.at(i)=='T'||s.at(i)=='G'||s.at(i)=='C')count++;
        else count=0;
        if(max<count)max=count;
    }
    cout<<max<<endl;
}

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

int main(){
      int n;cin >> n;
      int sum = 0;
      int arra[n + 10];for(int i = 0;i < n;i++)cin >> arra[i];
      int arrb[n + 10];
      for(int i = 0;i < n;i++)cin >> arrb[i];
      int arrc[n + 10];
      for(int i = 0;i < n - 1;i++)cin >> arrc[i];
      for(int i = 0;i < n;i++){
            sum += arrb[arra[i] - 1];
            if(i > 0 && arra[i] == arra[i - 1] + 1)sum += arrc[arra[i - 1] - 1];
      }
      cout << sum;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x0123456789) cerr<<#x0123456789<<':'<<x0123456789<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x0123456789:v)cerr<<x0123456789<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;
typedef long double ld;

signed main(){
    ll N,K;
    cin >> N >> K;
    ll a[N+1]={0};
    FOR(i,0,N)cin >> a[i+1];
    FOR(i,0,N)a[i+1]+=a[i];
    vector<ll> v;
    FOR(i,0,N+1)FOR(j,i+1,N+1)v.pb(a[j]-a[i]);
    REP(i,0,60){
        ll counter=0;
        FOR(j,0,v.size())if(v[j]&((ll)1<<i))counter++;
        if(counter>=K){
            vector<ll> yay;
            FOR(j,0,v.size())if(v[j]&((ll)1<<i))yay.pb(v[j]);
            v=yay;
        }
    }
    ll ans = v[0];
    FOR(i,0,v.size())ans &= v[i];
    cout << ans << endl;
}

Measured memory_bytes: 6512
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <numeric>
#include <queue>

using namespace std;

int main(){
    int X;
    cin >> X;
    if(X>=30 && X<=40){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

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

int P(int N,int p){
  int ans=0;
  while(N>=p){
    N/=p;
    ans+=N;
  }
  return ans;
}

int main() {
  int big=1000000007;
  int N;
  cin >> N;
  N++;
  vector<int>prime;
  vector<bool>is_prime(N);
  for(int i=0;i<N;i++){
    is_prime.at(i)=true;
  }
  is_prime.at(0)=false;
  is_prime.at(1)=false;
  for(int i=2;i<N;i++){
    if(is_prime.at(i)){
      prime.push_back(i);
      for(int j=2*i;j<N;j+=i) is_prime.at(j)=false;
    }
  }
  int l=prime.size();
  
  int64_t ans=1;
  for(int i=0;i<l;i++){
    int64_t a=P(N-1,prime.at(i));
    ans*=(a+1);
    ans%=big;
  }
  cout << ans;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int N;
int64_t D[200001];
int M;
int64_t T[200001];

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

    cin >> N;
    for(int i = 0; i < N; ++i){
        cin >> D[i];
    }
    cin >> M;
    for(int i = 0; i < M; ++i){
        cin >> T[i];
    }

    sort(D, D + N);
    sort(T, T + M);

    int n1 = 0;
    int n2 = 0;
    while(n1 < N && n2 < M){
        if(D[n1] == T[n2]){
            n1++;
            n2++;
        }
        else if(D[n1] < T[n2]){
            n1++;
        }
        else break;
    }

    if(n2 == M){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }

}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <queue>
#include <algorithm>

using namespace std;

int main(){
    //入力
    int h,w; cin >> h >> w;
    int ch,cw; cin >> ch >> cw;
    ch--; cw--;
    int dh,dw; cin >> dh >> dw;
    dh--; dw--;
    vector<vector<char>> maze(h,vector<char>(w));
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> maze[i][j];
        }
    } 
    //調べたかどうか
    vector<vector<int>> visited(h,vector<int>(w,-1));
    visited[ch][cw] = 0;
    deque<pair<int,int>> q;
    q.emplace_back(make_pair(ch,cw));
    //通常移動用
    vector<int> dy(4); dy = {1,-1,0,0};
    vector<int> dx(4); dx = {0,0,1,-1};
    //ワープ移動用
    vector<int> wy(20);wy = { 2, 2,2,2,2,  1, 1,1,1,  0,0, -1,-1,-1,-1, -2,-2,-2,-2,-2};
    vector<int> wx(20);wx = {-2,-1,0,1,2, -2,-1,1,2, -2,2, -2,-1, 1, 2, -2,-1, 0, 1, 2};
    //この書き方でいい
    //const int di[] = {-1,0,1,0};
    //const int dj[] = {0,-1,0,1};   

    while(!q.empty()){
        int y = q.front().first;
        int x = q.front().second;
        q.pop_front();

        int cnt = visited[y][x]; 
        //通常移動
        for(int i=0; i<4; i++){
            int ny = y + dy[i];
            int nx = x + dx[i];
            if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
            if(maze[ny][nx] == '#') continue;
            if(visited[ny][nx] <= cnt && visited[ny][nx] != -1) continue;

            visited[ny][nx] = cnt;
            //ワープでない場合は前から詰める
            //これで通常移動で行ける場所を調べ終えてから、ワープで行ける場所を調べられる
            q.emplace_front(make_pair(ny,nx));
        }

        cnt++;
        for(int i=0; i<20; i++){
            int ny = y + wy[i];
            int nx = x + wx[i];
            if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
            if(maze[ny][nx] == '#') continue;
            if(visited[ny][nx] <= cnt && visited[ny][nx] != -1) continue;

            visited[ny][nx] = cnt;
            q.emplace_back(make_pair(ny,nx));
        }
    }
    cout << visited[dh][dw] << endl;
}

Measured memory_bytes: 8540
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    try(Scanner sc = new Scanner(System.in)){
        while(true){
                int num = sc.nextInt();
                double score[] = new double[num];
                double ave = 0;
                double var = 0;
            if(num==0)
              break;
            for(int i=0;i<num;i++){
                score[i] = sc.nextInt();
                ave = ave + (score[i]/num);
            }

            for(int i=0;i<num;i++){
                var = var + ((score[i] - ave)*(score[i] - ave) / num);
            }
            System.out.printf("%s\n",Math.sqrt(var));
        }
        }
  }
}



Measured memory_bytes: 31384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i=0;i<n-1;i++){
            a[sc.nextInt()-1]++;
        }
        for(int i=0;i<n;i++){
            System.out.println(a[i]);
        }
    }
}


Measured memory_bytes: 57952
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const ll mod = 998244353;

ll dp[6060];

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


	int A, B, C, D;
	cin >> A >> B >> C >> D;

	C -= A;
	D -= B;

	dp[C + 2] = 1;
	for (int i = C + 2; i < C + D + 2; i++) dp[i + 1] = dp[i] * A % mod;

	for (int i = A; i < A + C; i++) {
		auto t = dp + C - i + A - B + 2;

		for (int j = B; j <= B + D; j++) {
			t[j - 1] = t[j - 2] * (i + 1) + t[j] * j - t[j - 1] * i * (j - 1);

			//t[j - 1] %= mod;
			t[j - 1] -= int(double(t[j - 1]) / mod) * mod;

		}
	}
	co((dp[D + 2] + 10 * mod) % mod);

	Would you please return 0;
}

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

using namespace std;

inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;}

const int maxn = 2e5 + 50;

int N , p[maxn] , ans[maxn] , anslen , odd[maxn][20] , even[maxn][20] , pos[maxn] , len[maxn];

struct Node{
	int l , r;
	pair < int , int > w;
	Node( int l , int r , pair < int , int > w ) : l( l ) , r( r ) , w( w ){}
	friend bool operator < ( const Node & x , const Node & y ){
		return make_pair( p[x.w.first] , p[x.w.second] ) > make_pair( p[y.w.first] , p[y.w.second] );
	}
};

int GetMin( int l , int r , int f[][20] ){
	int z = len[r - l + 1];
	return min( f[l][z] , f[r - (1 << z) + 1][z] );
}

pair < int , int > Query( int l , int r ){
	int w ;
	if( l & 1 ) w = GetMin( l , r , odd );
	else w = GetMin( l , r , even );
	w = pos[w];
	int t;
	if( l & 1 ) t = GetMin( w + 1 , r , even );
	else t = GetMin( w + 1 , r , odd );
	t = pos[t];
	return make_pair( w , t );
}

priority_queue < Node > pq;

void PushStatus( int l , int r ){
	if( l >= r ) return;
	pq.push( Node( l , r , Query( l , r ) ) );
}

int main( int argc , char * argv[] ){
	N = read();
	len[0] = -1;
	for(int i = 1 ; i <= N ; ++ i){
		p[i] = read();
		pos[p[i]] = i;
		len[i] = len[i >> 1] + 1;
	}
	memset( odd , 0x3f , sizeof( odd ) );
	memset( even , 0x3f , sizeof( even ) );
	for(int i = 1 ; i <= N ; i += 2) odd[i][0] = p[i];
	for(int i = 2 ; i <= N ; i += 2) even[i][0] = p[i];
	for(int j = 1 ; j < 20 ; ++ j)
		for(int i = 1 ; i + (1 << j) - 1 <= N ; ++ i)
			odd[i][j] = min( odd[i][j - 1] , odd[i + (1 << j - 1)][j - 1] ),
			even[i][j] = min( even[i][j - 1] , even[i + (1 << j - 1)][j - 1] );
	PushStatus( 1 , N );
	while( !pq.empty() ){
		Node s = pq.top(); pq.pop();
		int l = s.l , r = s.r;
		pair < int , int > w = s.w;
		PushStatus( l , w.first - 1 );
		PushStatus( w.first + 1 , w.second - 1 );
		PushStatus( w.second + 1 , r );
		ans[anslen ++] = w.first , ans[anslen ++ ] = w.second;
	}
	for(int i = 0 ; i < anslen ; ++ i){
		if( i ) putchar( 32 );
		printf( "%d" , p[ans[i]] );
	}
	puts( "" );
	return 0;
}

Measured memory_bytes: 36596
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
using namespace std;
#define N 10005
 
struct node{
    int x, y, id, id1, id2;
}ans[N];
 
struct mem{
    int y, id, id1, id2;
};
 
vector<mem>ve[N];
map<int,int>ma;
map<int,int>mb;
int low[N], dfn[N];
int visited[N];
int n, m, dfn_clock;
int nu;
 
void init(){
    for(int i=0;i<=n;i++) ve[i].clear();
    ma.clear();mb.clear();
    memset(dfn,-1,sizeof(dfn));
    memset(visited,0,sizeof(visited));
}
 
void dfs(int u,int fa){
    int i, j, k, v;
    node p;
    mem q;
    //printf("1111111111\n");
    low[u]=dfn[u]=dfn_clock++;
    
    visited[u]=1;
    for(i=0;i<ve[u].size();i++){
        q=ve[u][i];
        if(q.y==fa) continue;
    //    printf("%d\n",v);
        if(!visited[q.y]){
            dfs(q.y,u);
            low[u]=min(low[u],low[q.y]);
            if(low[q.y]>dfn[u]) {
                p.x=u;p.y=q.y;p.id=q.id;p.id1=q.id1;p.id2=q.id2;
                ans[nu++]=p;
            }
        }
        else low[u]=min(low[u],dfn[q.y]);
        
    }
}
 
bool cmp(node a,node b){
    return a.id<b.id;
}
 
main()
{
    int t, i, j, k, id;
    int s1, s2;
    mem p;
    t=1;
    while(t--){
        scanf("%d %d",&n,&m);
        init();k=1;id=1;
        while(m--){
            scanf("%d%d",&s1,&s2);
            if(ma[s1]==0) ma[s1]=k,mb[k]=s1,++k;
            if(ma[s2]==0) ma[s2]=k,mb[k]=s2,++k;
            int x=ma[s1], y=ma[s2];
            p.y=ma[s2];p.id=id++;p.id1=1;p.id2=2;
            ve[x].push_back(p);
            p.y=ma[s1];p.id=id++;p.id1=2;p.id2=1;
            ve[y].push_back(p);
        }
    
        dfn_clock=nu=0;
         dfs(1,-1);
         int f=1;
        for(i=1;i<=n;i++) {
            if(dfn[i]==-1){
            break;
            }
        }
        sort(ans,ans+nu,cmp);
        printf("%d\n",nu);
    }
}

Measured memory_bytes: 512
package main

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

func exec(stdin *Stdin, stdout *Stdout) {
	k := stdin.ReadInt()
	x := stdin.ReadInt()
	if x <= k*500 {
		stdout.Println("Yes")
	} else {
		stdout.Println("No")
	}
}

func main() {
	stdout := NewStdout()
	defer stdout.Flush()
	exec(NewStdin(bufio.ScanWords), stdout)
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), int(math.MaxInt32))
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}


Measured memory_bytes: 640
// C - Remainder Minimization 2019
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	long long l, r, m;
	cin >> l >> r;
	long long ans = -1;
	for (long long i = l; i <= min(l + 2019, r); i++)
		for (long long j = i + 1; j <= min(l + 2019, r); j++)
			if (ans < 0) ans = i * j % 2019;
			else ans = min(ans, i * j % 2019);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main{
	static final Scanner s=new Scanner(System.in);
	static IntStream REPS(int v){
		return IntStream.range(0,v);
	}
	static IntStream REPS(int l,int r){
		return IntStream.rangeClosed(l,r);
	}
	static IntStream INS(int n){
		return REPS(n).map(i->getInt());
	}
	static int getInt(){
		return Integer.parseInt(s.next());
	}
	
	public static void main(String[] $){
		System.out.println(INS(3).sorted().limit(2).sum());
	}
}


Measured memory_bytes: 26708
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int n;
    cin>>n;
    vector<int> h(n);
    rep(i,0,n) cin>>h[i];
    int land=0;
    int maxi=0;
    rep(i,0,n) maxi=max(maxi,h[i]);
    rep(i,1,maxi+1){
        bool check=false;
        rep(j,0,n){
            if(h[j]>=i&&check==false){
                land++;
                check=true;
            }else if(h[j]<i&&check==true){
                check=false;
            }
        }
    }
    cout<<land<<endl;
}

Measured memory_bytes: 256
n = gets.chomp
#a = Array.new(2n)
line = gets.chomp

pits = line.split(" ")
pits.map!{|a| a.to_i}
spits = pits.sort_by{|i| -i}
#p spits
res = 0
i = 1
while i < spits.size
  res += spits[i]
  i += 2
end
puts res

Measured memory_bytes: 1788
import math
M, D = map(int, input().split())


def is_prime(n):
    a = []
    for i in range(2, n+1):
        for k in range(2, int(math.sqrt(i)) + 1):
            if i % k == 0:
                a.append(i)
                break

    return a

lis = is_prime(M)
b = 0

if D <22:
    print(0)
else:
    for m in lis:
        for i in range(22, D+1):
            b1 = i%10
            b10 = i//10
            if b1 != 1 and b10 != 1 and b1 * b10 == m:
                b +=1
    print(b)

   

Measured memory_bytes: 3064