akhauriyash/Code-Regression huggingface dataset:
#include<iostream>                    
using namespace std;
int main(){
 
  int n,a[10000],i,s(1000000),b(-1000000);
  long long w=0;
  cin>>n;
  for(int i=0;i<n; i++)
  {
         cin>>a[i];
 
           w+=a[i];
		   
         if(s>a[i])
         {
	       s=a[i];
         }
        if(b<a[i])
         {      

	         b=a[i];

		}
  
  }
  cout<<s<<" "<<b<<" "<<w<<endl;


  return 0;
  }  



Measured memory_bytes: 3156
import java.util.Scanner;

/**
 * TITLE : Duplex Printing
 * URL : https://atcoder.jp/contests/abc157/tasks/abc157_a
 */
public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.println(N / 2 + N % 2);
        sc.close();
    }
}


Measured memory_bytes: 21844
import java.util.*;

public class Main {
    public static void main(String[] args) {
        solve(new Scanner(System.in));
//        solve(new Scanner(ex));
    }

    private static final String ex = "10 8";

    private static void solve(Scanner scanner) {
        String[] split = scanner.nextLine().split(" ");
        int N = Integer.parseInt(split[0]);
        int K = Integer.parseInt(split[1]);

        int ret = K;
        for (int i = 1; i < N; i ++) {
            ret *= (K - 1);
        }

        System.out.println(ret);
    }
}



Measured memory_bytes: 21844
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: u64 = read();

    let mut sum = 0;
    let mut max_i = 0;
    for i in 1..n + 1 {
        sum += i;
        if sum >= n {
            max_i = i;
            break;
        }
    }

    let mut remove = 0;
    for i in 1..n + 1 {
        if sum - i == n {
            remove = i;
            break;
        }
    }

    for i in 1..max_i + 1 {
        if i != remove {
            println!("{}", i);
        }
    }
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
fun main(args: Array<String>) {
    val N = readLine()?.toInt() ?: 0
    val activitiesEachDay: MutableList<List<Int>> = mutableListOf()
    val dp: MutableList<MutableList<Int>> = mutableListOf(mutableListOf(0, 0, 0))
    for (n in 0 until N) {
        activitiesEachDay.add(readLine()!!.split(" ").map(String::toInt))
        dp.add(mutableListOf(0, 0, 0))
    }
    // https://photos.app.goo.gl/Mbn1e7TctyhozFEb6
    for ((i, activities) in activitiesEachDay.withIndex()) {
        for((j, activity) in activities.withIndex()) {
            for (k in 0 until 3) {
                if (j == k)
                    continue
                if (dp[i + 1][k] < (dp[i][j] + activity)) {
                    dp[i + 1][k] = (dp[i][j] + activity)
                }
            }
        }
    }
    println(dp[N].max())
}

Measured memory_bytes: 95616
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;
int N, C, K;
vector<int>v;

int check() {
	int i(0);
	int bus(0);
	while (i < N) {
		int time_limit = v[i] + K;
		int member(1);
		int j;
		for (j = i + 1; j<N&&member < C&&v[j] <= time_limit; j++) {
			member++;
		}
		i = j;
		bus++;
	}

	return bus;
}

signed main() {
	cin >> N >> C >> K;
	rep(i, 0, N) {
		int a; cin >> a; v.push_back(a);
	}
	sort(all(v));
	cout << check() << endl;



	return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}

/*------------------------------------------------*/

