akhauriyash/Code-Regression huggingface dataset:
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N;
            N = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
            int[] A = new int[str.Length];
            for (int i = 0; i < str.Length; ++i)
            {
                A[i] = int.Parse(str[i]);
            }
            str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
            int[] B = new int[str.Length];
            for (int i = 0; i < str.Length; ++i)
            {
                B[i] = int.Parse(str[i]);
            }
            str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
            int[] C = new int[str.Length];
            for (int i = 0; i < str.Length; ++i)
            {
                C[i] = int.Parse(str[i]);
            }

            int pre = -1;
            int saticefied = 0;
            for (int i = 0; i < N; ++i)
            {
                if (pre == (A[i] - 1))
                    saticefied = saticefied + B[A[i] - 1] + C[pre - 1];
                else
                    saticefied = saticefied + B[A[i] - 1];
                pre = A[i];
            }


            Console.WriteLine("{0}", saticefied);//改行付き出力
        }
    }
}


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

int main(){
  char a;cin>>a;
  for(int i=0;i<3;i++){
    char b;cin>>b;
    if(a==b){cout<<"Bad"<<endl;return 0;}
    a=b;
  }
  cout<<"Good"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
using ll = long long;
using ld = long double;
using intpair = pair<int, int>;
const int MOD = 1e9 + 7;
inline int mod (ll a, int m = MOD) { return (a % m + m) % m; }
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((ll)((a) + (b) - 1)/(ll)(b))

signed main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(ALL(a));
    
    int ans = 1; ld ansd = 1;
    for(int i : a){
        ansd *= i;
        if(ansd > 2e18){
            cout << -1 << endl;
            return 0;
        }
        ans *= i;
        if(ans > 1000000000000000000){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3988
#include<stdio.h>
#include<math.h>
int main(){
	double a,b,c,d;
	scanf("%lf %lf %lf %lf",&a,&b,&c,&d);
	printf("%.8lf\n",sqrt(pow(c-a,2.0)+pow((d-b),2.0)));
	return 0;
}


Measured memory_bytes: 2104
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    string S;
    cin >> S;
    rep(i,12){
        cout << S[i];
        if(i==3) cout << " ";
    }
    cout << endl;
}

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)*}
    };

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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        n: usize,
        m: usize,
        lr: [(usize, usize); m],
    }
    let l = lr.iter().map(|item| item.0).max().unwrap();
    let r = lr.iter().map(|item| item.1).min().unwrap();
    if l > r {
        println!("0");
    } else {
        println!("{}", r - l + 1);
    }
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
# define PI           3.14159265358979323846  /* pi */


int main(){
    long k;
    cin >> k;
    string s;
    cin >> s;
    if (s.length() > k)
    {
        for (long i = 0; i < k; i++)
            cout << s[i];
        cout << "...";
    } else
        cout << s;
    return 0;
}

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


public class Main{

     public static void main(String []args){
        Scanner scanner = new Scanner(System.in);
        int d = scanner.nextInt();
        float t =(float) scanner.nextInt();
        int s = scanner.nextInt();
        
        float res = (float)d/s;
        if(res>t)
        System.out.println("No");
        else
        System.out.println("Yes");
        
        
     }
}


Measured memory_bytes: 35708
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ALL(a)  (a).begin(),(a).end()
 
const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;
 
template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}
 
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}





int main(){
    ll n;
    cin >> n;
    ll dig = 1000;
    vector<ll> fivelist_100(2001);
    for (ll i = -dig; i <= dig; i++){
        fivelist_100[i+dig] = i*i*i*i*i;
    }


    // ll minfivenum = 0;
    // for (ll i = 0; i < 100; i++){
    //     if (fivelist_100[i] <n &&fivelist_100[i] >n ){
    //         minfivenum = i;
    //         break;
    //     }
    // }

    // 意外と100*100なら大丈夫では？
    ll ansa,ansb;

    for (ll i = -dig; i <= dig; i++){
        for (ll j = -dig; j <= dig; j++){
            if (fivelist_100[i+dig] - fivelist_100[j+dig] ==n ){
                ansa=i;
                ansb=j;
            }
        }
    }
    

    cout<< ansa << " " << ansb<<endl;
    
    

    
}


Measured memory_bytes: 3656
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define DEBUG 0 
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;


