akhauriyash/Code-Regression huggingface dataset:
program triangles
  implicit none
  integer :: n, l(2000) = 0, m = 0, i, j
  read(*,*) n
  read(*,*) l(1:n)
  call quick_sort(l(1:n))
  do i = 1, n-2
    do j = i+1, n-1
      m = m+limit(l(1:n),j,l(i)+l(j))-j
    end do
  end do
  write(*,'(i0)') m
contains
  function limit(a,i,v) result(l)
    integer, intent(in) :: a(:), v
    integer, intent(in) :: i
    integer :: l, r, m
    l = i
    r = size(a,1)+1
    do while (r-l > 1)
      m = (r+l)/2
      if (a(m) < v) then
        l = m
      else
        r = m
      end if
    end do
  end
  recursive subroutine quick_sort(a)
    integer, intent(inout) :: a(:)
    integer :: n, l, r, m
    integer :: p
    n = size(a)
    l = 1
    r = n
    m = (n+1)/2
    p = a(l)+a(m)+a(r)-max(a(l),a(m),a(r))-min(a(l),a(m),a(r))
    do
      do while (a(l) < p)
        l = l+1
      end do
      do while (a(r) > p)
        r = r-1
      end do
      if (l >= r) exit
      a(l) = xor(a(l),a(r))
      a(r) = xor(a(l),a(r))
      a(l) = xor(a(l),a(r))
      l = l+1
      r = r-1
    end do
    if (l-1 > 1) call quick_sort(a(1:l-1))
    if (n > r+1) call quick_sort(a(r+1:n))
  end
end program triangles

Measured memory_bytes: 256
n = int(input())
s = [int(input()) for _ in range(n)]
candidate = [sum(s)]
for i in range(n):
    candidate.append(candidate[0] - s[i])
candidate.sort(reverse=True)
for i in range(n):
    if candidate[i] % 10 != 0:
        print(candidate[i])
        exit()
print(0)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};
constexpr int INF = 1 << 30;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    string s;
    cin >> s;

    vector<int> idx[10];
    for(int i=0;i<n;++i) {
        int num = int(s[i] -  '0');
        idx[num].push_back(i);
    }


    int ans = 0;
    int now = -1;
    for(int i=0;i<10;++i) {
        auto itr_i = upper_bound(idx[i].begin(), idx[i].end(), now);
        if(itr_i == idx[i].end()) continue;
        now = *itr_i;
        for(int j=0;j<10;++j) {
            auto itr_j = upper_bound(idx[j].begin(), idx[j].end(), now);
            if(itr_j == idx[j].end()) continue;
            now = *itr_j;
            for(int k=0;k<10;++k) {
                auto itr_k = upper_bound(idx[k].begin(), idx[k].end(), now);
                if(itr_k == idx[k].end()) continue;
                ++ans;
            }
            now = *itr_i;
        }
        now = -1;
    }
    cout << ans << endl;
}


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

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  if(N%2 == 1){
    cout << "No" << endl;
  }else{
   vector<char> A(N/2),B(N/2);
    for(int i=0;i<N/2;i++){
      A.at(i)=S.at(i);
      B.at(i)=S.at(N/2+i);
    }
    if(A==B){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextLong()
    val b = sc.nextLong()
    val k = sc.nextLong()
    println(problem093b(a, b, k))
}

fun problem093b(a: Long, b: Long, k: Long): String {
    val answers = mutableListOf<Long>()
    for (i in 0 until k) {
        val ai = a + i
        val bi = b - i
        if (ai == bi) {
            answers.add(ai)
            break
        }
        if (ai > bi) {
            break
        }
        answers.add(ai)
        answers.add(bi)
    }
    return answers.sorted().joinToString("\n")
}

Measured memory_bytes: 34372
N = gets.chomp.to_i

t = [0]
sum = 0
i = 1
while sum < 1000000000000001
  sum += 26**i
  t[i] = sum
  i+= 1
end

keta = 0
nokori = 0
1.upto(20) do |i|
  if t[i] >= N
    keta = i
    nokori = N - t[i-1]
    break
  end
end

n = nokori - 1

ans = []
(keta-1).downto(0) do |i|
  k = 26**i
  u = n/k
  ans.push u
  next if u.zero?
  n %= k*u
end

al = ('a'..'z').to_a
puts ans.map{|an| al[an]}.join('')


Measured memory_bytes: 14288
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

void solve() {
	int n;
	cin >> n;
	
	cout << fixed << setprecision(6);
	
	if(n % 2 == 0) cout << "0.5000000000" << endl;
	else cout << (((int)n / 2) + 1) / (float)n << endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

Measured memory_bytes: 3776
S = input()
gx, gy = map(int, input().split())
SL = S.split('T')
D = [len(sli) for sli in SL]
DX = D[2::2]
DY = D[1::2]

def reachable(D, s, g):
    dp = [{} for _ in range(len(D)+1)]
    dp[0][s] = 1
    for i in range(len(D)):
        d = D[i]
        for j in dp[i]:
            dp[i+1][j+d] = 1
            dp[i+1][j-d] = 1
    return g in dp[-1]

if reachable(DX, D[0], gx) and reachable(DY, 0, gy):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 387876
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define LEN 1000000

typedef struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
}*NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  // ここから
	
	NodePointer cur=nil->next;
	while(cur!= nil && cur->key!=key){
		cur=cur->next;
	}
	
	return cur;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
	// ここから
	if(t==nil) return;
	t->prev->next=t->next;
	t->next->prev=t->prev;
	free(t);

}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  //ここから
	
	deleteNode(nil->prev);
}

