akhauriyash/Code-Regression huggingface dataset:
// Take care of mod becoming -ve


#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define fro(i,s,e) for(auto i=s;i<=e;++i)
#define int long long
#define ld long double
#define fr(i,n) for(auto i=0;i<(int)n;i++)
#define ff first
#define pf pop_front()
#define ss second
#define mp make_pair
#define vi std::vector<int>
#define pii pair<int,int>
#define mii map<int,int>
#define setbits(x) __builtin_popcountll(x)
#define zrbits(x) __builtin_ctzll(x)
#define vii std::vector<int,int>
#define tc int t;cin>>t;while(t--)
#define FILE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inp(a) long long a;cin>>a;
#define ps(x,y) fixed<<setprecision(y)<<x
#define mkarr(arr,n,type) type *arr=new type[n];
#define endl "\n"
#define sz size()
#define rev(i,e,s) for(auto i=e;i>=s;--i)
const int mod = 1000000007;
#define min_pq priority_queue<int,std::vector<int>,greater<int>>
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
const int MAXN = 100005;
const int inf = 1e18;
#define fill(s,x) memset(s,x,sizeof(s));
inline int add(int a, int b) {return ((a % mod + b % mod) % mod);}
inline int sub(int a, int b) {return ((a % mod - b % mod) % mod);}
inline int mult(int a, int b) {return ((a % mod) * (b % mod)) % mod;}
#define pi 3.14159265358979323846264338327950
typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update> indexed_set;
// Use __gcd(a,b) for gcd
// find(all(x),key) to get the iterator and its index is obtained by find(all(x),key)-x.begin()
// find_if(iterator_first,iterator_last,unary function) returns first iterator if any element corresponding to unary function exists and if no such element is found it retrurns the last iterator
/*For example:
find_if(all(x),isodd) for x being a vector{10,25,40,55}; *it returns 25*/
/*search(all(v1),all(v2),pred) searches for all the elements of v2 present in v1 based on pred function the iterator correspond
to the first element of sequence if it exists and if not then th elast iterator is obtained.*/
//use substr(size_t pos,size_t len) for the substrings
int binsearch(int* a, int start, int end, int key) {
	while (start <= end) {
		int mid = start + (end - start) / 2;
		if (a[mid] < key)
			start = mid + 1;
		else if (a[mid] > key)
			end = mid - 1;
		else
			return mid;
	}
	return -1;
}
int power(int a, int b) {
	long long ans = 1;
	while (b > 0) {
		if (b & 1LL) {ans = (ans * a) % mod;}
		a = (a * a) % mod;
		b = (b >> 1LL);
	}
	return ans;
}
int n;
void solve() {
	
	 
}
int32_t main() {
	fio;
	// indexed_set s;
	// s.insert(2);
	// auto y = s.find_by_order(7);
	// cout << *x << " " << *y <<
	ld a;
	ld b;
	cin>>a>>b;
	ld ans=(a*b);
	cout<<(int)ans<<"\n";
	printclock;
	return 0;
}

Measured memory_bytes: 3812
W, H, N = map(int, input().split())
ans = [[0 for i in range(W)] for j in range(H)]
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        for i in range(H):
            for j in range(x):
                ans[i][j] = 1
    elif a == 2:
        for i in range(H):
            for j in range(x, W):
                ans[i][j] = 1
    elif a == 3:
        for i in range(y):
            for j in range(W):
                ans[i][j] = 1
    elif a == 4:
        for i in range(y,H):
            for j in range(W):
                ans[i][j] = 1
c = 0
for i in range(H):
    for j in range(W):
        if ans[i][j] == 0:
            c += 1