int main(){
    int a[3][3]={};
    rep(i,3){
        rep(j,3){
            cin>>a[i][j];
        }
    }
    int n;
    cin>>n;
    int b[10]={};
    rep(i,n){
        cin>>b[i];
    }

    rep(k,3){
        int cnt=0;
        rep(i,3){
            rep(j,n){
                if(a[k][i]==b[j]){
                    cnt++;
                    break;
                }
            }
        }
        if(cnt==3){
            cout<<"Yes"<<endl;
            return 0;
        }
    }

    rep(k,3){
        int cnt=0;
        rep(i,3){
            rep(j,n){
                if(a[i][k]==b[j]){
                    cnt++;
                    break;
                }
            }
        }
        if(cnt==3){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    int cnt=0;
    rep(i,3){
        rep(j,n){
            if(a[i][i]==b[j]){
                cnt++;
                break;
            }
        }
    }
    if(cnt==3){
        cout<<"Yes"<<endl;
        return 0;
    }
    cnt=0;
    rep(i,3){
        rep(j,n){
            if(a[i][2-i]==b[j]){
                cnt++;
                break;
            }
        }
    }
    if(cnt==3){
        cout<<"Yes"<<endl;
        return 0;
    }

    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
/*
考虑建立虚拟根 R 以后造 prufer 序列（和3776一样）
前 n-s-1 位随便，第 n-s 位是根节点，第 n-s+1 ~ n-1 位都是 R。
直接 dp 一下每个点的决策：
1、不作为根
2、作为根但是不填到 n-s 位去。 
3、作为根且搞定第 n-s 位。 
*/
#include<cstdio>

const int N = 5004, mod = 1000000007;

int n, ans, inv[N], fac[N], ifac[N], F[N][2];

int main()
{
	scanf("%d", &n);
	fac[0] = fac[1] = ifac[0] = ifac[1] = inv[1] = 1;
	for(int i = 2; i <= n; ++i)
	{
		fac[i] = 1ll * i * fac[i - 1] % mod;
		inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod;
		ifac[i] = 1ll * ifac[i - 1] * inv[i] % mod;
	}
	F[0][0] = 1;
	for(int i = 1, d; i <= n; ++i)
	{
		scanf("%d", &d);
		for(int j = i - 1; ~j; --j)
		{
			if(d >= 2)
				F[j + 1][0] = (F[j + 1][0] + 1ll * F[j][0] * ifac[d - 2]) % mod,
				F[j + 1][1] = (F[j + 1][1] + 1ll * F[j][1] * ifac[d - 2]) % mod;
			if(d >= 3)
				F[j + 1][1] = (F[j + 1][1] + 1ll * F[j][0] * ifac[d - 3]) % mod;
			F[j][0] = 1ll * F[j][0] * ifac[d - 1] % mod;
			F[j][1] = 1ll * F[j][1] * ifac[d - 1] % mod;
		}
	}
	if(!F[1][1])
		ans = 1ll * fac[n - 1] * inv[2] % mod;
	else for(int j = 3; j < n; ++j)
		ans = (ans + 1ll * F[j][1] * fac[n - j - 1] % mod * fac[j - 1] % mod * inv[2]) % mod;
	printf("%d", ans);
	return 0;
}


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

int main ()
{
    string str;
    getline(cin, str);
    
    for (int i = 0;i < str.size();i++)
    {
        if (65 <= str[i] && str[i] < 91) str[i] += 32;
        else if (97 <= str[i] && str[i] < 123) str[i] -= 32;
    }
    cout << str << endl;
    
    return 0;
}


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

#define ll long long
#define vecll vector<long long>
#define vecs vector<string>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
  ll n, p;
  string str;
  cin >> n;
  pair<string, pair<int, int>> s[n];

  forll(i, 0, n){
	cin >> s[i].first >> s[i].second.first;
	s[i].second.first *= -1;
	s[i].second.second = i + 1;
  }
  sort(s, s + n);
  forll(i, 0, n)
	cout << s[i].second.second << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e6, INF = 1e9 * 1e9 + 10, MOD = 998244353;

ld dp[SIZE];
vector<vector<ll>> gr;
bool used[SIZE];

void bst(int v, int ch) {
	used[v] = 1;

	for (auto to : gr[v]) {
		if (!used[to]) {
			bst(to, ch);
		}
	}

	if (v != ch) {
		ld cur = 0;
		for (auto to : gr[v]) {
			cur += (dp[to] + 1) / ld(gr[v].size());
		}
		dp[v] = cur;
	}
	else {
		if (gr[v].size() == 0) {
			dp[v] = 0;
		}
		else if (gr[v].size() == 1) {
			dp[v] = dp[gr[v][0]] + 1;
		}
		else {
			pair<ld, ll> mx = { -1, -1 };
			for (int i = 0; i < gr[v].size(); i++) {
				mx = max(mx, { dp[gr[v][i]], i });
			}
			ld s = 0;
			for (int i = 0; i < gr[v].size(); i++) {
				if (mx.second != i) s += (dp[gr[v][i]] + 1);
			}
			s /= ld(gr[v].size() - 1);
			dp[v] = s;
		}
	}
}
int main()
{
	fastInp;

	ll n, m;
	cin >> n >> m;

	gr.resize(n);
	for (int i = 0; i < m; i++) {
		ll u, v;
		cin >> u >> v;
		u--; v--;
		gr[u].push_back(v);
	}

	ld ans = INF;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) used[j] = 0;
		bst(0, i);
		ans = min(ans, dp[0]);
	}
	cout.precision(8);
	cout << ans;
	return 0;
}

// 192 / 216 - 8 / 9
// 192 / 8

// 54 / 72 - 3 / 4
// 54 / 6



Measured memory_bytes: 5880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(ll i=0;i<N;++i)
const ll INF = 1LL<<60;

int main(){
    ll N; cin >> N;
    map<char,ll> mp;
    rep(i,N){
        string s; cin >> s;
        mp[s[0]]++;
    }

    ll ans = 0; bool ok = false;
    char c[5] = {'M','A','R','C','H'};
    for(int bit = 0;bit < (1<<5);bit++){
        ll cnt = 0;
        vector<ll> index;
        for(int i = 0;i < 5;i++){
            if(bit & (1<<i)){
                cnt++;
                index.push_back(i);
            }
        }
        ll tmp = 1;
        if(cnt == 3){
            for(auto it : index){
                tmp *= mp[c[it]];
            }
            if(tmp){
                ok = true;
                ans += tmp;
            }
        }
    }
    if(!ok) ans = 0;
    cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
t=1
a=[]
x=[]
while True:
    if n<=(26**t-1)*26//25:
        break
    t+=1


n=n-(26**(t-1)-1)*26//25-1
for i in range(t-1,0,-1):
    a.append(n//(26**i))
    n=n%(26**i)
a.append(n)

for i in range(len(a)):
    x.append(chr(a[i]+97))
print("".join(x))

Measured memory_bytes: 61800
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans = Math.min(n * a,b);
        System.out.println(ans);
    } 
}

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

#define int long long
#define endl "\n"
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define IN freopen("input.txt","r",stdin);
#define OUT freopen("output.txt","w",stdout);

const int N = 2e5 + 5;


int32_t main()
{
    IOS;
    int n,k;
    cin >> n >> k;
    vector<int>a(n);
    for(int &e:a)
        cin >> e;
    sort(a.begin(),a.end());
    int cnt=0;
    for(int i=0;i<k;i++){
        cnt += a[i];
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3660
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
$hh = {}
while l = $stdin.gets do
  if lc == 0
  else
    tmp = l.chomp.split("").sort.join
    $hh[tmp] = 0 if $hh[tmp] == nil
    $hh[tmp] += 1
  end
  lc += 1
end

ans = 0
$hh.each do |k, v|
  if v >= 2
    ans += v*(v-1)/2
  end
end

puts ans


Measured memory_bytes: 18556
#include<stdio.h>
#include<string.h>
int main()
{
    char a[100];
    while(gets(a)!=NULL)
    {
        int i,max=0,count=0;
        for(i=0;i<=strlen(a);i++)
        {
            if(a[i]=='A'||a[i]=='C'||a[i]=='G'||a[i]=='T')
                count++;
            else
            {
                if(max<count)
                {
                    max=count;
                    count=0;
                }

            }
        }
        printf("%d\n",max);
    }

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const ll INF=100000000000000001;
const double PI=3.141592653589;

vector<P> a(25);

int main(){
  int n; cin>>n;
  rep(i,n){
    cin>>a[i].first;
  }
  rep(i,n){
    cin>>a[i].second;
  }
  int ans=-1;
  for(int bit=0;bit<(1<<n);bit++){
    int x=0;
    int y=0;
    // cout<<bitset<8>(bit)<<endl;
    rep(i,n){
      if((bit&(1<<i))!=0){
        x+=a[i].first;
        y+=a[i].second;
      }
    }
    // cout<<x<<" "<<y<<endl;
    ans=max(ans,x-y);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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 (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin >> n >> m;
	ll sum = m;
	ll p;
	cin >> p;
	REP(i, n - 1) {
		ll x;
		cin >> x;
		sum += min<ll>(m, x - p);
		p = x;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <cstdio>
int main() {
    int N;
    char s[100];
    scanf("%d", &N);
    scanf("%s", s);
    int r_count = 0, b_count = 0;
    for (int i = 0; i < N; i++)
    {
        if(s[i] == 'R') {
            r_count++;
        } else {
            b_count++;
        }
    }

    if (r_count > b_count) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}

Measured memory_bytes: 256
var
	i,l,r,mid,n:longint;
	a:array[1..1000001] of longint;

function check(k:longint):longint;
var	i:longint;
begin
	if ((a[n-1]<=k)and(a[n]<=k))or((a[n+1]<=k)and(a[n]<=k)) then exit(0);
	if ((a[n-1]>k)and(a[n]>k))or((a[n+1]>k)and(a[n]>k)) then exit(1);
	for i:=1 to n-1 do begin
		if ((a[n-i-1]<=k)and(a[n-i]<=k))or((a[n+i+1]<=k)and(a[n+i]<=k)) then exit(0);
		if ((a[n-i-1]>k)and(a[n-i]>k))or((a[n+i+1]>k)and(a[n+i]>k)) then exit(1);
	end;
	if a[1]>k then exit(1) else exit(0);
end;

begin
	readln(n);
	for i:=1 to 2*n-1 do read(a[i]);
	l:=1;
	r:=2*n-1;
	while l<r-1 do begin
		mid:=(l+r) shr 1;
		//writeln(l,' ',r);
		if check(mid)=0 then begin 
			//writeln(mid);
			r:=mid 
		end 
		else l:=mid;
	end;
	writeln(r);
end.

Measured memory_bytes: 896
import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))
heapq.heapify(a)
lst = []
for _ in range(m):
    b, c = map(int, input().split())
    lst.append((b, c))

lst = sorted(lst, key = lambda x: -x[1])
flag = False
for b, c in lst:
    for _ in range(b):
        min_num = heapq.heappop(a)
        if min_num < c:
            heapq.heappush(a, c)
        else:
            heapq.heappush(a, min_num)
            flag = True
            break
    if flag:
        break

print(sum(a))


Measured memory_bytes: 26488
main(){
  int a,b,c,d=0,e=0;
  while(scanf("%d,%d,%d",&a,&b,&c)!=-1){
    d+=a*a+b*b==c*c;
    e+=a==b;
  }
  printf("%d\n%d\n",d,e);
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define pb push_back
#define csl ios_base::sync_with_stdio(false); cin.tie(NULL)
typedef long long ll;
#define reps(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define rreps(i,a,b) for(ll i=ll(a);i>=ll(b);--i)
#define mi map<int,int>
#define rep(i,b) for(ll i=0;i<ll(b);i++)
typedef vector<long long> vll;
typedef vector<pair<int,int>> vii;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int main()
{
    csl;
    string s,t;
    cin >> s >> t;
    int ans = t.size();
    for(int i=0;i<=s.size()-t.size();i++)
    {
        int fi = 0;
        for(int j=0;j<t.size();j++)
        {
            if(t[j]!=s[i+j])
                fi++;
        }
        ans = min(ans,fi);
    }

    cout << ans << endl;
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
template<int MOD> struct ModInt {
    static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
    ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    int get() const { return (int)x; }
    ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
    ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
    ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
    ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0;
        while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
        return ModInt(u); }
    bool operator==(ModInt that) const { return x == that.x; }
    bool operator!=(ModInt that) const { return x != that.x; }
    ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; };
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
    ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }
typedef ModInt<1000000007> mint;
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N; ll A[301010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];

	mint ans = 0;
	rep(b, 0, 60) {
		ll msk = 1LL << b;

		int zero = 0, one = 0;
		rep(i, 0, N) {
			if (A[i] & msk) one++;
			else zero++;
		}

		ans += mint(msk) * zero * one;
	}
	cout << ans << endl;
}







Measured memory_bytes: 2560
#include <stdio.h>
int main(int argc, char *argv[])
{
	int a[10],i,n,all,ero,o;
	while(scanf("%d",&n) != EOF){
		o = 0;
		all = 1;
		ero = 1;
		for(i = 0; i < n; i++){
			scanf("%d",&a[i]);
			if(a[i] % 2 == 0)o++;
		}
		for(i = 0; i < n; i++){
			all *= 3;
		}
		for(i = 0; i < o; i++){
			ero *= 2;
		}
		all -= ero;
		printf("%d\n",all);
	}
	return 0;
}

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

string A, B; int N, cl[1 << 18], cr[1 << 18], cp[1 << 18];

int check(string V, string W, int pos) {
	for (int i = 0; i <= 3 * N; i++) { cl[i] = -(1 << 30); cr[i] = (1 << 30); cp[i] = 0; }
	for (int i = 0; i < 3 * N; i++) { if (W[i%N] == '1') { cl[i] = i; cr[i] = i; } }
	for (int i = 1; i <= 3 * N; i++) cl[i] = max(cl[i], cl[i - 1]);
	for (int i = 3 * N - 1; i >= 0; i--) cr[i] = min(cr[i], cr[i + 1]);

	int sum = 0, cnt = 0;
	for (int i = N; i < 2 * N; i++) {
		if (V[i%N] == '0') continue;
		int vl = i - cl[i], vr = cr[i] - i; cnt++; if (vl == 0) continue;
		cp[vl - 1] = max(cp[vl - 1], vr);
	}
	for (int i = N; i >= 0; i--) cp[i] = max(cp[i], cp[i + 1]);

	int ans = (1 << 30);
	for (int i = N; i >= 0; i--) {
		int vl = i, vr = cp[i];
		if (pos < 0) vl = max(vl, -pos);
		if (pos > 0) vr = max(vr, pos);
		ans = min(ans, (vl + vr) * 2 - abs(pos));
	}
	return ans + cnt;
}

int main() {
	cin >> A >> B; N = A.size(); bool flag = false;
	for (int i = 0; i < B.size(); i++) { if (B[i] == '1') flag = true; }
	if (A == B) { cout << "0" << endl; return 0; }
	if (flag == false) { cout << "-1" << endl; return 0; }

	int minx = (1 << 30);
	for (int i = -N; i <= N; i++) {
		string V = ""; for (int j = 0; j < N; j++) { if (A[j] != B[(j + i + N) % N]) V += "1"; else V += "0"; }
		minx = min(minx, check(V, B, i));
	}
	cout << minx << endl;
	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#define INF 1e9
using namespace std;

class data{
public:
	int x,y,t;
	data(){}
	data(int xx,int yy,int tt){
		x=xx;
		y=yy;
		t=tt;
	}
};

int dx[6]={0,1,1,0,-1,-1};
int dy[2][6]={
	1,0,-1,-1,-1,0,
	1,1,0,-1,0,1
};
int sx,sy,gx,gy;
int n;
int lx,ly;
int fie[201][201];
int dp[201][201][6];

int bfs(){
	for(int i=0;i<=200;i++){
		for(int j=0;j<=200;j++){
			for(int k=0;k<6;k++){
				dp[i][j][k]=INF;
			}
		}
	}
	queue<data> que;
	que.push(data(sx+100,sy+100,0));
	dp[sx+100][sy+100][0]=0;
	while(que.size()){
		queue<data> que2;
		while(que.size()){
			data q=que.front();
			que.pop();
			if(q.x-100==gx && q.y-100==gy)return dp[q.x][q.y][q.t];
			que2.push(q);
			bool flag=true;
			while(flag){
				flag=false;
				int sdir=abs((q.x-100)*(q.y-100)*q.t)%6;
				int nx=q.x+dx[sdir],ny=q.y+dy[q.x%2][sdir];
				if(nx>=100-lx && nx<=lx+100 && ny>=100-ly && ny<=100+ly){
					if(fie[nx][ny]!=-1 && dp[nx][ny][(q.t+1)%6]==INF){
						flag=true;
						if(nx-100==gx && ny-100==gy)return dp[q.x][q.y][q.t];
						que2.push(data(nx,ny,(q.t+1)%6));
						dp[nx][ny][(q.t+1)%6]=dp[q.x][q.y][q.t];
					}
				}
				q.x=nx;
				q.y=ny;
				q.t=(q.t+1)%6;
			}
		}
		while(que2.size()){
			data q=que2.front();
			que2.pop();
			if(dp[q.x][q.y][(q.t+1)%6]==INF){
				dp[q.x][q.y][(q.t+1)%6]=dp[q.x][q.y][q.t]+1;
				que.push(data(q.x,q.y,(q.t+1)%6));
			}
			for(int i=0;i<6;i++){
				int nx=q.x+dx[i],ny=q.y+dy[q.x%2][i];
				if(nx>=100-lx && nx<=lx+100 && ny>=100-ly && ny<=100+ly){
					if(fie[nx][ny]!=-1 && dp[nx][ny][(q.t+1)%6]==INF){
						dp[nx][ny][(q.t+1)%6]=dp[q.x][q.y][q.t]+1;
						que.push(data(nx,ny,(q.t+1)%6));
					}
				}
			}
		}
	}
	return -1;
}

int main(void){
	scanf("%d%d%d%d",&sx,&sy,&gx,&gy);
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int x,y;
		scanf("%d %d",&x,&y);
		fie[x+100][y+100]=-1;
	}
	scanf("%d%d",&lx,&ly);
	printf("%d\n",bfs());
	return 0;
}

Measured memory_bytes: 2196
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int N = scan.nextInt();
			int[]t = new int[N+1];
			int[]x = new int[N+1];
			int[]y = new int[N+1];
			boolean possi = true;
			
			for(int i = 1;i<=N;i++) {
				t[i] = scan.nextInt();
				x[i] = scan.nextInt();
				y[i] = scan.nextInt();
			}
			
			for(int i = 0;i<N;i++) {
				int sa = t[i+1]-t[i];
				
				//System.out.println(sa);
				
				int saitan = Math.abs(x[i+1]-x[i])+Math.abs(y[i+1]-y[i]);
				//System.out.println(saitan);
				
				
				if(sa<saitan) {
					possi = false;
					break;
				}
				
				if((sa-saitan)%2==1) {
					possi = false;
					break;
				}
				
				
				
			}
			
			
			System.out.println(possi?"Yes":"No");
			
			
		}	
	}
}


Measured memory_bytes: 91784
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MOD = 1e9+7;
const double pi = M_PI;

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

    int a,b,h,m;
    cin >> a >> b >> h >> m;

    double x1,y1;
    x1 = a*cos(2.0*pi*m/12.0/60.0+2.0*pi*h/12.0);
    y1 = a*sin(2.0*pi*m/12.0/60.0+2.0*pi*h/12.0);

    double x2,y2;
    x2 = b*cos(2.0*pi*m/60.0);
    y2 = b*sin(2.0*pi*m/60.0);

    double x,y;
    x = x1 - x2;
    y = y1 - y2;

    double ans = sqrt(x*x+y*y);

    printf("%.10lf\n",ans);

    return 0;
}

Measured memory_bytes: 4088
#!/usr/bin/env python
import sys

def _s(): return sys.stdin.readline().strip()
def _i(): return int(sys.stdin.readline().strip())

n= _i()
s= _s()

def f(c,n):
    return chr((ord(c)-65+n)%26+65)

ans=""
for c in s: ans += f(c,n)
print(ans)


Measured memory_bytes: 41580
#include <stdio.h>

int main(void)
{
	int n;
	int i;
	int count;
	
	while (scanf("%d", &n)){
		if (n == 0){
			break;
		}
		
		count = 0;
		while (n > 1){
			if (n % 2 == 0){
				n /= 2;
				count++;
			}
			else if (n % 2 != 0){
				n = n * 3 + 1;
				count++;
			}
		}
		printf("%d\n", count);
	}
	
	return (0);
}

Measured memory_bytes: 600
#from collections import deque
a,b,k=input().split()
a,b,k=int(a),int(b),int(k)

#多分両端からアクセスしないとTLEになる
'''
for i in range(b-a+1):
    if i<k:
        print(a+i)
    elif i>b-a-k:
        print(a+i)
'''

d=[]
if a+(k-1)>b:
    k=b-a+1
for i in range(k):
        d.append(a+i)
        d.append(b-i)
#辞書もsort可能
for i in sorted(set(d)):
    print(i)


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

int main() {
  int N;
  string S;
  cin >> N;
  cin >> S;
  if (N%2==1){
  cout << "No" << endl;
  return 0;
  }
  for (int i=0 ; i<N/2 ; i++){
  if (S.at(i)==S.at(N/2+i))
  continue;
  cout << "No" << endl;
  return 0;
  }
  cout << "Yes" << endl;
  }


Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let (n, k, x, y) = {
        let mut buf = String::new();
        std::io::stdin().read_to_string(&mut buf).unwrap();
        let mut iter = buf.split_whitespace();
        let n: usize = iter.next().unwrap().parse().unwrap();
        let k: usize = iter.next().unwrap().parse().unwrap();
        let x: usize = iter.next().unwrap().parse().unwrap();
        let y: usize = iter.next().unwrap().parse().unwrap();
        (n, k, x, y)
    };

    if n <= k {
        print!("{}", n * x);
    } else {
        print!("{}", k * x + (n - k) * y);
    }
}

