akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007

int main() {
    int N,M;
    cin>>N>>M;
    vector<ll> A(N);
    for(int i=0;i<N;i++) cin>>A[i];
    map<ll,ll> nums;
    ll sum=0;
    nums[sum]++;
    for(int i=0;i<N;i++){
        sum+=A[i];
        nums[sum%M]++;
    }
    ll res=0;
    for(map<ll,ll>::iterator it=nums.begin();it!=nums.end();it++){
        res+=it->second*(it->second-1)/2;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 4992
N, M = map(int, input().split())
ans = 1
n = 1
while n*n <= M:
    if M % n == 0:
        if M//n >= N:
            ans = max(n, ans)
        m = M//n
        if M//m >= N:
            ans = max(m, ans)
    n += 1
print(ans)


Measured memory_bytes: 38640
#include <bits/stdc++.h>
// until dimension reduction.

using namespace std;
typedef long long LL;

#define LOG(...) fprintf (stderr, __VA_ARGS__)
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fll;

string s[7] = {"MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};

string t; 
int main() {
#ifdef LiM_817
	freopen ("input.txt", "r", stdin);
	double cl = clock();
#endif

	cin >> t;
	int pos = -1; 
	for (int i = 0; i < 7; i++) if (s[i] == t) {
		pos = i;
		break;
	}
	
	if (pos == 6) cout << 7 << endl;
	else cout << 6-pos << endl;
#ifdef LiM_817
	cerr << fixed << setprecision(2) << "Time ellapsed: " << ((double)(clock() - cl) / CLOCKS_PER_SEC) << "s\n";
#endif
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n)
	fmt.Scan(&m)
	a := make([]int, m, m)
	for i := 0; i < m; i++ {
		a[i] = 1
	}
	for i := 0; i < n; i++ {
		b := make([]int, m, m)
		var k int
		fmt.Scan(&k)
		for j := 0; j < k; j++ {
			var c int
			fmt.Scan(&c)
			b[c - 1] = 1
		}
		for j := 0; j < m; j++ {
			a[j] *= b[j]
		}
	}

	answer := 0
	for i := 0; i < m; i++ {
		answer += a[i]
	}
	fmt.Println(answer)
}


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

#define debug(x) cout << #x << " = " << x << endl;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;
const ll mod = 1e9 + 7;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

ll exp(ll a, ll b)
{
  ll ans = 1;
  while(b)
  {
    if(b & 1)
      ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}

const int maxn = 5e6  + 5;
ll fat[maxn], inv[maxn];

ll C(int n, int k)
{
  if(n < k) 
    return 0;
  if(n < 0 || k < 0) 
    return 0;
  return (((fat[n] * inv[k]) % mod) * inv[n - k]) % mod;
}

void initFactorials()
{
  fat[0] = 1;
  inv[0] = 1;
  for(int i = 1; i < maxn; i++)
  {
    fat[i] = (i * fat[i-1]) % mod;
    inv[i] = exp(fat[i], mod - 2);
  }
}

ll cost(int i, int c1, int c2)
{
  ll c = (C(i + c2 + 1 , c2) - C(i + c1, c1 - 1) + mod) % mod;
  return c;
}

int main()
{
  initFactorials();
  ios::sync_with_stdio(false);
  int r1, r2, c1, c2;
  cin >> r1 >> c1 >> r2 >> c2;
  ll ans = 0;
  for(int i = r1; i <= r2; i++)
  {
    ans += cost(i, c1, c2);
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 81728
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N){
        cin >> a[i];
    }
    SORT(a);
    int ans = 0;
    REP(i, N){
        int j = upper_bound(ALL(a), a[i]) - a.begin() - i;
        if(j < a[i]){
            ans += j;
        }else if(j > a[i]){
            ans += j - a[i];
        }
        i += (j-1);
    }
    pr(ans);
}

Measured memory_bytes: 640
#include<set>
#include<cstdio>
#include<cctype>
#include<string>
inline int Read(){
	char a;
	int b;
	while(!isdigit(a=getchar()));
	b=a^'0';
	while(isdigit(a=getchar()))b=(((b<<2)+b)<<1)+(a^'0');
	return b;
}
int main()
{
	std::multiset<std::string> set;
	for(int i=Read();i;i--)set.insert("a");
	for(int i=Read();i;i--)set.insert("b");
	for(int i=Read();i;i--)set.insert("c");
	while(set.size()>1){
		std::string s=*set.begin(),t=*set.rbegin();
		set.erase(set.lower_bound(s));
		set.erase(set.lower_bound(t));
		set.insert(s+t);
	}
	printf("%s\n",(*set.begin()).c_str());
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);
        int a = in.nextInt(), b = in.nextInt(), c = in.nextInt();


        if(a < b && b < c)System.out.println("Yes");
        else System.out.println("No");
    }
}


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

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		
		while(true){
			int n=Integer.parseInt(in.next());
			if(n==0)break;

			List<Integer> A=new ArrayList<>(), B=new ArrayList<>();

			int j=1,s=1;
			while(s<=n){
				A.add(s);
				if(s%2==1)B.add(s);
				j++;
				s=j*(j+1)*(j+2)/6;
			}

			int DP[]=new int[n+1],INF=2000000000;
			for(int i=1;i<=n;i++)DP[i]=INF;

			for(int i=0;i<A.size();i++){
				int t=A.get(i);
				for(int k=0;k+t<=n;k++){
					DP[k+t]=Math.min(DP[k]+1, DP[k+t]);
				}
			}
			
			PrintWriter out=new PrintWriter(System.out);
			out.print(DP[n]+" ");
			
			for(int i=1;i<=n;i++)DP[i]=INF;
			
			for(int i=0;i<B.size();i++){
				int t=B.get(i);
				for(int k=0;k+t<=n;k++){
					DP[k+t]=Math.min(DP[k+t], DP[k]+1);
				}
			}
			
			out.println(DP[n]);
			out.flush();
		}
		
	}

}


