akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define PI 3.141592653589
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define EPS 1e-9
#define f first
#define s second
using namespace std;
int n, maxWeight;
pair<int,int> arr[105];
ll memo[105][100005];
ll solve(int idx, int W){
    if(W > maxWeight)
        return INT_MIN;
    if (idx == n)
        return 0;
    ll &res = memo[idx][W];
    if(res != -1)
        return res;
    return res = max(arr[idx].s+solve(idx+1, W+arr[idx].f), solve(idx+1, W));
}
int main(){
    IO;
    cin >> n >> maxWeight;
    memset(memo, -1, sizeof memo);
    for(int i = 0; i < n; ++i)
        cin >> arr[i].f >> arr[i].s;
    cout << solve(0, 0);
    return 0;
}


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

class SegmentTree {
 public:
  SegmentTree(int N) {
    size_ = N << 1;
    while (size_ & (size_ - 1)) size_ &= (size_ - 1);
    data_.resize(size_ << 1);
  }

  void Add(int begin, int end, int value) {
    AddInner(begin, end, value, 1, 0, size_);
  }

  int Sum(int index) const {
    int sum = data_[index += size_];
    while (index > 1) {
      sum += data_[index >>= 1];
    }
    return sum;
  }

 private:
  void AddInner(int begin, int end, int value,
                int node_index, int node_begin, int node_end) {
    if (end <= node_begin || node_end <= begin) return;
    if (begin <= node_begin && node_end <= end) {
      data_[node_index] += value;
    } else {
      AddInner(begin, end, value, (node_index << 1),
               node_begin, (node_begin + node_end) >> 1);
      AddInner(begin, end, value, (node_index << 1) + 1,
               (node_begin + node_end) >> 1, node_end);
    }
  }

  int size_;
  std::vector<int> data_;
};


int main() {
  int N, K;
  std::cin >> N >> K;
  std::vector<int> A(N), B(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> A[i];
  }
  for (int i = 0; i < K; ++i) {
    SegmentTree segment_tree(N);
    for (int j = 0; j < N; ++j) {
      segment_tree.Add(std::max(0, j - A[j]), std::min(N, j + A[j] + 1), 1);
    }
    int min = N;
    for (int j = 0; j < N; ++j) {
      min = std::min(min, A[j] = segment_tree.Sum(j));
    }
    if (min == N) break;
  }
  for (int a : A) {
    std::cout << a << ' ';
  }
  std::cout << std::endl;
  return 0;
}


Measured memory_bytes: 6952
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
using namespace std;

int main() {
	long long N; cin >> N;
	vector<int>A(N), D(N);
	for (int i = 0; i < N; i++)cin >> A[i];
	for (int i = 0; i < N; i++)D[i] = A[i] - A[(i - 1 + N) % N];

	long long sum = 0;
	for (int i = 0; i < N; i++)sum += A[i];

	long long z = N * (N + 1) / 2;

	bool flag = true;

	if (sum%z)flag = false;

	int k = sum / z;
	for (int i = 0; i < N; i++) {
		D[i] -= k;
		D[i] = -D[i];
		if (D[i] % N || D[i]<0)flag = false;
	}

	if (flag)cout << "YES" << endl;
	else cout << "NO" << endl;


	return 0;
}

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

int main()
{
    string s1,s2;
    cin >> s1 >> s2;
    reverse(s1.begin(),s1.end());
    if(s1 == s2) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
A,B,K = map(int, input().split())
flag = True

for i in range(A,A+K):
    print(i)
    if i == B:
        falg = False
        break

if flag:
 if A+(K-1) < B-(K-1):
    for i in range(B-(K-1),B+1):
        print(i)
        if i == B:
            break

 else:
    for i in range(A+K,B+1):
        print(i)
        if i == B:
            break

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


public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str_nums = br.readLine().split(" ");
        int[] nums = new int[3];
        nums[0] = Integer.parseInt(str_nums[0]);
        nums[1] = Integer.parseInt(str_nums[1]);
        nums[2] = Integer.parseInt(str_nums[2]);
        int triangle = 0;
        int acute = 0;
        int obtuse = 0;
        int right = 0;
        int a, b, c;
        
        while (nums[0] + nums[1] > nums[2] && nums[1] + nums[2] > nums[0] && nums[2] + nums[0] > nums[1]) {
            Arrays.sort(nums);
            a = nums[2];
            b = nums[1];
            c = nums[0];
            
            if (Math.pow(a, 2) == Math.pow(b, 2) + Math.pow(c, 2)) {right++; triangle++;}
            else if (Math.pow(a, 2) > Math.pow(b, 2) + Math.pow(c, 2)) {obtuse++; triangle++;}
            else {acute++; triangle++;}
            
            str_nums = br.readLine().split(" ");
            nums[0] = Integer.parseInt(str_nums[0]);
            nums[1] = Integer.parseInt(str_nums[1]);
            nums[2] = Integer.parseInt(str_nums[2]);
            //System.out.println(a+""+b+""+c);
        }
        
        System.out.println(triangle + " " + right + " " + acute + " " + obtuse);
    }
}



Measured memory_bytes: 24516
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <functional>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main(){
  ll N;
  cin >> N;

  map<ll,ll> mp;
  for(ll i = 1;i <= N;i++){
    ll now = i;
    ll div = 2;
    while(now > 1){
      if(now % div == 0){
        mp[div]++;
        now /= div;
      }
      else div++;
    }
  }

  ll ans = 1;


  for(auto itr:mp){
    ans *= itr.second + 1;
    ans %= MOD;
  }

  cout << ans << endl;

}


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