Measured memory_bytes: 4352
N, M = gets.split.map(&:to_i)
A = N.times.map { gets.split.map(&:to_i) }

open_event = Array.new(M + 1, true)
ans = N

(M - 1).times do
  counter = Hash.new(0)

  N.times do |i|
    event_id = A[i].find { |a| open_event[a] }
    counter[event_id] += 1
  end

  stop_event_id, max_cnt = counter.max_by { |k, v| v }

  ans = max_cnt if ans > max_cnt

  open_event[stop_event_id] = false
end

puts ans


Measured memory_bytes: 3068
s = input()
odd = ["R","U","D"]
even = ["L","U","D"]
cnt = 0
for i in s[::2]:
    if i in odd:
        cnt += 1
for j in s[1::2]:
    if j in even:
        cnt += 1
        
print("Yes") if cnt == len(s) else print("No")

Measured memory_bytes: 9084
using System;

public class Test
{
    public static void Main()
    {
        int a, b, c, x, n=0;
        string[] str = Console.ReadLine().Split(' ');
        a = int.Parse(str[0]);
        b = int.Parse(str[1]);
        c = int.Parse(str[2]);

        for (x = a; x <= b; x++)
        {
            if (c % x == 0)
            {
                n += 1;
            }
        }

        Console.WriteLine("{0}", n);

    }
}


