akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <cmath>
using namespace std;
int main()
{
    int n ,k;
    cin >> n >> k;
    int r,s,p;
    cin >> r >> s >> p;
    char t[n];
    cin >> t;
    int ans =0;
    for(int i=0;i<n;i++){

       if(t[i]=='r'){
            ans+=p;
            if(i+k<n&&t[i]==t[i+k]){
                t[i+k]='z';
            }
        }else if(t[i]=='s'){
            ans+=r;
            if(i+k<n&&t[i]==t[i+k]){
                t[i+k]='z';
            }
        }else if(t[i]=='p'){
            ans+=s;
            if(i+k<n&&t[i]==t[i+k]){
                t[i+k]='z';
            }
        }
    }
    
    cout << ans;
    
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <list>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(long long (i)=0;(i)<(long long)(n);(i)++)
#define RREP(i,n) for(long long (i)=(long long)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

typedef struct{ int to, cost; }Edge;
class Dijkstra{
    int V;
    vector< vector<Edge> > G;
    vector<int> d;
public:
    Dijkstra(int _V){
        V=_V;
        G.resize(V+10);
        d.resize(V+10);
    }
    void add_edge_oneway(int a, int b, int c){
        Edge e;
        e.to=b; e.cost=c;
        G[a].push_back(e);
    }
    void add_edge_twoway(int a, int b, int c){
        Edge e1,e2;
        e1.to=b; e1.cost=c; e2.to=a; e2.cost=c;
        G[a].push_back(e1);
        G[b].push_back(e2);
    }
    void init(int s){
        priority_queue< pair<int,int>,vector< pair<int,int> >, greater< pair<int,int> > > que;
        for(int i=0;i<V+10;i++)d[i]=1e9+7;
        d[s]=0;
        que.push(make_pair(0,s));
        while(!que.empty()){
            pair<int,int> p=que.top(); que.pop();
            int v=p.second;
            if(d[v]<p.first)continue;
            for(int i=0;i<G[v].size();i++){
                Edge e=G[v][i];
                if(d[e.to]>d[v]+e.cost){
                    d[e.to]=d[v]+e.cost;
                    que.push(make_pair(d[e.to],e.to));
                }
            }
        }
    }
    int dist(int a){
        return d[a];
    }
};

vector<int> G[100010];

int main(){
    
    int N,K;
    cin>>N;
    vector<int> A(N),B(N);
    REP(i,N-1)cin>>A[i]>>B[i];
    cin>>K;
    vector<int> V(N),P(N);
    REP(i,K)cin>>V[i]>>P[i];
    
    Dijkstra inst(100010);
    REP(i,N-1){
        inst.add_edge_twoway(A[i],B[i],1);
        G[A[i]].push_back(B[i]);
        G[B[i]].push_back(A[i]);
    }
    
    REP(i,K){
        inst.add_edge_twoway(100005,V[i],P[i]);
    }
    
    inst.init(100005);
    
    REP(i,K){
        if(inst.dist(V[i])!=P[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    
    for(int i=1;i<=N;i++){
        int val=inst.dist(i);
        REP(j,G[i].size()){
            int v=G[i][j];
            if(abs(inst.dist(v)-val)!=1){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    
    cout<<"Yes"<<endl;
    for(int i=1;i<=N;i++){
        cout<<inst.dist(i)<<endl;
    }
    
    return 0;
}




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

int main(){
	int a, b, d, r;
	double f;
	cin >> a >> b;
	d = a / b;
	r = a % b;
	f = (double)a / (double)b;
	printf("%d %d %f\n",d, r, f);
}

Measured memory_bytes: 1184
def main():
    N, M = map(int, input().split())
    E_mat = [[0]*(N+1) for _ in range(N+1)]
    for _ in range(M):
        a, b = map(int, input().split())
        E_mat[a][b] = 1
        E_mat[b][a] = 1
    E_inv = [[] for _ in range(N+1)]
    for v, e_mat in enumerate(E_mat[1:], 1):
        for u, e in enumerate(e_mat[1:], 1):
            if e==0 and v!=u:
                E_inv[v].append(u)
    colors = [0] * (N+1)
    
    def dfs(v, c):
        colors[v] = c
        cnts[c] += 1
        for u in E_inv[v]:
            if colors[u] == c:
                print(-1)
                exit()
            if colors[u] != 0:
                continue
            dfs(u, -c)
            
    K = []
    for v in range(1, N+1):
        cnts = [0, 0, 0]
        if colors[v] == 0:
            dfs(v, 1)
        K.append(cnts[1:])
    
    dp = 1
    for a, b in K:
        dp = dp<<a | dp<<b
    
    dp = bin(dp)[:1:-1]
    ans = 0
    mi = float("inf")
    for i, c in enumerate(dp):
        if c=="1":
            if mi > abs(N/2-i):
                mi = abs(N/2-i)
                ans = i
    
    print(ans*(ans-1)//2 + (N-ans)*(N-ans-1)//2)

main()


Measured memory_bytes: 20980
def floor_sum(n, m, a, b):
    res = 0
    while True:
        res += a//m * n * (n-1) // 2
        a %= m
        res += b//m * n
        b %= m
        Y = (a*n+b) // m
        X = Y*m-b
        if Y == 0:
            return res
        res += (n+(-X//a)) * Y
        n, m, a, b = Y, a, m, -X%a

import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
    n, m, a, b = map(int, input().split())
    print(floor_sum(n, m, a, b))

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


int main()
{
    static const double pi = 3.141592653589793;
    int A,B,H,M;
    cin >> A >> B >> H >> M;

    long double s = 360/12*(H+(static_cast<long double>(M)/60)) - 360/60*M;
    long double ans = sqrt(A*A + B*B - 2*A*B*cos(pi/180*s));
    cout << setprecision(20) << ans << endl;
}

Measured memory_bytes: 4168
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++){
    cin >> d.at(i);
  }
  int count = 0;
  for (int i = 0; i < N; i++){
    for (int j = i + 1; j < N; j++){
      count += d.at(i) * d.at(j);
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>

#define endl '\n'

using namespace std;

const int MAXK=1e5+3,MOD=1e9+7;
int dp[MAXK],prefix[MAXK];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,k;
    cin>>n>>k;
    dp[0]=1;
    for(int i=0;i<n;++i){
        int limit;
        cin>>limit;
        memset(prefix,0,sizeof(prefix));
        for(int i2=k;i2>=0;--i2){
            int l=i2+1,r=i2+min(k-i2,limit);
            if(l<=r){
                prefix[l]=(prefix[l]+dp[i2])%MOD;
                if(r<k){
                    prefix[r+1]=(prefix[r+1]-dp[i2]+MOD)%MOD;
                }
            }
        }
        int sum=0;
        for(int i2=0;i2<=k;++i2){
            sum=(sum+prefix[i2])%MOD;
            dp[i2]=(dp[i2]+sum)%MOD;
        }
    }
    cout<<dp[k]<<endl;
return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		final Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		
		int odd = 0, even = 0;
		for(int i = 0; i < N; i++){
			final long input = sc.nextLong();
			
			if(input % 2 == 0){
				even++;
			}else{
				odd++;
			}
		}
		
		if(odd % 2 == 1){
			System.out.println("NO");
		}else{
			System.out.println("YES");
		}
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

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

#define ll long long
// #define endl '\n'

void max_self(int &a, int b){ a = max(a, b);}
void min_self(int &a, int b){ a = min(a, b);}

void solve(){
	int k; cin>>k;
	int n = 7, cnt = 1;
	for(int i = 0; i<1e6; i++){
		n = ((n % k) + k) % k;
		if(n == 0){
			cout<<cnt<<endl;
			return;
		}
		n = n * 10 + 7;
		cnt++;
	}
	cout<<-1<<endl;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1;// cin>>t;
	for(int i = 1; i<=t; i++){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int i,j,n,m,mas[30],k;
string s;
char c;
int main()
{
    std::cin.sync_with_stdio(false);
    std::cin.tie(0);
    cin >> s;
    n=s.length();
    i=0;
    while (i<n)
    {
        c=s[i];
        c-=97;
        mas[c]++;
        i++;
    }
    i=0;
    while (i<30)
    {
        if (mas[i]>0)
        {
            k++;
        }
        i++;
    }
    if (k==26)
    {
        i=25;
        while (i>=0)
        {
            c=s[i];
            c-=97;
            mas[c]--;
            int k=1;
            while (c+k<26)
            {
                if (mas[c+k]==0&&c!=25)
                {
                    j=0;
                    while (j<i)
                    {
                        cout << s[j];
                        j++;
                    }
                    c+=97+k;
                    cout << c;
                    return 0;
                }
                k++;
            }
            i--;
        }
        cout << "-1";
    }
    else
    {
        cout << s;
        i=0;
        while (mas[i]>0)
        {
            i++;
        }
        c=i+97;
        cout << c;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

long long CaracalAttack(long long n)
{
    if(n == 1)
    {
        return 1;
    }
    
    return 1 + 2 * CaracalAttack(n / 2);
}

int main()
{
    long long h = 0;
    std::cin >> h;
    
    std::cout << CaracalAttack(h) << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stdlib.h>
#include <time.h>
#include <queue>
#include <sstream>
using namespace std;

int main(void){
	int sum[2];
	fill_n(sum, 2, 0);
	for(int i = 0; i < 2; i++){
		for(int j = 0; j < 4; j++){
			int a;
			cin >> a;
			sum[i] += a; 
		}
	}
	cout << max(sum[0], sum[1]) << endl;
}

Measured memory_bytes: 1160
const Main = (input) => {
    const _input = input.split(" ");
    const A = _input[0];
    const B = _input[1];

    const answer = (A > 9 || B > 9) ? -1 : A * B;

	console.log(answer);
}

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

Measured memory_bytes: 7372
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  a,b=LI()

  c=1
  while True:
    a*=2
    if a>b:
      break
    else:
      c+=1

  return c

print(main())


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

int main() 
{
	int n;
	scanf("%d", &n);
	int a[n];
	long long dp[n+1][n+1];
	memset(dp, 0, sizeof(dp));
	for(int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		dp[i][i] = a[i];
	}
	for(int i = 1; i < n; i++) {
		for(int j = 0; j < n; j++) {
			if(i + j >= n) break;
			dp[j][j+i] = max(a[j] - dp[j+1][j+i], a[j+i] - dp[j][j+i-1]);
		}
	}
	printf("%lld\n", dp[0][n-1]);
}

Measured memory_bytes: 74148
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
ll INF = 1e18;
int main(){
    int n, k;
    cin >> n >> k;
    V vec(n);
    V dp(k + 1,-1);
    for (int i = 0; i < n;i++)cin >> vec[i];
    dp[0] = 0;
    for(int i=1;i<=k;i++){
        bool h = false;
        for (int j = 0; j < n;j++){
            int k = i - vec[j];
            if (k >= 0 && dp[k] == 0)h = true;
        }
        if (h)dp[i] = 1;
        else dp[i] = 0;
    }
    if (dp[k])cout << "First" << endl;
    else cout << "Second" << endl;
}


Measured memory_bytes: 1024
N,M  = map(int,input().split())
N_List = sorted(list(map(int,input().split())))
N_Diff =[]
for i in range(1,M):
    N_Diff.append(N_List[i]-N_List[i-1])
if N >= M:
    ans = 0
elif M == 1:
    ans = sum(N_Diff)
else:
    ans = sum(sorted(N_Diff)[:M-N])
print(ans)

Measured memory_bytes: 20484
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    string s1,s2;
    cin>>s1>>s2;
    ll len=s1.size();
    ll ans=0;
    for(ll i=0;i<len;i++){
        if(s1[i]!=s2[i])    ans++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3912
ans = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(ans[int(input())-1])

Measured memory_bytes: 3060
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
int read(){
	int f=1,x=0; char c=getchar();
	while (c>'9' || c<'0') {if (c=='-') f=-1; c=getchar();}
	while (c>='0'&&c<='9') {x=x*10+c-'0'; c=getchar();}
	return f*x;
}
int x;
bool resolve(int a){
	int A[100],b=a,c=0,d=2;
	while(b!=1){
		while(b%d==0){
			A[++c]=d;
			b/=d;
		}
		d++;
	}
	if(c==1)return 0;
	
	if((c%2==0)&&(A[c/2]!=A[c/2+1])){
		int e=c/2;
		if(e==1)return 0;
		for(int i=1;i<e;i++)if(A[i]!=A[i+1])return 0;
		for(int i=e+1;i<c;i++)if(A[i]!=A[i+1])return 0;
		return 1;
	}
	if((c%3==0)&&(A[c/3]!=A[c/3+1])&&(A[c/3*2]!=A[c/3*2+1])){
		int e=c/3,f=c/3*2;
		if(e==1)return 0;
		for(int i=1;i<e;i++)if(A[i]!=A[i+1])return 0;
		for(int i=e+1;i<f;i++)if(A[i]!=A[i+1])return 0;
		for(int i=f+1;i<c;i++)if(A[i]!=A[i+1])return 0;
		return 1;
	}
	for(int i=1;i<c;i++)if(A[i]!=A[i+1])return 0;
	return 1;
}
int main(){
	cin>>x;
	while(x>=1){
		if((x==1)||(resolve(x)==1)){
			cout<<x<<endl;
			return 0;
		}
		x--;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

bool dp_x[8000][17002];
bool dp_y[8000][17002];


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

    int start = s.size();
    rep(i, 0, s.size())
    if (s[i] == 'F')
        --x;
    else
    {
        start = i;
        break;
    }

    vector<int> num_x, num_y;
    bool xy = true;
    int num = 0;
    rep(i, start, s.size())
    {
        // cout << i << ' ' << num << ' ' << xy << ' ' << !xy<< endl;

        if (s[i] == 'T')
        {
            if (xy)
                num_x.push_back(num);
            else
                num_y.push_back(num);
            num = 0;
            xy = !xy;
            while (i + 1 < s.size() and s[i + 1] == 'T')
            {
                xy = !xy;
                ++i;
                // cout << i << ' ' << xy << endl;
            }
        }
        else
            ++num;
    }
    if (xy)
        num_x.push_back(num);
    else
        num_y.push_back(num);

    // for (auto xx: num_x)
    //     cout << "x " << xx << endl;
    // for (auto xx: num_y)
    //     cout << "y " << xx << endl;
    

    dp_x[0][8000] = 1;
    rep(i, 0, num_x.size())
    rep(j, 0, 16001)
    if (dp_x[i][j])
    {
        dp_x[i + 1][j + num_x[i]] = 1;
        dp_x[i + 1][j - num_x[i]] = 1;
    }
    dp_y[0][8000] = 1;
    rep(i, 0, num_y.size())
    rep(j, 0, 16001)
    if (dp_y[i][j])
    {
        dp_y[i + 1][j + num_y[i]] = 1;
        dp_y[i + 1][j - num_y[i]] = 1;
    }

    if (dp_x[num_x.size()][x + 8000] == 1 and dp_y[num_y.size()][y + 8000] == 1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 70400
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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; }


int main() {
    ll n;
    cin >> n;
    string s;
    cin >> s;
    vector<ll> a(n+1, 0), b(n+1, 0), c(n+1, 0);
    rep1(i, n){
        if (s[i]=='W'){
            a[i] = -1;
            if (i!=0){
                b[i] += b[i-1] + 1;
                c[i] = c[i-1];
            }
            else b[i] = 1;
        }
        if (s[i]=='E'){
            a[i] = +1;
            if (i!=0){
                c[i] += c[i-1] + 1;
                b[i] = b[i-1];
            }
            else c[i] = 1;
        }
    }
    ll ans = 10e6;
    ll res = 0;
    rep1(i,n){
        if (i==0) res = c[n-1] - c[i];
        else if (i==n-1) res = b[i-1];
        else res = b[i-1] + (c[n-1] - c[i]);
        ans = min(ans, res);
    }
    cout << ans << endl;
}

Measured memory_bytes: 10592
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <climits>
#include <cstring>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

using namespace std;

const int N_MAX = 2000000001;
int a[5000001];

void maxheapfy(int ix, int n){
  int root_key = a[ix];
  int l_key = -N_MAX;
  int r_key = -N_MAX;
  if(2*ix+1 < n) l_key = a[2*ix+1];
  if(2*ix+2 < n) r_key = a[2*ix+2];
  // r max
  if(root_key < r_key && l_key < r_key){
    // swap r and root
    swap(a[2*ix+2], a[ix]);
    maxheapfy(2*ix+2, n);
  }
  else if(root_key < l_key && r_key < l_key){
    // swap l and root
    swap(a[2*ix+1], a[ix]);
    maxheapfy(2*ix+1, n);
  }
}

int main(){
  int n;
  cin >> n;
  rep(i, 0, n) cin >> a[i];
  
  //rep(i, 0, n) cout << a[i] << " ";
  //cout << endl;

  rep(ix, n/2, 0) maxheapfy(ix, n);
  
  rep(i, 0, n) cout << " " << a[i];
  cout << endl;
  return 0;
}



Measured memory_bytes: 4960
n = gets.chomp
monsters_hp = gets.chomp.split(" ").map(&:to_i)
min = monsters_hp.min
monsters_hp = monsters_hp - [min]

while 1 do
  monsters_hp = monsters_hp.map{|hp| hp%min}
  monsters_hp = monsters_hp - [0]

  if monsters_hp.empty? then
    print min
    break
  elsif monsters_hp.min < min then
    monsters_hp << min
    min = monsters_hp.min
    monsters_hp = monsters_hp - [monsters_hp.min]
  end
end


Measured memory_bytes: 13444
#include<iostream>
using namespace std;
int main(){
  int n,ok=0;
  cin>>n;
  for(int i=1;i<10;++i)
    for(int j=0;j<10;++j)
      if(i*j==n)
        ok=1;
  if(ok)
    cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 0
constexpr int kMod = 1000000007;
typedef long long LL;

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

  int v = 0;
  for (int i = 0; i < N - 2; ++i) {
    if (i%2 == 0) v += A[i];
    else          v -= A[i];
  }

#if DEBUG
  std::cout << "m1 + m(N-1)" << v << std::endl;
  std::cout << "m1 - m(N-1)" << A[0] - A[N-1] << std::endl;
  std::cout << "m1 = " <<  (v - (A[N-2] - A[N-1]))/2 << std::endl;;
#endif

  std::vector<LL> m(N);
  m[0] = (v - (A[N-2] - A[N-1]))/2;
  std::cout << m[0]*2 << " ";

  for (int i = 1; i < N - 1; ++i) {
    m[i] = A[i-1] - m[i - 1];
    std::cout << m[i]*2 << " ";
  }
  std::cout << 2*(A[N - 1]  - m[0]) << std::endl;
}


Measured memory_bytes: 2432
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {

	Scanner std = new Scanner(System.in);


	//List<Integer> list = new ArrayList<>();
	//int N = std.nextInt();

	//String S = std.next();
	long A = std.nextLong();
	long B = std.nextLong();
	long C = std.nextLong();
	long D = std.nextLong();

	long BBB = Takuma(B,C,D);
	long AAA = Takuma(A-1,C,D);

	long CCC = BBB-AAA;

	System.out.println(CCC);

	}


	public static long Takuma (long B,long C,long D) {

	long g;
	long bigC = B/C;
	long bigD = B/D;
	long CD = C*D;
	long copyC = C;

	//ユークリッドの互除法
	while((g = D%copyC) != 0) {
		D = copyC;
		copyC = g;
	}

	long l = CD/copyC;

	long bigL = B/l;



	long X = B - bigC - bigD + bigL; //B以下でCで割り切れるものとDで割り切れるものの数(重複は無視)

	//B以下でCで割れるものとDで割れるもの

	return X;

	}




	}




Measured memory_bytes: 21972
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
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; }
ll n, m;
vector<ll> x;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    vector<map<ll, ll>> modv(m);
    for (int i = 0; i < n; i++)
    {
        ll temp;
        cin >> temp;
        x.push_back(temp);
        modv[temp % m][temp]++;
    }
    ll ans = 0;
    vector<bool> used(m, false);
    rep(i, m)
    {
        if(used[i])continue;
        if (i == 0 || i + i == m)
        {
            used[i]=true;
            ll count=0;
            ll sum=0;
            for (auto y : modv[i])
            {
                count += y.second / 2;
                sum+=y.second;
            }
            ans+=sum/2;
        }
        else
        {
            used[i]=true;
            used[m-i]=true;
            ll counti = 0;
            ll countm = 0;
            ll sumi=0;
            ll summ=0;
            for (auto y : modv[i])
            {
                counti += y.second / 2;
                sumi+=y.second;
            }
            for (auto y : modv[m - i])
            {
                countm += y.second / 2;
                summ += y.second;
            }
            if(sumi==summ){
                ans+=sumi;
            }
            else if(sumi>summ){
                ans+=summ;
                ll temp=sumi-summ;
                ans+=min(temp/2,counti);
            }
            else{
                ans += sumi;
                ll temp = summ - sumi;
                ans += min(temp / 2, countm);
            }
        }
    }
    cout << ans << "\n";
}


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

using namespace std;

void Main() {
    string S, T;
    cin >> S;
    cin >> T;

    bool ans = true;
    for (int i = 0; i < S.size(); ++i) {
        if (S[i] != T[i]) {
            ans = false;
            break;
        }
    }
    cout << (ans ? "Yes" : "No") << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <ctype.h>
int main(){
  char ch;

  for(;;){
    scanf("%c",&ch);

    if(ch == '\n')break;

    if(islower(ch)){
      ch = toupper(ch);
      printf("%c",ch);
    }
    else if(isupper(ch)){
     ch = tolower(ch);
      printf("%c",ch);
    }
    else{
      printf("%c",ch);
    }
    
  }
  printf("\n");


  return 0; 
}

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

public class Program
{
    #region Standard I/O
    readonly TextReader input;
    readonly TextWriter output;

    X[] ReadLine<X>(Func<string, X> func)
    {
        return input.ReadLine().Split(' ').Select(func).ToArray();
    }

    void WriteLineOne(object obj)
    {
        output.WriteLine("{0}", obj);
    }

    void WriteLineMany(params object[] objects)
    {
        output.WriteLine(string.Join(" ", objects.Select(obj => obj.ToString())));
    }
    #endregion

    public void Run()
    {
        var firstLine = ReadLine(int.Parse);
        var h = firstLine[0];
        var w = firstLine[1];
        var image = Enumerable.Range(0, h).Select(_ => input.ReadLine()).ToArray();

        var borderLine = new string('#', w + 2);
        var lines =
            new[] { borderLine }
            .Concat(image.Select(line => "#" + line + "#"))
            .Concat(new[] { borderLine })
            .ToArray();

        foreach (var line in lines)
        {
            output.WriteLine(line);
        }
    }

    public Program(TextReader input, TextWriter output)
    {
        this.input = input;
        this.output = output;
    }

    public static void Main(string[] args)
    {
        new Program(Console.In, Console.Out).Run();
    }
}


Measured memory_bytes: 13524
#include <iostream>
#include <bits/stdc++.h>
#define MOD 998244353
#define pb push_back
#define ll long long int
using namespace std;



int main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     ll i,j,n,k,m;
     ll t;
     cin>>n>>m;
     ll s=0;
     for(i=0;i<m;i++)
     {
         cin>>k;
         s+=k;
     }
     if(n-s>=0)
         cout<<n-s;
     else
         cout<<-1;
}


Measured memory_bytes: 3660
def dice_expectation(p):
  return ((1 + p) * p / 2) * (1/p)

n, k = map(int, input().split())
pp = [0] * (n+1)
for i, p in enumerate(map(int, input().split())):
  pp[i+1] = pp[i] + dice_expectation(p)

max = -1
for i in range(k, n+1, 1):
  max = pp[i] - pp[i-k] if pp[i] - pp[i-k] > max else max

print(max)


Measured memory_bytes: 31780
#include <bits/stdc++.h>
using namespace std;
long long beki(long long n){
  long long a=1;
  for(int i=0;i<n;i++) a*=2;
  return a;
}
long long pati(long long n,long long x){
  long long c=beki(n+1)-2;
  if(n==0) return 1;
  else if(x==1) return 0;
  else if(x<=c) return pati(n-1,x-1);
  else if(x==c+1) return beki(n);
  else if(x<=2*c) return beki(n)+pati(n-1,x-c-1);
  else return 2*beki(n)-1;
}
int main() {
  long long n,x;
  cin>>n>>x;
  cout<<pati(n,x)<<endl;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string &s, char c){vector<string> v;int d=0,f=0;string t;for(char c:s){if(!d&&c==',')v.pb(t),t="";else t+=c;if(c=='\"'||c=='\'')f^=1;if(!f&&c=='(')++d;if(!f&&c==')')--d;}v.pb(t);return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  ll sum=accumulate(all(a),0ll);
  ll t=0;
  ll re=1e18;
  rep(i,n){
    if(i) MN(re,abs(t-(sum-t)));
    t+=a[i];
  }
  cout<<re<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define  fi0 for(ll i=0;i<n;i++)
string s;
string strd(int n){
    string x;
    while(n){
        int d=n%10;
        x+=(d+'0');
        n/=10;
    }
    reverse(x.begin(),x.end());
    return x;
}
void digit()
{
    cin>>s;
    ll sum=0;
    for(int i=0;i<s.size();i++){
        char a=(char)s[i];
        int d=(int) a-'0';
        sum+=d;
    }
    if(sum%9==0)cout<<"Yes\n";
    else cout<<"No\n";
}
int main()
{
    string s;
    cin>>s;
    ll n=s.size()+1;
    int cnt=0,maxi=0;

    s+='S';
   /// cout<<s<<endl;
    fi0 {
        if(s[i]=='R')cnt++;
        else{
            maxi=max(cnt,maxi);
            cnt=0;
        }
    }
    cout<<maxi<<endl;
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(ll a = 0;a < n;a++)

static const ll INF = 1e15;
static const ll mod = 1e9+7;

template<typename T>
static inline void chmin(T& ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
    if (ref < value) ref = value;
}

int main() {
    int n;
    cin >> n;
    vector<P> ps(n);
    rep(i, n) {
        cin >> ps[i].first >> ps[i].second;
    }
    sort(ps.begin(), ps.end());
    auto score = ps.back();
    cout << score.first + score.second << endl;
    return 0;
}


Measured memory_bytes: 4716
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  int K; 
  cin >> S >> K;
  for(int i = 0; i < K; i++){
    if(S.at(i) != '1'){
      cout << S.at(i) << endl;
      return 0;
    }
  }
  cout << 1 << endl;
}

Measured memory_bytes: 3596
from itertools import permutations, combinations,combinations_with_replacement,product
N,M,Q=map(int,input().split())
a=[i for i in range(1,M+1)]
A=list(combinations_with_replacement(a,N))
B=[list(map(int,input().split())) for i in range(Q)]
ans=[]
for i in A:
    tmp=0
    #print(i)
    for j in B:
        #print(j)
        if i[j[1]-1]-i[j[0]-1]==j[2]:
            tmp+=j[3]
        else:
            pass
    ans.append(tmp)
print(max(ans))

Measured memory_bytes: 25012
fun main(args: Array<String>) {
  val raw = readLine()!!
  val r = Regex(""" (\+|\-) """).split(raw).map { x ->
    x.toInt()
  }
  if( raw.contains("+") )
    println( r.reduce { x, y -> x + y } )
  else
    println( r.reduce { x, y -> x - y } )
}

Measured memory_bytes: 35772
/* 
 * Project: AtCoder Beginners Contest 155 A - Poor
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/06/23
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
using namespace std;

int a, b, c;

void solve() {
    if (a == b & b == c) {
        printf("No\n");
        return;
    }
    if (!(a ^ b) | !(b ^ c) | !(c ^ a)) {
        printf("Yes\n");
        return;
    }
    printf("No\n");
    return;

}

int main() {

    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);

    solve();

}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    ll k;
    cin >> s >> k;
    char ans = '*';
    
    for(ll i = 0; i < k; i++) {
        if (s[i] != '1') {
            ans = s[i];
            break;
        }
        
        ans = s[i];
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    unsigned long long n;
    cin >> n;
    unsigned long long ans = 0;

    if (n % 2 == 1)
    {
        cout << 0 << endl;
        return 0;
    }

    for (unsigned long long i = 10; i <= n; i *= 5)
    {
        ans += n / i;
    }
    cout << ans << endl;
}


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

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

using namespace std;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if((a+b==c)||(a==b+c)||(b==a+c)){
    cout<<"Yes";
  }else{
    cout<<"No";
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int mod = 1e9 + 7;
int main()
{
	SPEED
	int h, a;
	cin >> h >> a;
	if (h%a==0)
	{
		cout << (h/a);
	}
	else
	{
		cout << (h/a) + 1;
	}
	return 0;
}

Measured memory_bytes: 256
/* Coached by Dukkha */
#include <stdio.h>

#define N 100000
#define M 200000
#define INF 0x3f3f3f3f

int oo[1 + M * 2], oj[1 + M * 2], ow[1 + M * 2];

int link(int o, int j, int w) {
	static int _ = 1;

	oo[_] = o, oj[_] = j, ow[_] = w;
	return _++;
}

int ae[N], xx[N];

int dfs(int p, int i, int x) {
	int o;

	if (xx[i])
		return xx[i] == x;
	xx[i] = x;
	for (o = ae[i]; o; o = oo[o]) {
		int j = oj[o], w = ow[o];

		if (j != p && !dfs(i, j, x + w))
			return 0;
	}
	return 1;
}

int main() {
	int n, m, i, j;

	scanf("%d%d", &n, &m);
	while (m--) {
		int w;

		scanf("%d%d%d", &i, &j, &w), i--, j--;
		ae[i] = link(ae[i], j, w);
		ae[j] = link(ae[j], i, -w);
	}
	for (i = 0; i < n; i++)
		if (xx[i] == 0 && !dfs(-1, i, INF)) {
			printf("No\n");
			return 0;
		}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
struct pair_hash {
    template <class T1, class T2>
    size_t operator () (const pair<T1,T2> &p) const {
        auto h1 = hash<T1>{}(p.first);
        auto h2 = hash<T2>{}(p.second);
        return h1 ^ h2;  
    }
};
using Vote = pair<ll,ll>;
using Unordered_map = unordered_map<Vote, int, pair_hash>;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define showvec(arr,a,b) for(ll i=a;i<b;i++) cout<<arr[i]<<" ";
#define read_input(arr,a,b) for(ll i=a;i<b;i++) cin>>arr[i];
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define SmooothOperatorrrrr()                 \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                    \
    cout.tie(0);                   
#define deci(n) cout<<fixed<<setprecision(n)
const int mod=998244353;
const int mod2=1000000007;
#define M_PI 3.14159265358979323846
#define LL_MAX 9223372036854775807
#define MAXN 2000001
/**************************************************************************************************/
int main()
{
    SmooothOperatorrrrr();
    ll count=0;
    ll n;cin>>n;
    ll a[n];
    read_input(a,0,n);
    ll maxm=0;
    FOR(i,0,n)
    {
        maxm=max(maxm,a[i]);
        count+=(maxm-a[i]);
    }
    cout<<count<<endl;
}

Measured memory_bytes: 5172
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stack>
using namespace std;

int main() {
    long long n, a[200000 + 10], st[200000 + 10], dr[200000 + 10];
    stack<int> s, s1;
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for(int i = 1; i <= n; i++) {
        while(!s.empty() && a[i] < a[s.top()]) {
            s.pop();
        }
        if(s.empty()) {
            st[i] = 1;
        } else {
            st[i] = s.top() + 1;
        }
        s.push(i);
    }
    for(int i = n; i >= 1; i--) {
        while(!s1.empty() && a[i] < a[s1.top()]) {
            s1.pop();
        }
        if(s1.empty()) {
            dr[i] = n;
        } else {
            dr[i] = s1.top() - 1;
        }
        s1.push(i);
    }
    long long result = 0;
    for(int i = 0; i <= n; i++) {
        result += a[i] * (i - st[i] + 1) * (dr[i] - i + 1);
    }
    cout << result;
    return 0;
}


Measured memory_bytes: 5760
#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);(i)>0;(i)--)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define SORT(s) sort((s).begin(),(s).end())
#define SORTR(s,t) sort((s).begin(),(s).end(),greater<t>())

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<vector<int>> vvi;

const int INF = 1000000000;
const ll LINF = 1000000000000000000ll;
const double PI = acos(-1.0);
const double EPS = 1e-10;

const ll MOD = 1000000007ll;
const int MAX=510000;

string S,T;
void input(){
    cin>>S>>T;
    return;
}

void solve(){
    int ans=0;
    rep(i,3) if(S[i]==T[i]) ++ans;
    cout<<ans<<endl;
    return;
}

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

Measured memory_bytes: 256
from itertools import combinations

n = int(input())
L = list(map(int, input().split()))

cnt = 0
for edges in list(combinations(L, 3)):
  if len(set(edges)) != 3:
    continue
  
  e1 = edges[0] < edges[1] + edges[2]
  e2 = edges[1] < edges[0] + edges[2]
  e3 = edges[2] < edges[0] + edges[1]
  
  if e1 and e2  and e3:
    cnt += 1

print(cnt)


Measured memory_bytes: 20528
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

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

    int N;
    cin >> N;
    vector<int> A(N), B(N);
    vector<pair<int, int>> AB(N);
    REP(i, N) {
        cin >> A[i] >> B[i];
        AB[i] = make_pair(A[i] + B[i], i);
    }
    sort(ALL(AB));
    reverse(ALL(AB));
    ll ans = 0;
    REP(i, N) {
        int j = AB[i].second;
        if (i % 2 == 0) ans += A[j];
        else ans -= B[j];
    }
    cout << ans << endl;
}

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

using namespace std;

int main () {
	int n;
	cin >> n;
	int a[100005];
	for (int i=1;i<=n;i++) cin >> a[i];
	int ans=0;
	for (int i=1;i<=n;i++) {
		if (a[i]==i) {
			swap(a[i],a[i+1]);
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> ds(N);
    for (int i = 0; i < N; i++) {
        cin >> ds.at(i);
    }
    std::sort(ds.begin(), ds.end());
    int count = 0;
    for (int i = 0; i < ds.size(); i++) {
        if (i == 0) {
            count++;
        } else {
            if (ds.at(i -1) != ds.at(i)) {
                count += 1;
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int a,b;
    scanf("%d%d",&a,&b);
    if(0 <= a && a <= 100 && 2 <= b && b <= 1000 && b%2 == 0){
        if(13 <= a){
            printf("%d\n",b);
        }else if(6 <= a && a <= 12){
            printf("%d\n",b/2);
        }else if(a <= 5){
            printf("%d\n",0);
        }
    }
}

Measured memory_bytes: 128
#include <cassert>
#include <bitset>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;
typedef long long ll;

int a[50];
int n;

bool solve(int now, ll used, ll filled);

set<ll> st[50];

bool select(int now, int id, int vol, ll used, ll filled) {
  if (vol == 0) {
    if (used == (1LL<<n)-1) return 1;
    else return solve(now+1,used,filled);
  }
  int sum = 0;
  for (int i=id; i<n; ++i) if (!(used>>i&1)) sum += a[i];
  if (sum < vol) return 0;
  if (st[now].count(filled>>now)) return 0;
  st[now].insert(filled>>now);
  for (int i=id; i<n; ++i) {
    if (!(used>>i&1)&&vol-a[i]>=0)
      if (select(now,i+1,vol-a[i],used|1LL<<i,filled|1LL<<i))
        return 1;    
  }
  return 0;
}

bool solve(int now, ll used, ll filled) {
  for (int i=now; i<n; ++i) {
    if (!(used>>i&1)) return 0;
    if ((filled>>i&1) && select(i,i+1,a[i],used,filled^1LL<<i)) return 1;
  }
  return 0;
}

int main() {
  while(cin>>n,n) {
    REP(i,n) st[i].clear();
    REP(i,n) cin >> a[i];
    if (n==1) {
      cout << "YES" << endl;
      continue;
    }
    sort(a,a+n,greater<int>());
    if (solve(0, 1, 1))
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}

Measured memory_bytes: 20496
#include <bits/stdc++.h>
using namespace std;
int n;
void solve()
{
    vector < int > inp(n);
    for (int i=0;i<n;i++)
        cin>>inp[i];
    sort(inp.begin(),inp.end());
    cout<<inp[n-1]-inp[0]<<endl;
}
int main()
{
    while(cin>>n)
        solve();
}

Measured memory_bytes: 256
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=acos(-1);
const int inf=1e9;
const ll INF=1e18;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,a[5]={};
  cin >> n;
  for(int i=0; i<5; i++) {
    cin >> a[i];
  }
  sort(a,a+5);
  cout << (n-1)/a[0]+5 << endl;
}

Measured memory_bytes: 256
#include <math.h>

#include <algorithm>
#include <bitset>
#include <iostream>
#include <queue>
#include <sstream>
#include <vector>

using namespace std;

const int INF = 10000000;
typedef pair<int, int> P;

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> C(N);
  vector<vector<int>> A(N, vector<int>(M));
  // vector<vector<int>> test(N, vector<int>(M + 1));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M + 1; j++) {
      if (j == 0) {
        cin >> C[i];
      } else {
        cin >> A[i][j - 1];
      }
    }
  }

  int ans = INF;
  for (int i = 1; i <= (1 << N) - 1; i++) {
    bitset<12> use_flag(i);
    vector<int> sum_A(M, 0);
    int tmp_ans = 0;
    for (int j = 0; j < N; j++) {
      if (use_flag[j]) {
        for (int k = 0; k < M; k++) {
          sum_A[k] += A[j][k];
        }
        tmp_ans += C[j];
      }
    }

    bool pass_flag = true;
    for (int j = 0; j < M; j++) {
      if (sum_A[j] < X) {
        pass_flag = false;
        break;
      }
    }
    if (pass_flag) {
      ans = min(ans, tmp_ans);
    }
  }
  if (ans == INF) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3632