void delete(int key){
  //ここから
	
	deleteNode(listSearch(key));
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
	
	// ここから
	x->next=nil->next;
	nil->next->prev=x;
	nil->next=x;
	x->prev=nil;

}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}

/*
void insert(int x[], int number, int cnt);
int delete(int x[], int number, int cnt);
void delete_F(int x[]);
void delete_L(int x[],int cnt);

int main(){
	int list[LEN],N,cnt=0,number,flag=0;
	char command[15];
	
	for(int i=0;i<LEN;i++){
		list[i]=0;
	}
	
	scanf("%d",&N);
	
	
	for(int i=0;i<N;i++){
		scanf("%s",command);
		if(strcmp(command,"insert")==0){
			scanf("%d",&number);
			insert(list,number,cnt);
			cnt++;
		}else if(strcmp(command,"delete")==0){
			flag=0;
			scanf("%d",&number);
			flag=delete(list,number,cnt);
			if(flag) cnt--;
		}else if(strcmp(command,"deleteFirst")==0){
			delete_F(list);
			cnt--;
		}else{
			delete_L(list,cnt);
			cnt--;
		}
		
		printf("%d",list[0]);
		for(int j=1;j<cnt;j++){
			printf(" %d",list[j]);
		}
		printf("\n");
		
	}
	
	printf("%d",list[cnt-1]);
	for(int j=cnt-2;j>=0;j--){
		printf(" %d",list[j]);
	}
	printf("\n");
	
  return 0;
}

void insert(int x[], int number, int cnt){
	
	x[cnt]=number;

}

int delete(int x[], int number, int cnt){
	
	int j=0;
	if(number==x[cnt-1]) return 1;
	for(int i=cnt-2;i>=0;i--){
		if(number==x[i]){
			for(j=i;j<cnt-1;j++){
				x[j]=x[j+1];
			}
			return 1;
		}
	}
	
	return 0;
}
void delete_F(int x[]){
	
	;
	
}
void delete_L(int x[],int cnt){
	for(int i=0;i<cnt-1;i++){
		x[i]=x[i+1];
	}
}
*/


Measured memory_bytes: 32952
/***********************************
*******AUTHOR SHASHI KANT **********         
****GMAIL Shshiksnt140895@gmail.com*
************************************                                  
***********************************/
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
/*class graph
{
	map<int,list<int>>adj;
	public :
	       void addedge(int a, int b)
	       {
	           adj[a].push_back(b);
	           adj[b].push_back(a);
	       }

}*/
ll max_path(vector<vector<ll>>mat, ll n, ll m)
{
	int flag1 = 0;
    int flag2 = 0;

	for(ll i=0; i<m; i++)
	{
		if(mat[0][i] == 1 && flag1 == 0)
			 continue;
			else
			{
				mat[0][i] = 0;
				flag1 = 1;
			}
	}

	for(ll i=1; i<n; i++)
	{

		if(mat[i][0] == 1 && flag2 == 0)
			{ continue;}
			else
			{
				mat[i][0] = 0;
				flag2 = 1;
			}
	}
	
	for(ll i=1; i<n; i++)
	{
		for(ll j =1; j<m; j++)
		{
			if(mat[i][j] == 0)
				continue;
			else
				mat[i][j] = ((mat[i-1][j]%mod) + (mat[i][j-1])%mod )%mod;
		}
	}
	
	return mat[n-1][m-1]%mod;

}
int main(){
      // int t;
    //   cin>>t;
     //  while(t--)
  //     {
       	ll n, m;
       	cin>>n>>m;
       	vector<vector<ll>>mat(n, vector<ll>(m));
       	char ch ;
       	for(int i=0; i<n; i++)
       	{
       		for(int j=0; j<m; j++)
       			{
       				cin>>ch;
       				if(ch == '.')
                      mat[i][j] = 1;
                    else
                  	mat[i][j] = 0;
       			}
       	}

       cout<< max_path(mat, n, m);

      // }	
	return 0;
}

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

typedef long long ll;
int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    int n,sum=0,dt;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>dt;
        sum+=dt-1;
    }

    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int i, j, num, a, b, go;
	int m[200][200] = { 0 };

	scanf("%d", &num);

	for (i = 0; i < num; i++) {
		scanf("%d", &a);
		scanf("%d", &b);

		for (j = 0; j < b; j++) {
			scanf("%d", &go);
			m[a - 1][go - 1]++;
		}
	}
	
	for (i = 0; i < num; i++) {
		for (j = 0; j < num; j++) {
			printf("%d", m[i][j]);

			if (j != num - 1) {
				putchar(' ');
			}
		}
		putchar('\n');
	}

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))
#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define All(x) (x).begin(),(x).end()
#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))
#define End '\n'
#define Out(x) cout<<(x)<<End
template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);

    int h, w;

    cin >> h >> w;

    string grid[h];
    bool isOne;

    int i, j;

    rep(i, h) cin >> grid[i];

    rep(i, h) {
        rep(j, w) {
            if (grid[i][j] == '#') {
                isOne = true;

                if (0 <= i - 1 && grid[i - 1][j] == '#') isOne = false;
                if (i + 1 < h && grid[i + 1][j] == '#') isOne = false;
                if (0 <= j - 1 && grid[i][j - 1] == '#') isOne = false;
                if (j + 1 < w && grid[i][j + 1] == '#') isOne = false;

                if (isOne) {
                    Out("No");

                    return 0;
                }
            }
        }
    }

    Out("Yes");

    return 0;
}


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