#define int long long
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
 
using namespace std;

const unsigned int M = 1e9 + 7;

int32_t main() {
	fastio;

	int a, b;
	cin >> a >> b;
	int curr = 1, ans = 0;
	while(curr < b) {
		curr += a;
		--curr;
		++ans;
	}
	cout << ans;

	return 0;
}

/*
With each power strip we get a new sockets. If it satisfies the requirements, we stop there.
* Otherwise, we use one of those a sockets to get a power strip with a new sockets.
*/


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

const int S_MAX = 1e5, A = 1e9 + 7;
char s[S_MAX + 1];
int a[S_MAX], b[S_MAX], c[S_MAX];

int main() {
    scanf("%s", s);
    int l = strlen(s);
    
    int q = 1;
    if (s[0] == 'A' || s[0] == '?') a[0] = 1;
    if (s[0] == '?') q = 3;
    for (int i = 1; i < l; i++) {
        switch (s[i]) {
            case 'A':
                a[i] = (a[i - 1] + q) % A;
                b[i] = b[i - 1];
                c[i] = c[i - 1];
                break;
            case 'B':
                a[i] = a[i - 1];
                b[i] = (b[i - 1] + a[i - 1]) % A;
                c[i] = c[i - 1];
                break;
            case 'C':
                a[i] = a[i - 1];
                b[i] = b[i - 1];
                c[i] = (c[i - 1] + b[i - 1]) % A;
                break;
            case '?':
                a[i] = (static_cast<long>(3) * a[i - 1] + q) % A;
                b[i] = (static_cast<long>(3) * b[i - 1] + a[i - 1]) % A;
                c[i] = (static_cast<long>(3) * c[i - 1] + b[i - 1]) % A;
                q = static_cast<long>(q) * 3 % A;
                break;
        }
    }

    printf("%d\n", c[l - 1]);
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define mkp make_pair
#define nl cout<<endl
#define MOD 1000000007
#define loop(i,start,end) for(ull i=start;i<end;i++)
#define N 100001
#define all(v) v.begin(),v.end()
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define ov(a) for(int i=0;i<a.size();i++)cout<<a[i]<<" ";nl
int main() 
{
    fastio();

  ll n;cin>>n;
  vector<ll>v(n),dp(n+1,0);
  loop(i,0,n)cin>>v[i];

  for(int i = 1;i<n;i++)
  {
    dp[i] = dp[i-1]+abs(v[i]-v[i-1]);
    if(i>1)
      dp[i] =min(dp[i],dp[i-2]+abs(v[i]-v[i-2]));
  }
  cout<<dp[n-1];


  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int n;
double cnt;
int a[105];
int main(void)
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n; i++)
	{
		cnt += 1.0 / a[i];
	}
	cout << 1 / cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX(x,y) ((x)>(y)?(x):(y))
#define MIN(x,y) ((x)<(y)?(x):(y))

int n;
char S[5001];
int dp[5000][5000];

int main(){
  int i, j, r;
  scanf("%d",&n);
  scanf("%s",S);
  for(j=1;j<n;j++) dp[0][j] = S[0] == S[j];
  for(i=1;i<n;i++){
    for(j=i+1;j<n;j++){
      if(S[i] == S[j])
        dp[i][j] = dp[i-1][j-1] + 1;
    }
  }
  r = 0;
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      int x = MIN(j-i, dp[i][j]);
      r = MAX(r, x);
    }
  }
  printf("%d\n", r);

  return 0;
}


Measured memory_bytes: 96768
package main

import "fmt"

func main() {
	var d int
	var t int
	var s int
	fmt.Scan(&d)
	fmt.Scan(&t)
	fmt.Scan(&s)
	ans := d - t*s
	if ans > 0 {
		fmt.Print("No")
	} else {
		fmt.Print("Yes")
	}
}


Measured memory_bytes: 1768
# C - Snuke Festival

import bisect

N = int(input())
A = list(int(x) for x in input().split())
B = list(int(x) for x in input().split())
C = list(int(x) for x in input().split())

A.sort()
C.sort()

ans = 0
for j in range(N):
    ans += bisect.bisect_left(A, B[j]) * (N - bisect.bisect_right(C, B[j]))

print(ans)

Measured memory_bytes: 23360
#include <bits/stdc++.h>
using namespace std;
 
int main() {

string S;
long long K;
cin >>S>>K;
long long count=1;
vector<int>vec(101,0);
if(K==1){
    cout<<S.at(0)<<endl;
    return 0;
}
for(int i=0;i<S.size();i++){
    if(S.at(i)=='1'){
        vec.at(i)++;
    }
    else{
        count=S.at(i)-'0';
        break;
    }
}
 if(K<=101){
    if(vec.at(K-1)==1){
        cout<<1<<endl;
    }
    else{
        cout<<count<<endl;
    }
 } 
 else{
         cout<<count<<endl; 
 } 
}

Measured memory_bytes: 3660
#include <iostream>
#include <string>

using namespace std;

class Element {
   public:
    string value;
    Element* left;
    Element* right;

    Element() : value(""), left(NULL), right(NULL) {}
};

void insert(Element* dict, string s) {
    if (dict == NULL) {
        dict = new Element;
        dict->value = s;
    } else {
        Element* new_elem = new Element;
        new_elem->value = s;

        Element* elem = dict;
        while (true) {
            if (elem->value > s) {
                if (elem->left == NULL) {
                    elem->left = new_elem;
                    break;
                }
                elem = elem->left;
            } else {
                if (elem->right == NULL) {
                    elem->right = new_elem;
                    break;
                }
                elem = elem->right;
            }
        }
    }
}