int main(){
  int n, m;
  cin >> n >> m;
  vector<string> a(n);
  vector<string> b(m);
  rep(i,n) cin >> a[i];
  rep(i,m) cin >> b[i];
  bool ans = false;
  for(int i = 0;i <= n-m; i++){
    for(int j = 0; j <= n-m; j++){
      bool ok = true;
      rep(k,m){
        string cp = a[i+k].substr(j,m);
        if(b[k] != cp) ok = false;
      }
      if(ok) ans = true;
    }
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}



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

int main() {

  int N;
  cin >> N;

  vector<int> B(N-1);
  for(int i = 0;i < N-1;i++) {
    cin >> B.at(i);
  }

  int ans = 0;
  ans += B.at(0) + B.at(N-2);
  for(int i = 1;i < N-1;i++) {
    ans += min(B.at(i),B.at(i-1));
  }

  cout << ans << endl;

}



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

int main() {
   while (1) {
      string s;
      getline(cin, s);
      if (s == ".") break;

      stack<char> stk;
      bool ok = true;
      int n = s.size();
      for (int i = 0; i < n; i++) {
         if (s[i] == '(') stk.push(s[i]);
         if (s[i] == '[') stk.push(s[i]);
         if (s[i] == ')') {
            if (stk.empty() || stk.top() != '(') {
               ok = false;
               break;
            }
            stk.pop();
         }
         if (s[i] == ']') {
            if (stk.empty() || stk.top() != '[') {
               ok = false;
               break;
            }
            stk.pop();
         }
      }
      if (stk.empty() && ok) {
         puts("yes");
      } else {
         puts("no");
      }
   }
}


Measured memory_bytes: 3224
/******************************************
* AUTHOR : AMAN SAXENA *
* "There's some good in this world, and it's worth fighting for." *
* INSTITUTION : KIET Group of Institutions *
******************************************/
#include <bits/stdc++.h>

const long long MODULO=1000000007;
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define FOR1(i,a,n) for(int i=a;i<=n;i++)
#define FOR2(i,a,n) for(int i=a;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ll long long 
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pi 3.14159265359

using namespace std;

template <typename TYPE> void in(TYPE &x){cin>>x;}

void solve()
{
    int a[5];
    FOR(i,0,5)
        cin >> a[i];
    int c=0;
    FOR(i,0,5)
    {
        if(a[i]==0)
            c=i+1;
    }
    cout << c << '\n';
}

void test()
{
    int t;
    cin>>t;
    while(t--) //for(int j=1;j<=t;j++) cout << "Case #" << j << ": ";
    {
        solve();
    }
}

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

Measured memory_bytes: 3608
import numpy as np
N,X = [int(i) for i in input().split()]
L = [int(i) for i in input().split()]
POS = [0]
for l in L:
    POS.append(POS[-1] + l)
POS = np.array(POS)
print(np.count_nonzero(POS <= X))

Measured memory_bytes: 21308
//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<iomanip>
#include<queue>
#include<cmath>
#include<stack>
#include <map>
#define ll long long int
#define skip cin>>ws;
#define vll vector<ll> 
#define vb vector<bool>
#define vpll vector<pair<ll,ll>>
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define vs vector<string>
#define vvpll vector<vector<pair<ll, ll>>>
#define pb push_back
#define pob pop_back()
#define MOD (ll)(1e9 + 7)
#define test ll t; cin>>t; while(t--)

using namespace std;

void enter(vll &ar)
{
    ll n = ar.size();

    for(ll i=0;i<n;i++)
    {
        cin>>ar[i];
    }
}

void show(vll &a)
{
    ll n = a.size();

    for(ll i=0;i<n;i++)
    {
        cout<<a[i]<<" ";
    }
    cout<<"\n";
}

void SieveOfErat1sthenes(int n, vll &pri) 
{ 
    vb prime(n+1, true); 
   
    for (int p=2; p*p<=n; p++) 
    { 
        
        if (prime[p] == true) 
        { 
            pri.pb(p);
            
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
}

ll mo(ll a)
{
    return a%MOD;
}

bool compare(pll a, pll b)
{
    return a.first>b.first;
}

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

    ll n, k;
    cin>>n>>k;

    vll a(n);
    enter(a);

    vvll dp(k+1, vll(n+1)), mat(k+1, vll(n+1));
    vll sum(n+1, 0);
    sort(a.begin(), a.end(), greater<ll>());

    for(ll i=1;i<=n;i++)
    {
        sum[i] = sum[i-1] + a[i-1];
    }

    for(ll i=0;i<=n;i++) dp[0][i] = 1;
    for(ll i=0;i<=n;i++) mat[0][i] = 1;
    for(ll i=0;i<=k;i++) mat[i][0] = 1;
    //for(ll i=1;i<=k;i++) dp[i][0] = i;
 
    for(ll i=1;i<=k;i++)
    {
        for(ll j=1;j<=n;j++)
        {

            if(sum[j]>=i)
            {
                dp[i][j] = mo(mo(mat[i][j-1]) - mo(((i-a[j-1]-1>=0)?mat[i-a[j-1]-1][j-1]:0)) + MOD);
            }
          
            mat[i][j] = mo(mo(dp[i][j]) + mo(mat[i-1][j]));
            // for(ll l=i;l>=max(0LL, i-a[j-1]); l--)
            // {
            //     dp[i][j] = mo(mo(dp[i][j]) + mo(dp[l][j-1])); 
            // }
        }
    }

    // cout<<"sum: ";
    // show(sum);

    // for(ll i=0;i<=k;i++)
    // {
    //     for(ll j=0;j<=n;j++)
    //     {
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<"\n";
    // }

    if(sum[n]<k) dp[k][n] = 0;

    cout<<dp[k][n]<<"\n";

    return 0;
}


Measured memory_bytes: 167328
import sys


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


s = S()
if 'a' in s and 'b' in s and 'c' in s:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int a = 0, b = 0, c = 0;
	const int BUFF_SIZE = 20;
	char buff[BUFF_SIZE];

	for (int i = 0; i < 10; i++)
	{
		 fgets(buff, BUFF_SIZE, stdin);
		int h = atoi(buff);
		
		if (h > a)
		{
			c = b;
			b = a;
			a = h;
		}
		else if (h > b)
		{
			c = b;
			b = h;
		}
		else if (h > c)
		{
			c = h;
		}
	}

	printf("%d\n%d\n%d\n", a, b, c);
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define MAX 500000
struct Node{
	int key;
	Node *parent,*left,*right;
};
Node *root,*NIL;
int H;
void insert(int key){
	Node *y=NIL;//记录父结点
	Node *x=root;//子结点
	Node *z;
	
	z=(Node *)malloc(sizeof(Node));
	z->key=key;
	z->left=NIL;
	z->right=NIL;
	
	while(x!=NIL){
		y=x;
		if(x->key>z->key){
			x=x->left;
		}
		else
			x=x->right;
	}
	z->parent=y;
	if(y==NIL)
		root=z;
	else if(z->key<y->key)
		y->left=z;
	else
		y->right=z;
}
Node *find(Node *u,int key){
	while(u!=NIL&&u->key!=key){
		if(key<u->key){
			u=u->left;
		}
		else{
			u=u->right;
		}
	}
	return u;	
}
void preParse(Node *u){
	if(u==NIL)
		return ;
	cout<<" "<<u->key;
	preParse(u->left);
	preParse(u->right);
}
void inParse(Node *u){
	if(u==NIL)
		return ;
	inParse(u->left);
	cout<<" "<<u->key;
	inParse(u->right); 
}
int main(){
    cin>>H;
    char com[10];
    int x;
    for(int i=0;i<H;i++){
        cin>>com;
        if(com[0]=='i'){
            cin>>x;
            insert(x);
        }
        if(com[0]=='f'){
            cin>>x;
            if(find(root,x)!=NIL)
                cout<<"yes"<<endl;
            else
                cout<<"no"<<endl;
        }
        if(com[0]=='p'){
            inParse(root);
            cout<<endl;
            preParse(root);
            cout<<endl;
        }
    }
	return 0;
} 


Measured memory_bytes: 21836
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>

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

#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define elif else if
#define itn ll
#define int ll
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
///                →,↑,←,↓,↗,↖,↙,↘
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;


map<string, int> mp;

signed main() {
	ios::sync_with_stdio(false);
	int i, j, k;
	int n, m;
	cin >> n;
	vector<string> s1(n);
	rep(i, n) {
		cin >> s1[i];
		int num = mp[s1[i]];
		mp[s1[i]] = num + 1;
	}
	cin >> m;
	vector<string> s2(m);
	rep(i, m) {
		cin >> s2[i];
		int num = mp[s2[i]];
		if(num != 0)
			mp[s2[i]] = num - 1;
	}
	int max = 0;
	rep(i, n) {
		int num = mp[s1[i]];
		if (max < mp[s1[i]]) {
			max = mp[s1[i]];
		}
	}

	cout <<  max << endl;
	return 0;
}

Measured memory_bytes: 256
// atcoder/abc162/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.setf(std::ios_base::fixed);
  std::cout.precision(15);

  str s;
  while (cin >> s) {
    cout << (s[0] == '7' || s[1] == '7' || s[2] == '7' ? "Yes" : "No") << endl;
  }

  return 0;
}


Measured memory_bytes: 3640
#include <string>
#include <iostream>
#include <vector>
using namespace std;

int main(void) {
    int64_t N, K;
    cin >> N >> K;
    vector<int64_t> A(N+1);
    vector<int64_t> first(N+1, 0);
    vector<int64_t> second(N+1, 0);

    for (int64_t i = 1; i <= N; i++) {
        cin >> A[i];
    }

    int64_t dst = 1;
    for (int64_t i = 0; i < K; i++) {
        if (first[dst] == 0) {
            first[dst] = i;
            dst = A[dst];
        } else if (second[dst] == 0) {
            second[dst] = i;
            dst = A[dst];
        } else {
            int64_t loop = second[dst] - first[dst];
            if (loop <= K - i) {
                int64_t skip = (int64_t)((K - i) / loop) * loop;
                i += skip - 1;
            } else {
                dst = A[dst];
            }
        }
    }

    cout << dst << endl;

    return 0;
}

Measured memory_bytes: 7568
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    IFOR(i, 1, 9){
        if(n % i == 0 && n / i <= 9){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

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

int main(void)
{
    char a, b;
    cin >> a >> b;
    if (a > b)
    {
        cout << ">" << endl;
    }
    else if (a < b)
    {
        cout << "<" << endl;
    }
    else
    {
        cout << "=" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
 
int main()
{
    int i,j;
    int d;
   int t;
   int k,n;
string s;
string p = "es";
string r="s";
cin>>s;
n=s.length();
if(s.back()== 's')
{
  s.replace(s.begin()+n,s.end(),p);
}
else
{
   s.replace(s.begin()+n,s.end(),r);
}
cout<<s<<endl;
}

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

#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i = (int)(begin), i##_end = (int)(end); i<i##_end; ++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x

void solve(ll A, ll B, ll C, ll X){
	ll ans = 0;
	rep(a, A + 1){
		rep(b, B + 1){
			rep(c, C + 1){
				if(a * 500 + b * 100 + c * 50 == X) ans++;
			}
		}
	}
	printf("%lld\n", ans);
}

int main(void){
	ll A;
	ll B;
	ll C;
	ll X;
	scanf("%lld", &A);
	scanf("%lld", &B);
	scanf("%lld", &C);
	scanf("%lld", &X);
	solve(A, B, C, X);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        Scanner as = new Scanner(System.in);
        int a = as.nextInt();
        int b = as.nextInt();

        if(a<b){
          
 
        System.out.println("a < b");
         }
        else if(a==b){
        
        System.out.println("a == b");
             
               }
             else{
                  
                  System.out.println("a > b");
                  
                  }
 
 
   }
 
 
}

Measured memory_bytes: 26288
#include<cmath>
#include<cstdio>
using namespace std;
int a,b;
int number(int x)
{
	int cnt=1;
	while(x) {x/=10; cnt*=10;}
	return cnt;
}
int main()
{
	scanf("%d%d",&a,&b);
	int k=a*number(b)+b;
	int m=sqrt(k);
	if(m*m==k) printf("Yes\n");
	else printf("No\n");
	return 0;
}


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

const int N = 1005;
int cnt[N];

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

    int n, m;
    cin>>n>>m;

    for (int i=0; i<m; i++) {
        int k;
        cin>>k;

        for (int i=0; i<k; i++) {
            int x;
            cin>>x;
            cnt[x]++;
        }
    }

    int ans = 0;
    for (int i=1; i<=n; i++)
        if (cnt[i] == 0)
            ans ++;
    cout<<ans<<endl;
}


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

using namespace std;
const long long mod = 1e9 + 7;

void mul(long long& a, long long b) {
  a *= b;
  a = (a + mod*mod) % mod;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<long long> a(n);
  for(int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  
  int p = 0, z = 0, neg = 0;
  for(int i = 0; i < n; ++i) {
    if(a[i] > 0) p++;
    else if(a[i] == 0) z++;
    else neg++;
  }
  if(k > (n - z)) {
    cout << 0 << '\n';
    return 0;
  }
  if(z + neg == n && z > 0) {
    if(k > (n - z)) {
      cout << 0 << '\n';
    } else {
      //k <= neg
      if(k & 1) {
        cout << 0 << '\n';
      } else {
        long long prod = 1;
        for(int i = 0; i < k; ++i) {
          mul(prod, a[i]);
        }
        cout << prod << '\n';
      }
    }
    return 0;
  }
  if(a[n - 1] < 0) {
    if(k & 1) {
      long long prod = 1;
      for(int i = n - 1; i >= n - k; --i) {
        mul(prod, a[i]);
      }
      cout << prod << '\n';
    } else {
      long long prod = 1;
      for(int i = 0; i < k; ++i) {
        mul(prod, a[i]);
      }
      cout << prod << '\n';
    }
    return 0;
  }
  if(a[0] > 0) {
    long long prod = 1;
    for(int i = n - 1; i >= n - k; --i) {
      mul(prod, a[i]);
    }
    cout << prod << '\n';
    return 0;
  }
  if(a[0] == a[n - 1] && a[0] == 0) {
    cout << 0 << '\n';
    return 0;
  }
  if(p + z == n && z > 0) {
    long long prod = 1;
    for(int i = n - 1; i >= n - k; --i) {
      mul(prod, a[i]);
    }
    cout << prod << '\n';
    return 0;
  }
  if(k == p + neg) {
    if(neg & 1) {
      if(z > 0) {
        cout << 0 << '\n';
      } else {
        long long prod = 1;
        for(int i = 0 ; i < n; ++i) {
          mul(prod, a[i]);
        }
        cout << prod << '\n';
      }
    } else {
      long long prod = 1;
      for(int i = 0; i < n; ++i) {
        if(a[i] == 0) {
          
        } else {
          mul(prod, a[i]);
        }
      }
      cout << prod << '\n';
    }
    return 0;
  }  
  vector<long long> pre(n), suff(n);
  pre[0] = a[0];
  for(int i = 1; i < n; ++i) {
    long long x = pre[i - 1];
    mul(x, a[i]);
    pre[i] = x;
  }
  suff[n - 1] = a[n - 1];
  for(int i = n - 2; i >= 0; --i) {
    long long x = suff[i + 1];
    mul(x, a[i]);
    suff[i] = x;
  }
  int len = 0;
  while(len <= neg) {
    if(k - len <= p) {
      break;
    }
    len += 2;
  }  
  long long prod = (len == 0 ? 1 : pre[len - 1]);
  if(k > len) {
    mul(prod, suff[n - k + len]);
  }
  for(int L = len + 2; L <= min(k, neg); L += 2) {
    if(a[L - 1] * a[L - 2] > a[n - k + L - 2] * a[n - k + L - 1]) {
      prod = (L == 0 ? 1 : pre[L - 1]);
      if(n - k + L < n) {
        mul(prod, suff[n - k + L]);
      }
    } else {
      break;
    }
  }   
  cout << prod << '\n';
}  
  
  
  
  
  



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

using namespace std;

int main(){
	int n;
	while(cin >> n,n){
		vector<int> v(26,0);
		int i;
		vector<char> c(n);
		for(i=0;i<n;i++){
			cin >> c[i];
		}
		for(i=0;i<n;i++){
			//cout << "turn: " << i << endl;
			v[c[i] - 'A']++;
			int max_index = distance(v.begin(), max_element(v.begin(),v.end()));
			int j;
			for(j=0;j<26;j++){
				if(max_index != j && v[max_index] <= v[j] + (n-i-1)){
					break;
				}
			}
			if(j==26){
				cout << (char)('A' + max_index) << " " << i+1 << endl;
				break;
			}
		}
		if(i==n){
			cout << "TIE" << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3096
#include <cstdio>
#include <cstring>
using namespace std;

char x[200001];

int main() {
    scanf("%s", x);
    int n = strlen(x);
    int s = 0, t = 0, r = 0;
    for (int i = 0; i < n; i++) {
        if (x[i] == 'S') s++;
        if (x[i] == 'T') t++;
        if (t > s) {
            r += t - s;
            s = t = 0;
        }
    }
    r += s - t;
    printf("%d\n", r);
    return 0;
}

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

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef string str;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;

//0~nの範囲操作
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//1~nの範囲操作
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
//n~0を後ろから範囲操作
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
//出力後改行を
#define fin(ans) cout << (ans) << endl;
//出力後空白を
#define blank(ans) cout << (ans) << " ";
//２つの値をセットに\
sort -> p -> q
#define mp(p, q) make_pair(p, q)
//３つ以上の値をセットに(3より多いときはカッコ内を増やす)\
sort -> p -> q -> r
#define mt(p, q, r) make_tuple(p, q, r)
//配列全操作
#define all(a) a.begin(), a.end()

void Main()
{
  ll n; cin >> n;
  vll a(n); rep(i, n) cin >> a[i];
  vpll ans(n); rep(i, n) ans[i] = mp(a[i], i + 1);
  sort(all(ans));
  rep(i, n) blank(ans[i].second);
  fin("")
  return;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a);i>(b);--i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

int main() {
  int s, t=1;
  cin >> s;
  
  while(1) {
    
    if(s == 1 || s == 2 || s == 4) {
      break;
    }
    
    if(s%2 == 0) {
      s /= 2;
    }
    else {
      s = s*3 + 1;
    }
    t++;
  }
  int ans = t+3;
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
int main()
{
    ll n,m;
    cin>>n>>m;
    char a[n+1][m+1];
    ll dp[n+1][m+1];
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=m;j++)
        {
            cin>>a[i][j];
            dp[i][j]=0;
        }
    }
    for(ll i=2;i<=m;i++)
    {

        if(a[1][i]=='#')
            break;
        else
        dp[1][i]=1;
    }
    for(ll i=2;i<=n;i++)
    {

        if(a[i][1]=='#')
            break;
        else
        dp[i][1]=1;
    }
    for(ll i=2;i<=n;i++)
    {
        for(ll j=2;j<=m;j++)
        {
            if(a[i][j]=='.')
            {
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
            }
        }
    }
    cout<<dp[n][m]<<endl;
    return 0;
}


Measured memory_bytes: 12304
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
 
// ここから
function main(){
  for(var line = 1, maxLines = input[0] - 0; line <= maxLines; line++){
    var inputArray = new Int32Array(input[line].split(" "));
    var i0 = inputArray[0];
    var i1 = inputArray[1];
    var i2 = inputArray[2];

      console.log(isTri(i0,i1,i2) || isTri(i1, i2, i0) || isTri(i2, i0, i1) ? 'YES' : 'NO');
  }
}

function isTri(a, b, c){
  return a*a + b*b == c*c;
}

Measured memory_bytes: 10468
#include <bits/stdc++.h>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int INF = LLONG_MAX/3;
const int MAX = 710000;

/*-----Library-----*/

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

struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
    vector<int> sizeuf; //要素数
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n); rank.resize(n); sizeuf.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
            sizeuf[i]=1;
        }
    }

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

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

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

    int size(int x){
        return sizeuf[root(x)];
    }
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}

long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}
//コンビネーション
/*
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 */
/*-----Library-----*/
const int MOD=1e9+7;
signed main(){
    string l;
    cin>>l;
    int table[110000];
    table[0]=1;
    for(int i=1;i<110000;i++)table[i]=table[i-1]*3%MOD;
    int s=l.size();
    int ans=table[s];
    int cnt=1;
    for(int i=0;i<s;i++){
        if(l[i]=='1'){
            cnt*=2;
            cnt%=MOD;
        }else{
            ans-=(cnt*table[s-i-1])%MOD*2%MOD;
          	if(ans<0)ans+=MOD;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll,ll> P;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
ll c,d,e,f,p,t,x,y,ans=0;
 
set<ll> s,loop;
vl visited(300000,0);
ll n,m,r;
ll num=0;
vl gragh[300000];
vl low(300000,INF),pre(300000,INF);
vector<P> ANS;
 
void input(void){
    cin>>n>>m;
    rep(i,m){
        cin>>c>>d;
        gragh[d].push_back(c);
        gragh[c].push_back(d);
    }
}

void dfs(ll a,ll b){
    visited[a]=1;
    pre[a]=num;
    low[a]=num;
    num++;
    for(ll i:gragh[a]){
        if(i!=b){
            if(visited[i]==0){
                dfs(i,a);
            }
            if(pre[a]<pre[i])low[a]=min(low[a],low[i]);
		else low[a]=min(low[a],pre[i]);
        }
    }

    if(pre[a]!=0&&pre[a]==low[a]){
        ANS.emplace_back(min(a,b),max(a,b));
    }
}

ll solve(void){
    dfs(0,-1);
    sort(all(ANS));
    rep(i,ANS.size()){
        x=ANS[i].first;
        y=ANS[i].second;
        cout<<x<<" "<<y<<endl;
    }
    return ans;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}


Measured memory_bytes: 18564
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <cctype>
#include <utility>
#include <map>
#include <string>
#include <climits>
#include <set>
#include <sstream>
#include <utility>
#include <ctime>
#include <cassert>
#include <fstream>
using namespace std;
typedef long long LL;
#define MS(A) memset(A, 0, sizeof(A))
#define MSV(A,a) memset(A, a, sizeof(A))
#define MP make_pair
#define PB push_back
#define getcx getchar_unlocked
#define INF (int(1e9))
#define INFL (LL(1e18))
#define EPS 1e-12
#define chkbit(s, b) (s & (1<<b))
#define setbit(s, b) (s |= (1<<b))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define MOD 1000000007
#define MAX 1000000

int main() {

	LL n, i = 0;
	char s[1000000];
	cin>>n;

	while(n>0) {
		LL rem = n % 26;

		if(rem == 0) {
			s[i++] = 'z';
			n = (n/26) -1;
		} else {
			s[i++] = (rem - 1) + 'a';
			n = n/26;
		}
	}

	//<<"i " <<i<<endl;

	for(int j = i-1; j >=0 ;j--) {
		cout<<s[j];
	}

		//s[i] = '\0';
		//reverse(s, s+strlen(s));
		//cout<<s<<endl;
	cout<<endl;

	return 0;

}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int n;
	cin >> n;
	ll a[n], b[n], c[n];
	rep(i, n) cin >> a[i] >> b[i] >> c[i];

	ll dp[n+1][3];
	// dp[i][j] : i日目に行動j(0:a, 1:b, 2:c)を行った時の幸福度の総和の最大値

	dp[0][0] = 0;
	dp[0][1] = 0;
	dp[0][2] = 0;

	for(int i = 1; i <= n; i++){
		dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i-1];
		dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i-1];
		dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i-1];
	}

	cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
}