using namespace std;


void solve() {
    int n; cin >> n;
    int ct=0, cx=0, cy=0;
    for (int _ = 0; _ < n; _++) {
        int t,x,y;
        cin >> t >> x >> y;
        int d = abs(x-cx) + abs(y-cy);
        int dt = t - ct;
        if (dt>=d && (dt-d)%2==0) {
            ct=t, cx=x, cy=y;
        } else {
            cout << "No"; return;
        }
    }
    cout << "Yes";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
use proconio::input;
use std::cmp::min;

fn main() {
    input! {
        n: u64,
        a: [u64; n+1]
    };
    if n == 0 {
        if a[0] == 1 {
            println!("1");
        } else {
            println!("-1");
        }
        return ();
    }

    let mut e: Vec<u64> = vec![0; (n+1) as usize];
    let mut s: u64 = a.iter().sum();
    e[0] = 1;
    let mut x: u64;

    for i in (1..(n+1)).map(|e| e as usize) {
        e[i] = min((e[i-1] - a[i-1]) * 2, s);
        if e[i] < a[i] {
            println!("-1");
            return ();
        }
        s = s - a[i];
    }
    println!("{}", e.iter().sum::<u64>());
}


Measured memory_bytes: 4320
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define inf 1001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define aint(x) (x).begin(),(x).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(15) << fixed;

  char c;
  cin >> c;
  cout << (islower(c) ? 'a' : 'A') << endl;
  
}


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pop_b pop_back
#define pf push_front
#define pop_f pop_front

typedef long long ll;
typedef pair<ll,ll> ii;
typedef long double ld; 
typedef vector<int> vi;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define rep2r(i, l, r) for (ll i = (r) - 1; i >= (l); i--)

int main()
{
	int k, a, b;
	cin>>k>>a>>b;
	int p = (a)/k;
	cout<<(k*(p + (a%k ? 1 : 0)) <= b ? "OK" : "NG")<<endl;
}

Measured memory_bytes: 3576
dataset = gets.to_i
dataset.times do |i|
	data = gets
	c = data.split(nil)
	if c[0].to_i ** 2 + c[1].to_i ** 2 == c[2].to_i ** 2 or
		c[1].to_i ** 2 + c[2].to_i ** 2 == c[0].to_i ** 2 or
		c[2].to_i ** 2 + c[0].to_i ** 2 == c[1].to_i ** 2
		puts "YES"
	else
		puts "NO"
	end
end

