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

using namespace std;

#define ll long long
ll input(){
	ll x=0,f=0;char ch=getchar();
	while(ch<'0'||ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return f? -x:x;
}

#define lowbit(x) x&-x

const int N=2e5+7;

ll dp[N];
ll a[N],h[N],t[N];
int n;

void update(int x,ll y){for(;x<=n;x+=lowbit(x)) t[x]=max(t[x],y);}
ll query(int x){ll res=0;for(;x;x-=lowbit(x)) res=max(res,t[x]);return res;}

int main(){
	n=input();
	for(int i=1;i<=n;i++) h[i]=input();
	for(int i=1;i<=n;i++) a[i]=input();

	for(int i=1;i<=n;i++){
		dp[i]=query(h[i])+a[i];
		update(h[i],dp[i]);
	}
	printf("%lld\n",query(n));
}

Measured memory_bytes: 6528
S = input()
T = input()
mx = 0
for i in range(len(S) - len(T) + 1):
    t = 0
    for j in range(len(T)):
        if i + j < len(S) and S[i + j] == T[j]:
            t += 1
    mx = max(mx, t)
print(len(T) - mx)


Measured memory_bytes: 67664
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, ans = 0;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  for (int i = 0; i < N; i++) {
    if (i != N-1) ans += vec.at(i);
    else ans += vec.at(i) / 2;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main() {
	int k;
	cin >> k;
	string s;
	cin >> s;
	if (s.length() <= k) {
		cout << s << "\n";
		return 0;
	}
	cout << s.substr(0, k) << "...\n";
	return 0;
}


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

int main() {
  int N = 0;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    int A = 0;
    cin >> A;
    
    if (A % 2 == 0) {
      if (!(A % 3 == 0 || A % 5 == 0)) {
        cout << "DENIED" << endl;
  		return 0;
      }
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}

Measured memory_bytes: 3596
def main():
    N = int(input())
    A = list(map(int, input().split()))
    pos = [-1] * (N+1)
    for i in range(N):
        pos[A[i]] = i
    left = list(range(N+2))
    right = list(range(N+2))
    ans = 0
    for i in range(N, 0, -1):
        p = pos[i]
        l = left[p]
        r = right[p]
        ans += i * (p-l+1) * (r-p+1)
        left[r+1] = left[p]
        right[l-1] = right[p]
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 76880
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY =2147483647;
int main(){
    char c;
    cin>>c;
    if(c-'A'>=0&&c-'Z'<=0) cout<<'A'<<endl;
    else cout<<'a'<<endl;
}

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

int N;

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

Measured memory_bytes: 640
using System;
using System.CodeDom;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
class Simple {
    private string S;
    void Solve() {
        //input
        S = io.String;
        //cal
        var ans = "";
        foreach(var c in S) {
            switch(c) {
            case '0':
                ans += "0";
                break;                
            case '1':
                ans += "1";
                break;
                
            case 'B':
                if(ans.Length > 0) ans = ans.Substring(0, ans.Length - 1);
                break;
            }     
        }
        //ret
        Console.WriteLine(ans);
    }     
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Simple().Stream();
    void Stream() {
        Solve();
        io.writeFlush();
    }
}
class SimpleIO {
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[] {' '};
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
    public SimpleIO() {
        nextBuffer = new string[0];
        BufferCnt = 0;
        Console.SetOut(sw);
    }
    public string Next() {
        if(BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++];
        string st = Console.ReadLine();
        while(st == "") st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}


Measured memory_bytes: 13140
using System;
using System.Linq;

public class Progaram
{
  public static void Main()
  {
   	var values = Console.ReadLine().Split(' ').Select(s=>int.Parse(s)).ToArray();
    var bCount = Math.Ceiling(values[0] / (double)values[3]);
    var aCount = Math.Ceiling(values[2] / (double)values[1]);
    Console.WriteLine(aCount <= bCount ? "Yes" : "No");
  }
}

Measured memory_bytes: 28132
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x, y, a, b, c; cin >> x >> y >> a >> b >> c;
    vll p(a), q(b), r(c);
    for (ll i = 0; i < a; i++) cin >> p[i];
    for (ll i = 0; i < b; i++) cin >> q[i];
    for (ll i = 0; i < c; i++) cin >> r[i];

    sort(ALL(p)), sort(ALL(q)), sort(ALL(r));
    reverse(ALL(p)), reverse(ALL(q)), reverse(ALL(r));

    multiset<ll> ps, qs;
    for (ll i = 0; i < x; i++) ps.insert(p[i]);
    for (ll i = 0; i < y; i++) qs.insert(q[i]);

    for (ll i = 0; i < c; i++) {
        auto plast = ps.begin(), qlast = qs.begin();
        // cout << *plast << ' ' << *qlast << '\n';
        if (*plast > r[i] && *qlast > r[i]) break;
        else if (*plast < r[i] && *qlast < r[i]) {
            if (*plast < *qlast) {
                ps.erase(plast);
                ps.insert(r[i]);
            } else {
                qs.erase(qlast);
                qs.insert(r[i]);
            }
        } else if (*plast < r[i]) {
            ps.erase(plast);
            ps.insert(r[i]);
        } else if (*qlast < r[i]) {
            qs.erase(qlast);
            qs.insert(r[i]);
        }
    }

    ll ans = 0;
    for (ll ppp: ps) ans += ppp;
    for (ll qqq: qs) ans += qqq;
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A;
  cin >> A;
  if(A <= 25) {
    cout << "Christmas";
  }
  if(A <= 24) {
    cout << " Eve";
  }
  if(A <= 23) {
    cout << " Eve";
  }
  if(A <= 22) {
    cout << " Eve";
  }
}

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

vector<vector<int>> a(3, vector<int>(3));
map<int, bool> mp;

int main() {
	rep(i, 3)rep(j, 3) cin >> a[i][j];
	int n; cin >> n;
	rep(i, n) {
		int b; cin >> b;
		mp[b] = true;
	}
	bool elf = false;
	rep(i, 3)if (mp[a[i][0]] && mp[a[i][1]] && mp[a[i][2]])elf = true;
	rep(i, 3)if (mp[a[0][i]] && mp[a[1][i]] && mp[a[2][i]]) elf = true;
	if (mp[a[0][0]] && mp[a[1][1]] && mp[a[2][2]]) elf = true;
	if (mp[a[0][2]] && mp[a[1][1]] && mp[a[2][0]]) elf = true;
	cout << (elf ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
n,d = map(int,input().split())
co = []
for i in range(n):
    co.append(tuple(int(j) for j in input().split()))
flag = 0
for i in range(n):
    for j in range(i+1,n):
        sq = 0
        for k in range(d):
            sq = sq + (co[i][k]-co[j][k])**2
        sqrt = sq**(1/2)
        if float(int(sqrt)) == sqrt:
            flag = flag + 1

print(flag)

Measured memory_bytes: 3064
N = int(input())
ans = 0
min_v = 10 ** 4 + 1
for i in range(N):
    s = int(input())
    ans += s
    if s % 10 != 0 and min_v > s:
        min_v = s
if ans % 10 == 0:
    print(max(0, ans - min_v))
else:
    print(ans)


Measured memory_bytes: 2940
n, k = map(int, input().split())
lr = [list(map(int, input().split())) for _ in range(k)]
mod = 998244353

dp = [0] * n
dp[0] = 1

acc = 0

for i in range(1, n):
    for l, r in lr:
        if i - l >= 0:
            acc += dp[i - l]
            acc %= mod
        if i - r - 1 >= 0:
            acc -= dp[i - r - 1]
            acc %= mod
        dp[i] = acc

print(dp[-1])


Measured memory_bytes: 16764
#include <iostream>
#include <string>
#include <queue>
#include <utility>
//#include <>
using namespace std;
int N, A, B, C, ans = (1 << 30), L[10];

void solve(int now, int al, int bl, int cl, int mp){
    if(now == N){
        if(al * bl * cl == 0) return;
        ans = min(ans, mp + abs(al - A) + abs(bl - B) + abs(cl - C) - 30);
        return;
    }
    solve(now+1, al + L[now], bl, cl, mp + 10);
    solve(now+1, al, bl + L[now], cl, mp + 10);
    solve(now+1, al, bl, cl + L[now], mp + 10);
    solve(now+1, al, bl, cl, mp);
}

int main() {
    cin >> N >> A >> B >> C;
    for(int i=0; i<N; i++) cin >> L[i];
    solve(0,0,0,0,0);
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef pair<int,int> pii;

#define size(x) ((int) x.size())

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if (c >= a && c <= b)
        cout << "Yes";
    else
        cout << "No";
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
use std::collections::HashMap;
use std::num;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        a: i64,
        b: i64,
        c: i64,
        x: i64,
    }
    let mut ans = 0;
    for i in 0..a + 1 {
        for j in 0..b + 1 {
            let target = x - 500 * i - 100 * j;
            if target < 0 {
                break;
            }
            if target % 50 == 0 && target / 50 <= c {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main() {
    int n;
    cin>>n;
    string s;
    int ac=0,tle=0,re=0,wa=0;
    while(n--)
    {
        cin>>s;
        if(s[0]=='A')
        ac++;
        else if(s[0]=='T')tle++;
        else if(s[0]=='R')re++;
        else wa++;
    }
    cout<<"AC x "<<ac<<"\n";
    cout<<"WA x "<<wa<<"\n";
    cout<<"TLE x "<<tle<<"\n";
    cout<<"RE x "<<re<<"\n";
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstdint>
#include <cmath>
#include <numeric>
#include <functional>
#include <queue>
#include <stack>
#include <deque>
#include <utility>

using namespace std;

int main()
{
  int h,w,n;
  cin >> h >> w >> n;
  int s_r,s_c;
  cin >> s_r >> s_c;
  std::string s, t;

  cin >> s >> t;

  int l = s_c - 1;
  int r = s_c - 1;
  int u = s_r - 1;
  int d = s_r - 1;

  for(int i = 0;
      i < s.length();
      ++i)
    { 
      if(s[i] == 'L')
        {
          --l;
          if(l == -1)
            {
              cout << "NO" << endl;
              return 0;
            }
        }
      else if(s[i] == 'R')
        {
          ++r;
          if(r == w)
            {
              cout << "NO" << endl;
              return 0;
            }
        }
      else if(s[i] == 'U')
        {
          --u;
          if(u == -1)
            {
              cout << "NO" << endl;
              return 0;
            }
        }
      else
        {
          ++d;
          if(d == h)
            {
              cout << "NO" << endl;
              return 0;
            }
        }

      if(t[i] == 'L')
        {
          if(r != 0)
            {
              --r;
            }
        }
      else if(t[i] == 'R')
        {
          if(l != (w - 1))
            {
              ++l;
            }
        }
      else if(t[i] == 'U')
        {
          if(d != 0)
            {
              --d;
            }
        }
      else
        {
          if(u != (h - 1))
            {
              ++u;
            }
        }
    }

  cout << "YES" << endl;


  return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

template <typename T>
bool Setmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  in(int, n, l);
  int mini = numeric_limits<int>::max();
  int minit;
  int ans = 0;
  rep(i, n) {
    int t = l + i;
    if (Setmin(mini, abs(t))) minit = t;
    ans += t;
  }
  ans -= minit;
  out(ans);
}


Measured memory_bytes: 3620
import math
import itertools


def solve():
    n = read()
    result = think(n)
    write(result)


def read():
    return read_int(1)[0]


def read_int(n):
    return list(map(int, input().rstrip().split()[:n]))


def think(n):
    if n < 357:
        return 0
    digits = math.ceil(math.log10(n))
    if digits % 10 == 0:
        digits += 1

    count = 0
    dictionary = ['3', '5', '7']
    for d in range(3, digits + 1):
        for list_of_012 in itertools.product([0, 1, 2], repeat=d):
            buf = ''
            for elem in list_of_012:
                buf += str(dictionary[elem])
            if int(buf) <= n and buf.count('3') >= 1 and buf.count('5') >= 1 and buf.count('7') >= 1:
                # print(buf)
                count += 1
    return count


def write(result):
    print(result)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 42604
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func isInRange(n int) bool {
	return n >= 1 && n <= 9
}

func isTimesTables(n int) bool {
	for i := 1; i <= 9; i++ {
		if n%i == 0 && isInRange(n/i) {
			return true
		}
	}
	return false
}

func main() {
	n := nextInt()
	if isTimesTables(n) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<queue>
#include<math.h>
#include<complex>

using namespace std;


//ユークリッドの互除法　a,bは最大公約数を求めたい２つの数
long long int gcd(long long int a, long long int b) {
             long long int tmp;
             long long int r = 1;
             if (b > a) {
                           tmp = a;
                           a = b;
                           b = tmp;
             }
             r = a % b;
             while (r != 0) {
 
 
                           a = b;
                           b = r;
                           r = a % b;
 
             }
             return b;
}

const long long int mod=1000000007;
int main(){
	//cout << fixed << setprecision(10);
	long long int k,t,a[2000];
	string str,str2;
	cin>>k>>t;
	for(int i=0;i<t;i++){
		cin>>a[i];
	}
	sort(a,a+t);
	cout<<max(2*a[t-1]-k,1LL)-1<<endl;
}


Measured memory_bytes: 256
# include <stdio.h>
# include <bits/stdc++.h>
 
 
#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define For(i,x,y)  for (int i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (int i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
// ROAD to...                                                                                                                                                                                                                Red
 
using namespace std;
 
inline bool isvowel (char c) {
	c = tolower(c);
    if (c == 'a' || c == 'e' || c == 'i' || c == 'y' || c == 'o' || c == 'u') return 1;
    return 0;
}
 
const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;
 
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;
 
int main () {               
    cin >> n;
    for (int i = 1; i <= n; i ++) {
    	cin >> a[i];
    	if (a[i] & 1) cur ++;
    }
    if (cur & 1) cout << "NO";
    else cout << "YES";
    return Accepted;
}
 
// Coded By OB

Measured memory_bytes: 18688
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const double PI = acos(-1);
const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}

ll dp[5000];
int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    double d, t, s;
    cin >> d >> t >> s;
    Yes(d / s <= t);


}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
#define int long long
set<int>graph[200001];
int visited[200001];
int mx=0,cnt=0;
void dfs(int cur){
	visited[cur]=1;
	cnt++;
	for(auto &child:graph[cur]){
		if(!visited[child])dfs(child);
	}
}
signed main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		graph[x].insert(y);
		graph[y].insert(x);
	}
	for(int i=1;i<=n;i++){
		if(!visited[i]){
			cnt=0;
			dfs(i);
			mx=max(mx,cnt);
		}
	}
	cout<<mx;
}

Measured memory_bytes: 39492
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;


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

string S; cin >> S;
int N = S.size();

vector<bool> Sb(N, true); 
if (S[1] == 'R') Sb[0] = false;
if (S[N-2] == 'L') Sb[N-1] = false;
rep(i, 1, N-1) {
    if (S[i] == 'R' && S[i+1] == 'R') Sb[i] = false;
    else if (S[i] == 'L' && S[i-1] == 'L') Sb[i] = false;
}

VI Scnt(N, 0);
for (int i = 0; i < N;){
    if (Sb[i] == true) {++Scnt[i]; ++i;}
    else if (S[i] == 'R' && Sb[i] == false){
        int len = 0;
        while (i + len < N && S[i + len] == 'R' && Sb[i + len] == false) ++len;
        int sublen = len;
        while(sublen >= 1){
            if (sublen % 2 == 0) ++Scnt[i + len];
            else ++Scnt[i + len + 1];
            --sublen;
        }
        i += len;
    }
    else if (S[i] == 'L' && Sb[i] == false){
        int len = 0;
        while (i+ len < N && S[i + len] == 'L' && Sb[i + len] == false) ++len;
        int sublen = len;
        while(sublen >= 1){
            if (sublen % 2 == 0) ++Scnt[i - 1];
            else ++Scnt[i - 2];
            --sublen;
        }
        i += len;
    }
}
rep(i, 0, N) cout << Scnt[i] << ' ';
cout << "\n"; 

return 0;
}

// 境界，出力文字列 チェック



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

int main(){
	int a, b;
	cin >> a >> b;
	int sub = b-a;
	int x = 0;
	for (int  i = 1; i <= sub; i++){
		x += i;
	}

	cout << x-b << endl;
	return 0;
}


Measured memory_bytes: 256
/* Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define all(v) v.begin(), v.end()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  Long a, b;
  cin >> a >> b;
  Long ans = (a * (a - 1)) / 2;
  ans += (b * (b - 1)) / 2;
  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define LSOne(i) (i&(-i))
#define rep(i,a,b) for(int(i)=(a);(i)<(b);i++)
#define rrep(i,a,b) for(int(i)=(a);(i)>(b);i--)
#define BUG(x) {cout<<#x<<" = "<<x<<endl;}
#define left(x) (x<<1)
#define right(x) ((x<<1) +1)
#define middle(s,e)(s+(e-s)/2)
#define size_tree(n) 2*(int)pow(2,ceil(log2(n)))
#define CL(A,I) (memset(A,I,sizeof(A)))
#define endl '\n'
#define PHAS(_n) (pbits[(_n)>>5] & (1u << ((_n) & 0x1f)))
#define PSET(_n) (pbits[(_n)>>5] |= (1u << ((_n) & 0x1f)))
//unsigned int pbits[200000000/32+1];

static const int INF = 0x3f3f3f3f;
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const long double epsilon = 1e-15;
static const long double pi = acos((long double) -1);
using namespace std;
inline void init_io(){ios_base::sync_with_stdio(false);cin.tie(NULL);}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef long long ll;
const int MAX_N = 100001;

/*
struct data{
  string s;
  int p,i;
  data():s(""), p(0), i(0){};
  data(string s_, int p_, int i_) : s(s_),p(p_), i(i_){};
  bool operator < (data other) const {
	if(s==other.s)
		return p>other.p;
    return s < other.s;
  }
};
*/

int arr[3*MAX_N];

void rarr(int n){
        rep(i,0,n)
            cin>>arr[i];
}

int mod = 1000000007;

int A[2001][2001];
int B[2001][2001];
int C[2001][2001];
int D[2001][2001];

int main()
{
        init_io();
        int h,w;
        char c ;
        cin>>h>>w;
        rep(i,0,h)
            rep(j,0,w)
            {
                int x = 0;
                cin>>c;
                if(c=='.')
                    x=1;
                A[i][j]=B[i][j]=C[i][j]=D[i][j]=x;
            }
        rep(i,0,h)
            rep(j,1,w)
                if(A[i][j])
                    A[i][j]+=A[i][j-1];
        rep(i,0,h)
            for(int j=w-2;j>=0;j--)
                if(B[i][j])
                    B[i][j]+=B[i][j+1];

        rep(i,1,h)
            rep(j,0,w)
                if(C[i][j])
                    C[i][j]+=C[i-1][j];
        
        for(int i=h-2;i>=0;i--)
            rep(j,1,w)
                if(D[i][j])
                    D[i][j]+=D[i+1][j];

        int ans = 0;
        rep(i,0,h)
            rep(j,0,w)
                if(A[i][j])
                    ans=max(ans,1+((j>0)?A[i][j-1]:0)+((j<w-1)?B[i][j+1]:0)+((i>0)?C[i-1][j]:0)+((i<h-1)?D[i+1][j]:0));
        cout<<ans<<endl;
        return 0;
}

Measured memory_bytes: 63744
// https://atcoder.jp/contests/abc153/tasks/abc153_c

#include <bits/stdc++.h>
using namespace std;
int main() {
    #define int long long
    int N, K;
    cin >> N >> K;

    int a[N+1];
    int sum = 0;
    for(int i = 1; i <= N; i++) {
        int b;
        cin >> b;

        sum += b;
        a[i] = b;
    }

    sort(a+1, a+N+1, greater<int>());
    for(int i = 1; i <= min(N,K); i++) {
        sum -= a[i];
    }

    cout << sum << endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n;
		while(true){
			n=sc.nextInt();
			if(n==-1) break;
			System.out.println(f(n));
		}
	}
	static String f(int n){
		int four[]=new int[10];
		four[0]=1;
		String str="";
		for(int i=1;i<10;i++){
			four[i]=four[i-1]*4;
		}
		for(int i=9;0<=i;i--){
			if(four[i]<=n){
				str=str+Integer.toString(n/four[i]);
				n%=four[i];
			}
			else if(!str.equals("")){
				str=str+"0";
			}
		}
		if(str.equals("")){
			return "0";
		}
		else return str;
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll m = 1e9 + 7;

ll mpow(ll b, ll p) {
  ll res = 1;
  while (p) {
    if (p & 1) {
      res = (res * b) % m;
    }
    p >>= 1;
    b = (b * b) % m;
  }
  return res;
}

int main() {
  ll n;
  cin >> n;
  ll ans = mpow(10, n) + mpow(8, n) - 2 * mpow(9, n);
  ans = (ans % m + m) % m;
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 3604
N = int(input())
S = [input() for _ in range(N)]
ans = 0
ba = b = a = 0
for s in S:
    ans += s.count('AB')
    if s[0] + s[-1] == 'BA':
        ba += 1
    elif s[0] == 'B':
        b += 1
    elif s[-1] == 'A':
        a += 1
if ba == 0:
    ans += min([b, a])
elif b or a:
    ans += ba + min([b, a])
else:
    ans += ba + min([b, a]) - 1
print(ans)


Measured memory_bytes: 3700
w, h, n = map(int, input().split())
l, r = 0, w
d, u = 0, h
for _ in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        if l <= x:
            l = x
    elif a == 2:
        if r >= x:
            r = x
    elif a == 3:
        if d <= y:
            d = y
    elif a == 4:
        if u >= y:
            u = y
if l >= r or u <= d:
    print(0) 
else:
    print((r-l)*(u-d))

Measured memory_bytes: 38256
n=int(input())
X=[]
for i in range(n):
    x,l=map(int,input().split())
    X.append([x-l,l+x])

X.sort(key=lambda x:x[1])

a=X[0][0]-1
ans=0
for i in range(n):
    if X[i][0]<a:
        continue
    else:
        a=X[i][1]
        ans+=1
        
print(ans)

Measured memory_bytes: 21464
import sys
fastinput=sys.stdin.readline
N,K=map(int,fastinput().split())
data=[[int(j) for j in fastinput().split()] for k in range(N)]
ab=sorted(data,key=lambda x:x[0])
number=0
for a,b in ab:
    number+=b
    if number>=K:
        print(a)
        break

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

long long n, k, sum = 0;
vector<long long> a, v;

long long solve();
bool ch(long long x);

int main() {
  cin >> n >> k;
  a.resize(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 1;
  for(int i = 0; i < n; ++i) sum += a[i];
  for(long long i = 1; i * i <= sum; ++i)
    if(sum % i == 0) {
      if(ch(i)) ans = max(ans, i);
      if(ch(sum / i)) ans = max(ans, sum / i);
    }
  return ans;
}

bool ch(long long x) {
  v.assign(n + 1, 0);
  for(int i = 0; i < n; ++i) v[i + 1] = a[i] % x;
  sort(v.begin(), v.end());
  for(int i = 1; i <= n; ++i) v[i] += v[i - 1];
  for(int i = 0; i <= n; ++i) {
    long long now = v[n] - v[i];
    now = x * (n - i) - now;
    if(max(now, v[i]) <= k) return 1;
  }
  return 0;
}

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

using namespace std;

int main(){
	int i;
	char a[111], b[111], c[111];
	while(~scanf("%s %s %s", a, b, c)){
		char p = b[0];
		cout << 'A' << p << 'C' << endl;
	}
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8

row, col = map(int, input().split())
spreadsheet = []

for i in range(row):
    val = list(map(int, input().split()))
    val.append(sum(val))
    spreadsheet.append(val)

for r in spreadsheet:
    print(' '.join(map(str, r)))

last_row = []
for j in range(len(spreadsheet[0])):
    col_sum = 0
    for i in range(len(spreadsheet)):
        col_sum += spreadsheet[i][j]
    last_row.append(col_sum)

print(' '.join(map(str, last_row)))



Measured memory_bytes: 5700
#include <iostream>

using namespace std;

int main()
{
    int n,x,t;
    cin>>n>>x>>t;
    int sum;
    if(n%x==0)
    {
        sum = n/x;
    }
    else
    {
        sum = (n/x)+1;
    }
    int ans = sum*t;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3620
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500 * i + 100 * j + 50 * k == x:
                ans += 1

print(ans)


Measured memory_bytes: 3060
a, b, c = map(int, input().split())
if a > 100 or a < -100:
 exit()
elif -100 > b or 100 < b:
 exit()
elif -100 > c or 100 < c:
 exit()
if a <= c and c <= b:
 print("Yes")
else:
 print("No")

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

#define int ll
#define FOR(i,n,k) for(int i=n;i<k;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N = 1e5 + 5;

int dp[N];

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

int32_t main()
{
    IOS;
    int n,w,wt = 0;
    cin>>n>>w;
    FOR(i,1,n+1)
    {
        int weight,value;
        cin>>weight>>value;
        for(int weight_already = w - weight;weight_already >= 0;weight_already--)
        {
            max_self(dp[weight_already + weight], dp[weight_already] + value);
        }
    }
    int ans = INT_MIN;
    FOR(i,0,w+1) max_self(ans,dp[i]);
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define debug(var) std::cout << #var << " : " << var;
using ll = long long;
using ull = unsigned long long;
ll mod = 1e9 + 7;

int main(){


	int A, B, C; std::cin >> A >> B >> C;

	std::cout << ((A + B >= C) ? "Yes" : "No");

	return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, M, Q = (int(i) for i in input().split())
    T = [[int(i) for i in input().split()] for j in range(Q)]

    def dfs(A):
        cur = 0
        if len(A) == N:
            for a, b, c, d in T:
                if A[b-1] - A[a-1] == c:
                    cur += d
        elif len(A) == 0:
            for i in range(1, M+1):
                v = dfs(A + [i])
                cur = max(cur, v)
        else:
            for i in range(A[-1], M+1):
                v = dfs(A + [i])
                cur = max(cur, v)
        return cur

    print(dfs([]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 74816
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	var N int
	fmt.Scan(&N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	A := make([]int, N)
	for i := range A {
		sc.Scan()
		A[i], _ = strconv.Atoi(sc.Text())
	}

	m := make(map[int]int)
	for _, a := range A {
		m[a]++
	}
	var keys []int
	for k := range m {
		keys = append(keys, k)
	}
	sort.Ints(keys)

	MAX := 1000000

	flags := make([]bool, MAX+1)
	for i := 1; i <= MAX; i++ {
		flags[i] = true
	}

	count := 0
	for _, k := range keys {
		v, _ := m[k]
		if !flags[k] {
			continue
		}
		if v == 1 {
			count++
		}
		for i := 2 * k; i <= MAX; i += k {
			flags[i] = false
		}
	}
	fmt.Println(count)

}


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

int main() {
    string S;
    int Q;
    cin >> S >> Q;
    bool rev = false;
    string f = "";
    string b = "";
    rep(i, Q) {
        int q = 0;
        cin >> q;
        if (q == 1) {
            rev = !rev;
            continue;
        }
        int F;
        char C;
        cin >> F >> C;
        if (!rev) {
            if (F == 1)
                f = f + C;
            else
                b = b + C;
        } else {
            if (F == 1)
                b = b + C;
            else
                f = f + C;
        }
    }

    string ans = "";
    if (!rev) {
        reverse(all(f));
		ans = f;
        ans = ans + S;
        ans = ans + b;
    } else {
		reverse(all(S));
    	reverse(all(b));
		ans = b;
		ans = ans + S;
		ans = ans + f;
        
    }
    cout << ans << endl;
}

Measured memory_bytes: 1836
#include <stdio.h>

int main(void) {

    int N;

    scanf("%d", &N);

    if (!(1 <= N && N <= 10000)) {
        fprintf(stderr, "ERROR\n");
        return 1;
    }

    if (N%1000 == 0) printf("%d\n", N%1000);
    else printf("%d", 1000-(N%1000));

    return 0;
}

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

#define int long long

int M=1e9+7;

signed main() {
	int N,K;
	cin>>N>>K;
	vector<int> candies(N+1);
	for (int i=0;i<N;i++){
		cin>>candies[i];
	}
	vector<vector<int>> dp(N+1,vector<int>(K+1));
	for (int i=0;i<=N;i++) dp[i][0]=1;
	for (int i=1;i<=N;i++){
		vector<int> prefix_sum(K+1);
		prefix_sum[0]=dp[i-1][0];
		for (int j=1;j<=K;j++){
			prefix_sum[j]=(prefix_sum[j-1]%M+dp[i-1][j]%M)%M;
		}
		for (int j=1;j<=K;j++){
			if (j<=candies[i-1]) dp[i][j]=prefix_sum[j];
			else dp[i][j] = (M+prefix_sum[j]-prefix_sum[j-candies[i-1]-1])%M;
		}
	}
	cout<<dp[N][K];
    return 0; 
}


Measured memory_bytes: 83028
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;
  if (s == u)
    a--;
  else
    b--;
  cout << a << ' ' << b << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	int t = 1;
	//cin >> t;
	while(t--){
		string s , t;
		cin >> s >> t;
		int sz = s.size(), ans = 0;
		for(int i = 0; i < sz; ++i)
			if(s[i] != t[i])
				++ans;
		cout << ans << endl;

	}
	return 0;
}

Measured memory_bytes: 3880
from itertools import product

N = int(input())
A = list(map(int, input().split()))
ans = 0

for mask in product([-1, 0, 1], repeat=N):
    prd = 1
    for (a, d) in zip(A, mask):
        prd *= (a + d)
    if prd % 2 == 0:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;

int main(void) {
    int h,w;
    for (;;){
        cin >> h >> w;
        if (!h && !w) break;
        for (int i=0; i<h; i++) {
            cout << '#' << string(w-2,(!i || i==h-1)?'#':'.') << '#' << endl;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3120
#![allow(unused_macros, unused_imports, dead_code, non_snake_case)]

use std::io;

fn read_line() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}

macro_rules! from_line {
    ($($a:ident : $t:ty),+) => {
        $(let $a: $t;)+
        {
            let _line = read_line();
            let mut _it = _line.trim().split_whitespace();
            $($a = _it.next().unwrap().parse().unwrap();)+
            assert!(_it.next().is_none());
        }
    };
}

macro_rules! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; input_inner ! {iter , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let mut s = {use std :: io :: Read ; let mut s = String :: new () ; std :: io :: stdin () . read_to_string (& mut s ) . unwrap () ; s } ; let mut iter = s . split_whitespace () ; input_inner ! {iter , $ ($ r ) * } } ; }
macro_rules! input_inner {($ iter : expr ) => {} ; ($ iter : expr , ) => {} ; ($ iter : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ iter , $ t ) ; input_inner ! {$ iter $ ($ r ) * } } ; ($ iter : expr , mut $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let mut $ var = read_value ! ($ iter , $ t ) ; input_inner ! {$ iter $ ($ r ) * } } ; }
macro_rules! read_value {($ iter : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ iter , $ t ) ) ,* ) } ; ($ iter : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ iter , $ t ) ) . collect ::< Vec < _ >> () } ; ($ iter : expr , chars ) => {read_value ! ($ iter , String ) . chars () . collect ::< Vec < char >> () } ; ($ iter : expr , usize1 ) => {read_value ! ($ iter , usize ) - 1 } ; ($ iter : expr , $ t : ty ) => {$ iter . next () . unwrap () . parse ::<$ t > () . expect ("Parse error" ) } ; }

fn main() {
    loop {
        from_line!(n: i32);
        if n == 0 { break }
        let mut hi = 0;
        let mut lo = 1000;
        let mut s = 0;
        for _ in 0..n {
            from_line!(v: i32);
            s += v;
            if lo > v { lo = v };
            if hi < v { hi = v };
        }
        println!("{}", (s - lo - hi) / (n - 2))
    }
}



Measured memory_bytes: 5028
N=int(input())
l=""
mod=10**9+7
Sa=list(input())
Sb=list(input())
for i in range(N):
   if Sa[i]==Sb[i]:
      l+="X"
   else:
      l+="Y"
l=l.replace("YY","Y")
ans=6 if l[0]=="Y" else 3
for i in range(1,len(l)):
   if l[i]=="Y" and l[i-1]=="Y":
      ans*=3
   if l[i]=="X" and l[i-1]=="X":
      ans*=2
   if l[i]=="Y" and l[i-1]=="X":
      ans*=2
   ans=ans%mod
print(ans)

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

int main() {
  string s, t, u;
  int a, b;
  cin >> s>> t>> a>> b>> u;

  if (u==s)
  cout << a-1 << ' ' << b << endl;
  else
  cout << a << ' ' << b-1 << endl;
}

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

int main(){
  long long int a,b,c,k;
  cin >> a >> b >> c >> k;
  long long int ans;
  if(k%2!=0)
    ans=b-a;
  else
    ans=a-b;
  
  if(ans>1000000000000000000)
    cout << "Unfair" << endl;
  else
    cout << ans << endl;
}

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

int main()
{
    int N;
    cin >> N;
    map<string, int> G{};

    ll ans = 0;
    for (int i = 0; i < N; i++)
    {
        string item;
        cin >> item;
        if (G.count(item) == 0)
        {
            ans++;
            G[item] = 1;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 19148
#include <stdio.h>
#define N_ELEMENT 1000000
int main() {
  int s;
  scanf("%d", &s);
  int a[N_ELEMENT];
  a[0] = s;
  int i,j; /* index */

  for (i = 1;i < N_ELEMENT;++i) {
    if (a[i-1] % 2 == 1) {
      a[i] = 3*a[i-1] + 1;
    } else if (a[i-1] % 2 == 0) {
      a[i] = a[i-1] / 2;
    } else {
      printf("Error\n");
    }
  }

  int count[N_ELEMENT] = {0};
  for (i = 0;i < N_ELEMENT;++i) {
    int	temp = a[i] - 1;
    ++count[temp];
    for (j = 0;j < 100;++j) {
      if (count[j] == 2) {
        goto end;
      }
    }
  }
 end:
  printf("%d\n",i + 1);
  return 0;
}

Measured memory_bytes: 7936
#include<bits/stdc++.h>
using namespace std;
char s[15];
long long cof[15],n,datat[15],pow_10[10],cnt,cou=0;
void gen(long long lv)
{
	if(lv==n-1)
	{
		datat[n-1]=1;
		/*for(int i=0;i<n-1;i++)
		{
			printf("%lld ",data[i]);
		}
		printf("\n");*/
		cnt=0;
		for(int i=n-1;i>=0;i--)
		{
			if(datat[i]==1)
			{
				cnt=0;
			}else
			{
				++cnt;
			}
			cof[i]=cnt;
		}
		/*for(int i=0;i<n;i++)
		{
			printf("%lld ",cof[i]);
		}
		printf("\n");*/
		for(int i=0;i<n;i++)
		{
			cou+=(pow_10[cof[i]]*(s[i]-48));
		}
		return;
	}
	for(int i=0;i<=1;i++)
	{
		datat[lv]=i;
		gen(lv+1);
	}
}
int main()
{
	pow_10[0]=1;
	for(int i=1;i<=10;i++)
	{
		pow_10[i]=pow_10[i-1]*10;
	}
	scanf("%s",s);
	n=strlen(s);
	gen(0);
	printf("%lld\n",cou);
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int a[32]={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};
  int k;
  cin>>k;
  cout<<a[k-1]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

static const ll MAX = 100001;
ll dp[MAX] = {};
ll h[MAX] = {};

int main() {
   

    ll n, k;
    cin >> n >> k;
    for (ll i=1;i<=n;i++){
        cin >> h[i];
    }
    dp[1] = 0;
    dp[2] = abs(h[2] - h[1]);
    ll minv = mop;
    ll par;
    for (ll i=3;i<=n;i++){
        minv = mop;
        for (ll j=1;j<=k;j++){
            if(i-j <= 0){
                break;
            }else{
                par = dp[i-j] + abs(h[i] - h[i-j]);
                if(par < minv){
                    minv = par;
                }
            }
        }
        dp[i] = minv;
    }
    
    cout << dp[n] << endl;




}




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

using namespace std;

int main() {
    string s;
    int count = 700;
    cin >> s;
    
    if (s[0] == 'o') count+=100;
    if (s[1] == 'o') count+=100;
    if (s[2] == 'o') count+=100;
    
    cout << count << endl;
}

Measured memory_bytes: 3164
#include <stdio.h>

int main(int argc, char *argv[])
{
    int i, N, T, t, prev;
    long long x = 0;
    scanf("%d %d", &N, &T);

    scanf("%d", &prev);
    for ( i = 1; i < N; i++ ){
        scanf("%d", &t);
        x += (t-prev)>T?T:(t-prev);
        prev = t;
    }
    x += T;
    printf("%lld\n", x);
    return 0;
}

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

int N;
vll A;

int b_search(int i, ll a){
  int ub=i, lb=-1;
  while(ub-lb>1){
    int mid=(ub+lb)/2;
    if(a>=A[mid]) lb=mid;
    else ub=mid;
  }
  return lb;
}

int main(){
  cin>>N;
  for (int i=0;i<N;++i){
    ll a;cin>>a;A.push_back(a);
  }

  sort(A.begin(), A.end());
  int used[N];
  memset(used, 0, sizeof(used));

  int ans=0;

  for (int i=N-1;i>=1;--i){
    if (used[i]==1) continue;
  

  for (int t=1;t<40;++t){
    int j=b_search(i, (ll)pow(2, t)-A[i]);
    while(used[j]==1) j--;
    if(A[j]+A[i]==(ll)pow(2, t)){
      ans++;
      used[j]=1;
      break;
    }
  }
}

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2672
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s; i<n; ++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
 
typedef long long ll;
typedef pair<int, int> ii;
 
int main(){
 
  int n, a, b;
  cin >> n >> a >> b;
  string s;
  cin >> s;
 
  int ab = a + b, sum = 0, cnt = 0;
 
  rep(i, s.size()){
    if(s[i] == 'a'){
      if(sum < ab){
        cout << "Yes" <<endl;
        sum++;
      }
      else cout << "No" <<endl;
    }
    else if(s[i] == 'b'){
      if(sum < ab && cnt < b){
        cout << "Yes" <<endl;
        sum++;
        cnt++;
      }
      else cout << "No" <<endl;
    }
    else cout << "No" <<endl;
 
  }
 
  return 0;
}

Measured memory_bytes: 896
from xml.dom import minidom


n, k = map(int, input().split())

AB = [list(map(int, input().split())) for _ in range(n)]
AB.sort()

now = -1
idx = 0
while k > 0:
    if idx >= n:
        break
    a, b = AB[idx]
    k -= b
    now = a
    idx += 1
print(now)


Measured memory_bytes: 28112