Measured memory_bytes: 61632
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n;
main()
{
cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a.begin(),a.end());
  cout<<a[n-1]-a[0]<<endl;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: usize,
        lv: [usize; n]
    };

    let res = lv
        .into_iter()
        .combinations(3)
        .filter(|v| {
            let mut v = v.clone();
            v.sort();
            v[0] + v[1] > v[2] && v.iter().collect::<HashSet<_>>().len() == 3
        })
        .count();
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2268
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <string>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,P> pip;
typedef long long ll;
const int inf=(1<<31)-1;
const double pi=acos(-1);

double n;

int main(){
	while(cin>>n){
		if(n<=48) cout<<"light fly"<<endl;
		else if(n<=51) cout<<"fly"<<endl;
		else if(n<=54) cout<<"bantam"<<endl;
		else if(n<=57) cout<<"feather"<<endl;
		else if(n<=60) cout<<"light"<<endl;
		else if(n<=64) cout<<"light welter"<<endl;
		else if(n<=69) cout<<"welter"<<endl;
		else if(n<=75) cout<<"light middle"<<endl;
		else if(n<=81) cout<<"middle"<<endl;
		else if(n<=91) cout<<"light heavy"<<endl;
		else cout<<"heavy"<<endl;
	}
}

Measured memory_bytes: 1220
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<bitset>
using namespace std;
int main(){
	string str;
	cin>>str;
	if(str=="SUN") cout<<7;
	if(str=="MON") cout<<6;
	if(str=="TUE") cout<<5;
	if(str=="WED") cout<<4;
	if(str=="THU") cout<<3;
	if(str=="FRI") cout<<2;
	if(str=="SAT") cout<<1;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int N; string S; cin >> N >> S;

    F0R(i, sz(S)) {
        int X = S[i] - 'A';
        X += N; X %= 26;
        S[i] = ('A' + X);
    }
    cout << S << endl;
	
	return 0;
}
 




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=10;
//i_am_noob
int a,b;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> a >> b;
	print1(a*(a-1)/2+b*(b-1)/2);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef complex<int> cli;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<ut,VI> PQ;
const int SIZE=2*1e5;
const LL INF=1<<30;
const LL p=7+1e9;
LL A[SIZE] ,B[SIZE];
int main(){
	int N;
	cin >> N;
	REP(i,N){
		cin >> A[i];
		B[A[i]]++;
	}	
	LL maxim=0;
	REP(i,SIZE/2+100){
		maxim=max(maxim,B[i]+B[i+1]+B[i+2]);
	}
	cout << maxim << endl;
	return 0;
}

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