Measured memory_bytes: 17976
dish = [0]*5
time_mod = [0]*5
for i in range(5):
    dish[i] = int(input())
    time_mod[i] = dish[i] % 10
    if time_mod[i] == 0:
        time_mod[i] = 10
#print(time_mod)
min_time_mod = min(time_mod)
last = time_mod.index(min_time_mod)
ans = 0
for i in range(5):
    if i != last:
        ans += dish[i] + (10 - time_mod[i])
    elif i == last:
        ans += dish[i]
print(ans)

Measured memory_bytes: 38384
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<lint, lint> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI=3.141592653589793238462643383279;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	if (!b)return T(1);
	if (b & 1)return mypow(a, b - 1) * a;
	T memo = mypow(a, b >> 1);
	return memo * memo;
}
lint modpow(lint a, lint b, lint m) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	lint memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size() - 1)std::cout << vec[i] << " ";
	std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
int main(){
	int a,b,c,d,e;
	std::cin>>a>>b>>c>>d>>e;
	if(a==0)std::cout<<1;
	else if(b==0)std::cout<<2;
	else if(c==0)std::cout<<3;
	else if(d==0)std::cout<<4;
	else std::cout<<5;
	std::cout<<std::endl;
	return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}






int main(){
	ll D;
	cin >> D;
	vector<ll> c(26);
	FOR(i,0,26) cin >> c[i];
	vector<ll> last(26,0),s(26);



	FOR(i,0,D){
		FOR(j,0,26) cin >> s[j];
		ll score=-INF,res;
		ll sc = 0;
		FOR(j,0,26){
			sc -= c[j]*(i+1-last[j]);
		}
		FOR(j,0,26){
			ll sc_j = c[j]*(i+1-last[j]) + s[j];
			if(sc+sc_j >= score){
				score = sc + sc_j;
				res = j;
			}
		}
		last[res] = i+1;
		cout << res+1 << endl;
	}

}