Measured memory_bytes: 4992
#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--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define OUT(s) cout << s << "\n";

using namespace std;
// https://atcoder.jp/contests/abc161

int N,M;
vector<int> A(1010);
int ALL = 0;

void Main()
{
    auto t = 1.0 * ALL / (4 * M);
    int c = 0;
    REP(i, N) {
        if (A[i] >= t) {
            c++;
        }
    }
    if (c >= M) {
        OUT("Yes");
    } else {
        OUT("No");
    }
}

int main()
{
	cin.tie(0);
    ios::sync_with_stdio(false);
	// cout << fixed << setprecision(15);
    cin >> N >> M;
    REP(i, N) {
        cin >> A[i];
        ALL = ALL + A[i];
    }
	Main();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    string num;
    cin>>num;
    for (int i=0; i<num.size(); i++) {
        if(num.at(i)=='1'){
            num.at(i)='9';
        }else{
            num.at(i)='1';
        }
    }
    cout<<num<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;

namespace ABC172_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string T = Console.ReadLine();
            int count = 0;
            for(int i = 0; i < S.Length; i++)
            {
                if (S[i] != T[i])
                {
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 27440
<?php
  
$abcd = explode(' ', trim(fgets(STDIN)));
$a = $abcd[0];
$b = $abcd[1];
$c = $abcd[2];
$d = $abcd[3];
 
$ac = intdiv($a-1,$c);
$bc = intdiv($b,$c);
$cx = $bc - $ac;
 
$ad = intdiv($a-1,$d);
$bd = intdiv($b,$d);
$dx = $bd - $ad;
 
$cd = lcm($c, $d);
$acd = intdiv($a-1,$cd);
$bcd = intdiv($b,$cd);
$abx = $bcd - $acd;
 
$ans = $b - $a + 1 - $cx - $dx + $abx;
echo intval($ans);
 
function gcd($m, $n){
    if($n > $m) list($m, $n) = array($n, $m);
     
    while($n !== 0){
        $tmp_n = $n;
        $n = $m % $n;
        $m = $tmp_n;
    }
    return $m;
}
 
function lcm($m, $n){
    return $m * $n / gcd($m, $n);
}
 
  
?>

Measured memory_bytes: 4604
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

typedef pair<int,int> P;
typedef long long ll;

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	cout << min(c,b/a) << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  while(true){
    int n;
    scanf("%d",&n);
    if(n==0)break;
    vi a(n);
    REP(i,n)scanf("%d",&a[i]);
    sort(ALL(a));
    int sum = 0;
    FOR(i,1,n-1)sum += a[i];
    sum /= (n-2);
    printf("%d\n",sum);
  }
  return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x,y) make_pair(x,y)



const int MAX = 1010000;
//const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
ll X,Y;
cin>>X>>Y;
COMinit();


if((X+Y)%3!=0){
  cout<<0<<endl;
  return 0;
}



ll m = (2*X-Y)/3;
ll n = (2*Y-X)/3;


if(m<0||n<0){
  cout<<0<<endl;
  return 0;
}

ll mmm = min(m,n);

ll ans = COM(m+n,mmm);



cout<<ans<<endl;

}



Measured memory_bytes: 23936
#include<bits/stdc++.h>
using namespace std;
inline void chmin(int& a, int b) { a = min(a, b); }
    
const int INF = INT_MAX;
const int MAX_N  = 1000000;
const int BACKET = 500;
    
     
int main()
{
  int N, Q;
  int A[MAX_N];
  int small[MAX_N / BACKET + 1];
  char s[32];
    
  fill_n(A, MAX_N, INF);
  fill_n(small, MAX_N / BACKET + 1, INF);
    
  fgets(s, sizeof(s), stdin);
  sscanf(s, "%d %d", &N, &Q);
      
  while(Q--) {
    int t, a, b;
    fgets(s, sizeof(s), stdin);
    sscanf(s, "%d %d %d", &t, &a, &b);
    if(t == 0) {
      int curr = a / BACKET;
      bool update = small[curr] == A[a];
      A[a] = b;
      if(small[curr] >= b) {
        small[curr] = b;
      } else if(update) {
        small[curr] = INF;
        for(int i = 0; i < BACKET; i++) chmin(small[curr], A[curr * BACKET + i]);
      }
    } else {
      int begin = (a + BACKET - 1) / BACKET;
      int end   = b / BACKET;
      int ret = INF;
      if(begin >= end) {
        for(int i = a; i <= b; i++) chmin(ret, A[i]);
      } else {
        for(int i = begin * BACKET - 1; i >= a; i--) chmin(ret, A[i]);
        for(int i = begin; i < end; i++) chmin(ret, small[i]);
        for(int i = end * BACKET; i <= b; i++) chmin(ret, A[i]); 
      }
      printf("%d\n", ret);
    }
  }
}

Measured memory_bytes: 5116
//knapsack
#include<iostream>
#include<vector>
using namespace std;

int main(){
    int n, weight_max;
    cin >> n >> weight_max;
    vector<vector<int>> vec(n, vector<int>(2)); //vec.at(count) = {weight, value}
    for ( int i = 0; i < n; ++i){
        cin >> vec.at(i).at(0) >> vec.at(i).at(1);
    }

    vector<vector<long long>> dp(2, vector<long long>(weight_max+1, 0));
    for ( int count = 0; count < n; ++count) {
        for ( int weight = 0; weight < weight_max+1; ++weight) {
            if ( weight < vec.at(count).at(0)) {
                dp.at(1).at(weight) = dp.at(0).at(weight);
            }
            else {
                dp.at(1).at(weight) = max(dp.at(0).at(weight-vec.at(count).at(0)) + vec.at(count).at(1), dp.at(0).at(weight));
            }
        }
        for ( int i = 0; i < weight_max+1; ++i){
            dp.at(0).at(i) = dp.at(1).at(i); //slide
        }
        cout << endl;
    }
    cout << dp.at(1).at(weight_max) << endl;
}

Measured memory_bytes: 2560
n,a,b,c,d = map(int,input().split())
x = abs(a-b)
c,d = min(c,d),max(c,d)
for i in range((n+1)//2):
  j = n-i-1
  if c*j-d*i<=x<=d*j-c*i:
    print("YES")
    exit()
print("NO")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ALL(a)  (a).begin(),(a).end()


int countDivisor(int a){
    int cnt=0;
    for(int i=1; i<=a; i++){
        if(a%i==0) cnt++;
    }
    return cnt;
}

int main(){
    int n, cnt=0;
    cin >> n;

    for(int i=1; i<=n; i=i+2){
        if(countDivisor(i) == 8) {
            cnt++;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
s = input()
if len(s) % 2 == 1:
    print("No")

else:
    i = 0
    flag = False
    while i+1 < len(s):
        if s[i:i+2] != "hi":
            flag = True
            break
        i += 2
    
    if flag:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 3060
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main{
	static Map<Long,Long> map= new TreeMap<>();
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  long n=sc.nextLong(),p=sc.nextLong();
	  primeEnum(p);
	  long res=1;
	  for (long key : map.keySet()){
	    	if(map.get(key)>=n) {
	    		long buff=map.get(key)/n;
	    		res*=Math.pow(key,buff);
	    	}
	  }
	  System.out.println(res);
	  //System.out.println(map.toString());
  }
	public static Map<Long,Long> primeEnum(long n) {
		for(long i=2;i<=Math.sqrt(n);i++) {
			if(n%i!=0)continue;
			long e=0;
			while(n%i==0) {
				e++;
				n/=i;
			}
			if(map.containsKey(i)) {
				map.put(i, e+map.get(i));
			}else {
				map.put(i, e);
			}
		}
		if(n!=1) {
			if(map.containsKey(n)) {
				map.put(n, 1+map.get(n));
			}else {
				map.put(n, 1L);
			}
		}
		return map;
	}
}



Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>

using namespace std;

const int INF = 1 << 30;

template<typename T>
class MaxFlow {
public:
	explicit MaxFlow(int n) : g(n), level(n), iter(n) {}
    struct Edge {
        Edge(int to, T cap, int rev) : to(to), cap(cap), rev(rev) {}
        int to, rev;
        T cap;
    };
	void addEdge(int src, int dst, T cap){
		g[src].emplace_back(dst, cap, g[dst].size());
		g[dst].emplace_back(src, 0, g[src].size()-1);
	}
	T maxFlow(int s, int t){
		T res = 0;
		int n = g.size();
		while(true){
            fill(level.begin(), level.end(), -1);
			level[s] = 0;
			queue<int> qu; qu.push(s);
			while(!qu.empty()){
				int p = qu.front(); qu.pop();
				for(const Edge& e : g[p]){
					if(e.cap > 0 && level[e.to] == -1){
						level[e.to] = level[p]+1;
						qu.push(e.to);
					}
				}
			}
			if(level[t] == -1) break;
            fill(iter.begin(), iter.end(), 0);
			for(T f;(f=dfs(s, t, INF)) > 0;res+=f);
		}
		return res;
	}
    const vector<vector<Edge>>& getGraph() const { return g; }
private:
	T dfs(int pos, int dst, T f){
		if(pos == dst) return f;
		for(int& i=iter[pos];i<g[pos].size();++i){
			Edge& e = g[pos][i];
			if(e.cap == 0 || level[e.to] <= level[pos]) continue;
			int d = dfs(e.to, dst, min(f, e.cap));
			if(d > 0){
				e.cap -= d;
				g[e.to][e.rev].cap += d;
				return d;
			}
		}
		return 0;
	}
	vector<vector<Edge>> g;
	vector<int> level;
	vector<int> iter;
};

int main(){
    int N, M; cin >> N >> M;
    vector<string> vs(N);
    for(auto& s : vs) cin >> s;
    MaxFlow<int> mf(N*M+2);
    for(int i=0;i<N;i++){
        for(int j=i%2;j<M;j+=2){
            if(vs[i][j] == '#') continue;
            int dx[] = {-1, 0, 1, 0};
            int dy[] = {0, -1, 0, 1};
            for(int d=0;d<4;d++){
                int nx = i+dx[d];
                int ny = j+dy[d];
                if(nx < 0 || N <= nx || ny < 0 || M <= ny || vs[nx][ny] == '#') continue;
                mf.addEdge(i*M+j, nx*M+ny, 1);
            }
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            if((i+j)%2) mf.addEdge(i*M+j, N*M+1, 1);
            else mf.addEdge(N*M, i*M+j, 1);
        }
    }
    cout << mf.maxFlow(N*M, N*M+1) << endl;
    auto& g = mf.getGraph();
    for(int i=0;i<N;i++){
        for(int j=i%2;j<M;j+=2){
            for(auto& e : g[i*M+j]){
                if(e.to < N*M && !e.cap){
                    int src = i*M+j;
                    int dst = e.to;
                    if(src > dst) swap(src, dst);
                    if(src+1 == dst && src%M != M-1){
                        vs[src/M][src%M] = '>';
                        vs[dst/M][dst%M] = '<';
                    } else {
                        vs[src/M][src%M] = 'v';
                        vs[dst/M][dst%M] = '^';
                    }
                }
            }
        }
    }
    for(auto& s : vs) cout << s << endl;
}

Measured memory_bytes: 4740