int main(){
    int n,v[50],c[50],ans;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    for(int i=0;i<n;i++){
        cin>>c[i];
    }
    for(int i=0;i<n;i++){
        if(v[i]>c[i]){
            ans+=v[i]-c[i];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n,k;
  cin >> n >> k;
  pr(n-k+1);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
signed main(){
	
	string s,t;
	cin>>s;
	for(int i=0;i<s.size();i++){
	    if(s[i]=='0')t+='0';
	    else if(s[i]=='1')t+='1';
	    else if(t.size()!=0) t.pop_back();
	}
	cout<<t<<endl;
}

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

typedef long long int ll;

using namespace std;

ll max(ll a,ll b)
{
	if(a>b)
		return a;
	return b;
}

ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 

int main()
{
	
	ll n,m;
	cin>>n>>m;
	vector <ll> v(n);
	set <int> odd;
	set <int> even;
	map <ll,int> count;
	set <int>::iterator it;
	map <ll,int>::iterator it2;
	for(int i=0;i<n;i++)
	{
		cin>>v[i];
		v[i]/=2;
		if(v[i]%2==0)
			even.insert(v[i]);
		else
			odd.insert(v[i]);
	}

	if(even.size()>0&&odd.size()>0)
	{
		cout<<"0\n";
		return 0;
	}
	set <int> even2;
	while(even.size()>0)
	{
		for(it=even.begin();it!=even.end();it++)
		{
			int x=*(it)/2;
			if(x%2==0)
				even2.insert(x);
			else
				odd.insert(x);

		}
		even=even2;
		even2.clear();
		count[2]+=1;
		if(odd.size()>0&&even.size()>0)
		{
			cout<<"0\n";
			return 0;
		}
	}
	vector <int> primes;
	SieveOfEratosthenes(sqrt(pow(10,9))+1,primes);
	int k=primes.size();
	for(it=odd.begin();it!=odd.end();it++)
	{int x=*it;
		for(int i=0;i<k;i++)
		{
			
			int y=primes[i];
			int c=0;
			while(x>0&&x%y==0)
			{
				x/=y;
				c++;
			}
			if(count[y]<c)
				count[y]=c;

			if(x<=1)
				break;
		}
		if(x>1)
		{
			if(count[x]<1)
				count[x]=1;
		}
	}

	ll lcm=1;

	for(it2=count.begin();it2!=count.end();it2++)
	{
		ll x=it2->first;
		int y=it2->second;
		while(y>0)
		{
			lcm*=x;
			y--;
		}
	}

	ll xyz=m/lcm;
	xyz=(xyz+1)/2;
	cout<<xyz<<endl;



	
	



	return 0;
}


Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>

using namespace std;
using ll = long long int;
using vec = vector<int>;

#define rep(n) for(int i = 0; i < (n); ++i)
#define Sort(a)    sort(a.begin(), a.end())
#define gSort(a)   sort(a.begin(), a.end(), greater<int>())
const int INF = 2147483647;
const ll  MOD = 1000000007;

int main() {
    ll n, k; cin >> n >> k;

    ll ans;
    
    ans = min(n, min(n % k, abs((n % k) - k)));

    cout << ans;
}

Measured memory_bytes: 256
import sys
#from me.io import dup_file_stdin

def price(pack,unit_price,units,off):
    return pack//units*units*unit_price*(1.-off) + pack%units*unit_price

#@dup_file_stdin
def solve():
    while True:
        w = int(sys.stdin.readline())
        if w == 0 :return
        min = max([380*25,550*17,850*10])
        for a in range(0,w//200+1):
            need = w - a*200 
            for b in range(0,need//300+1):
                if((need-b*300)%500!=0):continue
                c = (need-b*300)//500
                p = price(a,380,5,0.2)+price(b,550,4,0.15)+price(c,850,3,0.12)
                if p < min:
                    min = p
        print("{:.0f}".format(min))
solve()

Measured memory_bytes: 7632
n = gets.to_i
array = gets.split.map(&:to_i)

count = 0
array.each_index do |i|
  if i > 0 && i < n-1
    a = [array[i-1], array[i], array[i+1]].sort
    count += 1 if a[1] == array[i]
  end
end

puts count

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;

 
int main() {
    int k,a,b;
    cin >> k >> a >> b;
    bool t=false;
    for (int i=a;i<=b;i++){
        if (i%k==0) t=true;
    }
    if (t) cout << "OK" << endl;
    else cout << "NG" << endl;
}


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

#define ll long long
#define pb push_back
#define bit(a , b) (((a)>>(b))&1)

const int maxn = 1e5 + 20;
const int maxm = 16;

int t[maxn] , a[maxm] , dp[1 << maxm];

int And[1 << maxm];

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

	int n;
	cin >> n;

	for(int i = 0; i < n - 1; i++)
	{
		int a , b , c;
		cin >> a >> b >> c;

		t[a] ^= c;
		t[b] ^= c;
	}

	for(int i = 0; i < n; i++)
		a[t[i]]++;

	int res = a[0] , mask = 0;
	for(int i = 1; i < maxm; i++)
	{
		res += a[i] / 2;
		a[i] %= 2;

		mask += (1 << i) * a[i];
	}

	for(int i = 0; i < maxm; i++)
		And[1 << i] = i;

	for(int mask = 1; mask < (1 << maxm); mask++)
	{
		int lb = (mask&(-mask));

		if(lb == mask)
			continue;

		And[mask] = And[mask ^ lb] ^ And[lb];
	}

	for(int mask = 1; mask < (1 << maxm); mask++)
	{
		if(And[mask] != 0)
			continue;

		dp[mask] = 1;
		for(int submask = mask; submask > 0; submask = (submask - 1) & mask)
			if(submask != mask && And[submask] == 0)
				dp[mask] = max(dp[mask] , dp[submask] + 1);
	}

	cout << n - res - dp[mask] << endl;
}










Measured memory_bytes: 1152
import math

N, A, B= map(int, input().split())

if (A - B) % 2 == 0:
    print(abs(A - B) // 2)

else:

    t1 = A - 1
    t2 = B - 1
    t3 = N - A
    t4 = N - B

    t = min(t1, t2, t3, t4)

    res = t + 1 + (abs(A - B) - 1) // 2
    
    print(res)

Measured memory_bytes: 9076
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;
using System.IO;

public class Playground
{
    //private static List<string[]> item = new List<string[]>();

    public static void Main(string[] args)
    {
        Input();
        //Method();
        System.Console.ReadLine();
    }

    private static void Input()
    {
        var dic = new HashSet<string>();
        int num = int.Parse(Console.ReadLine());
        var sb = new StringBuilder(4000000);
        for (int i = 0; i < num; i++)
        {
            var ope = (Console.ReadLine().Split(' '));
            //if (ope[0][0] == 'i')
            if (ope[0].Equals("insert"))
            {
                dic.Add(ope[1]);
            }
            else
            {
                if (dic.Contains(ope[1]))
                {
                    sb.AppendLine("yes");
                }
                else
                {
                    sb.AppendLine("no");
                }
            }
        }
        Console.Write(sb.ToString());
    }

    //private static void Method()
    //{
    //    //var dic = new Dictionary<int, string>();
    //    var dic = new HashSet<string>();
    //    foreach (var ope in item)
    //    {
    //        if (ope[0].Equals("insert"))
    //        {
    //            dic.Add(ope[1]);
    //        }
    //        else
    //        {
    //            if (dic.Contains(ope[1]))
    //            {
    //                Console.WriteLine("yes");
    //            }
    //            else
    //            {
    //                Console.WriteLine("no");
    //            }
    //        }
    //    }
    //}
}

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

int main() {
    int n;
    cin >> n;
    vector<int> l (n);
    for(int i=0; i<n;i ++){
        cin >> l.at(i);
    }
    sort(l.begin(),l.end());
    reverse(l.begin(),l.end());
    int n1 = 0;
    for(int i=1; i<n; i++){
        n1 += l.at(i);
    }
    if(l.at(0) < n1) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
const int MAX=2e5;
const ll MOD=1e9+7;
const int INF=1<<30;
ll kiriage(ll a,ll b){return a%b==0?a/b:a/b+1;}

int main(){
  int N; cin >> N;
  string S,T; cin >> S >> T;
  for(int i=0;i<N;i++){
    cout << S[i] << T[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;

int c[50];
signed main() {
	int a, b; cin >> a >> b;
	for (int d = 0; d < b; d++) {
		int e, f; cin >> e >> f;
		c[e - 1]++; c[f - 1]++;
	}
	for (int i = 0; i < a; i++) {
		cout << c[i] << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

int main() {
  int N,K; cin >>N >>K;
  vector<int> l(N);
  rep(i,0,N) cin >>l[i];
  sort(l.rbegin(),l.rend());
  int ans=0;
  rep(i,0,K) ans+=l[i];
  cout <<ans <<endl;
  return 0;
}


Measured memory_bytes: 256
'''
INPUT SHORTCUTS
N, K = map(int,input().split())
N ,A,B = map(int,input().split())
string = str(input())
arr = list(map(int,input().split()))
N = int(input())
'''

N = int(input())
h = {}
maxnum = 1
for _ in range(N):
	string = ''
	string = str(input())
	if string in h:
		h[string]+=1
		maxnum = max(maxnum,h[string])
	else:
		h[string]=1
maxList = []
for i in h.keys():
	if h[i]==maxnum:
		maxList.append(i)
maxList.sort()
for x in maxList:
	print(x)

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

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    for(int i=1;i<=n;i++){
        int sum = 0;
        int num = i;
        while(num>0){
            sum = sum + (num%10);
            num = num/10;
        }
        if(a <= sum && sum <= b){
            ans = ans + i;
            }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
  int D, N;
  cin >> D >> N;
  if (D == 0) {
    if (N == 100) {
      printf("101\n");
    } else if (N < 100) {
      printf("%d\n", N);
    }
  } else if (D == 1) {
    if (N == 100) {
      printf("%d\n", 100 * 101);
    } else {
      printf("%d\n", 100 * N);
    }
  } else {
    if (N == 100) {
      printf("%d\n", 10000 * 101);
    } else {
      printf("%d\n", 10000 * N);
    }
  }
}

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

int main() {
  long long int x;
  int y=0;
  cin >> x;

  if (x%2 == 0) {
    cout << x/2 -1 << endl;
    return 0;
  }
  else {
    cout << x/2 << endl;
    return 0;
  }


}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;
const long long INF = 1LL << 61;

int main() {
	int N; cin >> N;
	vector<double> v(N);
	rep(i, N)cin >> v[i];
	sort(v.begin(), v.end());
	double max = v[0];

	rep(i, N - 1) {
		max = (max + v[i + 1]) / 2;
	}
	cout << fixed << setprecision(15) << max << endl;
}

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

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> v(N);
  for (int i = 0; i < N; i++) cin >> v[i];

  int sum = accumulate(v.begin(), v.end(), 0);
  int min = *min_element(v.begin(), v.end());
  cout << N + (X - sum) / min << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>
using namespace std;
inline int read(int f = 1, int x  = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 1e5+5;
int gcd(int a, int b) { return b?gcd(b, a%b):a; }
int n, m, d, a[N];
int main()
{
    n = read(), m = read();
    for(int i = 1; i <= n; ++i) a[i] = read(), d = gcd(a[i], d);
    for(int i = 1; i <= n; ++i) if(a[i] >= m&&(a[i]-m)%d == 0) return puts("POSSIBLE"), 0;
    puts("IMPOSSIBLE");
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 2000000000
#define infLL 2000000000000000000
#define MAX 200005
#define sf(a) scanf("%d", &a)
#define sfl(a) scanf("%lld", &a)
#define pf(a) printf("%d ", a)
#define pfl(a) printf("%lld\n", a)
#define Case(t) printf("Case %d: ", t)
#define pii pair<int, int>
#define MOD 1000000007
#define mod 998244353
#define PI acos(-1.0)
#define eps 1e-9
#define mem(a, b) memset(a, b, sizeof(a))
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

vector<pii>edge[MAX];
ll dp[MAX];

void dfs(int u, int p = -1)
{
    for(auto v : edge[u])
    {
        if(v.first==p)
            continue;
        dp[v.first] = (dp[u] + v.second);
        dfs(v.first, u);
    }
}

void solve()
{
    int n;
    cin>>n;
    for(int i = 0; i < n-1; i++)
    {
        int u, v, w;
        cin>>u>>v>>w;
        edge[u].push_back({v, w});
        edge[v].push_back({u, w});
    }
    dfs(1);
    for(int i = 1; i <= n; i++)
        cout<<dp[i]%2<<endl;
}

int main()
{
    FASTIO;
    solve();

    return 0;
}


Measured memory_bytes: 14936
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  int maxN = 0;
  int minN = INF;
  rep (i, n) {
    cin >> v[i];
    maxN = max(maxN, v[i]);
    minN = min(minN, v[i]);
  }
  P(maxN - minN);

  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>

using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;
    int d;
    int A;
    set<int> hasConfection;
    for (int i = 0; i < K; i++)
    {
        cin >> d;
        for (int j = 0; j < d; j++)
        {
            cin >> A;
            hasConfection.insert(A);
        }
    }
    
    cout << N - hasConfection.size() << endl;
    return 0;
}


Measured memory_bytes: 3632
# ABC122C - GeT AC
import sys
input = sys.stdin.readline

n, q = list(map(int, input().rstrip().split()))
s = input().rstrip()
arr = [list(map(int, input().rstrip().split())) for _ in range(q)]
cnt = [0] * (n + 1)
for i in range(n):
    if s[i : i + 2] == "AC":
        cnt[i + 1] = cnt[i] + 1
    else:
        cnt[i + 1] = cnt[i]
for i, j in arr:
    print(cnt[j - 1] - cnt[i - 1])

Measured memory_bytes: 30648
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
 
#define pb push_back
#define mp make_pair

typedef long long ll; 

#define fi first
#define se second
 
#define all(x) (x).begin(), (x).end()
 
using namespace std;             
//using namespace __gnu_pbds;
 
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int INF = (int)1e10;

bool u[10];

void solve() {
    int a, b;
    cin >> a >> b;
    u[a] = 1;
    u[b] = 1;
    for (int i = 1; i <= 3; i++) {
        if (!u[i]) {
            cout << i;
            return;
        }
    }   
}           
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int tt = 1;
 
    while (tt--) {
        solve();
    }
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
 
signed main(){
	int n;cin>>n;
	string s;
	rep(i,40){
		if(n>>i&1){
			s+='1';
			if(i%2==0){
				n-=(1<<i);
			}
			else{
				n+=(1<<i);
			}
		}
		else s+='0';
	}
	while(!s.empty()&&s.back()=='0')s.pop_back();
	reverse(s.begin(),s.end());
	if(s.empty())s="0";
	cout<<s<<endl;
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    string s;
    cin >> s;
    a--; b--; c--; d--;
    bool ans = true;
    FOR(i, a, c){
        if(s[i] == '#' && s[i+1] == '#') ans = false;
    }
    FOR(i, b, d){
        if(s[i] == '#' && s[i+1] == '#') ans = false;
    }
    bool flag = (c < d ? true : false);
    FOR(i, b, d+1){
        if(flag) break;
        if(s[i-1] == '.' && s[i] == '.' && s[i+1] == '.') flag = true;
    }
    cout << (ans && flag ? "Yes" : "No") << endl;
    return 0;
}


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

public class Main {
    static ContestScanner in;
    static Writer out;
    public static void main(String[] args) {
        Main main = new Main();
        try {
            in = new ContestScanner();
            out = new Writer();
            main.solve();
            out.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void solve() throws IOException {
        int left = Integer.MAX_VALUE;
        int right = 0;
        int n = in.nextInt();
        for (int i = 0; i < n; i++) {
            int a = in.nextInt();
            left = Math.min(left, a);
            right = Math.max(right, a);
        }
        System.out.println(right - left);
    }

}

@SuppressWarnings("serial")
class MultiSet<T> extends HashMap<T, Long>{
    @Override public Long get(Object key){return containsKey(key)?super.get(key):0L;}
    public void add(T key,long v){put(key,get(key)+v);}
    public void add(T key){put(key,get(key)+1);}
    public void sub(T key){final long v=get(key);if(v==1)remove(key);else put(key,v-1);}
    public MultiSet<T> merge(MultiSet<T> set)
    {MultiSet<T>s,l;if(this.size()<set.size()){s=this;l=set;}else{s=set;l=this;}
        for(Entry<T,Long>e:s.entrySet())l.add(e.getKey(),e.getValue());return l;}
}

class Writer extends PrintWriter{
    public Writer(String filename)throws IOException
    {super(new BufferedWriter(new FileWriter(filename)));}
    public Writer()throws IOException{super(System.out);}
}
class ContestScanner implements Closeable{
    private BufferedReader in;private int c=-2;
    public ContestScanner()throws IOException
    {in=new BufferedReader(new InputStreamReader(System.in));}
    public ContestScanner(String filename)throws IOException
    {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
    public String nextToken()throws IOException {
        StringBuilder sb=new StringBuilder();
        while((c=in.read())!=-1&&Character.isWhitespace(c));
        while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public String readLine()throws IOException{
        StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
        while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public long nextLong()throws IOException,NumberFormatException
    {return Long.parseLong(nextToken());}
    public int nextInt()throws NumberFormatException,IOException
    {return(int)nextLong();}
    public double nextDouble()throws NumberFormatException,IOException
    {return Double.parseDouble(nextToken());}
    public void close() throws IOException {in.close();}
}


Measured memory_bytes: 21460
import java.util.*;
public class Main {
  
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int minMod10 = 10;
    int ans = 0;
    for (int i = 0; i < 5; i++) {
      int wait = sc.nextInt();
      int mod10 = wait % 10;
      if (mod10 == 0) {
        ans += wait;
      } else {
        ans +=(wait/10 + 1) * 10;
        if (mod10 < minMod10) {
          minMod10 = mod10;
        }
      }
    }
    
    if (minMod10 != 10) {
      ans -= (10-minMod10);
    }

    System.out.println(ans);
  }  
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F(i,a) for(ll i=0;i<a;i++)

int main()
{
    ll n,su=0;
    cin>>n;
    string s;
    cin>>s;
    for(ll i=0;i<n-2;i++){
        if(s.substr(i,3).compare("ABC")==0) {
            su++;
            i+=2;
        }
    }
    cout<<su;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
//    ll n,i,j,s=0,k,d;
//    cin>>n;
//        j=(n/2)+1;
//    for(i=n;;i--)
//    {
//        s+=(i%j);
//        cout<<i%j<<endl;
//        j++;
//        if(j==n+1)
//            break;
//    }
//    j=(n/2)+1;
//    k=j;
//    for(i=1;i<j;i++)
//    {
//        s+=(i%k);
//        cout<<i%k<<endl;
//        k++;
//        if(k==j)
//            break;
//    }
//    cout<<s<<endl;
      ll a,b;
      cin>>a>>b;
      if(a+b<=9)
        cout<<a+b<<endl;
      else
        cout<<"error"<<endl;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, k) = (v[0], v[1]);
    let mut expect = 0.0f64;
    for i in 1..n + 1 {
        let mut point = i as u64;
        let mut prob = 1.0 / (n as f64);
        while point < k as u64 {
            point *= 2;
            prob *= 0.5;
        }
        expect += prob;
    }
    println!("{:?}", expect);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    int a[n],b[n],c[m],d[m];
    for(int i=0;i<n;i++){
    	cin>>a[i]>>b[i];
    }
    for(int i=0;i<m;i++){
    	cin>>c[i]>>d[i];
    }
    int dis,num;
    for(int i=0;i<n;i++){
    	num=0;
    	dis=1000000000;
    	for(int j=0;j<m;j++){
    		//<<(abs(a[i]-c[j])+abs(b[i]-d[j]))<<endl;
    		if(dis>(abs(a[i]-c[j])+abs(b[i]-d[j]))){
    			num=j;
    			//cout<<num<<endl;
    			dis=abs(a[i]-c[j])+abs(b[i]-d[j]);
    		}
    	}
    	cout << num+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;

namespace ALDS1_5_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int N = int.Parse(input);

            string[] factor_st = Console.ReadLine().Split(' ');
            int[] factor = new int[N];
            for (int i = 0; i < N; i++)
            {
                factor[i] = int.Parse(factor_st[i]);
            }

            int k = int.Parse(Console.ReadLine());
            string[] analyte_st = Console.ReadLine().Split(' ');
            bool[] analyte = new bool[k];
            for (int i = 0; i < k; i++)
            {
                analyte[i] = solve(0, int.Parse(analyte_st[i]), factor);
                if (analyte[i])
                {
                    Console.WriteLine("yes");
                } else
                {
                    Console.WriteLine("no");
                }
            }
        }

        public static bool solve (int i, int m, int[] list)
        {
            if (m == 0) return true;
            if (i >= list.Length) return false;

            bool res = solve(i + 1, m, list) || solve(i + 1, m - list[i], list);
            return res;
        }
    }
}

Measured memory_bytes: 8980
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] s = br.readLine().split("\\s+");
		int n = Integer.parseInt(s[0]);
		int m = Integer.parseInt(s[1]);
		String[] str = new String[n];
		for(int i=0;i<n;i++)
			str[i] = br.readLine();
		
		Arrays.sort(str);
		StringBuilder sb = new StringBuilder();
		for(int i=0;i<n;i++)
			sb.append(str[i]);
		System.out.println(sb);
	}
}


Measured memory_bytes: 34004
def main():
    n, m = map(int, input().split())
    store = [[int(a) for a in input().split()] for _ in range(n)]
    store = sorted(store, key=lambda x: x[0])

    money = 0
    drink = 0
    for s in store:
        if drink + s[1] > m:
            money += (m - drink) * s[0]
            break
        money += s[1] * s[0]
        drink += s[1]
    print(money)


main()


Measured memory_bytes: 23516
import collections

N = int(input())
a = list(map(int, input().split()))

B = collections.Counter(a)
k = list(B.keys())
v = list(B.values())

if len(B) == 3 and k[0]^k[1]^k[2] == 0 and v[0] == v[1] == v[2]:
    print("Yes")
elif len(B) == 2 and 0 in k and (v[0] == 2*v[1] or v[1] == 2*v[0]):
    print("Yes")
elif len(B) == 1 and 0 in k:
    print("Yes")
else: print("No")

Measured memory_bytes: 20692
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long 
#define ld long double
#define PB push_back
#define lc 2 * v
#define rc 2 * v + 1
#define mid (s + e) / 2
#define pii pair <int,  int>
#define pll pair <long long , long long>  
#define FAST ios::sync_with_stdio(false);cin.tie(0);
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

const ll maxn = 1e4 + 100 , N = 2000 + 30 , Q = 5000 , mod = 1e9 + 7 , INF = 1e18 , lg = 32;

int n;
int is1[Q][Q] , is2[Q][Q];
ll dp[Q][Q] , fac[maxn] , inv[maxn] , bad , ans;

inline ll power(ll a , ll b) {
    ll res = 1;
    while(b) {
        if(b & 1) {
            res = (res * a) % mod;
        }
        a = (a * a) % mod;
        b /= 2;
    }
    return res;
}

inline ll c(ll a , ll b) {
    ll res = (fac[a] * inv[b]) % mod;
    res = (res * inv[a - b]) % mod;
    return res; 
}

int main() {
    fac[0] = inv[0] = 1;
    for (int i = 1; i < maxn; ++i) {
        fac[i] = (i * fac[i - 1]) % mod;
        inv[i] = power(fac[i] , mod - 2);
    }

    cin >> n;
    for (int i = 0; i < n; ++i) {
        int x, y; cin >> x >> y;
        is1[x + N][y + N]++;
        is2[N + -x][N + -y]++;

        bad = (bad + c(2 * (x + y) , 2 * x)) % mod;

        dp[N + -x][N + -y]++;
    }

    for (int i = 1; i < Q; ++i) {
        for (int j = 1; j < Q; ++j) {
            dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
            dp[i][j] = (dp[i][j] + dp[i][j - 1]) % mod;
            if(is1[i][j]) {
                ans = (ans + dp[i][j] * is1[i][j]) % mod;
            }
        }
    }

    ans -= bad;
    ans += mod; ans %= mod;

    ans = (ans * power(2 , mod - 2)) % mod;
    cout << ans << endl;
} 


Measured memory_bytes: 245648
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

struct Edge{
  ll to, cost;
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
ll inf = 1e15;
ll mod = 1e9 + 7;

vll dijkstra(const Graph &g, int s){
  vll d(g.size(), inf);
  d[s] = 0;
  priority_queue<P, vector<P>, greater<P>> que;
  que.push(P(0, s));
  while(!que.empty()){
    ll dist = que.top().first;
    int v = que.top().second;
    que.pop();
    if(d[v] < dist) continue;
    for(const auto &e: g[v]){
      if(d[e.to]<=d[v]+e.cost) continue;
      d[e.to] = d[v] + e.cost;
      que.push(P(d[e.to], e.to));
    }
  }
  return d;
}

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

  ll n;
  cin >> n;
  ll a, b, c;
  Graph g(n);

  REP(i, n - 1){
    cin >> a >> b >> c;
    a--;
    b--;
    g[a].push_back((Edge){b, c});
    g[b].push_back((Edge){a, c});
  }
  ll q, k;
  cin >> q >> k;
  k--;
  vll x(q), y(q);
  REP(i, q){
    cin >> x[i] >> y[i];
    x[i]--;
    y[i]--;
  }

  vll dist = dijkstra(g, k);

  REP(i, q){
    cout << dist[x[i]] + dist[y[i]] << endl;
  }
  return 0;
}


Measured memory_bytes: 12656
use std::cmp::min;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b' ');
    let k: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut hv = vec![0i32; n];
    for i in 0..n {
        hv[i] = read(&mut stdin_lock, &mut buf, b'\n');
    }

    hv.sort();

    let mut ans = hv[n - 1] - hv[0];
    for i in 0..n - k + 1 {
        ans = min(ans, hv[i + k - 1] - hv[i])
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
//---------- begin scannner ----------
mod scanner {
    use std::str::FromStr;
    use std::str::SplitWhitespace;
    use std::io::Read;
    use std;
    pub struct Scanner<'a> {
        it: SplitWhitespace<'a>
    }
    impl<'a> Scanner<'a> {
        pub fn new(s: &'a String) -> Scanner<'a> {
            Scanner {
                it: s.split_whitespace()
            }
        }
        pub fn next<T: FromStr>(&mut self) -> T {
            match self.it.next().unwrap().parse::<T>() {
                Ok(v) => v,
                _ => panic!("Scanner error")
            }
        }
    }
    pub fn read_string() -> String {
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }
}

//---------- end scannner ----------

fn run() {
    let sc = scanner::read_string();
    let mut sc = scanner::Scanner::new(&sc);
    let n: usize = sc.next();
    let m: usize = sc.next();
    let mut s = vec![vec![]; m];
    for i in 0..m {
        let k: usize = sc.next();
        for _ in 0..k {
            s[i].push(sc.next::<u32>() - 1);
        }
    }
    let mut p: Vec<usize> = vec![];
    for _ in 0..m {
        p.push(sc.next());
    }
    let mut ans = 0;
    for i in 0..(1 << n) {
        let mut ok = 1;
        for j in 0..m {
            let mut c = 0;
            for &k in &s[j] {
                c ^= (i >> k) & 1;
            }
            if c != p[j] {
                ok = 0;
            }
        }
        ans += ok;
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4352