Measured memory_bytes: 3636
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

int n,arr[55],ans;

int main()
{
	scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&arr[i]);
    for(int i=1;i<=n;i++)
    	for(int j=i+1;j<=n;j++)
        	ans+=arr[i]*arr[j];
   	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pii pair<int,int>
#define pb push_back
#define INF INT_MAX
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)
#define iso ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
int main()
{
    iso;
    int n;
    cin>>n;
    priority_queue<int>p;
    int ar[n];
    f(i,0,n)
    {
        int t;
        cin>>t;
        ar[i]=t;
        p.push(t);
    }
    int f=p.top();
    p.pop();
    int s=p.top();
    for(int i=0;i<n;i++)
    {
        if(ar[i]==f)
            cout<<s<<"\n";
        else
            cout<<f<<"\n";
    }
}


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

#define REP(i, s, n) for(int i = s; i < n; ++i)
#define rep(i, n)		 REP(i, 0, n)
#define SORT(c)			 sort((c).begin(), (c).end())
#define IINF	INT_MAX
#define LLINF LLONG_MAX

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

/*
 * class Node {
 * public:
 * int num;
 * int index;
 * bool operator<(const Node& b) const {
 *  if(num < b.num) return (num < b.num);
 *  else return index > b.index;
 * }
 *
 * Node(){
 *  num=0; index=0;
 * }
 * Node(int n, int i) : num(n), index(i){
 * }
 * };
 */

