akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
  int A,B,X;
  cin>>A>>B>>X;
  if(A<=B&&X%1000==0){
    cout<<X/1000*A<<endl;
  }else if(A<=B){
    cout<<X/1000*A+A<<endl;
  }else if(2*B<=A&&X%500==0){
    cout<<X/500*B<<endl;
  }else if(2*B<=A){
    cout<<X/500*B+B<<endl;
  }else if(B<A&&A<2*B&&X%1000==0){
    cout<<X/1000*A<<endl;
  }else if(B<A&&A<2*B&&X%500==0){
    cout<<X/1000*A+B<<endl;
  }else if(B<A&&A<2*B&&X%1000>500){
    cout<<X/1000*A+A<<endl;  
  }else {
    cout<<X/1000*A+B<<endl;
  }
 
 
  return 0;
}




Measured memory_bytes: 3116
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

bool good(int k) {
	if (k & 1) {
		return true;
	}
	return ((k % 3 == 0) || (k % 5 == 0));
}

int main() {
	bool ok = true;

	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		if (!good(t)) {
			ok = false;
		}
	}
	if (ok) {
		cout << "APPROVED" << endl;
	} else {
		cout << "DENIED" << endl;
	}
	return 0;
}


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

int main(){
  int N;
  cin>>N;
  int ans=0;
  for(int i=0;i<N;i++){
    int l,r;
    cin>>l>>r;
    ans+=r-l+1;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define DEC(i, a, b) for (int i = (a); i > (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
typedef long long ll;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const ll LINF = (int)1e18;
const double EPS = 1e-9;

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int a,b;
  cin >> a >> b;
  if (a*b % 2 == 0) cout << "No" << endl;
  else cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef pair<pll, pll> node;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll Mod = 1000000007LL;
const int Maxn = 2e5 + 10;
const int Maxk = 60;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

map<ll, ll> mp;

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n;
	cin >> n;
	ll v, ans = n;
	for(int i = 0; i < n; i++){
		cin >> v;
		mp[v] ++;
		if(mp[v] == v) ans -= v;
	}
	cout << ans;
	return 0;
}

/*

                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/


Measured memory_bytes: 6272
#include <iostream>
#include <vector>

using namespace std;

int main(){
	vector<int> a;
	int n;
	cin>>n;
	int i;
	for (i=0;i<n;i++){
		int temp;
		cin>>temp;
		a.push_back(temp);
	}
	for (i=n-1;i>=0;i--){
		cout<<a[i];
		if (i!=0){
			cout<<" ";
		}
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<string,int> P;

bool judge(int n){
  vector<char> S;
  while(n>0){
    char ch = '0' + n%10;
    S.push_back(ch);
    n /= 10;
  }

  int l = S.size();
  bool flag = true;
  for(int i=0;i<l/2;i++){
    if(S[i]!=S[l-i-1]) flag = false;
  } 
  return flag;
}
int main(){
  	int A, B;
    cin >> A >> B;
    int ans = 0;

    for(int i=A;i<=B;i++){
      if(judge(i)) ans++;
    }
    cout << ans <<endl;


  return 0;
}






Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
mod = 10 ** 9 + 7

cnt = Counter(a)
if n % 2 == 0:
    for i, j in cnt.items():
        if j != 2 or not(1 <= i <= n - 1) :
            print(0)
            exit()
else:
    for i, j in cnt.items():
        if i == 0:
            if j != 1:
                print(0)
                exit()
        else:
            if j != 2 or not(1 <= i <= n - 1):
                print(0)
                exit()

num = n // 2
ans = pow(2, num, mod)
print(ans)

Measured memory_bytes: 14812
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
template<typename T>
void print(T x) {
    cout << x << endl;
}
int main(void) {
    int n; cin >> n;
    int sum = 0;
    rep(i, n) {
        int a; cin >> a;
        if ((i+1)&1 && a&1) sum++;
    }

    cout << sum;
}



Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,M,K;
  cin>>N>>M>>K;
  bool x=false;
  for(int i=0;i<=N;i++){
  for(int j=0;j<=M;j++){
  if(i*(M-j)+j*(N-i)==K){x=true; break;}
  }
  }if(x)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
S=list(input())

for i in S[::2]:
	if not(i=="R" or i=="U" or i=="D"):
		print("No")
		sys.exit()

for i in S[1::2]:
	if not(i=="L" or i=="U" or i=="D"):
		print("No")
		sys.exit()
	
print("Yes")

Measured memory_bytes: 3060
n,c = gets.chomp.split(" ").map{ |it| it.to_i}
class Vi
  attr_reader :s,:t,:c
  def initialize(ss,tt,cc)
    @s = ss
    @t = tt
    @c = cc
  end
end
class Machine
  attr_reader :t,:c
  def initialize(tt,cc)
    @t = tt
    @c = cc
  end
  def set(data)
    @t = data.t
    @c = data.c
  end
  def check(data)
    if(data.c == @c)
      return true if (data.s >= @t)
      return false
    else
       return true if ((data.s - 0.5) >= @t)
       return false
    end
  end
end
sl = []
tl = []
cl = []
vl = []
n.times do |nn|
  list = gets.chomp.split(" ").map{ |it| it.to_i}
  sl.push(list[0])
  tl.push(list[1])
  cl.push(list[2])
  vl.push(Vi.new(list[0],list[1],list[2]))
end
vl.sort!{ |a,b| a.t <=> b.t}
vl.sort!{ |a,b| a.s <=> b.s}

list = [Machine.new(-1,-1)]
while(vl.size > 0)
  ok = false
  cas = vl.shift
  list.size.times do |nn|
    unless ok
      if list[nn].check(cas)
        list[nn].set(cas)
        ok =true
      end
    end
  end
  list.push(Machine.new(cas.t,cas.c)) unless ok
end
print "#{list.size}\n"


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

using namespace std;

const int N = 10;

int a[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
  }
  int total = 1, sub = 1;
  for (int i = 0; i < n; i++) {
    if (a[i] % 2 == 0) {
      sub *= 2;
    }
    total *= 3;
  }
  printf("%d\n", total - sub);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <functional>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define INF (1ll << 60)

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

struct SegmentTree {
	ll init_val;
	int n;
	vector<ll> dat;
	
	SegmentTree(int _n) {
		init_val = -INF;
		n = 1;
		while (n < _n) n *= 2;
		dat.clear();
		dat.resize(2 * n - 1, init_val);
	}
	
	void update(int k, ll a) {
		k += n - 1;
		dat[k] = a;
		
		while (k > 0) {
			k = (k - 1) / 2;
			dat[k] = max(dat[2 * k + 1], dat[2 * k + 2]);
		}
	}
	
	ll query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return init_val;
		if (a <= l && r <= b) return dat[k];
		return max(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r));
	}
	
	ll query(int a, int b) {
		return query(a, b, 0, 0, n);
	}
};

ll n, d;
ll x[30], y[30];

void dfs(int pos, int end, P sum, vector<P> &v) {
	if (pos == end) {
		v.push_back(sum);
		return;
	}
	
	dfs(pos + 1, end, P(sum.first + x[pos], sum.second + y[pos]), v);
	dfs(pos + 1, end, P(sum.first - x[pos], sum.second - y[pos]), v);
	dfs(pos + 1, end, sum, v);
}


int main() {
	
    cin >> n >> d;
    REP(i,n) cin >> x[i] >> y[i];
     
	vector<P> s, u;
     
    dfs(0, n / 2, P(0, 0), s);
    dfs(n / 2, n, P(0, 0), u);
	
	sort(s.rbegin(), s.rend());
	sort(u.begin(), u.end());
	
	s.erase(unique(s.begin(), s.end()), s.end());
	u.erase(unique(u.begin(), u.end()), u.end());
	
	SegmentTree seg(u.size());
	REP(i, u.size()) seg.update(i, u[i].second);
	
	int l = 0, r = 0;
	ll ans = -INF;
	REP(i, s.size()) {
		while (l < u.size() && u[l].first < -d - s[i].first) l++;
		while (r < u.size() && u[r].first <= d - s[i].first) r++;
		
		ans = max(ans, s[i].second + seg.query(l, r));
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 713364
import std.stdio;
import std.algorithm;
import std.array;
import std.conv;
import std.string;
import std.uni;
import std.range;

void main()
{
    auto a = readln.strip.repeat(2).join("");
    if (a.indexOf(readln.strip) != -1)
        writeln("Yes");
    else
        writeln("No");
}



Measured memory_bytes: 2480
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    tx += (-sx);
    ty += (-sy);
    sx = sy = 0;

    string ans = "";

    for (int i = 0; i < ty; i++) ans += 'U';
    for (int i = 0; i < tx; i++) ans += 'R';
    for (int i = 0; i < ty; i++) ans += 'D';
    for (int i = 0; i < tx + 1; i++) ans += 'L';
    for (int i = 0; i < ty + 1; i++) ans += 'U';
    for (int i = 0; i < tx + 1; i++) ans += 'R';
    ans += 'D';
    ans += 'R';
    for (int i = 0; i < ty + 1; i++) ans += 'D';
    for (int i = 0; i < tx + 1; i++) ans += 'L';
    ans += 'U';

    cout << ans << endl;


    return 0;
}






















































Measured memory_bytes: 256
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	ll N;
	cin>>N;
 
	// 解法
	ll ans = 0;
	for (ll i = 1; i < N; ++i){
		ll m = (N-i)/i;
		if (m<=i) break;
		if (N%i!=0) continue;
		else ans += m;
		// printf("%lld\n", m);
	}
	
	//出力
	cout << ans << endl;
}


Measured memory_bytes: 256
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::HashMap;

fn main() {
    input!(n: usize, mut xs: [i64; n]);
    xs.insert(0, 0);
    xs.push(0);
    let sum = xs.windows(2).map(|x| (x[0] - x[1]).abs()).sum::<i64>();

    for i in 1..n + 1 {
        let mut ans = sum;
        ans -= (xs[i] - xs[i - 1]).abs() + (xs[i] - xs[i + 1]).abs();
        ans += (xs[i - 1] - xs[i + 1]).abs();
        println!("{}", ans);
    }
}


Measured memory_bytes: 5244
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 0x3f3f3f3f;
const double pi = 3.14;
const ll mod = 1000000007;
ll gcd(ll a, ll b)
{
	if(b==0) return a;

	else return gcd(b, a%b);
}
ll lcm(ll a, ll b)
{
	return (a*b)/gcd(a,b);
}
ll fastpower(ll base, ll exp, ll mod)
{
	ll ans = 1ll;

	while(exp)
	{
		if(exp&1)
		{
			ans = (ans%mod * base%mod)%mod;
		}
		exp/=2;
		base = (base%mod * base%mod)%mod;
	}
	return ans;
}
const int MAX = 1e5+9;
bool visited[MAX];
vector< int > adj[MAX+1];
void dfs(int node)
{
	visited[node] = true;

	for(auto u : adj[node])
	{
		if(!visited[u])
		{
			dfs(u);
		}
	}
}

int main() {
	// your code goes here
	
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	int h1, s1, h2, s2;
	cin >> h1 >> s1 >> h2 >> s2;
	int i = 0;

	while(1)
	{
		if(i%2 == 0)
		{
			h2 = h2-s1;
			if(h2<=0) 
			{	cout << "Yes"<< '\n';
				break;
			}
		}
		else
		{
			h1 = h1-s2; 
			if(h1 <= 0) 
			{
				cout << "No" <<'\n';
				break;
			}
		}
		i++;
	}
	return 0;
	} 

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

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int inf = 1e17;
typedef pair<int, int> P;
typedef pair<int, P> PP;
vector<int>G[10];
int rwa[10][30005];


signed main() {
	int n; cin >> n;
	string s; cin >> s;
	rep(i, s.size()) {
		G[s[i] - '0'].push_back(i);
		rwa[s[i] - '0'][i + 1]++;
	}
	rep(i, 10)rep(j, n)rwa[i][j + 1] += rwa[i][j];
	int cnt = 0;
	rep(i, 1000) {
		int j = i / 100, k = (i % 100) / 10, l = i % 10;
		if (G[j].size()) {
			int pj = G[j][0];
			if (G[l].size()) {
				int pl = G[l][G[l].size() - 1];
				if (rwa[k][pl] - rwa[k][pj + 1]>0) {
					cnt++;
				}
			}
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3072
def check(n,x):
    ct = 0
    for n in range(1,n+1):
        for m in range(1,n):
            for o in range(1,m):
                if n+m+o == x:
                    ct+=1
    print(ct)

while True:
    n,x = map(int, input().split())
    if n==0 and x==0:
    	break
    else:
        check(n,x)



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 
 
int main() {
	ll n;
	cin>>n;
	ll a[102];
	ll sum=0;
	for(ll i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	ll ans=inf;
	ll sum1=0;
	for(ll i=0;i<n-1;i++){
		sum1+=a[i];
		ans=min(ans,abs(sum-2*sum1));
	}
	cout <<ans;
	// your code goes here
	return 0;
}

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

#define M 108
#define MAXX 999999999999999
#define PI 3.14159265358979323846
#define ep emplace_back
#define mk make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> PII;
typedef pair<lli,lli> PLL;

int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   
//   freopen("input.txt","rt",stdin);

   string s,t;
   cin>>s>>t;
   
   vector<int> res;
   
   int ns = (int)s.size();
   int nt = (int)t.size();
   
   res.ep(nt);
   
   for(int i=0;i<ns-nt+1;i++)
   {
      int same = 0;
      
      int k = i;
      for(int j=0;j<nt;j++,k++)
      {
         if(t[j]==s[k])
            same++;
      }
      
      res.ep(nt-same);
   }
   
   lli ans = *min_element(all(res));
   cout<<ans<<"\n";


}


Measured memory_bytes: 3656
a, b, c = gets.split.map(&:to_i)
as = []
bs = []
a.times do
  as << gets.split.map(&:to_i)
end
b.times do
  bs << gets.split.map(&:to_i)
end
cs = []
bs = bs.transpose
as.each do |x|
  ans = []
  bs.each do |y|
    t = 0
    b.times do |i|
      t += x[i] * y[i]
    end
    ans << t
  end
  puts ans.join(" ")
end


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

  vector<long long> result(N+1,0);
  
  for(int i=0; i<N+1; i++){
	if(i==0) result.at(i) = 2;
    else if(i==1) result.at(i) = 1;
    else if(result.at(i) == 0){
      result.at(i) = result.at(i-1) + result.at(i-2);
    }
  }
  printf("%lld", result.at(N));
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <string>
using namespace std;
string actionFunction(string x,string y) {
    vector<vector<int>> dp(x.length()+1,vector<int>(y.length()+1,0));
    if(x.length()==0 || y.length()==0)return "";
    for(int row=1;row<=x.length();row++) {
        for(int col=1;col<=y.length();col++) {
            if(x[row-1]==y[col-1])dp[row][col]=max({dp[row-1][col-1]+1,dp[row-1][col],dp[row][col-1]});
            else dp[row][col]=max(dp[row-1][col],dp[row][col-1]);
        }
    }
    int maxlength=dp[x.length()][y.length()];
    int row=x.length(),col=y.length();
    string out;
    while(maxlength!=0 && col>0 && row>0) {
        if(dp[row][col-1]==maxlength) {
            col--;continue;
        }
      	if(dp[row-1][col]==maxlength) {
        	row--;continue;
        }
        if(dp[row-1][col-1]==maxlength-1) {
            out.push_back(y[col-1]);
            row--;
            maxlength--;
            col--;
        }
    }
    return out;
}
string reverseString(string a) {
    for(int i=0;i<a.length()/2;i++) {
        swap(a[i],a[a.length()-i-1]);
    }
    return a;
}
int main(void){
    string x,y;
    cin>>x>>y;
    cout<<reverseString(actionFunction(x,y))<<endl;
}


Measured memory_bytes: 35584
#include<stdio.h>
int main(void){
  char S[11];
  char a[]="ACGT";
  int i,j,b=0,c=0,d=0;
  scanf("%s",S);
  for(i=0;i<11;i++){
    for(j=0;j<4;j++){
      if(S[i]==a[j]) b=1;
    }
    if(b==1) c++;
    if(b==0){
      if(d<c) d=c;
      c=0;
    }
    b=0;
  }
  printf("%d\n",d);
  return 0;
}

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

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

  ll N; cin >> N;
  ll ans = 0;
  for (ll i = 1; i <= N; i++) {
    for (ll j = 1; j <= N; j++) {
      ll C = N - i * j;
      if (C > 0) ans++;
      else break;
    }
  }
  cout << ans << '\n';
  return 0;
}

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

int main(){
	int n,hand[2],sum[2];
	while(1){
		sum[0]=0;
		sum[1]=0;
		cin>>n;
		if(n==0)break;
		for(int i=0;i<n;i++){
			cin>>hand[0]>>hand[1];
			if(hand[0]>hand[1]){
				sum[0]+=hand[0]+hand[1];
			}else if(hand[0]<hand[1]){
				sum[1]+=hand[0]+hand[1];
			}else{
				sum[0]+=hand[0];
				sum[1]+=hand[1];
			}
		}
		cout<<sum[0]<<' '<<sum[1]<<endl;
	}
	return 0;
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int _i=(first);_i<(last);++_i){cout<<#a<<"["<<_i<<"] = "<<(a)[_i]<<endl;}
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define MOD 1000000007
//#define MOD 998244353

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

template <class T, class U>
std::ostream& operator<<(std::ostream &os, const std::pair<T, U> &p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}
 
template <class T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v) {
    os << "[";
	for (int i = 0; i < v.size(); ++i) {
        if (i) {
            if (i % 5 == 0) {
                os << ",\n ";
            } else {
                os << ", ";
            }
        }
		os << v[i];
	}
	os << "]";
	return os;
}

template <class T>
using vec2 = vector<vector<T>>;

template <class T>
using vec3 = vector<vector<vector<T>>>;

const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

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

    int N;
    cin >> N;
    vector<int> L(N);
    REP(i, N) {
        cin >> L[i];
    }

    ll result = 0;
    REP(i, N) FOR(j, i + 1, N) FOR(k, j + 1, N) {
        if (L[i] == L[j] || L[j] == L[k] || L[k] == L[i]) {
            continue;
        }
        bool b0 = (L[i] + L[j] > L[k]);
        bool b1 = (L[j] + L[k] > L[i]);
        bool b2 = (L[k] + L[i] > L[j]);
        if (b0 && b1 && b2) {
            ++result;
        }
    }

    cout << result << endl;
    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  vec a(n+1);
  for(ll i=1;i<=n;i++) cin >> a[i];
  for(ll i=0;i<n;i++) a[i+1]+=a[i];
  mat dp(n,vec (n,inf));
  for(ll i=0;i<n;i++) dp[i][i]=0;
  for(ll i=1;i<n;i++) {
    for(ll j=0;j<n-i;j++) {
      for(ll k=j;k<j+i;k++) {
        dp[j][j+i]=min(dp[j][j+i],dp[j][k]+dp[k+1][j+i]+a[j+i+1]-a[j]);
      }
    }
  }
  cout << dp[0][n-1] << endl;
}

Measured memory_bytes: 1536
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = MAP()
if A + B >= 10:
    print("error")
else:
    print(A + B)

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

int k, x, y = 0;

int main()
{
    cin >> x;
    for (k = 1; k <= 360; k++) {
        y = y + x;
        if (!(y % 360)) {
            cout << k << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int INF = 0x7fffffff;
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
  lll ii,jj,kk;
  vector<int> ret;
  lll n,k;

  cin >> n >> k;

  lll mod,modM;
  mod = n % k ;

  cout << min(mod,abs(mod-k)) << endl;

  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#define INF 1000000000
using namespace std;

int ary[1010][1010];
int dp[2][1010][128];
int H,W;

inline int tor(int n){
	return (n>>1)&45;
}
inline int tod(int n){
	return n>>3;
}

int solvecell(int x,int y){
	int hog[128];
	fill(hog,hog+128,INF);
	int tmp,tmq,tmr,ou=x&1,in=ou^1;
	int tes[4]={};
	int dx[4]={-1,0,0,1},dy[4]={0,-1,1,0};
	if(ary[x][y])for(int i=0;i<4;i++) tes[i]+=8;
	for(int i=0;i<4;i++){
		if(ary[x+dx[i]][y+dy[i]]){
			for(int j=0;j<4;j++) if(i!=j)tes[j]+=1<<(i*2);
		}
	}
	for(int i=0;i<128;i++){
		tmp=tod(i);
		hog[tmp]=min(hog[tmp],dp[in][y][i]);
	}
	for(int i=0;i<128;i++){
		tmp=tor(i);
		hog[tmp]=min(hog[tmp],dp[ou][y-1][i]);
	}
	for(int i=0;i<128;i++){
		for(int j=0;j<4;j++){
			tmp=i|tes[j];
			tmq=i^tmp;
			tmr=0;
			if(tmq&1) tmr+=ary[x-1][y];
			if(tmq&4) tmr+=ary[x][y-1];
			if(tmq&8) tmr+=ary[x][y];
			if(tmq&16) tmr+=ary[x][y+1];
			if(tmq&64) tmr+=ary[x+1][y];
			dp[ou][y][tmp]=min(dp[ou][y][tmp],hog[i]+tmr);
		}
	}
}

int main(){
	cin>>H>>W;
	char c;
	for(int i=0;i<2;i++){
		for(int j=0;j<1010;j++){
			fill(dp[i][j],dp[i][j]+128,INF);
		}
	}
	dp[1][1][0]=0;
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			cin>>c;
			if(c=='.') c='0';
			ary[i][j]=c-'0';
		}
	}

	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			solvecell(i,j);
		}
		for(int j=1;j<=W;j++)fill(dp[(i&1)^1][j],dp[(i&1)^1][j]+128,INF);
	}
	int res=INF;
	for(int i=0;i<128;i++){
		res=min(res,dp[H&1][W][i]);
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 8040
#include<stdio.h>
#include<string.h>

int main(){
  char taro[101], hanako[101];
  int count, taro_s=0, hanako_s=0, i;

  scanf("%d",&count);
  for(i=0;i<count;i++){
    scanf("%s %s",taro,hanako);

    if(strcmp(taro,hanako)>0) taro_s+=3;
    else if(strcmp(taro,hanako)<0) hanako_s+=3;
    else {
      taro_s+=1;
      hanako_s+=1;
    }
  }
  printf("%d %d\n",taro_s,hanako_s);
  return 0;
}



Measured memory_bytes: 2040
# coding: utf-8
data=[list(map(int,input().split())) for i in range(3)]
for i in range(101):
    for j in range(101):
        for k in range(101):
            for w in range(3):
                if not (data[0][w]-i==data[1][w]-j==data[2][w]-k):
                    break
            else:
                print('Yes')
                exit()
print('No')

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
const int MAX=30;
int main(){
	bool student[MAX+2];
	int n;
	for(int i=1; i<=30; i++) student[i]=false;
	for(int i=1;i<=28;i++){
		cin >> n;
		student[n]=true;
	}
	for(int i=1; i<=30; i++)
		if(student[i]==false) cout << i << endl;
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int n,m;
int Map[55][55];
int visit[55];
int x[1000],y[1000],z[1000];
int main()
{
    int a,ans = 0;
    cin >> n;
	cin >> m;
	for (int i = 1; i <= m; i++)
	{
		cin >> x[i];
		cin >> y[i];
	}
	for (int i = 1; i <= m; i++)
	{
		a = 1;
		for (int k = 1; k <= n; k++)
		{
			z[k] = k;
		}
		while (a == 1)
		{
			a = 0;
			for (int k = 1; k <= m; k++)
			{
				if (k != i&&z[x[k]] != z[y[k]])//使得所有i节点能到达的最小节点是z[i]
				{
					z[x[k]] = min(z[x[k]], z[y[k]]);
					z[y[k]] = min(z[x[k]], z[y[k]]);
					a = 1;
				}
			}
		}
		a = 0;
		for (int k = 1; k <= n; k++)
		{
			if (z[k] != 1)//判断最后能否到达1
			{
				a = 1;
				break;
			}
		}
		if (a == 1)
		{
			ans++;
		}
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
s = list(input())

for i in range(3**2):
    number = int(s[0])
    str = s[0]
    for j in range(3):
        if ((i>>j)&1):
            number += int(s[j+1])
            str += '+'+s[j+1]
        else:
            number -= int(s[j+1])
            str += '-'+s[j+1]
    if number == 7:
        print(str + '=7')
        exit(0)

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

using namespace std;


string s;
int k;

int main() {

  cin >> k >> s;



  if(s.length()<=k)
    cout << s <<endl;
  else{
    cout << s.substr(0,k) << "..."<<endl;
  }
  
  return 0;
}


  


Measured memory_bytes: 3596
def factorization(n):
    arr = dict()
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr[i] = cnt

    if temp != 1:
        arr[temp] = 1

    if not arr and n != 1:
        arr[n] = 1

    return arr


MOD = 10 ** 9 + 7
MAX = 10 ** 5 + 50
modinv = lambda a, mod=10 ** 9 + 7: pow(a, mod - 2, mod)
fac, inv = [1] * MAX, [1] * MAX
for i in range(1, MAX):
    fac[i] = fac[i - 1] * i % MOD
    inv[i] = modinv(fac[i])
comb = lambda n, k: fac[n] * inv[k] * inv[n - k] % MOD

N, M = map(int, input().split())
ans = 1
for v in factorization(M).values():
    ans = (ans * comb(N + v - 1, v) % MOD)
print(ans)


Measured memory_bytes: 11148
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  string s, t;
  cin >> s >> t;
  int n = (int)s.size();

  vector<vector<int>> sv(26), tv(26);

  rep(i, 0, n) {
    sv[s[i] - 'a'].push_back(t[i]);
    tv[t[i] - 'a'].push_back(s[i]);
  }

  rep(i, 0, n) {
    if ((int)sv[s[i] - 'a'].size() != (int)tv[t[i] - 'a'].size()) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}


Measured memory_bytes: 6064
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <queue>
#include <unordered_set>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long

int h, w;
bool s[100][100];
int d[100][100];
int whiteCount;

int main(void)
{
    cin >> h >> w;

    rep(i, h)
    {
        string temp;
        cin >> temp;
        rep(j, w)
        {
            bool b = (temp[j] == '.');
            s[i + 1][j + 1] = b;
            d[i + 1][j + 1] = +inf;
            if (b)
                whiteCount++;
        }
    }

    queue<pair<int, int>> qu;
    qu.push(make_pair(1, 1));
    d[1][1] = 0;

    int dx[4] = {0, 1, 0, -1};
    int dy[4] = {1, 0, -1, 0};

    while (qu.size() > 0)
    {
        auto p = qu.front();
        qu.pop();
        int x = p.first;
        int y = p.second;
        int dd = d[x][y] + 1;

        rep(i, 4)
        {
            int xx = x + dx[i];
            int yy = y + dy[i];

            if (!s[xx][yy])
                continue;

            if (dd >= d[xx][yy])
                continue;

            d[xx][yy] = dd;
            qu.push(make_pair(xx, yy));

            if (xx == h && yy == w)
            {
                int point = whiteCount - (dd + 1);
                cout << point << endl;

                return 0;
            }
        }
    }

    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main() {
	char str[101]={};
	scanf("%s", str);
	int len=strlen(str);
	int ans=0;
	for (int i = 0; i < len/2; i++) {
		if(str[i]!=str[len-i-1])
			ans++;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+10;
int x, y, z;
int main()
{
    //freopen("/Users/zhangkanqi/Desktop/11.txt","r",stdin);
    cin >> x >> y >> z;
    cout << z << " " << x <<" " << y << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <iostream>
#include <set>
using namespace std;

int main(){
  string s; cin >> s;
  REP(i,3) if(s[i] == s[i + 1]){
    puts("Bad");
    return 0;
  }
  puts("Good");
  return 0;
}

Measured memory_bytes: 256
import java.lang.Math.*

fun main(args: Array<String>){
    val n = readLine()!!.toInt()
    val h = readLine()!!.split(" ").map { it.toInt() }

    val dp = Array(n){0}
    dp[1] = abs(h[0] - h[1])

    for(i in 2 until n){
        dp[i] = min(abs(h[i] - h[i - 1]) + dp[i - 1], abs(h[i] - h[i - 2]) + dp[i - 2])
    }
    println(dp.last())
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

int main() {
  int n;
  cin >> n;
  double x = n / 1.08;

  FOR(i, -5, 5) {
    int test_x = (int)x + i;
    if (int(test_x * 1.08) == n) {
      cout << test_x << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(int argc, char const *argv[]) {
  int n=0;
  std::cin >> n;
  for(int i=1;i<=n;i++){
    int x = i;
    if ( x % 3 == 0 ){
      std::cout << " " << i;
    }else{
      while(x){
        if ( x % 10 == 3 ){
          std::cout << " " << i;
          break;
        }
         x /= 10;
      }
    }
  }
  std::cout << std::endl;
  return 0;
}

Measured memory_bytes: 3096
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        System.out.println(Math.max(0, c - (a - b)));

    }

}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 

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

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

    double x1, y1, x2, y2;
    cin>>x1>>y1>>x2>>y2;
    printf("%.10f", sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)));
}


Measured memory_bytes: 3236
#include<bits/stdc++.h>
#define ll long long int
 
using namespace std;
 
const ll mod=1000000007;
const ll inf=1e18;
 
ll gcd(ll a,ll b){
  if(a%b == 0){
    return b;
  }else{
    return gcd(b, a%b);
  }
}
 
vector<ll> soinsu(ll a){//素因数分解する。例:soinsu(60)={2,2,3,5}
  if(a<=0) return {};
  if(a==1) return {1};
  vector<ll> f;
  ll b=a;
  for(ll i=2;i*i<=a;i++){
    if(b%i==0){
      f.push_back(i);
      b=b/i;
      i--;
    }
  if(b==1)break;
  }
  if(b!=1)f.push_back(b);
  return f;
}
 
int main(){
 
  ll a,b;
  cin >> a >> b;
  //gcd(a,b)の素因数の数を数えたい(1に注意する)
  ll d=gcd(a,b);

  
 
  vector<ll> v=soinsu(d);
  //vは昇順になっているので、cを一番最近見た素数として、新しく見た素数がcと違うならs++してcを更新。
  ll c=1;//1を考慮して初期値はc=s=1
  ll s=1;
  for(ll i=0;i<v.size();i++){
    if(v[i]!=c){
      c=v[i];
      s++;
    }
  }
  // set<ll> u;
  // for(int i=0;i<v.size();i++)u.insert(v[i]);
  // cout << u.size()+1 << endl;
  cout << s << endl;

 
  // for(int i=0;i<v.size();i++)cout << v[i] << endl;
 
 
}

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

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

using ll = long long int;
const ll MOD = 1e9 + 7;

int main() {
  std::string S;
  std::cin >> S;

  rep(i, S.length()) {
    std::cout << "x";
  } std::cout << "" << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<typename T = int>inline T in() { T x; cin >> x; return x; }
#define REP(i,n) for(ll i=0;i<(n);++i)
#define REP1(i,n) for(ll i=1;i<=(n);++i)
#define REPI(i,ini,n) for(ll i=(ini);i<(n);++i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b) (((a)+(b)-1)/(b))
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1e9
#define INFL static_cast<ll>(INF)
int main()
{
	while (true)
	{
		int n = in();
		if (n == 0)break;
		vector<int>s(n);
		REP(i, n)s[i] = in();
		sort(ALL(s));
		int sum = 0;
		REP1(i, s.size() - 2)sum += s[i];
		cout << sum / (n - 2) << endl;
	}
}


Measured memory_bytes: 3044
#include<iostream>
#include <math.h>
using namespace std;
int main()
{
    double N,K;
    cin >> N >> K;
    double answer = 0;

    for(int i = 1; i <= N; ++i){
        double j,k;
        for(j = 0; K > i * pow(2, j); j++) {

        }
        answer += powl(0.5f, j) / N;
    }
    printf("%.16f\n", answer);
    return 0;
}

Measured memory_bytes: 768
N = gets.to_i

dist = {}

N.times do |i|
  dist[i + 1] = gets.to_i
end

queue = [[1, 0]]
check_list = {}

until queue.empty?
  id, d = queue.shift
  next if check_list[id]
  check_list[id] = d

  queue << [dist[id], d + 1]
end

if check_list[2]
  puts check_list[2]
else
  puts -1
end


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

int main (void) {
    char c;

    cin >> c ;

    switch (c) {
        case 'a':
        cout << "vowel" << endl;
        break;

        case 'e':
        cout << "vowel" << endl;
        break;

        case 'i':
        cout << "vowel" << endl;
        break;

        case 'o':
        cout << "vowel" << endl;
        break;

        case 'u':
        cout << "vowel" << endl;
        break;

        default:
        cout << "consonant" << endl;

    }
    
    return 0;
    
}

Measured memory_bytes: 3568
N = int(input())
A = list(map(int, input().split()))
res = ""
res_tmp = 0
for j, a in enumerate(A):
    res_tmp += a if j % 2 == 0 else -a
res += (str(res_tmp) + " ")

for i, a in enumerate(A[:-1]):
    res_tmp = -res_tmp + a*2
    res += (str(res_tmp) + " ")
print(res[:-1])


Measured memory_bytes: 14092
# -*-coding: utf-8 -*-
N, X = map(int, input().split())
L = list(map(int, input().split()))
D = 0
for i in range(1, N+1):
    D += L[i-1]
    # print(i+1, D)
    if D > X:
        ans = i
        break
    if i == N:
        ans = i+1

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() cin.tie(0), ios::sync_with_stdio(false)

int N, M, Q;

int sum[550][550];

int query(int p, int q)
{
    return sum[q][q] - sum[p - 1][q] - sum[q][p - 1] + sum[p - 1][p - 1];
}

int main()
{
    fast();

    cin >> N >> M >> Q;
    for (int i = 0; i < M; i++)
    {
        int l, r;
        cin >> l >> r;
        sum[l][r]++;
    }

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            sum[i + 1][j + 1] += sum[i + 1][j] + sum[i][j + 1] - sum[i][j];
        }
    }

    for (int i = 0; i < Q; i++)
    {
        int p, q;
        cin >> p >> q;
        cout << query(p, q) << endl;
    }
}

Measured memory_bytes: 2048
import sys
def input(): return sys.stdin.readline().strip()

def main():
    a, b = map(int, input().split())
    if a == 1: a += 13
    if b == 1: b += 13
    if a == b:
        print("Draw")
    elif a > b:
        print("Alice")
    else:
        print("Bob")

if __name__ == "__main__":
    main()


Measured memory_bytes: 61908
def Fib(n):
    a, b = 1, 2
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n - 2):
            a, b = b, a + b
        return b

now_step = 0
ans = 1
N, M = map(int, input().split(" "))
for i in range(M):
    a = int(input())
    if now_step == a:
        ans *= 0
        break
    elif now_step == (a - 1):
        now_step = a + 1
        continue
    else:
        ans *= Fib((a - 1) - now_step)
        now_step = a + 1
if now_step != N:
    ans *= Fib(N - now_step)
print(ans % 1000000007)



Measured memory_bytes: 3064
n=gets.to_i
x,y=n.times.map{gets.split.map(&:to_f)}.transpose

count=0
count_n=0
[*1..n].permutation.to_a.each do |perm|
  (n-1).times do |i|
    count+=((x[perm[i+1]-1]-x[perm[i]-1])**2+(y[perm[i+1]-1]-y[perm[i]-1])**2)**0.5
  end
  count_n+=1
end
puts sprintf("%.7f",count/count_n)


Measured memory_bytes: 20448
#include <stdio.h>
#define N 500001
#define NIL 200000
void maxHeapify(int);
void buildMaxHeap();
int heap[N],n;

int main(){
  int i;
  for( i = 0 ; i < N ; i++ ){
    heap[i] = NIL;
  }

  scanf("%d",&n);

  for( i = 1 ; i <= n ; i++ ){
    scanf("%d",&heap[i]);
  }

  buildMaxHeap();

  for( i = 1 ; i <= n ; i++ ){
    printf(" %d",heap[i]);
  }   
  printf("\n");
  return 0;
}
  
  
void maxHeapify(int i){
  int l,r,largest,a;
    l = 2*i;
   
    r = 2*i+1;
    
  if( l <= n && heap[l] > heap[i] ) largest = l;
  else largest = i;
    
  if( r <= n && heap[r] > heap[largest] )  largest = r;
    
  if( largest != i){
    a = heap[largest];
    heap[largest] = heap[i];
    heap[i] = a;
    maxHeapify(largest);
  }
}
void buildMaxHeap(){
  int i;
  for( i = n/2 ; i >= 1 ; i--){
    maxHeapify(i); 
  }
}

Measured memory_bytes: 2552
n, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
ans = [0]*n
if (sum(a) == x):
    print(n)
else:
    for i in range(n):
        if (x >= a[i]):
            ans[i] = 1
            x -= a[i]
        else:
            print(sum(ans))
            exit()
    if (0 in ans):
        print(sum(ans))
    else:
        print(sum(ans)-1)

Measured memory_bytes: 9036
import Control.Monad
import Data.List
import qualified Data.Map.Strict as M

main=do
    s<-getLine
    print $ sol (length s) s

sol n s
    | length iss == 1 = 0
    | otherwise = minimum $ map (\is->maximum $ unfoldr cf (n,is)) iss
    where
        iss = M.elems $ foldl' (\m (c,i)->M.alter (altf i) c m) M.empty $ zip s [0..]

altf i (Just u) = Just (i:u)
altf i Nothing = Just [i]

cf (-1, _) = Nothing
cf (p, []) = Just(p, (-1,[]))
cf (p, i:is) = Just(p-i-1, (i,is))

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

using namespace std;

using LL = long long;

template<typename T>
ostream& operator << (ostream& out, const vector<T>& v) {
    out << "[";
    for(const auto& x : v) {
        out << x << ", ";
    }
    return out << "]";
}

template<typename S, typename T>
ostream& operator << (ostream& out, const pair<S, T>& p) {
    return out << "{" << p.first << ", " << p.second << "}";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int N;
    cin >> N;
    vector<int> A(N);
    int tot = 0;
    for(auto& a : A) {
        cin >> a;
        tot ^= a;
    }
    for(auto a : A) {
        cout << (tot ^ a) << " ";
    }
    cout << "\n";
    
    
    return 0;
}


Measured memory_bytes: 3984
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

const int COM_MAX = 550000;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_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 || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

long long pow_mod(long long n,long long k,long long m){
    if (k == 0){
        return 1;
    } else if (k % 2 == 1){
        return pow_mod(n,k-1,m)*n % m;
    } else {
        long long t = pow_mod(n,k/2,m);
        return t*t % m;
    }
}

int main(){
    int a,b,c; cin >> a >> b >> c;
    int mx = max(a*10+b+c,max(a+b*10+c,c*10+a+b));
    cout << mx << endl;
}

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

int main(){
    int i;
    int j;
    for( i = 1; i<10; i++){
        for( j = 1; j<10; j++){
            printf("%dx%d=%d\n",i,j,i*j);


        }


    }


    return 0;
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
using namespace std;

const long long INF=9000000000000000;
int main(){
  string a,b,c;
  char ans,q;
  int aa=0,bb=0,cc=0,x=1;
  cin>>a>>b>>c;
  int d=a.size(),e=b.size(),f=c.size();
  for(int i=0;i<310;i++){
    if(x==1){
      while(a[aa]=='a'){
        aa++;d--;
      }
      if(d==0){
      ans='A';
      break;
      }
      q=a[aa];
      d--;
      aa++;
      if(q=='b')
      x=2;
      if(q=='c')
      x=3;
    }
    if(x==2){
      while(b[bb]=='b'){
        bb++;e--;
      }
      if(e==0){
        ans='B';
        break;
      }
      q=b[bb];
      e--;
      bb++;
      if(q=='a')
      x=1;
      if(q=='c')
      x=3;
    }
    if(x==3){
      while(c[cc]=='c'){
        cc++;f--;
      }
      if(f==0){
        ans='C';
        break;
      }
      q=c[cc];
      f--;
      cc++;
      if(q=='b')
      x=2;
      if(q=='a')
      x=1;
    }
  }
  cout<<ans<<endl;
}


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

int main(){
	int N,X,ans=1,pos=0;
	cin >> N >> X;
	for(int i=0;i<N;i++){
		int l;
		cin >> l;
		pos+=l;
		if(pos<=X)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256