print(c)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define debug(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec)
{ for (auto v : vec) os << v << ' '; os << '\n'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{ os << '(' << pa.first << ',' << pa.second << ')'; return os; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
{ cerr << " " << H; debug_out(T...); }
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n;
    cin >> n;
    double ans = 0;
    rep(i, n) {
        double a;
        cin >> a;
        ans += 1 / a;
    }
    ans = 1 / ans;
    cout << ans << endl;
}

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


Measured memory_bytes: 3772
/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */
//codeforces1038D
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define mp make_pair
#define pb push_back
void parseArray(ll* A,ll n){ for ( ll K = 0; K < n; K++){ cin >> A[K]; } }
ll modInverse(ll a, ll b){ return 1<a ? b - modInverse(b%a,a)*b/a : 1; }
ll gcd(ll a, ll b){ return b?gcd(b, a % b):a; }
ll lcm(ll a, ll b){ return (a*b)/gcd(a, b); }
ld dist(ll x, ll y, ll a, ll b){ return sqrt((x - a)*(x - a) + (y - b)*(y - b)); }
void debug(ll* a, ll n) { for ( int k = 0; k < n; k++ ){ cout << a[k] << " ";} cerr << "\n"; }

int main(){
	FASTIO;
	string s, t; cin >> s >> t;
	vector<ll> alph[30];
	ll n = s.length(), m = t.length();
	for ( int k = 0; k < n; k++ ){
		alph[s[k] - 'a'].pb(k);
	}
	ll ans = 0;
	ll idx = -1;
	for ( int k = 0; k < m; k++ ){
		if (alph[t[k] - 'a'].empty()) return cout << -1 << endl, 0;
		ll lo = 0, hi = alph[t[k] - 'a'].size() - 1, mid;
		ll cur = -1;
		while (lo <= hi) {
			mid = (lo + hi) / 2;
			if (alph[t[k] - 'a'][mid] > idx) {
				cur = mid;
				hi = mid - 1;
			}else { lo = mid + 1; }
		}
		if (cur == -1) {
			ans += n;
			idx = alph[t[k] - 'a'][0];
		}else {
			idx = alph[t[k] - 'a'][cur];
		}
	}
	ans += idx + 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1736
#include <iostream> 
#include <sstream> 
#include <fstream> 
#include <string> 
#include <vector> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <set> 
#include <map> 
#include <algorithm> 
#include <functional> 
#include <utility> 
#include <bitset> 
#include <cmath> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
using namespace std;

int main(){
	int N,K,L[55];
	cin>>N>>K;
	for(int i=1;i<=N;i++){
		cin>>L[i];
	}
	sort(L+1,L+N+1);
	int sum=0;
	for(int i=1;i<=K;i++) sum+=L[N+1-i];
	cout<<sum<<endl;
return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n := scanInt(sc)
	m := scanInt(sc)
	c := scanInt(sc)

	bs := make([]int, m)
	for i := 0; i < m; i++ {
		bs[i] = scanInt(sc)
	}

	nAns := 0
	for i := 0; i < n; i++ {
		d := 0
		for i := 0; i < m; i++ {
			a := scanInt(sc)
			d += a * bs[i]
		}
		if d+c > 0 {
			nAns += 1
		}
	}

	fmt.Println(nAns)
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}


Measured memory_bytes: 640
#include<iostream>
//#include<cmath>
#include <string>
#include<vector>
#include <iomanip>
using namespace std;

class Dice{
private:
//  vector<vector<int>> nextsurface(6,vector<int>(4));
vector<int> surface;
public:
  Dice(vector<int> dice){
    surface=dice;
  }

  void roll_dice(char direction){
    if(direction=='N'){
      int temp=surface.at(0);
      surface.at(0)=surface.at(1);
      surface.at(1)=surface.at(5);
      surface.at(5)=surface.at(4);
      surface.at(4)=temp;
    }
    else if(direction=='E'){
      int temp=surface.at(0);
      surface.at(0)=surface.at(3);
      surface.at(3)=surface.at(5);
      surface.at(5)=surface.at(2);
      surface.at(2)=temp;
    }
    else if(direction=='S'){
      int temp=surface.at(0);
      surface.at(0)=surface.at(4);
      surface.at(4)=surface.at(5);
      surface.at(5)=surface.at(1);
      surface.at(1)=temp;
    }
    else{
      int temp=surface.at(0);
      surface.at(0)=surface.at(2);
      surface.at(2)=surface.at(5);
      surface.at(5)=surface.at(3);
      surface.at(3)=temp;
    }
  }

  void disp_topdice(){
    cout<<surface.at(0)<<endl;
  }

  int get_surfacenum(int snum){
    return surface.at(snum-1);
  }

  int right_side(int upper,int front){
    int upperface,frontface;
    for(int i=0;i<6;i++){
      if(upper==surface.at(i)) upperface=i;
      if(front==surface.at(i)) frontface=i;
    }
    switch(upperface){
      //return は内部のindex+1
      case 0:
      if(frontface==1) return 2+1;
      else if(frontface==2) return 4+1;
      else if(frontface==4) return 3+1;
      else if(frontface==3) return 1+1;
      break;
      case 1:
      if(frontface==5) return 2+1;
      else if(frontface==2) return 1;
      else if(frontface==0) return 3+1;
      else if(frontface==3) return 5+1;
      break;
      case 2:
      if(frontface==5) return 4+1;
      else if(frontface==4) return 1;
      else if(frontface==0) return 1+1;
      else if(frontface==1) return 5+1;
      break;
      case 3:
      if(frontface==5) return 1+1;
      else if(frontface==1) return 1;
      else if(frontface==0) return 4+1;
      else if(frontface==4) return 5+1;
      break;
      case 4:
      if(frontface==5) return 3+1;
      else if(frontface==3) return 1;
      else if(frontface==0) return 2+1;
      else if(frontface==2) return 5+1;
      break;
      case 5:
      if(frontface==1) return 3+1;
      else if(frontface==3) return 4+1;
      else if(frontface==4) return 2+1;
      else if(frontface==2) return 1+1;
      break;
    }
}

};

int main(void){
  vector<int> dice(6);
  string str;
  int loop,up,frnt,snum;

  for(int i=0;i<6;i++)cin>>dice.at(i);
  Dice dice1(dice);
//  cin>>str;
  //for(int i=0;i<str.size();i++) dice1.roll_dice(str[i]);
//  dice1.disp_topdice();
cin>>loop;
for(int i=0;i<loop;i++){
  cin>>up>>frnt;
  snum=dice1.get_surfacenum(dice1.right_side(up,frnt));
  cout<<snum<<endl;
}

  return 0;


}



Measured memory_bytes: 3108
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
    int h, w;
    cin >> h >> w;
    while(!(h == 0 && w == 0)){
        for (int i = 0; i < h; i++){
            for (int j = 0; j < w; j++){
                if((i+j+2)%2==0){
                    cout << "#";
                }
                else{
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
        cin >> h >> w;
    }
}



Measured memory_bytes: 3112
console.log((args=>{
  const [N,...P] = args.trim().split('\n').map(v=>v|0);
  const dp = Array(N+1).fill(0);
  for ( let i = 0; i < N; i++ ) dp[P[i]+1] = dp[P[i]] + 1;
  return `${N-dp.reduce((a,b)=>(a>b)?a:b,0)}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 61796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ss second
#define ff first
#define pb push_back
int main(){
    ios_base::sync_with_stdio(0);
    int n;
    cin>>n;
    string x;
    cin>>x;
    if(x.size()>n){
        for(int i=0;i<n;i++){
            cout<<x[i];
        }
        cout<<"...";


    }
else{
    cout<<x;
}
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int mod = 1000000007;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	map<int, int> mp;
	rep(i, n) mp[a[i]]++;
	vector<ll> res;
	vector<ll> res2;
	for (auto& c : mp) {
		if (c.second >= 2) res.emplace_back(c.first);
		if (c.second >= 4) res2.emplace_back(c.first);
	}
	sort(res.rbegin(), res.rend());
	sort(res2.rbegin(), res2.rend());
	ll ans = 0;
	if (res.size() >= 2) ans = res[0] * res[1];
	if (res2.size() >= 1) ans = max(ans, res2[0] * res2[0]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5376
def bellman_ford(num, start):
    dist = [float("inf") for i in range(num)]
    dist[start] = 0
    for i in range(num):
        update = False
        for j, k, l in adj:
            if dist[k] > dist[j] + l:
                dist[k] = dist[j] + l
                update = True
                if i == num-1:
                    return False
        if not update:
            break
    return True

v, e = map(int, input().split(" "))
adj = []
for i in range(e):
    s,t = map(int, input().split(" "))
    adj.append([s, t, -1])
for i in range(v):
    if not bellman_ford(v,i):
        print(1)
        quit()
print(0)


Measured memory_bytes: 5624
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
	vector<int> high(10);
	int i;
	
	for(i = 0; i < 10; i++){
		scanf("%d",&high[i]);
	}
	
	sort(high.begin(), high.end());
	
	cout << high[9] << endl;
	cout << high[8] << endl;
	cout << high[7] << endl;
	
}

Measured memory_bytes: 0
import Control.Applicative
import Data.List
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Control.Arrow

readIntBS = fst . fromJust . BS.readInt

main = do
  [n,c,k] <- map read . words <$> getLine :: IO [Int]
  ts <- sort . map readIntBS . BS.lines <$> BS.getContents :: IO [Int]

  print $ length $ solve ts c k

  where
    solve [] _ _ = []
    solve xs c k = a : solve b c k
      where
        (a,b) = aux (head xs) xs 1
        aux _ [] _ = ([],[])
        aux t0 (x:xs) c0 = if c0 <= c && x <= t0+k then first (x:) (aux t0 xs (c0+1)) else ([],x:xs) 
      


Measured memory_bytes: 16636
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;

void solve(){
    ll n,p;
    cin>>n>>p;
    vector<ll>a(n);
    int odd=0;
    rep(i,n){
        cin>>a[i];
        if(a[i]%2)odd++;
    }
    if(odd){
        cout<<(ll)pow(2,n-1)<<"\n";
    }
    else{
        if(p)cout<<0<<"\n";
        else cout<<(ll)pow(2,n)<<"\n";
    }

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

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

int main() {
  ll n;
  double ans,a1,a2;
  cin >> n;
  a2=n;
  n=n/2+n%2;
  a1=n;
  ans=a1/a2;
  cout<<ans<<endl;
}


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

int main() {
    int n;
    long long sum = 0;
    cin >> n;
    for (int i=1; i<n+1; i++){
        if(i%3!=0 && i%5!=0) {
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((LL)1e9+7) 
#define INF ((LL)1e9+7)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

LL modpow(LL x, LL b){
	LL res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

LL modinv(LL x){
	return modpow(x, MOD-2);
}

int main(){
	string a, b;
	cin >> a >>b;
	int ans = 0;
	REP(i, 3)ans += a[i] == b[i];
	cout << ans << endl;
	return 0;
}


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

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(int n;cin>>n,n;){
		vi a((n-1)*n/2);
		rep(i,a.size())
			cin>>a[i];
		cout<<accumulate(allof(a),0)/(n-1)<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main()
{
    long inputN;
    int inputK, printOutput = 0;
    
    scanf("%li %d", &inputN, &inputK);
    
    while(1)
    {
        // Count positional notation of given number in system of value stored in inputK
        inputN /= inputK;
        // Counts the digits required to write number in system of value stored in inputK
        printOutput += 1;
        
        if(inputN == 0)
        {
            break;
        }
    }
    
    printf("%d\n", printOutput);
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			String s = scanner.nextLine();
			System.out.println(s.substring(0, 1) + (s.length() - 2) + s.substring(s.length() - 1));
		}
	}
}


Measured memory_bytes: 21460
#include<iostream>
#include<cstdio>
#include<string>
#include<map>
using namespace std;

int main() {
  int n;
  char str[10], com[13];
  map<string, bool>  T;  // 標準ライブラリからmapを使用

  cin >> n;
  for ( int i = 0; i < n; i++ ) {
    scanf("%s%s", com, str);
    if ( com[0] == 'i' ) T[string(str)] = true;
    else {
      if ( T[string(str)] ) printf("yes\n");
      else printf("no\n");
    }
  }

  return 0;
}


Measured memory_bytes: 47404
#include<stdio.h>

int main(void)
{
	int pips[6],pips2[6],dice[6][6] = {{10,2,4,1,3,10},{3,10,0,5,10,2},{1,5,10,10,0,4},{4,0,10,10,5,1},{2,10,5,0,10,3},{10,3,1,4,2,10}};
	int i,j,top,front,right;

	for(i = 0;i < 6;i++){
		scanf("%d",&pips[i]);
	}
	for(i = 0;i < 6;i++){
		scanf("%d",&pips2[i]);
	}
	for(i = 0;i < 6;i++){
		if(pips[i] == pips2[0] && pips[5 - i] == pips2[5])top = i;
		if(pips[i] == pips2[1] && pips[5 - i] == pips2[4])front = i;
	}
	right = dice[top][front];
	j = 0;
	if(right != 10)j++;
	if(pips[right] == pips2[2])j++;
	if(pips[5 - right] == pips2[3])j++;
	if(pips[5 - front] == pips2[4])j++;
	if(pips[5 - top] == pips2[5])j++;
	if(j == 5){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 580
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		String result = "NO";
		
		List<Integer> inputList = new ArrayList<Integer>();
		Scanner sc = new Scanner(System.in);
		
		inputList.add(sc.nextInt());
		inputList.add(sc.nextInt());
		inputList.add(sc.nextInt());
		
		int count7 = 0;
		int count5 = 0;
		
		for(int input : inputList){
			if(input == 5) count5++;
			if(input == 7) count7++;
		}
		
		if (count5 == 2 
				&& count7 == 1){
			result = "YES";
		}
		
		System.out.print(result);
		return;
	}

}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

int main() {
    string S, T;
    cin >> S;
    cin >> T;

    int n = S.size(), m = T.size();
    int ans = n;

    for_(i,0,n-m+1) {
        int cnt = 0;
        for_(j,0,m) if (S[i + j] != T[j]) ++cnt;
        ans = min(ans, cnt);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
//Some custom functions for quick use(fast_power,nCr,lcm,gcd)
ll power(ll a, ll b)
{
  if(b == 0)
   {
      return 1;
   }
   else if(b % 2 == 0)
   {
      return power(a*a, b/2);
   }
   else
   {
      return a * power(a*a, b/2);
   }
}
long long int nChoosek( long long int n, long long int k )
{
if (k > n) return 0;
if (k * 2 > n) k = n-k;
if (k == 0) return 1;
    int result = n;
for( int i = 2; i <= k; ++i )
{
        result *= (n-i+1);
        result /= i;
}
    return result;
}

long long int lcm(long long int a,long long int b)
{
    long long int m,n;
    m=a;
    n=b;
    while(m!=n)
    {
        if(m < n)
        {
            m=m+a;
        }
        else
        {
            n=n+b;
        }
    }
    return m;
}

long long int gcd(long long int a,long long int b)
{ 
if (a == 0) 
return b; 
return gcd(b % a, a);
}
/* Basic DFS Boilerplate */ 
vector<ll> adj[10005]; // graph is stored as adjacency list
bool visited[10005];
void dfs(ll s)  //given node s
{
    if(visited[s])
        return;
    visited[s]=true;
    //the process on node 's'
    for(auto u : adj[s])
    {
        dfs(u);
    }    
}
/* Basic BFS Boilerplate */
ll x;   // given node
queue<ll>q;
bool vis[10005];
ll dist[10005];
//
void bfs(ll x)
{
    vis[x]=true;
    dist[x]=0LL;
    q.push(x);
    while (!q.empty())
    {
        ll s=q.front();
        q.pop();
        //the process
        //on node x
        for(auto u :adj[x])
        {
            if(vis[u]==true)
                continue;
            vis[u]=true;
            dist[u]=dist[x]+1;
            q.push(u);
        }
    }
    
}
int main()
{
    fastio
    map<string,ll>m;
    ll n;
    cin>>n;
    ll ctr=0;
    for (ll i = 0; i < n; i++)
    {
        string s;
        cin>>s;
        if(!m[s])
        {
            ctr++;
        }
        m[s]++;
    }
    cout<<ctr<<'\n';
    return 0;
}


Measured memory_bytes: 19492
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion

int main()
{
	int n; cin >> n;
	ll res = 0;
	for (int i = 1; i <= n; ++i)
	{
		for (int j = i; j <= n; j += i)
		{
			res += j;
		}
	}
	cout << res << endl;
}

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

using namespace std;

int dp[100005];

int dfs(int idx){
  if(dp[idx] > 0) return dp[idx];
  if(idx == 0)return 0;
  int i = 1;
  int ret = 1000000;
  while(i <= idx){
   	ret = min(dfs(idx - i), ret);
    i *= 6;
  }
  i = 1;
  while(i <= idx){
    ret = min(dfs(idx - i), ret);
    i *= 9;
  }
  return dp[idx] = ret + 1;
}

int main(){
  int N;
  cin >> N;
  cout << dfs(N) << endl;
}

Measured memory_bytes: 3712
from itertools import groupby
n, k = map(int, input().split())
s = input()

t = []
if s[0] == "0":
    t.append(("1", 0))

cnt = 1
for i in range(n):
    if i != n-1:
        if s[i] == s[i+1]:
            cnt += 1
        else:
            t.append((s[i], cnt))
            cnt = 1
    if i == n-1:
        t.append((s[i], cnt))

if s[-1] == "0":
    t.append(("1", 0))

S = [t[0][1]]
rm = [0]
m = len(t)
for i in range(m//2):
    tmp = S[-1]
    S.append(tmp+t[2*i+1][1]+t[2*i+2][1])
    rm.append(tmp+t[2*i+1][1])

ans = []
for i in range(m//2+1):
    if i - k < 0:
        ans.append(S[i])
    else:
        ans.append(S[i]-rm[i-k])
print(max(ans))


Measured memory_bytes: 16060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int N = 2e5+10;
int a[N],n;
int main () {
    scanf("%d",&n);
    int ans=0,minans=INF;
    for(int i=1;i<=n;++i) {
        scanf("%d",a+i);
        if(a[i]<minans) {
            minans=a[i];
            ans++;
        }
    }
    cout << ans;
}

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

const int Maxl = 26;

string s;
bool was[Maxl];

int main()
{
	cin >> s;
	for (int i = 0; i < s.length(); i++)
		was[s[i] - 'a'] = true;
	for (int i = 0; i < Maxl; i++) if (!was[i]) {
		cout << s << char('a' + i) << endl;
		return 0;
	}
	int pnt = int(s.length()) - 2;
	while (pnt >= 0 && s[pnt] > s[pnt + 1]) pnt--;
	if (pnt < 0) { printf("-1\n"); return 0; }
	for (int i = pnt + 1; i < s.length(); i++)
		was[s[i] - 'a'] = false;
	for (int i = s[pnt] - 'a' + 1; i < Maxl; i++) if (!was[i]) {
		s[pnt] = i + 'a';
		for (int j = 0; j <= pnt; j++)
			printf("%c", s[j]);
		printf("\n");
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

char s[100010];
int main(){
	int n;
	scanf("%d%s",&n,s);
	int i=0,p=0;
	for(;i<n;i++){
		if(s[i]=='o')p=0;
		else{
			p++;
			if(p==2)break;
		}
	}
	printf("%d\n",i);
}


Measured memory_bytes: 2144
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int H = sc.nextInt();
      int A = sc.nextInt();
      if(H%A==0){
        System.out.println(H/A);
      }else{
        System.out.println(H/A+1);
      }
    }
}

Measured memory_bytes: 35696
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

int main(){
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='+')ans++;
        else ans--;
    }
    cout<<ans<<endl;
}


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

 using namespace std;
 typedef long long ll;
 #define rep(i, n) for(int i = 0; i < (int)(n); i++)

 bool isprime(int x) {
    bool finished = false;
    for (int i = 2; i <= sqrt(x); i++) {
      if (x % i == 0) {
        finished = true;
        break;
      }
    }
    if (finished) return 0;
    else return 1;
 }

 int main() {
   int X;
   cin >> X;

   for (int i = 0;; i++) {
      if (isprime(X + i) == 1) {
        cout << X + i << endl;
        break;
      }
   }
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(1); 
const ll mod=998244353;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=(1<<18)+10;
char s[N];
int p[N],n;
int win[N][20];

bool gao(int a,int b) {
	if (b>a) return s[b-a]=='0';
	else return s[a-b]=='1';
}
int main() {
	scanf("%d",&n);
	scanf("%s",s+1);
	rep(i,0,(1<<n)) {
		scanf("%d",p+i);
		win[i][0]=p[i];
	}
	rep(k,0,n) {
		rep(i,0,(1<<n)) {
			int u=win[i][k],v=win[(i+(1<<k))%(1<<n)][k];
			if (gao(u,v)) win[i][k+1]=u; else win[i][k+1]=v;
		}
	}
	rep(i,0,(1<<n)) printf("%d\n",win[i][n]);
}


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

int main() 
{
    long long n;
    cin>>n;
    vector<int> dp(n+1,0);
    for(int i=1; i<=n; i++)
    {
        for(int j=i;j<=n; j+=i)
            dp[j]++;
    }
    long long answer=0;
    for(int i=0; i<=n; i++)
    {
        answer+=(long long)i*dp[i];
    }
    cout<<answer;
	return 0;
}

Measured memory_bytes: 42336
#if 0
#endif
#include <cstdio>
#include <algorithm>
#include <stack>
#define debug(...) // fprintf(stderr, __VA_ARGS__)

inline int input() { int x; scanf("%d", &x); return x; }

struct Tree {
	int L, R;
	Tree *lt, *rt;
	int max, lazy;

	inline void update() {
		max = std::max(lt -> max, rt -> max);
	}

	inline void push_down() {
		lt -> max += lazy;
		lt -> lazy += lazy;
		rt -> max += lazy;
		rt -> lazy += lazy;
		lazy = 0;
	}

	void add(int l, int r, int x) {
		if(r < L or l > R)
			return;
		if(l <= L and R <= r) {
			max += x;
			lazy += x;
		} else {
			push_down();
			lt -> add(l, r, x);
			rt -> add(l, r, x);
			update();
		}
	}

	int query(int l, int r) {
		if(r < L or l > R)
			return 0;
		if(l <= L and R <= r)
			return max;
		push_down();
		return std::max(lt -> query(l, r), rt -> query(l, r));
	}

	Tree(int l, int r): L(l), R(r), max(0), lazy(0) {
		if(l == r)
			return;
		int mid = (l + r) >> 1;
		lt = new Tree(l, mid);
		rt = new Tree(mid + 1, r);
	}
};

struct Dot {
	int x, y;
};

const int maxn = 300005;
Dot dot[maxn];
int x[maxn], up[maxn], down[maxn];

inline bool cmp(Dot x, Dot y) {
	return x.x < y.x;
}

int solve(int n, int w, int h) {
	if(not n) return 0;
	for(int i = 1; i <= n; i ++)
		debug("%d, %d\n", dot[i].x, dot[i].y);

	int mid = h >> 1;
	int i = 1, p = 0;
	int res = 0;
	std::stack<int> stup, stdown;
	Tree T(1, n);

	stup.push(0);
	stdown.push(0);

	while(i <= n) {
		++ p;
		x[p] = dot[i].x;
		up[p] = h - mid;
		down[p] = mid;

		while(i <= n and dot[i].x == x[p]) {
			if(dot[i].y >= mid)
				up[p] = std::min(up[p], dot[i].y - mid);
			if(dot[i].y <= mid)
				down[p] = std::min(down[p], mid - dot[i].y);
			i ++;
		}

		while(up[stup.top()] > up[p]) {
			int tmp = stup.top();
			stup.pop();
			T.add(stup.top() + 1, tmp, up[p] - up[tmp]);
			debug("%d-%d add %d\n", stup.top() + 1, tmp, up[p] - up[tmp]);
		}

		while(down[stdown.top()] > down[p]) {
			int tmp = stdown.top();
			stdown.pop();
			T.add(stdown.top() + 1, tmp, down[p] - down[tmp]);
			debug("%d-%d add %d\n", stdown.top() + 1, tmp, down[p] - down[tmp]);
		}

		stup.push(p);
		stdown.push(p);
		T.add(p, p, w - x[p - 1] + up[p] + down[p]);
		debug("%d-%d add %d\n", p, p, w - x[p - 1] + up[p] + down[p]);
		res = std::max(res, T.query(1, p) - (w - dot[i].x));

		debug("%d: %d, %d ans=%d\n", x[p], up[p], down[p], T.query(1, p) - (w - dot[i].x));
	}

	return res;
}

int main() {
	int w = input(), h = input(), n = input(), ans = 0;

	for(int i = 1; i <= n; i ++) {
		dot[i].x = input();
		dot[i].y = input();
		if(dot[i].x == 0 or dot[i].x == w or dot[i].y == 0 or dot[i].y == h) {
			n --;
			i --;
		}
	}

	std::sort(dot + 1, dot + n + 1, cmp);
	dot[0].x = 0;
	dot[n + 1].x = w;
	for(int i = 1; i <= n + 1; i ++)
		ans = std::max(ans, h + dot[i].x - dot[i - 1].x);
	ans = std::max(ans, solve(n, w, h));

	for(int i = 1; i <= n; i ++)
		std::swap(dot[i].x, dot[i].y);

	std::sort(dot + 1, dot + n + 1, cmp);
	dot[0].x = 0;
	dot[n + 1].x = h;
	for(int i = 1; i <= n + 1; i ++)
		ans = std::max(ans, w + dot[i].x - dot[i - 1].x);
	ans = std::max(ans, solve(n, h, w));

	printf("%d\n", ans << 1);
}

Measured memory_bytes: 64384
// 2020-07-18 04:28:33
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  using P = pair<ll, int>;
  int n;
  cin >> n;
  vector<P> as(n);
  rep(i, n) {
    ll a;
    cin >> a;
    as[i] = {a, i+1};
  }
  sort(as.rbegin(), as.rend());
  vector<vector<ll> > dp(n+1, vector<ll>(n+1, 0));
  ll ans = 0;
  rep(i, n) {
    int m = i+1;
    repc(l, m) {
      int r = m-l;
      if(l > 0) {
        ll score = as[i].first * abs(as[i].second - l);
        chmax(dp[l][r], dp[l-1][r] + score);
      }
      if(r > 0) {
        ll score = as[i].first * abs(as[i].second - (n - r + 1));
        chmax(dp[l][r], dp[l][r-1] + score);
      }
      chmax(ans, dp[l][r]);
    }
  }
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

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


int main()
{
	int a, b[4],input,i;
	cin >> input;
	b[3] = input % 10;
	input = input / 10; 
	b[2] = input % 10;
	input = input / 10;
	b[1] = input % 10;
	input = input / 10;
	a = input % 10;

	int op[4];
	for (op[1] = -1; op[1] < 2; op[1] +=2)
	{
		for (op[2] = -1; op[2] < 2; op[2] += 2)
		{
			for (op[3] = -1; op[3] < 2; op[3] += 2)
			{
				if (a + op[1] * b[1] + op[2] * b[2] + op[3] * b[3] == 7)
				{
					cout << a;
					for (i = 1; i < 4; ++i)
					{
						if (op[i] == 1)
							cout << '+';
						else
							cout << '-';
						cout << b[i];
					}
					cout << "=7"<<endl;
					return 0;
				}
			}
		}
	}
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;
    int count;
    int ans = 0;
    string s;
    cin >> n >> s;
    for(int i=0;i<n;i++){
        count=0;
        string x = s.substr(0,i+1);
        string y = s.substr(i+1,n-i-1);
        for(char c='a';c<='z';c++){
            int xx = x.find(c);
            int yy = y.find(c);
            if(xx != -1 && yy != -1){
                count ++;
                
            }
        }
        if(count>ans){
            ans = count;
        }
    }
    cout << ans << endl;
}

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

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t,n,m,i,j,k,sum=0;
    cin>>n;
    vector<int> a(n);
    int count=0;
    for(i=0;i<n;i++){
        cin>>a[i];
        if(a[i]!=i+1)
            count++;
    }
    if(count>2){
        cout<<"NO"<<'\n';
    }
    else    cout<<"YES"<<'\n';




    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.text.*;
/*
Main class for AOJ where there is no input.
*/
public class Main{
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = Integer.parseInt(sc.nextLine());
      String[] sArr;
      int[] iArr = new int[3];
      
      
      while(n > 0){
         sArr = sc.nextLine().split(" ");
         iArr[0] = Integer.parseInt(sArr[0]);
         iArr[1] = Integer.parseInt(sArr[1]);
         iArr[2] = Integer.parseInt(sArr[2]);
         
         Arrays.sort(iArr);
         
         if(Math.pow(iArr[2], 2) == Math.pow(iArr[0],2) + Math.pow(iArr[1],2)){
            System.out.println("YES");
         }else{
            System.out.println("NO");
         }
         n--;
      }
   }//main
}//class


Measured memory_bytes: 32204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define REP(i, n) for(int i=0; i<n; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll mod = 1e9+7;

struct edge{
    int to;
    int cost;
};
using graph = vector<vector<edge>>;

int main(){
    int n, x; cin >> n >> x;
    vector<int> m;
    int tmp;
    int gram = 0;
    int ans = 0;
    REP(i, n){
        cin >> tmp;
        m.push_back(tmp);
        gram += tmp;
        ans += 1;
    }
    sort(ALL(m));
    while(gram <= x){
        gram += m[0];
        ans += 1;
    }
    cout << ans-1 << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
# 整数の入力
n, y = map(int, input().split())
# 計算
for i in range(y//10000 + 1):
    for j in range(y//5000 + 1):
        k = n-i-j
        if k >= 0 and 10000*i+5000*j+1000*k==y:
            print(i, j, k)
            sys.exit()
print(-1, -1, -1)

Measured memory_bytes: 2940
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

typedef vector<long long int> vint;
typedef vector<string> vstr;
typedef long long int llint;



int main(void) {
	llint N, M, maxL, minR,ans;
	maxL = 0;
	minR = 1000000;
	cin >> N >> M;
	vint L(M), R(M);
	for (int i = 0; i < M; i++)cin >> L[i] >> R[i];

	for (int i = 0; i < M; i++){
		maxL = max(maxL, L[i]);
		minR = min(minR, R[i]);
	}
	if ((minR - maxL + 1) < 0)ans = 0;
	else ans = minR - maxL + 1;
	cout << ans << endl;
}


Measured memory_bytes: 1792
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
h, w  = map(int, input().split())
#  = list(map(int, input().split()))
masu = [list(input()) for i in range(h)]
#
# c = collections.Counter()


dumy = ['.'] * w
masu.append(dumy)
masu.insert(0, dumy)


for i in range(h+2):
    masu[i] = ['.'] + masu[i] + ['.']

nbomb = [[0] * (w + 2) for _ in range(h+2)]

for i, line in enumerate(masu[1:-1]):
    for j, m in enumerate(line[1:-1]):
        if m == '#':
            i_ = i + 1
            j_ = j + 1
            nbomb[i_-1][j_-1] += 1
            nbomb[i_-1][j_-0] += 1
            nbomb[i_-1][j_+1] += 1
            nbomb[i_-0][j_-1] += 1
            nbomb[i_-0][j_+1] += 1
            nbomb[i_+1][j_-1] += 1
            nbomb[i_+1][j_-0] += 1
            nbomb[i_+1][j_+1] += 1

for ml, bl in zip(masu[1:-1], nbomb[1:-1]):
    ml = ml[1:-1]
    bl = bl[1:-1]

    for m_, b_ in zip(ml, bl):
        if m_ == '.':
            print(b_, end='')
        else:
            print('#', end='')
    print()


Measured memory_bytes: 3828
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{

    class Program
    {
        static void Main(string[] args)
        {

            int A = int.Parse(Console.ReadLine());
            Console.ReadLine();
            Console.ReadLine();
            Console.ReadLine();
            int E = int.Parse(Console.ReadLine());
            int K = int.Parse(Console.ReadLine());

            if(E - A > K)
            {
                Console.WriteLine(":(");
            }
            else {
                Console.WriteLine("Yay!");
            }

            
        }
    }
}

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

int main()
{
  int N;
  std::cin >> N;
  double v[50];
  for (int i=0; i<N; i++) std::cin >> v[i];
  std::sort(v, v+N);
  double val = v[0];
  for (int i=1; i<N; i++) {
    val = (val + v[i]) / 2.0;
    v[i] = val;
  }
  std::cout << val << std::endl;
  return 0;
}


Measured memory_bytes: 3808
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

int main() {
    int x, y, z;
    std::cin >> x >> y >> z;

    const int n = x + y + z;
    std::vector<long long> a(n), b(n), c(n);
    std::vector<int> perm(n);

    long long sumA = 0;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i] >> b[i] >> c[i];
        perm[i] = i;
        sumA += a[i];
        b[i] -= a[i];
        c[i] -= a[i];
    }

    std::sort(perm.begin(), perm.end(), [&](int i, int j) {
        return b[i] + c[j] > c[i] + b[j];
    });

    long long l = 0;
    long long r = 0;

    constexpr long long INF = 1e17;

    auto maxK = [&](std::vector<long long> a, int k) {
        std::multiset<int> st;
        long long sum = 0;
        std::vector<long long> ret(n + 1, -INF);
        for (int i = 0; i < n; i++) {
            int j = perm[i];
            sum += a[j];
            st.insert(a[j]);
            if (st.size() > k) {
                auto it = st.begin();
                sum -= *it;
                st.erase(it);
            }
            if (st.size() == k) {
                ret[i + 1] = sum;
            }
        }
        return ret;
    };

    auto L = maxK(b, y);
    std::reverse(perm.begin(), perm.end());
    auto R = maxK(c, z);

    long long ans = -INF;
    for (int i = 0; i <= n; i++) {
        ans = std::max(ans, sumA + L[i] + R[n - i]);
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 8960
#include <iostream>
#include <utility>
#include <algorithm>
#include <cmath>
#include <vector>

const int NUM = 10000;

using namespace std;

int main()
{
    long long n, m;
    while(1){
        cin >> n;
        cin >> m;
        if(n == 0 && m ==0){
            break;
        }

        vector<pair <long long, long long>> data(NUM);
        long long total_encounter = 0;
        long long d, p;
        for(long long i = 0 ; i < n; i++){
            cin >> d;
            cin >> p;
            data[i] = make_pair(p, d);
            total_encounter += d * p;
        }
        
        sort(data.begin(), data.end());
        reverse(data.begin(), data.end());
        
        long long cost = 0;
        long long index = 0;
        long long guard;
        for(int i = 0; i < n; i++){
            if(m <= 0)break;
            int guard = min(m, data[i].second);
            m -= guard;
            total_encounter -= guard * data[i].first;
        }
        cout << total_encounter << endl;
    }
    return 0;
}

Measured memory_bytes: 1352
//
//  main.c
//  Princess's Marriage
//
//  Created by x15071xx on 2016/06/13.
//  Copyright ?? 2016??´ AIT. All rights reserved.
//

#include <stdio.h>
#define NUM 10000
int main(int argc, const char * argv[]) {
    
    //???????????¨??¨?¨????
    //?\????????????°????????¨?????? * ???????????°??????????????°?????????
    //ok
    
    while (1) {
        
        int array[NUM][2]={0};//di pi
        int n=0,m=0;
        int i,j;
        int d=0,p=0;
        int sum_p=0;
        int p_max=-1,p_i = 0;

        scanf("%d %d",&n,&m);
        
        if (n==0&&m==0) {
            break;
        }
        
        for (i=0; i<n; i++) {
            scanf("%d %d",&d,&p);
            array[i][0] = d;
            array[i][1] = p;
            sum_p = sum_p + (d * p);
        }
        
        //??????????¨????
        
        while (m!=0 && sum_p!=0) {
            for (i=0; i<n; i++) {
                if (p_max < array[i][1]) {
                    p_max=array[i][1];
                    p_i=i;
                }
            }
            
            array[p_i][1] = -1;
            
            if (m-array[p_i][0] <= 0) {
                sum_p = sum_p - (m * p_max);
                m = 0;
            } else {
                sum_p = sum_p - (array[p_i][0] * p_max);
                m = m - array[p_i][0];
            }
            
            p_max=-1;
        }
        
        printf("%d\n",sum_p);
        
    }
    return 0;
}

Measured memory_bytes: 684
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();
		int N = sc.nextInt();
		int p[] = new int[N];

		int a = X;
		int ans1 = X;
		int ans2 = X;
		int s = 0;

		for(int i = 0;i<N;i++) {
			p[i] = sc.nextInt();
		}
		for(int i = 0 ;i<N+1;i++) {
			for(int j = 0;j<N;j++) {
				if(p[j]!=X) {
					s++;
				}
			}
			if(s==N) {
				ans1 = X;
				break;
			}
			s=0;
			X = X-1;
		}
		X=a;
		s=0;
		for(int i = 0 ;i<N+1;i++) {
			for(int j = 0;j<N;j++) {
				if(p[j]!=X) {
					s++;
				}
			}
			if(s==N) {
				ans2 = X;
				break;
			}
			s=0;
			X = X+1;
		}

		X=a-ans1;
		N=ans2-a;

		if(X<=N) {
			System.out.println(ans1);
		}else {
			System.out.println(ans2);
		}

	}

}


Measured memory_bytes: 35868
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long int ll;

const int limit=2500100;
ll M,N;
int m[limit],n[limit];
ll ms[limit],ns[limit];
ll md,nd;

int main(void){
	cin >> M >> N >> m[0] >> md >> n[0] >> nd;
	rep(i,M-1) m[i+1]=(m[i]*58+md)%(N+1);
	rep(i,N-1) n[i+1]=(n[i]*58+nd)%(M+1);
	sort(m,m+M+1);
	sort(n,n+N+1);
	rep(i,M) ms[i+1]=ms[i]+m[i+1];
	rep(i,N) ns[i+1]=ns[i]+n[i+1];

	ll ans=M*N;
	rep(i,M+1){
		ll cur=ms[i];
		int index=lower_bound(n,n+N+1,M-i)-n;
		if(index-1>=0) cur+=ns[index-1];
		cur+=(M-i)*(N-index+1);
		ans=min(ans,cur);
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int n;
  cin >> n;

  int l[2*n];
  for (int i=0; i<2*n; i++) {
    cin >> l[i];
  }
  sort(l, l+2*n, greater<int>());

  int total=0;
  for (int i=0; i<2*n; i+=2) {
    total += min(l[i], l[i+1]);
  }

  cout << total << endl;
}


Measured memory_bytes: 256
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    int a, b;
    cin >> a >> b;

    cout << (a-1) * (b -1) << endl;
    return 0;
}

Measured memory_bytes: 256
/*
First, solve the problem.Then write the code. - John Johnson
@author: returnAC
*/
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define need_for_speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); // Thanks Joshua :)
#define watch(x) cout<<"->"<<#x<<" : "<<x<<endl;
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c)) 
typedef long long ll;
typedef unsigned long long llu;
const double PI = 2*acos(0.0);

signed main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	need_for_speed;
	string s;
	cin>>s;
	for(int i=0;i<s.length()-1;i++)
		if(s[i]==s[i+1])
			cout<<"Bad"<<endl,exit(0);
	cout<<"Good"<<endl;
}

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

int main(){
  string S ; cin >> S ;
  
  int N = stoi(S) ; 
  int cnt = 0 ; 
  for(int i = 0 ; i < S.size() ; i++){
    cnt += S.at(i) - '0'; 
  }
  
  if( N%cnt  == 0 ) cout << "Yes" << endl ; 
  else cout << "No" << endl ; 
  
}

Measured memory_bytes: 3592