#define DEBUG 0

int main() {
		int n;
		ll	ans = 1;
		cin >> n;
		vector <ll>		mount(n);
		vector <bool> fix(n, false);
		ll pre = 0;
		rep(i, n) {
				ll t;
				cin >> t;
				if(pre != t) fix[i] = true;
				mount[i] = pre = t;
		}

    if(DEBUG) {
				rep(i, n) cout << mount[i] << "\t";
				cout << endl;
				rep(i, n) cout << fix[i] << "\t";
				cout << endl;
		}

    vector<ll> a(n);
    rep(i, n) cin >> a[i];

		pre = 0;
		for(int i = n - 1; i >= 0; i--) {
				if(pre != a[i]) {// fix
						bool endflag = false;
						if(fix[i] && mount[i] != a[i]) endflag = true;
						if(mount[i] < a[i]) endflag = true;

						if(endflag) {
								cout << 0 << endl;
								return 0;
						}

						fix[i]	 = true;
						mount[i] = a[i];
				}
				else mount[i] = min(mount[i], a[i]);

				pre = a[i];
		}

		if(DEBUG) {
				rep(i, n) cout << mount[i] << "\t";
				cout << endl;
				rep(i, n) cout << fix[i] << "\t";
				cout << endl;
		}

		rep(i, n) {
				if(!fix[i]) ans = (ans * mount[i]) % 1000000007;
		}

		cout << ans << endl;

		return 0;
}


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