Measured memory_bytes: 6120
#include<stdio.h>
int q[10010];
int topo(int v,int e,int *a,int *b){
  int ta[10010],nt[100010];
  int i,t,r,c[10010]={0};
  for(i=0;i<e;i++)c[b[i]]++;
  for(i=r=0;i<v;i++){
    ta[i]=-1;
    if(c[i]==0)q[r++]=i;
  }
  for(i=0;i<e;i++){
    nt[i]=ta[a[i]];
    ta[a[i]]=i;
  }
  for(t=0;t<v;t++){//printf("%d:",q[t]);
    //for(i=0;i<v;i++)printf("%d ",c[i]);printf("\n");
    for(i=ta[q[t]];i+1;i=nt[i]){
      c[b[i]]--;
      if(c[b[i]]==0)q[r++]=b[i];
    }
  }
  //for(i=0;i<v;i++)printf("%d ",c[i]);printf("\n");
}
int main(){
  int v,e,m,i,s,a[100010],b[100010];
  scanf("%d %d",&v,&e);
  for(i=0;i<e;i++)scanf("%d %d",&a[i],&b[i]);
  topo(v,e,a,b);
  for(i=0;i<v;i++)printf("%d\n",q[i]);
  return 0;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

template<class T>
inline bool chmax(T &a, T b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
};

template<class T>
inline bool chmin(T &a, T b) {
  if(a > b) {
    a = b;
    return true;
  }
  return false;
};

int main() {
  int X;
  cin >> X;
  if (X == 3 || X == 5 || X == 7) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
};


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

int main(){
	int n;scanf("%d",&n);
	vector<ll>v(n);
	vector<int>ans;
	ll cnt[2]{};
	bool flag=true;
	rep(i,n){
		scanf("%lld",&v[i]);
		if(v[i]>=0)cnt[i%2]+=v[i],flag=false;
	}
	if(flag){
		int ans=max_element(v.begin(),v.end())-v.begin();
		cout<<v[ans]<<endl<<n-1<<endl;
		int cnt=n-1;
		rep(i,ans){
			puts("1");cnt--;
		}
		int D=cnt;
		rep(i,D){
			printf("%d\n",cnt+1);cnt--;
		}
		return 0;
	}
	int a=(cnt[0]<cnt[1]);
	printf("%lld\n",max(cnt[0],cnt[1]));
	while(1){
		bool flag=false;
		rep(i,v.size()){
			if(v[i]<0&&i%2==a){
				ans.push_back(i+1);
				flag=true;
				if(i==0||i==v.size()-1){
					v.erase(v.begin()+i);
					if(i==0)a=!a;
				}
				else{
					int d=v[i-1]+v[i+1];
					rep(j,3)v.erase(v.begin()+i-1);
					v.insert(v.begin()+i-1,d);
				}
				break;
			}
		}
		if(!flag)break;
	}
	if(a){
		ans.push_back(1);
		v.erase(v.begin());
	}
	if(v.size()%2==0){
		ans.push_back(v.size());
		v.pop_back();
	}
	int s=v.size();
	while(s>1){
		ans.push_back(2);
		s-=2;
	}
	cout<<ans.size()<<endl;
	for(int i:ans)printf("%d\n",i);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
const int INF=0x3f3f3f3f;
const int M=2e5+5;
int n,k,c;
char s[M];
 
int l[M],r[M];
 
int ml[M],mr[M];

int main(){
	cin>>n>>k>>c;
	cin>>s+1;
	memset(ml,INF,sizeof(ml));
	for(int i=1;i<=n;i++){
		l[i]=l[i-1];
		if(s[i]!='x'){
			l[i]=max(l[i],i-c-1>=1?l[i-c-1]+1:1);
		}
		ml[l[i]]=min(ml[l[i]],i);
	}
	memset(r,INF,sizeof(r));
	r[n+1]=k;
	for(int i=n;i>=1;i--)
	{
		r[i]=r[i+1];
		if(s[i]!='x')
			r[i]=min(r[i],i+c+1<=n?r[i+c+1]-1:k);
		if(r[i]>0)
			mr[r[i]]=max(mr[r[i]],i);
	}
	for(int i=1;i<=n;i++)
	{
		if(i==ml[l[i]]&&ml[l[i]]==mr[l[i]]){
			cout<<i<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4864
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int k,x; cin >> k >> x;
    cout << ((500*k >= x) ? "Yes": "No"); return 0;
}


Measured memory_bytes: 256
N = input()
A, B = map(int, raw_input().split())
P = map(int, raw_input().split())
cnt = [0, 0, 0]

for p in P:
    if p <= A:
        cnt[0] += 1
    elif p >= B + 1:
        cnt[2] += 1
    else:
        cnt[1] += 1

print min(cnt)


Measured memory_bytes: 2568
#include <iostream>
#include <algorithm>
#include <set>
#include <stdlib.h>
#include <cmath>
using namespace std;

int d, c[29], s[409][29], p[409], ap[409], cp[29], rs;
set<int> st[29];

int cc()
{
	for (int i = 0; i < 26; i++)
		cp[i] = 0;
	int ans = 0;
	for (int i = 1; i <= d; i++) {
		for (int j = 0; j < 26; j++) {
			if (p[i] == j) {
				cp[j] = i;
				ans += s[i][j];
			}
			else
				ans -= (i - cp[j]) * c[j];
		}
	}
	return ans;
}

void rm(int n, int k)
{
	auto pi = st[k].find(n);
	auto l = pi; l--;
	auto r = pi; r++;
	int pl = (n - (*l) - 1), pr = ((*r) - n - 1), plr = ((*r) - (*l) - 1);
	st[k].erase(n);
	rs -= s[n][k];
	rs += pl * (pl + 1) / 2 * c[k]; rs += pr * (pr + 1) / 2 * c[k];
	rs -= plr * (plr + 1) / 2 * c[k];
}

void ins(int n, int k)
{
	auto r = st[k].lower_bound(n);
	auto l = r; l--;
	int pl = (n - (*l) - 1), pr = ((*r) - n - 1), plr = ((*r) - (*l) - 1);
	st[k].insert(n);
	rs += s[n][k];
	rs -= pl * (pl + 1) / 2 * c[k]; rs -= pr * (pr + 1) / 2 * c[k];
	rs += plr * (plr + 1) / 2 * c[k];
}

void up(int n, int k)
{
	rm(n, p[n]);
	p[n] = k;
	ins(n, p[n]);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> d;
	for (int i = 0; i < 26; i++) {
		cin >> c[i];
		st[i].insert(0); st[i].insert(d + 1);
	}
	for (int i = 1; i <= d; i++) {
		for (int j = 0; j < 26; j++)
			cin >> s[i][j];
		p[i] = rand() % 26;
		st[p[i]].insert(i);
	}
	rs = cc();
	double k = 100, sc = 3500, kt = 0.9992, mx = rs;
	for (int i = 0; i < 3000000; i++) {
		double e1 = rs;
		int n = (rand() % d) + 1, kp = (rand() % 25) + 1;
		int hk = p[n], tk = (hk + kp) % 26;
		up(n, tk);
		int e2 = rs;
		double pb = exp((e2 - e1) / (k * sc));
		if (pb < rand() / (double)RAND_MAX)
			up(n, hk);
		k *= kt;
		if (mx < rs) {
			mx = rs;
			for (int j = 1; j <= d; j++)
				ap[j] = p[j];
		}
	}
	for (int i = 1; i <= d; i++)
		cout << ap[i] + 1 << '\n';
	return 0;
}

Measured memory_bytes: 4376
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a,b,c;
  double d=0;
  int h=0,e=1;
  cin>>a>>b;
  a=a+b;
  for(int i=a.size()-1;i>=0;i--){
    d=d+((int)a[i]-48)*e;
    e=e*10;
  }
  d=sqrt(d);
  h=(int )d;
  if(d==h) cout<<"Yes";
  else cout<<"No";
  cout<<"\n";
}


Measured memory_bytes: 256
r = "000111222333444455555666666777777888888888899999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
c = {"a" => "light fly", "0" => "fly","1" => "bantam","2" => "feather","3" => "light","4" => "light welter","5" => "welter","6" => "light middle","7" => "middle","8" => "light heavy","9" => "heavy"}
while a = gets
	a = (a.to_f - 0.00000000000001).to_s.split(".")[0].to_i - 48
	puts c[r[a]]
end

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

int main() {
  string s;
  cin >> s;

  int pa = 0;
  int gu = 0;
  int win = 0;
  int lose = 0;
  for(int i=0;i<s.size();i++) {
    if(pa == gu) {
      gu++;
      if(s[i] == 'p') lose++;
    } else {
      pa++;
      if(s[i] == 'g') win++; 
    }
  }

  cout << win - lose << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int n,x[2];
int mx[5],mn[5];
signed main(){
	scanf("%d",&n);
	for(int i=0;i<4;i++)mx[i]=-2e9-50,mn[i]=2e9+50;
	for(int i=1;i<=n;i++){
		scanf("%d%d",&x[0],&x[1]);
		mx[0]=max(mx[0],x[0]+x[1]);mn[0]=min(mn[0],x[0]+x[1]);
		mx[1]=max(mx[1],x[0]-x[1]);mn[1]=min(mn[1],x[0]-x[1]);
		mx[2]=max(mx[2],-x[0]+x[1]);mn[2]=min(mn[2],-x[0]+x[1]);
		mx[3]=max(mx[3],-x[0]-x[1]);mn[3]=min(mn[3],-x[0]-x[1]);
	}int ans=0;
	for(int i=0;i<4;i++)ans=max(ans,mx[i]-mn[i]);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 3808
Scanf.scanf "%s" (fun s ->
    let n = String.length s in
    let arr = Array.make 2019 0 in
    arr.(0) <- 1;
    let rec loop i cur ten =
        if i >= 0 then (
            let cur = (cur + ten * ( int_of_char s.[i] - 48)) mod 2019 in
            arr.(cur) <- arr.(cur) + 1;
            loop (i - 1) cur ((ten * 10) mod 2019)
        )
    in
    loop (n - 1) 0 1;
    Array.fold_left (fun acc v -> acc + v * (v - 1) / 2) 0 arr |> Printf.printf "%d\n"
)

Measured memory_bytes: 4476
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}


int n;
vector<ll> a;

// xorを適用した結果が、足し算を適用した結果より大きくなることはない
// xorの方が足し算より小さくなるまで続ける

bool check(int right, ll xorsum, ll sum){
  xorsum ^= a[right];
  sum += a[right];
  return xorsum == sum;
}

int main() {
  cin >>n;
  a.assign(n, 0); rep(i, n) cin >>a.at(i);
  ll xorsum = 0;
  ll sum = 0;
  ll res = 0;
  int right = 0;
  rep(left, n){
    while (right < n && check(right, xorsum, sum)){
      xorsum ^= a[right]; sum += a[right];
      right++;
    }
    res += right - left;
    if (right == left) right++;
    else{
      xorsum ^= a[left]; sum -= a[left];
    }
  }
  cout <<res <<endl;
}

Measured memory_bytes: 1792
N = int(input())
d_list = list(map(int, input().split()))

d_list.sort()
from bisect import bisect_right
ans = 0

for i in range(1, max(d_list)):
    idx = bisect_right(d_list, i)
    if N //2 == idx:
        ans += 1
print(ans)


Measured memory_bytes: 14396
import java.util.Scanner;

public class Main {

  static Scanner sc = new Scanner(System.in);
  static int a;
  static int b;


  public static void main(String[] args) {
    a = sc.nextInt();
    b = sc.nextInt();
    //    System.out.println("a :" + a + " b:" + b);
    int answer = output(a, b);
    System.out.println(answer);
  }

  private static int output(int a, int b) {
    int answer = 0;
    for (int i = a; i <= b; i++) {
      String num = String.valueOf(i);
      if (check(num)) {
        answer++;
      }
    }
    return answer;
  }

  private static boolean check(String num) {
    int length = num.length();
    for (int i = 0; i < length / 2; i++) {
      String s = num.substring(i, i + 1);
      String s2 = num.substring(length - i - 1, length - i);
      //      System.out.println(
      //        "num :" + num + " s:" + s + " num.substring:" + s2);
      if (!s.equals(s2)) {
        return false;
      }
    }
    return true;
  }
}


Measured memory_bytes: 37996
#include <iostream>

using namespace std;

int n, p;
int data[21];

bool check(int idx, int target) {
  if (target == 0) return true;
  if (target < 0) return false;
  if (idx >= n) return false;

  int cur_val = data[idx];
  return check(idx+1, target) || check(idx+1, target - cur_val);
}

int main() {
  int p;

  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> data[i];

  cin >> p;
  for (int i = 0; i < p; i++) {
    int target;
    cin >> target;
    if (check(0, target)) cout << "yes\n";
    else cout << "no\n";
  }

  return 0;
}



Measured memory_bytes: 3032
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<math.h>
typedef long long ll;
using namespace std;

int main()
{
	int A, B; scanf("%d%d", &A, &B);
	if (1 > A || A > 9 || 1 > B || B > 9) printf("-1");
	else printf("%d", A*B);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

typedef long long int int64;

const int mod=1000000007;

int permutation(int n,int k){
  if(k>n) return 0;
  int res=1;
  int i;
  for(i=1;i<=k;i++) res=(int64)res*(n+1-i)%mod;
  return res;
}

void run(void){
  int n,k;
  scanf("%d%d",&n,&k);
  printf("%d\n",permutation(k,n));
}

int main(void){
  run();
  return 0;
}



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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;
typedef std::queue<long> QI;
#define rep(i,n) for(long i = 0; i < (long)n; ++i)
const double pi = M_PI;
const long mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      long n, a, b, c, d; scan(n, a, b, c, d);
      bool res = false;
      for(long i = 2; i < n; ++i) {
         long left1  = a + (i-1) * c;
         long right1 = a + (i-1) * d;
         long left2  = b + (n-i) * c;
         long right2 = b + (n-i) * d;
         bool t =
            ( left1 <= right2 and right2 <= right1 ) or
            ( left1 <= left2  and left2  <= right1 );
         res = res or t;
      }
      puts(res ? "YES" : "NO");
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}



Measured memory_bytes: 256
s = input()

if s != s[::-1]:
  print("No")
  exit()
  
x = s[:((len(s)-1)//2)]
if x != x[::-1]:
  print("No")
  exit()
  
y = s[((len(s)+3)//2-1):]
if y != y[::-1]:
  print("No")
  exit()

print("Yes")

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int g[8][8];
int n, m;

bool used[8] = {};
int ans = 0;

void dfs(int x, int cnt)
{
    if (cnt == n)
    {
        ans++;
        return;
    }

    used[x] = 1;
    rep(i, n)
    {
        if (!used[i] && g[x][i] == 1)
            dfs(i, cnt + 1);
    }
    used[x] = 0;
}

int main()
{
    rep(i, 8) rep(j, 8) g[i][j] = 0;

    cin >> n >> m;

    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a][b] = g[b][a] = 1;
    }

    dfs(0, 1);

    OP(ans);

    return 0;
}

Measured memory_bytes: 256
// A.

#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <stdio.h>

typedef long long LL;

int main(int argc, char* argv[]) {
	char buffer[3072000];
	LL cnt[20][20] = {};
	LL sum[20][20] = {};
	LL n = 0, ans = 0;
	char c, *bufptr = buffer;
	fread(buffer, 1, 3072000, stdin);
	while ((c = *bufptr++) >= '0') {
		n = (n * 10) + (c - '0');
	}
	for (LL i = 0; i < n; ++i) {
		LL x = 0, two = 0, five = 9, df = 0;
		while ((c = *bufptr++) >= ' ') {
			x = c >= '0' ? (x * 10 + c - '0') : x;
			five -= df;
			df += c == '.';
		}
		two = __builtin_ctzll(x);
		x >>= two;
		two += five;
		while (x % 5 == 0) {
			++five;
			x /= 5;
		}
		cnt[two > 18 ? 18 : two][five] += 1;
	}
	for (int i = 0; i <= 18; ++i) {
		sum[i][0] = cnt[18 - i][18];
		for (int j = 1; j <= 18; ++j) {
			sum[i][j] += sum[i][j - 1] + cnt[18 - i][18 - j];
		}
	}
	for (int i = 1; i <= 18; ++i) {
		for (int j = 0; j <= 18; ++j) {
			sum[i][j] += sum[i - 1][j];
		}
	}
	for (int i = 0; i <= 18; ++i) {
		for (int j = 0; j <= 18; ++j) {
			ans += sum[i][j] * cnt[i][j];
			if (i >= 9 && j >= 9) {
				ans -= cnt[i][j];
			}
		}
	}
	printf("%lld\n", ans >> 1);
	return 0;
}


Measured memory_bytes: 4272
s = list(map(int,list(input())))
n = len(s)
w = 0
for i in range(n):
    for j in range(i, n):
        if j == i:
            w += s[i]*(10**(n-1-j))*(2**j)
        else:
            w += s[i]*(10**(n-1-j))*(2**(j-1))
print(w)

Measured memory_bytes: 2940
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define F first
#define S second
#define MEM(i,j) memset(i,j,sizeof i)
#define ALL(v) v.begin(),v.end()
#define MP make_pair
#define ET cout << "\n"
#define DB(a,s,e) {for(int i=s;i<e;i++) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll n,bit[200005],h[200005];

void modify(ll x,ll v)
{
	for(;x<=n;x+=x&-x) bit[x]=max(bit[x],v);
}

ll query(ll x)
{
	ll re=0;
	for(;x;x&=x-1) re=max(re,bit[x]);
	return re;
}

int main()
{jizz
	ll a;
	cin >> n;
	for(int i=0;i<n;++i)
		cin >> h[i];
	for(int i=0;i<n;++i)
		cin >> a,a+=query(h[i]),modify(h[i],a);
	cout << query(n) << "\n";
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <math.h>

int prime[80000];
int size;

int isPrime(int x){
	int i;
	for(i=0;i<size && prime[i]<=sqrt(x);i++){
		if(x % prime[i] == 0) return 0;
	}
	return 1;
}

void mkPrime(void){
	int i;

	prime[0] = 2;
	size = 1;

	for(i=3;i<1000100;i+=2){
		if(isPrime(i)){
			prime[size++] = i;
		}
	}
}

int main(void){
	int i,n,count;

	mkPrime();

	while(scanf("%d",&n) != EOF){
		count = 0;
		for(i=0;prime[i]<=n;i++,count++);
		printf("%d\n",count);
	}

	return 0;
}

Measured memory_bytes: 592
#include <set>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 100;

int n, x[N], y[N];
set < pair <int, int> > s;
vector < pair <int, int> > v;

int main() {

    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf("%d %d", &x[i], &y[i]);
        s.insert({x[i], y[i]});
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            v.push_back({x[j] - x[i], y[j] - y[i]});
        }
    }

    int res = n;

    for (int i = 0; i < v.size(); i++) {
        int p = v[i].first;
        int q = v[i].second;
        int now = 0;
        if (p == 0 && q == 0) {
            continue;
        }
        for (int j = 0; j < n; j++) {
            int nx = x[j] - p;
            int ny = y[j] - q;
            if (s.count(make_pair(nx, ny)) == 0) {
                now++;
            }
        }
        res = min(res, now);
    }

    printf("%d\n", res);

    return 0;

}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

x = list(input())
del(x[4])
x = [int(i) for i in x]

if x[0]+x[1]+x[2]+x[3]==7:
    print(str(x[0]) + '+' + str(x[1]) + '+' + str(x[2]) + '+' + str(x[3]) + '=7')
    exit()
elif x[0]-x[1]+x[2]+x[3]==7:
    print(str(x[0]) + '-' + str(x[1]) + '+' + str(x[2]) + '+' + str(x[3]) + '=7')
    exit()
elif x[0]+x[1]-x[2]+x[3]==7:
    print(str(x[0]) + '+' + str(x[1]) + '-' + str(x[2]) + '+' + str(x[3]) + '=7')
    exit()
elif x[0]+x[1]+x[2]-x[3]==7:
    print(str(x[0]) + '+' + str(x[1]) + '+' + str(x[2]) + '-' + str(x[3]) + '=7')
    exit()
elif x[0]-x[1]-x[2]+x[3]==7:
    print(str(x[0]) + '-' + str(x[1]) + '-' + str(x[2]) + '+' + str(x[3]) + '=7')
    exit()
elif x[0]+x[1]-x[2]-x[3]==7:
    print(str(x[0]) + '+' + str(x[1]) + '-' + str(x[2]) + '-' + str(x[3]) + '=7')
    exit()
elif x[0]-x[1]+x[2]-x[3]==7:
    print(str(x[0]) + '-' + str(x[1]) + '+' + str(x[2]) + '-' + str(x[3]) + '=7')
    exit()
elif x[0]-x[1]-x[2]-x[3]==7:
    print(str(x[0]) + '-' + str(x[1]) + '-' + str(x[2]) + '-' + str(x[3]) + '=7')
    exit()

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


int main(){
    ll A, B, M;
    cin >> A >> B >> M;
    vector<ll> a(A), b(B);

    for(int i = 0; i < A; i++) cin >> a[i];
    for(int i = 0; i < B; i++) cin >> b[i];

    ll x, y ,c, ans;
    ans = 1e7;
    for(int i = 0; i < M; i++){
        cin >> x >> y >> c;
        x--;
        y--;
        ans = min(ans, a[x] + b[y] - c);
    }
    
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());

    ans = min(ans, a[0] + b[0]);

    cout << ans << endl;

}

Measured memory_bytes: 1792
//
// Created by Myabu on 2020/01/25.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;


int main(void){
    int N;
    cin>>N;
    
    vector<int> p(N);

    for (int i = 0; i < N; ++i) {
        cin>>p[i];
    }
    
    sort(p.begin(), p.end());
    
    int ans = 0;
    for (int i = 0; i < N-1; ++i) {
        ans += p[i];
    }
    
    ans += p[N-1]/2;
    
    cout<<ans<<endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#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 N;
  cin>>N;
  vector<int> s(N);
  int ans=0;
  REP(i,N){
    cin>>s[i];
    ans+=s[i];
  }
  sort(ALL(s));
  if(ans%10==0){
    REP(i,N){
      if(s[i]%10>0){
        ans-=s[i];
        break;
      }
      if(i==N-1){
        ans=0;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
N=gets.to_i;A=gets.split.map &:to_i;D=[*0..10**6];s=0;2.upto(N-2){|i|s+=A[i];1.upto(A[i]){|j|D.unshift D[j*2-1]}};gets.to_i.times{p (D[x=gets.to_i]||x-s)+A[0]-A[1]}

Measured memory_bytes: 49988
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int n,l,r;
int sum;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&l,&r);
		sum=sum+r-l+1;
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
S = input()
f=0
l=0
for i in range(len(S)):
    if(S[i] =="A"):
        f = i+1
        break
for j in range(len(S)-1,0,-1):
    if(S[j] == "Z"):
        l = j+1
        break
print(l-f+1)

Measured memory_bytes: 9268
#include <bits/stdc++.h>
    using namespace std;
     
   	int main(){
      string str;
      cin >> str;
      
      int N = str.size();
      int count=0;
      for(int i=2; i< N-1; i++){
        if(str.at(i) == 'C'){
          count++;
        }
      }
      
      int COUNT=0;
      
      for(int i=0; i<N; i++){
      	if(str.at(i)>= 'A' && str.at(i)<= 'Z'){
          COUNT++;
        }
      }
      
      
      
      if(str.at(0) == 'A' && count == 1 && COUNT == 2){
        cout<<"AC"<<endl;
      }else{
         cout<<"WA"<<endl;
      }
      
      
    }

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define vpush(v,x) v.push_back(x);
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,w,h;
    vint v;
    cin>>a>>b>>w;
    vpush(v,a);
    vpush(v,b);
    vpush(v,w);
    sort(all(v));
    cout<<v[0]+v[1];
    return(0);
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto L = RD;
	auto R = RD;
	auto d = RD;

	long ans;
	foreach (i; L..R+1)
	{
		if (i % d == 0)
			++ans;
	}

	writeln(ans);
	stdout.flush;
	debug readln;
}

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

typedef long long ll;
const int N = 55;
ll n, p[N], v[N], a[N];
ll x, d, m[N], f[N * N * N], ans;
int main() {
  scanf("%lld%lld%lld%lld", &n, &x, &d, &m[1]);
  for (ll i = 2; i <= n; i++) {
    scanf("%lld%lld", &m[i], &p[i]);
  }
  for (ll i = 1; i <= n; i++) {
    v[i] = 1;
    a[i] = i;
  }
  for (ll i = n; i >= 2; i--) {
    v[p[i]] += v[i];
    m[p[i]] += m[i];
  }
  sort(a + 1, a + 1 + n, [&](const ll &a, const ll &b){return v[a] * m[b] > v[b] * m[a];});
  memset(f, 0x3f, sizeof f);
  f[0] = 0;
  for (ll i = 1; i <= n; i++) {
    ll z = a[i] == 1 ? n : min(n, d);
    for (ll c = 1; z; z -= c, c <<= 1) {
      c = c <= z ? c : z;
      for (ll j = n * n * n; j >= c * v[a[i]]; j--) {
        f[j] = min(f[j], f[j - c * v[a[i]]] + c * m[a[i]]);
      }
    }
  }
  for (ll i = 0; i <= n * n * n; i++) if (f[i] <= x) {
    ll res = x - f[i], cur = i;
    for (ll j = 1; j <= n; j++) {
      ll c = a[j] == 1 ? res / m[a[j]] : min(res / m[a[j]], max(0LL, d - n));
      res -= c * m[a[j]];
      cur += c * v[a[j]];
    }
    ans = max(ans, cur);
  }
  printf("%lld\n", ans);
}


Measured memory_bytes: 1536
namespace ABC_087
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = int.Parse(System.Console.ReadLine());
            var a = int.Parse(System.Console.ReadLine());
            var b = int.Parse(System.Console.ReadLine());
            System.Console.WriteLine(buyingSweets(x, a, b));
        }

        static private int buyingSweets(int x, int a, int b)
        {
            var remains = x - a;
            while (remains - b >= 0)
            {
                remains -= b;
            }
            return remains;
        }
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<long> A(N + 1);
  for (int i = 1, a; cin >> a; i++) A.at(i) = A.at(i - 1) + a;
  sort(A.begin(), A.end());
  A.push_back(-1);
  long ans = 0;
  for (long i = 0, cnt = 1; i < N + 1; i++) {
    if (A.at(i) == A.at(i + 1)) cnt++;
    else ans += cnt * (cnt - 1) / 2, cnt = 1;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 4736
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-8;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#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()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};

void solve(string s){
  set<string> app;

  queue<pair<int,string> > q;
  q.push(mp(0,s));
  while(!q.empty()){
    int cc=q.front().F;
    s=q.front().S;
    q.pop();
    if(app.count(s))continue;
    app.insert(s);
    bool end=true;
    rep(i,SZ(s)-1){
      if(s[i]!=s[i+1]){
        end=false;
        break;
      }
    }

    if(end){
      cout<<cc<<endl;
      return;
    }

    rep(i,SZ(s)-1){
      if(s[i]==s[i+1])continue;
      string t=s;
      char a=min(s[i],s[i+1]);
      char b=max(s[i],s[i+1]);

      if(a!='r' && b!='r')t[i]=t[i+1]='r';
      else if(a!='g' && a!='g')t[i]=t[i+1]='g';
      else t[i]=t[i+1]='b';
      if(app.count(t))continue;
      q.push(mp(cc+1,t));
    }
  }
  cout<<"NA"<<endl;
}

main(){
  string s;
  while(cin>>s,s!="0")
    solve(s);
}

Measured memory_bytes: 1840