void delete_dict(Element* dict) {
    if (dict == NULL)
        return;

    delete_dict(dict->left);
    delete_dict(dict->right);
    delete dict;
}

Element* find(Element* dict, string s) {
    Element* elem = dict;
    while (true) {
        if (elem == NULL)
            break;

        if (elem->value == s)
            return elem;
        else if (elem->value > s)
            elem = elem->left;
        else
            elem = elem->right;
    }
    return NULL;
}

int main() {
    ios::sync_with_stdio(false);

    Element* dict = new Element;

    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string op, value;
        cin >> op >> value;

        if (op == "insert") {
            insert(dict, value);
        } else {
            Element* e = find(dict, value);
            if (e != NULL)
                cout << "yes\n";
            else
                cout << "no\n";
        }
    }

    delete_dict(dict);
}



Measured memory_bytes: 47812
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000

int main(){
    char N;
    cin>>N;
    if(N=='A') cout<<"T"<<endl;
    else if(N=='C') cout<<"G"<<endl;
    else if(N=='T') cout<<"A"<<endl;
    else cout<<"C"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n;
    cin >> n;
    int a[n],b[n],c[n];
    rep(i,n){
        cin >> a[i];
        a[i]--;
    }
    rep(i,n)cin >> b[i];
    rep(i,n-1)cin >> c[i];
    int ans=0;
    rep(i,n){
        ans+=b[a[i]];
        if(i==0)continue;
        if(a[i-1]==a[i]-1)ans+=c[a[i]-1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 3

int pane[MAX][MAX];
int temp[MAX][MAX];
int d_x[4]={0,1,0,-1};
int d_y[4]={1,0,-1,0};


void empty(int *,int *);
void swap(int *,int *);
int cal();
int dfs(int ,int ,int ,int ,const int );

int main() {
  int i,j;
  int h,ans,row,col;
      
  for(i=0; i<MAX; i++){
    for(j=0; j<MAX; j++)
      scanf("%d",&pane[i][j]);
  }  
  empty(&row,&col);  
  for(h=0; h<100; h++){
    for(i=0; i<MAX; i++){
      for(j=0; j<MAX; j++)
	temp[i][j] = pane[i][j];
    }    
    ans = dfs(row,col,-1,0,h);    
    if(ans!=-1){
      printf("%d\n",ans);
      break;
    }    
    for(i=0; i<MAX; i++){
      for(j=0; j<MAX; j++)
	pane[i][j] = temp[i][j];
    }    
    ans = -1;
    if(h==99) printf("%d\n\n",ans);
  }      
  return 0;
}

void empty(int *row,int *col){
  int i,j;
  for(i=0; i<MAX; i++)
    for(j=0; j<MAX; j++)
      if(!pane[i][j]){
	*row = j;
	*col = i;
	return;
      }  
}
   
void swap(int *a,int *b){
  int temp;
  
  temp = *a;*a = *b;*b = temp;
}
  
int cal(){
  int i,e;
  int count=0; 
  for(i=0; i<9; i++){
    e = pane[i/3][i%3];
    if(e){
      e--;
      count += abs(i/3 - e/3) + abs(i%3 - e%3);
    }
  }   
  return count;
}
  
int dfs(int x,int y,int p,int deep,const int limt){
  int i, len, x_2, y_2, emc;
  
  len = cal();
  if(len==0) return deep;
  if(deep+len > limt) return -1; 
  for(i=0; i<4; i++){
    x_2 = x+d_x[i];
    y_2 = y+d_y[i];      
    if(~p && i==(p+2)%4) continue;
    if(!(0<=x_2 && x_2<3 && 0<=y_2 && y_2<3)) continue;    
    swap(&pane[y][x],&pane[y_2][x_2]);
    emc = dfs(x_2,y_2,i,deep+1,limt);
    if(~emc) return emc;       
    swap(&pane[y][x],&pane[y_2][x_2]);
  }   
  return -1;
} 



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;

const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a, b;
    vector<int> num(n);
    rep(i,n) {
        cin >> num[i];
        if(num[i]<0) b.push_back(num[i]);
        else a.push_back(num[i]);
    }
    bool ok = false;
    int s = a.size();
    int t = b.size();

    if(s>0){
        if(n==k){
            if(t%2==0) ok = true;
        }
        else ok = true;

    } else {
        if(k%2==0) ok = true;
    }
    mint ans = 1;
    if(!ok) {
        sort(all(num), [](int x, int y) {
            return abs(x) < abs(y);
        });
        rep(i,k) ans *= num[i];
    } else {
        sort(all(a));
        sort(b.rbegin(), b.rend());
        if(k%2==1){
            ans *= a.back();
            a.pop_back();
        }
        vector<ll> P;
        while(a.size() >= 2){
            ll x = a.back();
            a.pop_back();
            ll y = a.back();
            a.pop_back();
            P.push_back(x*y);
        }
        while(b.size() >= 2){
            ll x = b.back();
            b.pop_back();
            ll y = b.back();
            b.pop_back();
            P.push_back(x*y);
        }
        sort(P.rbegin(), P.rend());
        rep(i,k/2) ans *= P[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6320
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace ABC178
{
    class Program
    {
        static void Main(string[] args)
        {
            //var NXT = Console.ReadLine().Split().Select(double.Parse).ToArray();
            //var N = long.Parse(Console.ReadLine());
            var abcd = Console.ReadLine().Split().Select(long.Parse).ToArray();
            // var CA = Enumerable.Repeat(0, (int)N).Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();
            //var L = Console.ReadLine().Split().Select(long.Parse).OrderBy(x => x).ToArray();
            var ans = new long[4];
            ans[0] = abcd[0] * abcd[2];
            ans[1] = abcd[0] * abcd[3];
            ans[2] = abcd[1] * abcd[2];
            ans[3] = abcd[1] * abcd[3];

            Console.WriteLine(ans.Max());

        }
    }
}


Measured memory_bytes: 28300
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m ; cin>>n>>m;
    vector<int> c(m,0);
    rep(i,m) cin>>c[i];
    sort(c.begin(),c.end(),greater<int>());
    
    vector<int> coin(50100,INF);
    rep(i,m) coin[c[i]]=1;
    for(int i=1 ; i<=n; i++){
        for(int j=0; j<m; j++){
            if(i-c[j]>=0){
            coin[i]=min(coin[i],coin[i-c[j]]+1);}
        }
    }
    cout<<coin[n]<<endl;
    
    return 0;
}


Measured memory_bytes: 3220
#include <iostream>
#include <string>
using namespace std;
int main(){
    string tar;
    bool a1, a2;
    a1=a2=false;
    cin>>tar;
    if (tar[0]=='0') a1=true;
    else if (tar[0]=='1'){
        if (tar[1]=='1' || tar[1]=='2') a1=true;
    }
    if (tar[0]=='0' && tar[1]=='0') a1=false;
    if (tar[2]=='0') a2=true;
    else if (tar[2]=='1'){
        if (tar[3]=='1' || tar[3]=='2') a2=true;
    }
    if (tar[2]=='0' && tar[3]=='0') a2=false;
    if (a1==true && a2==true) cout<<"AMBIGUOUS\n";
    else if (a1==true && a2==false) cout<<"MMYY\n";
    else if (a1==false && a2==true) cout<<"YYMM\n";
    else cout<<"NA\n";
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
int cmp3(T lhs, T rhs) { return (lhs == rhs) ? 0 : (lhs > rhs) ? 1 : -1; }

template<typename T>
__attribute__((unused))
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
__attribute__((unused))
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

using namespace std;

void solve(int N, int K, int C, string const &S) {
  vector<int> left(N+2,0), right(N+2,0);
  for (int i = 1; i <= N; ++i) {
    left[i] = max(left[i-1], left[max(0,i-C-1)] + (S[i] == 'o'));
  }
  for (int i = N; i >= 0; --i) {
    int w = (S[i+1] == 'o') ? 1 + right[min(N+1,i+1+C)] : 0;
    right[i] = max(right[i+1], w);
  }
  for (int i = 1; i <= N; ++i) {
    if (S[i] == 'o' && left[i-1] + right[i] < K) {
      printf("%d\n", i);
    }
  }
}

int main() {
  int N, K, C;
  string S;
  cin >> N >> K >> C >> S;

  solve(N, K, C, "-" + S + "-");
  return 0;
}


Measured memory_bytes: 3452
import java.util.*;

public class Main{
	public static void main(String[] args) {
		Scanner fs = new Scanner(System.in);
		int n = fs.nextInt();
		if(n == 1)System.out.println("Hello World");
		else {
			int a = fs.nextInt(),b = fs.nextInt();
			System.out.println(a+b);
		}
		fs.close();
	}
}

Measured memory_bytes: 26924
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <class T> ll size(const T& x) { return x.size(); }
#define rep(i,a,b) for(ll i = (a); i < (b); ++i)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define pb push_back
#define fs first
#define sc second
#define MOD 1000000007
#define MOD2 998244353
#define INF 1000000000000000000ll
#pragma GCC optimize("O1")
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
template <class T> T smod(T a, T b) {
  return (a % b + b) % b; }

#define MAXN 1000010

int spf[MAXN];

// Calculating SPF (Smallest Prime Factor) for every
// number till MAXN.
// Time Complexity : O(nloglogn)
void sieve()
{
    spf[1] = 1;
    for (int i=2; i<MAXN; i++)

        // marking smallest prime factor for every
        // number to be itself.
        spf[i] = i;

    // separately marking spf for every even
    // number as 2
    for (int i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for (int i=3; i*i<MAXN; i++)
    {
        // checking if i is prime
        if (spf[i] == i)
        {
            // marking SPF for all numbers divisible by i
            for (int j=i*i; j<MAXN; j+=i)

                // marking spf[j] if it is not
                // previously marked
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
}

// A O(log n) function returning primefactorization
// by dividing by smallest prime factor at every step
vector<int> getFactorization(int x)
{
    vector<int> ret;
    while (x != 1)
    {
        ret.push_back(spf[x]);
        x = x / spf[x];
    }
    return ret;
}

int cnt[1000010] = {0};
int main()
{
    cin.sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	/*ll t;
	cin >> t;
	while(t--)*/
    int n;
    sieve();
    cin >> n;
    vector<int> A(n);
    rep(i,0,n)
    {
        cin >> A[i];
    }

    set<int> used;
    rep(i,0,n)
    {
        vector<int> ans = getFactorization(A[i]);
        set<ll> ans2;
        rep(i,0,ans.size())
        {
            ans2.insert(ans[i]);
        }
        iter(it,ans2)
        {
            used.insert(*it);
            cnt[*it]++;
        }
    }
    bool is_coprime = true;
    bool is_setprime = true;
    iter(it,used)
    {
        int val = cnt[(*it)];
        if(val > 1)
        {
            is_coprime = false;
        }

        if(val == n)
        {
            is_setprime = false;
        }
    }
    if(is_coprime)
    {
        cout << "pairwise coprime" << '\n';
        return 0;
    }
    if(is_setprime)
    {
        cout << "setwise coprime" << '\n';
        return 0;
    }
    cout << "not coprime" << '\n';
    return 0;
}


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

int main(){
    int X, A, B;
    cin >> X >> A >> B;
    if(A-B>=0){
        cout << "delicious" <<endl;
    }
    else if(A-B<0 && A-B>=X*(-1)){
        cout << "safe" <<endl;
    }
    else{
        cout << "dangerous" <<endl;
    }
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(1000000)

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

memo=[-1 for i in range(0,N)]
memo[-1]=0
memo[-2]=abs(h[-2]-h[-1])

def ans(num):
    if memo[num]!=-1:
        return memo[num]

    memo[num]=min(ans(num+1)+abs(h[num+1]-h[num]),ans(num+2)+abs(h[num+2]-h[num]))

    return memo[num]

print(ans(0))


Measured memory_bytes: 116728
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード
 
//ループ
#define rep(i, n) for(int i = 0; i < (n); i++) //普通のループ
#define repr(i, n) for(int i = n; i >= 0; i--) //逆ループ
 
//型名省略
typedef long long ll;
//値
static const ll MX = 100005;
static const ll MX_ll = 1e18;
const double PI = acos(-1); //π
 
using namespace std;
 
//ソート
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 
//#include "./lib/generic/search.h"
 
//ポップカウントの計算
int pcnt(int x){ 
    return __builtin_popcount(x);  //2進数の1の数を数えす
}
 
//再帰的にf(n)を求める
int f(int x){
    if(x==0) return 0;
    return f(x%pcnt(x))+1; //1度割ることができたら1回操作が増えるので+1している
}
 
int main(){
    ll a;
    cin >> a;
    string b;
    cin >> b;
    b.erase(1,1); //小数点削除
    ll nb = (ll)atoi(b.c_str());
    a *= nb;
    a /= 100;
    printf("%lld\n", a);
    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x,y,z,k;
    cin>>x>>y>>z>>k;
    ll a[x],b[y],c[z];
    for(ll i=0;i<x;i++)
    {
        cin>>a[i];
    }
    for(ll i=0;i<y;i++)
    {
        cin>>b[i];
    }
    for(ll i=0;i<z;i++)
    {
        cin>>c[i];
    }
    vector<ll>max2;
    for(ll i=0;i<x;i++)
    {
        for(ll j=0;j<y;j++)
        {
            max2.push_back(a[i]+b[j]);
        }
    }
    sort(max2.begin(),max2.end(),greater<ll>());
    for(ll i=0;i<max2.size();i++)
    {
      //  cout<<max2[i]<<" ";
    }
    //cout<<endl;
    vector<ll>max3;
    ll maxi=min(k,(ll)max2.size());
    for(ll i=0;i<maxi;i++)
    {
        for(ll j=0;j<z;j++)
        {
            max3.push_back(max2[i]+c[j]);
        }
    }
    sort(max3.begin(),max3.end(),greater<ll>());
    for(ll i=0;i<k;i++)
    {
        cout<<max3[i]<<" ";
    }
	return 0;
}


Measured memory_bytes: 42980
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int A,B,T;
  cin>>A>>B>>T;
  cout<<B*(T/A)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

long double length(long double x1, long double y1, long double x2, long double y2){
	return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
}

long double area(long double len1, long double len2, long double len3){
	long double len;
	len = (len1 + len2 + len3) / 2;
	return sqrt(len * (len - len1) * (len - len2) * (len - len3));
}

int main(){
	
	double x_origin, y_origin, length1, length2, length3, x1, y1, x2, y2;
	
	scanf("%lf,%lf", &x_origin, &y_origin);
	scanf("%lf,%lf", &x1, &y1);
	
	length1 = length(x1, y1, x_origin, y_origin);
	
	double ans;
	
	ans = 0;
	
	while(scanf("%lf,%lf", &x2, &y2) != EOF){
		length2 = length(x2, y2, x_origin, y_origin);
		length3 = length(x2, y2, x1, y1);
		//printf("%f %f %f",length1, length2, length3);
		ans += area(length1, length2, length3);
		length1 = length2;
		x1 = x2;
		y1 = y2;
	}
	
	printf("%.10f\n", ans);
	
	return 0;
}

Measured memory_bytes: 1240
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int N=gi();
	    String S=gs();
        StringBuilder sb=new StringBuilder();
        for (int i=0; i<S.length(); i++) {
        	char c=S.charAt(i);
        	char nc= (char)(((c+N-65)%26)+65);
        	sb.append(nc);
        }


        System.out.print(sb.toString());

//        if (N%2==0 && s.substring(0, N/2).equals(s.substring(N/2))) {
//        	System.out.println("Yes");
//        }else{
//        	System.out.println("No");
//        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35692
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>

using namespace std;

using ll = long long;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

template<class T>
void print(vector<T> a) {
  cout << "[ ";
  REP(i, a.size()) cout << a[i] << " ";
  cout << "]" << endl;
}

void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...);
}

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

vector<vector<ll>> table(20 + 1, vector<ll>(50000 + 1, -1));
ll N, M;
vector<ll> c;
ll dfs(ll i, ll sum) {
  if (sum == N) return 0;
  if (i == M) return N; // numeric_limits<ll>::max() / 2;
  if (table[i][sum] != -1) return table[i][sum];

  if (sum + c[i] <= N) {
    return table[i][sum] = min(dfs(i + 1, sum), dfs(i, sum + c[i]) + 1);
  } else {
    return table[i][sum] = dfs(i + 1, sum);
  }
}

int main() {
  ll input(n, m); N = n; M = m;
  c = vector<ll>(m);
  REP(i, m) cin >> c[i];
  cout << dfs(0, 0) << endl;
}



Measured memory_bytes: 13256
a,b,c,k=map(int,input().split())
ans=min(a,k)
k=max(0,k-a)
if k==0:
    print(ans)
    exit()
k=max(0,k-b)
if k==0:
    print(ans)
    exit()
ans-=min(c,k)
k=max(0,k-c)
if k==0:
    print(ans)
    exit()


Measured memory_bytes: 61636
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define endl            "\n"
#define forn(i,x1,n)     for(int i=x1; i<n; i++)
#define forit(it, m)    for(decltype(m)::iterator it = m.begin(); it!=m.end(); ++it)
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x1)      __builtin_popcountll(x1)
#define zrobits(x1)      __builtin_ctzll(x1)
#define mod             1000000007
#define inf             1e18
#define ps(x1,y)         fixed<<setprecision(y)<<x1
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x1)            int x1; cin>>x1; while(x1--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());


void zeus()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int32_t main() {

    zeus();

    int h, w, m; cin >> h >> w >> m;

    int row[h + 1] = {0};
    int col[w + 1] = {0};

    set<pair<int, int>> pairs;

    forn(i, 0, m) {
        int x; int y; cin >> x >> y;
        row[x]++;
        col[y]++;
        pairs.insert({x, y});
    }

    pair<int, int> rows[h], cols[w];

    forn(i, 1, h + 1) {
        rows[i - 1] = {row[i], i};
    }

    forn(i, 1, w + 1) {
        cols[i - 1] = {col[i], i};
    }

    sort(rows, rows + h);

    // forn(i, 0, h) {
    //     cout << rows[i].ss << " " << rows[i].ff << endl;
    // }
    sort(cols, cols + w);

    int maxrow = rows[h - 1].ff;
    int maxcol = cols[w - 1].ff;
    // cout << rows[h - 1].ss << " " << cols[w - 1].ff << endl;
    // cout << maxrow << " " << maxcol << endl;
    int ans = maxrow + maxcol - 1;

    for (int i = h - 1; i >= 0; i--) {
        if (rows[i].ff < maxrow) {
            break;
        }
        for (int j = w - 1; j >= 0; j--) {
            if (cols[j].ff < maxcol) {
                break;
            }
            // cout << rows[i].ss << " " << cols[j].ss << endl;
            if (pairs.count({rows[i].ss, cols[j].ss}) == 0) {
                ans++;
                cout << ans << endl;
                return 0;
            }
        }
    }

    cout << ans << endl;






}








Measured memory_bytes: 36444
#include<bits/stdc++.h>
using namespace std;
const int N=305;
int dp[N][N][N];
int main()
{
    string s; int k;
    cin>>s>>k;
    int n=s.size();
    s='a'+s;
    for(int i=1;i<=n;i++)
    {
        dp[0][i][i]=1;
        if(i==n)
            continue;
        if(s[i]==s[i+1])
            dp[0][i][i+1]=2;
        else
            dp[0][i][i+1]=1;
    }
    for(int len=2;len<n;len++)
    {
        for(int i=1;i+len<=n;i++)
        {
            dp[0][i][i+len]=max(dp[0][i][i+len-1],dp[0][i+1][i+len]);
            if(s[i]==s[i+len])
                dp[0][i][i+len]=max(dp[0][i][i+len],dp[0][i+1][i+len-1]+2);
        }
    }
    for(int x=1;x<=n;x++)
    {
        for(int i=1;i<=n;i++)
        {
            dp[x][i][i]=1;
            if(i!=n) dp[x][i][i+1]=2;
        }
        for(int len=2;len<n;len++)
        {
            for(int i=1;i+len<=n;i++)
            {
                if(s[i]==s[i+len])
                    dp[x][i][i+len]=dp[x][i+1][i+len-1]+2;
                dp[x][i][i+len]=max(max(dp[x][i+1][i+len],dp[x][i][i+len-1]),max(dp[x][i][i+len],dp[x-1][i+1][i+len-1]+2));
            }
        }
    }
    cout<<dp[k][1][n]<<endl;
    return 0;
}


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

int main(){
    int n,x,t; cin >> n >> x >> t;
    n += (x-1);
    cout << n/x*t << endl;
}

Measured memory_bytes: 3644
#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 tmp;
  for (int i = 0; i < N; i++)
  {
    for (int j = N - 1; j > i; j--)
    {
      if (d.at(j) > d.at(j-1))
      {
        tmp = d.at(j);
        d.at(j) = d.at(j-1);
        d.at(j-1) = tmp;
      }
    }
  }
  
  int r = 0;
  tmp = 0;
  for (int i = 0; i < N; i++)
  {
    if(tmp != d.at(i))
    {
      r++;
      tmp = d.at(i);
    }
  }
  cout << r << endl;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int>v(n);
    for (auto& x : v)
        cin >> x;
    sort(v.rbegin(), v.rend());
    int id = 0;
    long long ans = 0;
    for (int i(0); i < n - 1; ++i) {
        ans += v[id];
        if (i & 1 ^ 1) {
            id++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int n; cin>>n;
	int ans=0;
	for(int i=1; i<=n; i++){
		int aux = (log10(i)+1);
		if(aux%2!=0)
			ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3852
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i< (int)(n); i++)
#define rep2(i,x,n) for(int i = (int)x; i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define repitr(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){

	int n;
	cin >> n;
	vector<pair<int, int>> vp;
	int fp;
	if(n % 2 == 1) fp = n;
	else fp = n + 1;
	rep2(i, 1, n){
		rep2(j, i+1, n+1){
			if(i+j != fp) vp.push_back(make_pair(i, j));
		}
	}
	cout << vp.size() << endl;
	for(auto p : vp){
		cout << p.first << " " << p.second << endl;
	}
	return 0;
	
}

Measured memory_bytes: 384
A=[]
while True:
	try:
		x=int(input())
		A.append(x)
	except EOFError:
		break

num=[]
for i in range(101):
	num.append((A.count(i),i))

num.sort(reverse=True)
mode_value=num[0][0]
B=[]
for i in num:
	if i[0]==mode_value:
		B.append(i[1])
		
B.sort()
for i in B:
	print(i)

Measured memory_bytes: 7568
AList = list(map(int, input().split()))
BList = list(map(int, input().split()))
CList = list(map(int, input().split()))
N = int(input())
DList = [int(input()) for i in range(N)]

def Bcheck(AList,BList,CList):
    if AList[0]=="x" and AList[1]=="x" and AList[2]=="x":
        return "bingo"
    elif BList[0]=="x" and BList[1]=="x" and BList[2]=="x":
        return "bingo"
    elif CList[0]=="x" and CList[1]=="x" and CList[2]=="x":
        return "bingo"
    elif AList[0]=="x" and BList[0]=="x" and CList[0]=="x":
        return "bingo"
    elif AList[1]=="x" and BList[1]=="x" and CList[1]=="x":
        return "bingo"
    elif AList[2]=="x" and BList[2]=="x" and CList[2]=="x":
        return "bingo"
    elif AList[0]=="x" and BList[1]=="x" and CList[2]=="x":
        return "bingo"
    elif AList[2]=="x" and BList[1]=="x" and CList[0]=="x":
        return "bingo"
    else:
        return 0

i=0
while i<N:
    if AList.count(DList[i])!=0:
        AList[(AList.index(DList[i]))]="x"
    elif BList.count(DList[i])!=0:
        BList[(BList.index(DList[i]))]="x"
    elif CList.count(DList[i])!=0:
        CList[(CList.index(DList[i]))]="x"
        
    if Bcheck(AList,BList,CList)=="bingo":
        print("Yes")
        quit()

    i+=1

print("No")

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

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

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> p(m), y(m);
  vector<vector<ll>> yd(n + 1);

  rep(i, m) cin >> p[i] >> y[i], yd[p[i]].push_back(y[i]);
  rep(i, n) sort(yd[i + 1].begin(), yd[i + 1].end());
  rep(i, m) printf("%06lld", p[i]),
      printf("%06lld\n", lower_bound(yd[p[i]].begin(), yd[p[i]].end(), y[i]) -
                             yd[p[i]].begin() + 1LL);
}


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

const long long INF = 1LL << 60;
int N, K;
long long h[100010];
long long dp[100010];

int main() {
  cin >> N >> K;
  for (int i = 0; i < N; i++) cin >> h[i];

  for (int i = 0; i < 100010; i++) dp[i] = INF;

  dp[0] = 0;
  for (int i = 1; i < N; i++) {
    for (int j = 1; j <= K; j++) {
      if (i - j >= 0) {
        dp[i] = min(dp[i], dp[i - j] + llabs(h[i] - h[i - j]));
      }
    }
  }

  cout << dp[N - 1] << endl;

  return 0;
}

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

public class Main {
	public static void main(String[] args) throws IOException {
		setIO();
		
		int X = ni();
		out.println(X >= 30 ? "Yes" : "No");

		f.close();
		out.close();
	}

	static final int MOD = 1000000007;

	static BufferedReader f;
	static PrintWriter out;

	static int ni(StringTokenizer st) {
		return Integer.parseInt(st.nextToken());
	}

	static int ni() throws IOException {
		return Integer.parseInt(f.readLine());
	}

	static StringTokenizer nl() throws IOException {
		return new StringTokenizer(f.readLine());
	}

	static int[] nia(int N) throws IOException {
		StringTokenizer st = nl();
		int[] A = new int[N];
		for (int i = 0; i < N; i++)
			A[i] = ni(st);
		return A;
	}

	static void setIO(String s) throws IOException {
		f = new BufferedReader(new FileReader(s + ".in"));
		out = new PrintWriter(new FileWriter(s + ".out"));
	}

	static void setIO() {
		f = (new BufferedReader(new InputStreamReader(System.in)));
		out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	}
}


Measured memory_bytes: 33032
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <string>
#include <stack>
#include <set>
#include <vector>
#include <numeric>

using namespace std;

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef pair<int,int> pii;

const int INF = 1 << 29;
const double EPS = 1e-10;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
  return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
  os<<'[';
  rep(i,a.size()) os<<(i?" ":"")<<a[i];
  return os<<']';
}



int main() {
  for (int n; cin >> n, n != 0; ) {
    vi s(n);
    rep(i, n) cin >> s[i];

    cout << (accumulate(all(s), 0) - *max_element(all(s)) - *min_element(all(s))) / (n - 2) << endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 1196
N,M=list(map(int,input().split()))
root=[i for i in range(N)]
height=[0]*N
def find(a):
   f=a
   if a==root[a]:
      return a
   while a!=root[a]:
      a=root[a]
   root[f]=a
   return a
def union(a,b):
   A=find(a)
   B=find(b)
   if A==B:
      return
   if height[A]>height[B]:
      root[B]=root[A]
   else:
      root[A]=root[B]
      if height[A]==height[B]:
         height[B]+=1

for i in range(M):
   a,b,c=map(int,input().split())
   a-=1;b-=1
   union(a,b)
l=[0]*N
for j in range(N):
   l[find(j)]+=1
print(N-l.count(0))

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

int main(){
    string s, t;
    cin >> s;
    cin >> t;
    if (s.size() > t.size()) {
        cout << "GREATER\n";
        return 0;
    }
    else if (s.size() < t.size()) {
        cout << "LESS\n";
        return 0;
    }
    for (int i = 0; i < s.size(); i++) {
        if (s[i] > t[i]) {
            cout << "GREATER\n";
            return 0;
        } else if (s[i] < t[i]) {
            cout << "LESS\n";
            return 0;
        }
        
    }
    cout << "EQUAL\n";
    return 0;
}

Measured memory_bytes: 256
from collections import *
from itertools import *
from bisect import *
import copy

n,a,b=map(int,input().split())
mod=10**9+7
fac=[0,1]

num=n
for i in range(2,b+1):
    num=num*pow(i,mod-2,mod)*(n+1-i)%mod
    #print(num,i)
    if a==i:
        numa=num
    if b==i:
        numb=num
if a==1:
    numa=n
#print(numa,numb)
print((pow(2,n,mod)-numa-numb)%mod-1)


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}


const ll INF = 1LL << 61;
struct P {
  int L;
  int R;
  int C;
};

const int MAX_N = 112345;
const int MAX_M = 112345;
vector<P> p[MAX_M];

struct RMQ {
  using Val = ll;
  int n;
  vector<Val> vs;
  void clear(int N) {
    for (n = 1; n < N; n <<= 1);
    vs.assign(n * 2, INF);
  }
  Val get(int pos) {
    return vs[n+pos];
  }
  void update(int pos, Val val) {
    vs[n+pos] = val;
    for (int k = (n+pos)/2; k > 0; k >>= 1)
      vs[k] = min(vs[2*k], vs[2*k+1]);
  }
  // [l, r) の最小値を返す
  Val query(int l, int r) {
    return query(0, n, 1, l, r);
  }
  Val query(int nl, int nr, int k, int l, int r) {
    if (r <= nl || nr <= l) return INF;
    if (l <= nl && nr <= r) return vs[k];
    Val x = query(nl, (nl+nr)/2, 2*k  , l, r);
    Val y = query((nl+nr)/2, nr, 2*k+1, l, r);
    return min(x, y);
  }
};

int main2() {
  REP(i, MAX_M) p[i].clear();

  int N = nextInt();
  int M = nextInt();
  REP(i, M) {
    int L = nextInt();
    int R = nextInt();
    int C = nextInt();
    p[R].push_back((P){L, R, C});
  }

  RMQ dp;
  dp.clear(N+10);
  REP(i, N+1) dp.update(i,INF);
  dp.update(0, 0);
  dp.update(1, 0);
  for (int i = 2; i <= N; i++) {
    ll val = INF;
    for (P range : p[i]) {
      chmin(val, dp.query(range.L, range.R) + range.C);
    }
    dp.update(i, val);
  }

  ll ans = dp.get(N);
  if (ans >= INF / 2) ans = -1;
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 7936
//In the Name of Allah Most Gracious, Most Merciful//
/*If you want something you've never had, you have  to do something you never did.*/

#include<bits/stdc++.h>
using namespace std;


#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define M 100007
#define INF 1e9
#define INFL 1e18
#define PI acos(-1)
#define mp make_pair

//const int fx[]= {+1,-1,+0,+0};
//const int fy[]= {+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move


int N,W;
int w[101000];
int v[101000];
ll dp[101][100010];


ll myknapsack(ll i,ll sum)
{
    if(i>=N)
    {
        return 0;
    }
    if(dp[i][sum]!=-1)
        return dp[i][sum];
    ll ret1=0,ret2=0;
    if(sum+w[i]<=W)
    {
        ret1=v[i]+myknapsack(i+1,sum+w[i]);
    }
    ret2=myknapsack(i+1,sum);

    dp[i][sum]=max(ret1,ret2);
    return dp[i][sum];
}

int main()
{

   //  #ifndef ONLINE_JUDGE
   //    freopen("input.txt","r",stdin);
   //    freopen("output.txt","w",stdout);
  //   #endif
  cin>>N>>W;
  for(int i=0;i<N;i++)
  {
      cin>>w[i]>>v[i];
  }
  memset(dp,-1,sizeof dp);
  ll ans=myknapsack(0,0);
  cout<<ans<<endl;
}



Measured memory_bytes: 82516
import heapq
import sys

lines = sys.stdin.readlines()

N, M = [int(n) for n in lines[0].strip().split()]
prices = [-int(n) for n in lines[1].strip().split()]

heapq.heapify(prices)

for _ in range(M):
    price = -heapq.heappop(prices)
    heapq.heappush(prices, -1 * (price // 2))

print(-sum(prices))

Measured memory_bytes: 20932