int main(){
    int N,M,C,i,j,A,Total,count;
    int B[20]={0};
    count = 0;
    cin >> N >> M >> C;
    for(i=0;i<M;i++){
        cin >> B[i];
    }
    for(j=0;j<N;j++){
        Total = 0;
        for(i=0;i<M;i++){
            cin >> A;
            Total+=A*B[i];
        }
        if(Total+C>0){
            count++;
        }
    }

    cout << count << endl;
    return 0;
}

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

int main() {
	int num;
	string text;
	int len;
	cin >> num;
	cin >> text;
	len=text.length();
	if (len <= num) {
		cout << text;
	}
	else {
		cout << text.substr(0, num) + "...";
	}
	return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;
using T = std::tuple<int,int,int>;

struct SegmentTree{
    int numLeaves;
    std::vector<ll> data;
 
    SegmentTree(int n){
        numLeaves = 1;
        while(numLeaves < n){
            numLeaves *= 2;
        }
 
        data.resize(numLeaves * 2);
        std::fill(data.begin(), data.end(), 0);
    }
 
    void add(int k, ll v){
        k += numLeaves;
        data[k] += v;
 
        while(k > 1){
            k /= 2;
            data[k] = data[k*2] + data[k*2+1];
        }
    }
 
    ll sum(int l, int r){
        l += numLeaves;
        r += numLeaves;
 
        ll s = 0;
 
        for(;l<r;l/=2,r/=2){
            if(l & 1){
                s += data[l];
                l += 1;
            }
 
            if(r & 1){
                r -= 1;
                s += data[r];
            }
        }
 
        return s;
    }
 
    // [0, i] の和が v 以上である最小の i を計算する
    int lower_bound(int v){
        int index = 0;
        int k = 1;
        ll s = 0;
 
        while(k < numLeaves){
            index *= 2;
 
            if(s + data[k*2] < v){
                index += 1;
                s += data[k*2];
                k = k * 2 + 1;
            }else{
                k = k * 2;
            }
        }
 
        return index;
    }
 
    ll at(int k){
        return data[k + numLeaves];
    }
};

int Q;
std::vector<T> queries;
std::vector<int> v;

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

    std::cin >> Q;

    for(int i=0;i<Q;++i){
        int t;
        std::cin >> t;

        if(t == 1){
            int a, b;
            std::cin >> a >> b;

            queries.emplace_back(t, a, b);
            v.emplace_back(a);
        }else{
            queries.emplace_back(t, -1, -1);
        }
    }

    std::sort(v.begin(), v.end());
    v.erase(std::unique(v.begin(), v.end()), v.end());

    ll B = 0, n = 0;
    SegmentTree seg(200100), seg2(200100);

    for(int i=0;i<Q;++i){
        int t, a, b;
        std::tie(t, a, b) = queries[i];

        int ai = std::lower_bound(v.begin(), v.end(), a) - v.begin();

        if(t == 1){
            seg.add(ai, 1);
            seg2.add(ai, a);
            B += b;
            n += 1;
        }else{
            int mi = seg.lower_bound((n + 1) / 2),
                m = v[mi];
            ll c1 = seg.sum(0, mi),
               s1 = seg2.sum(0, mi),
               c2 = seg.sum(mi + 1, v.size()),
               s2 = seg2.sum(mi + 1, v.size());

            ll res = (1ll * m * c1 - s1) + (1ll * s2 - 1ll * m * c2) + B;
            std::cout << m << " " << res << std::endl;
        }
    }
}


Measured memory_bytes: 14480
s = list(input())
ans = [-1, -1]

for i in range(len(s)):
    if i < len(s)-2:
        if s[i] == s[i+1] or s[i] == s[i+2]:
            ans = [i+1, i+3]
            break
    elif i == len(s)-2:
        if s[i] == s[i+1]:
            if len(s) == 2:
                ans = [i+1, i+2]
            else:
                ans = [i, i+2]
            break

print(" ".join(map(str, ans)))


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

int n,t;
pair<int,int> a[3010];
int dp[3010][6010];
int ans;

int main() {
    cin >> n >> t;
    for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
    sort(a,a+n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < t; j++) {
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            dp[i + 1][j + a[i].first] = max(dp[i + 1][j + a[i].first], dp[i][j] + a[i].second);
            ans = max(ans, dp[i+1][j]);
            ans = max(ans, dp[i+1][j + a[i].first]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 70656
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

#define int long long

inline int read () {
	int ret = 0, t = 1;
	char c = getchar();
	while ((c < '0' || c > '9') && c != '-') c = getchar();
	if (c == '-') t = -1, c = getchar();
	while (c >= '0' && c <= '9') ret = ret * 10 + c - '0', c = getchar();
	return ret * t;
}

int h, n;

int dp[20020] = {};

int w[1010], c[1010];

signed main () {
	h = read(), n = read();
	int i, j;
	for (i = 1; i <= n; i++) w[i] = read(), c[i] = read();
	for (i = 1; i <= 20000; i++) {
		dp[i] = 1e9 + 7;
		for (j = 1; j <= n; j++) if (i - w[j] >= 0) dp[i] = min(dp[i], c[j] + dp[i - w[j]]);
	}
	int ans = 1e9 + 7;
	for (i = h; i <= 20000; i++) ans = min(ans, dp[i]);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1016
#!/usr/bin/env python3

N = int(input())
H = list(map(int, input().split()))
ans = 0
suc = 0
for i in range(1, N):
    if H[i-1] >= H[i]:
        suc += 1
    else:
        ans = max(ans, suc)
        suc = 0
ans = max(ans, suc)
print(ans)


Measured memory_bytes: 15020
import sys
input = sys.stdin.readline
N = int(input())
counta = 0
ans = 1
def hantei(i) :
    count = 0
    while True :
        if i % 2 == 0 :
            count+=1
            i = i // 2
        else :
            break
    return count
for i in range(1,N+1) :
    k = hantei(i)
    if k > counta :
        ans = i
        counta = k
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#define NUM 25

typedef struct Node{
  int parent,left,right;
}Node;

Node T[NUM];
int n,A[NUM],B[NUM];

void depth(int a, int b){
  if(a == -1)
    return;

  A[a] = b;
  depth(T[a].left, b+1);
  depth(T[a].right, b+1);
}

int height(int a){
  int h1=0,h2=0;

  if(T[a].left != -1)
    h1 = height(T[a].left)+1;

  if(T[a].right != -1)
    h2 = height(T[a].right)+1;

  if(h1 > h2)
    return B[a] = h1;

  else
    return B[a] = h2;
}

int sibling(int a){
  if(T[a].parent == -1)
    return -1;

  if(T[T[a].parent].left != a && T[T[a].parent].left != -1)
    return T[T[a].parent].left;

  if(T[T[a].parent].right != a && T[T[a].parent].right != -1)
    return T[T[a].parent].right;

  return -1;
}

void print(int a){
  int d = 0;

  printf("node %d: parent = %d, sibling = %d, ", a, T[a].parent, sibling(a));

  if(T[a].left != -1)
    d++; 

  if(T[a].right != -1)
    d++;

  printf("degree = %d, depth = %d, height = %d, ", d, A[a], B[a]);


  if(T[a].parent == -1)
    printf("root\n");

  else if(T[a].left == -1 && T[a].right == -1)
    printf("leaf\n");

  else
    printf("internal node\n");
}

int main(){
  int a,l,ri,ro,i;

  scanf("%d", &n);

  for(i = 0; i < n; i++)
    T[i].parent = -1;

  for(i = 0;i < n; i++){
    scanf("%d%d%d", &a, &l, &ri);

    T[a].left = l;
    T[a].right = ri;

    if(l != -1)
      T[l].parent = a;

    if(ri != -1)
      T[ri].parent = a;
  }

  for(i = 0; i < n; i++){
    if(T[i].parent == -1)
      ro = i;
  }

  depth(ro, 0);
  height(ro);

  for(i = 0; i < n; i++)
    print(i);

  return 0;
}

Measured memory_bytes: 612
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if a <= 5 {
		fmt.Println(0)
		return
	}
	if a <= 12 {
		fmt.Println(b / 2)
		return
	}
	fmt.Println(b)
}


Measured memory_bytes: 512