akhauriyash/Code-Regression huggingface dataset:
//h17-1 フェーン現象
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<math.h>
#include<time.h>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<set>
#include<stack>
#include<queue>
#include<cstdlib>
#include<algorithm>
#include<random>
#include<cassert>
using namespace std;
#include<boost/multiprecision/cpp_int.hpp>
namespace boost_multiprecision = boost::multiprecision;
#define LL long long
#define CINT boost_multiprecision::cpp_int
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while(true)

int N,Q,S,T;//標高が1上がると温度がS下がる
int A[200001];
LL h[200000];
CINT ans = 0;

int main(){
    cin >> N >> Q >> S >> T;

    cin >> A[0];
    for(int i=1; i<N+1; i++){
        cin >> A[i];
        h[i-1] = A[i] - A[i-1];
        if(h[i-1] > 0) ans -= S*abs(h[i-1]);
        if(h[i-1] < 0) ans += T*abs(h[i-1]);
    }

    for(int i=0; i<Q; i++){
        int L,R,X;
        cin >> L >> R >> X;

    if(L>0){
        if(h[L-1] > 0) ans += S*abs(h[L-1]);
        if(h[L-1] < 0) ans -= T*abs(h[L-1]);
        h[L-1] += X;
        if(h[L-1] > 0) ans -= S*abs(h[L-1]);
        if(h[L-1] < 0) ans += T*abs(h[L-1]);
    }

    if(R<N){
        if(h[R] > 0) ans += S*abs(h[R]);
        if(h[R] < 0) ans -= T*abs(h[R]);
        h[R] -= X;
        if(h[R] > 0) ans -= S*abs(h[R]);
        if(h[R] < 0) ans += T*abs(h[R]);
    }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 5632
# coding: utf-8
import sys
input = sys.stdin.readline

N = int(input())
D, X = map(int, input().split())
lst_day = [day for day in range(1, D+1)]

eaten_choco = sum(len(lst_day[::int(input())]) for _ in range(N))
print(eaten_choco + X)

Measured memory_bytes: 3060
def solve trans,m,n
  prev = Array.new(n,1.0)
  (m-1).times do
    cur = Array.new(n,0)
    n.times do |i|
      n.times do |j|
        cur[i] = [cur[i], prev[j]*trans[j][i]].max
      end
    end
    cur,prev = prev,cur
  end
  prev.max
end

loop do
  n,m = gets.chomp.split.map{|i|i.to_i}
  break if n==0
  trans = []
  n.times do
    a = gets.chomp.split.map{|i|i.to_f}
    trans << a
  end
  puts "%.2f" % solve(trans,m,n)
end

Measured memory_bytes: 6180
#include<bits/stdc++.h>
using namespace std;
vector <int > sam({0,2,5,5,4,5,6,3,7,6});
vector <pair<int , int > > allowed;

string find_max(string &curr,string  &temp){
	int sz =(int) curr.size();
	int tsz= (int) temp.size();
	bool flg = false;
	if(tsz > sz){
		flg = true ;
	}
	else if(tsz == sz ){
		
		for(int i = 0 ; i < sz ; i++){
			int a = curr[i]-'0';
			int b = temp[i]-'0';
			
			if(a > b)
				break ;
			if( a < b){
				flg = true ;
				break ;
			}
		}
	}
	
	if(flg )
		return temp;
	return curr ;
}

int main(){
	
	/* 5
	 * 117
	 * 711
	 * */
	 
	 int n, m;
	 scanf("%d%d",&n,&m);
	 
	 for(int i = 0 ; i< m ; i++){
		int temp ;
		scanf("%d",&temp);
		allowed.emplace_back(temp,sam[temp]);
	}

	sort(allowed.begin(),allowed.end(),[](pair<int,int> x , pair<int,int> y){

		return x.first > y.first;
		 
	 });

	const int nax = 1e4+5;
	vector < string > dp(nax,"");
	for(auto x : allowed){
		char value = x.first + '0';
		int cost = x.second;
		for(int i = 1; i <= n ; i++){
			
			if(i-cost >=0 ){
				if(dp[i-cost]!="" || i-cost==0){
					string temp = dp[i-cost];
					temp += value ;
					if(temp.size()<dp[i].size())
						continue ;
					//~ sort(temp.begin(),temp.end(),greater<int>());
					
					dp[i] = find_max(dp[i],temp);
				}
			}
			
			
		}
		
		
	}
	
	cout << dp[n] << endl;
	
	return 0;
}


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

using namespace std;
int ans = 99997851;

int main()
{
    int n, m , x, val, cost;
    cin>>n>>m>>x;
    
    vector<int> adj[n];

    
    for(int i = 0; i < n ; i ++){
        for(int j =  0; j < m + 1; j++){
            cin>>val;
            adj[i].push_back(val);
        }
        
    }
    
    bool ok;
    
    for(int i = 0 ; i < pow(2,n); i++){
        int d[m+1] =  {0};
        cost = 0;
        for(int j = 0 ; j < n; j++){
            if(((i>>j)&1) == 1){
                
                cost += adj[j][0];

                for(int k = 1; k < m + 1; k++){
                    d[k] += adj[j][k];
                }
            }
        }
        
        ok = true;
        
        for(int l = 1; l < m + 1 ; l++){
            if(d[l] < x){
                ok = false;
                break;
            }
        }
        
        if(ok){
            ans = min(ans, cost);
        }
    }
    
    if(ans != 99997851){
        cout<<ans;
    }
    
    else{
        cout<<-1;
    }

    return 0;
}


Measured memory_bytes: 4100
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
const int inf = 1 << 30;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

ll X;

int main(){
	cin >> X;
	ll ans = (X / 500LL) * 1000LL;
	X %= 500;
	ans += (X / 5LL) * 5;
	cout << ans << endl;
	return 0;
}

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

int n, k;
string s;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> k >> s;
    vector<pair<int, int>> a;
    int len = 0;
    for (int i = 0; i < n; i++) {
        len++;
        if ((i < n - 1 && s[i] != s[i + 1]) || i == n - 1) {
            a.push_back({len, s[i] - '0'});
            len = 0;
        }
    }

    int ops = !a[0].second, ans = 0;
    for (int l = 0, r = 0, cur = a[0].first; l < (int)a.size(); l++) {
        r = max(l, r);
        if (l > 0) {
            cur -= a[l - 1].first;
            ops -= (!a[l - 1].second);
        }
        
        while (r < (int)a.size() - 1 && ops + !a[r + 1].second <= k) {
            r++;
            cur += a[r].first;
            ops += (!a[r].second);
        }

        ans = max(ans, cur);
    }

    cout << ans;
}


Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<int,pair<int,int>>m;
int main()
{
    int n;cin>>n;
    int a[n],ans=0;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(a[i]+a[j]>a[k]&&a[i]+a[k]>a[j]&&a[j]+a[k]>a[i]&&a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k]) ans++;
            }
        }
    }
    cout<<ans;
}



Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main()
{
int n,s=0;
bool ok=false;
cin>>n;
    while(n>0)
    {

        s=n%10;
        n/=10;
        if(s==7)
            ok=true;
    }
    if(ok)
        cout<<"Yes";
    else
        cout<<"No";


}




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

int main(){
    int N,A,B;
    cin>>N>>A>>B;
    int NUM=0;
    
    for (int n=1; n<=N; n++) {
        int sum=0;
        int num=n;
        for (int k=0; k<=4; k++) {
            sum=sum+num%10;
            num=num/10;
        }
        
        if (A<=sum&&sum<=B) {
            NUM=NUM+n;
        }
    }
    cout<<NUM;
    
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    constexpr auto K = 100001L;

    set<int64_t> primes;
    vector<int64_t> targets;
    vector<bool> is_prime(K, true);
    int64_t p = 2;
    for (p = 2L; p * p <= K; ++p) {
        if (is_prime[p]) {
            primes.insert(p);

            if (primes.count((p + 1) / 2)) {
                targets.push_back(p);
            }

            for (auto q = 2 * p; q < K; q += p) {
                is_prime[q] = false;
            }
        }
    }
    for (; p < K; ++p) {
        if (is_prime[p]) {
            primes.insert(p);

            if (primes.count((p + 1) / 2)) {
                targets.push_back(p);
            }
        }
    }

    int64_t q;
    cin >> q;
    for (auto _ : irange(0L, q)) {
        int64_t l, r;
        cin >> l >> r;

        cout << upper_bound(targets.begin(), targets.end(), r) -
                        lower_bound(targets.begin(), targets.end(), l)
             << endl;
    }
}

Measured memory_bytes: 1152
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        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! {
        n: u32,
        val: [u32; n],
    };

    println!("{}", proc(val, 0));
}

fn proc(val: Vec<u32>, count: u32) -> u32 {
    if val.iter().all(|v| v % 2 == 0) {
        return proc(val.into_iter().map(|v| v / 2).collect(), count + 1);
    }
    return count;
}


Measured memory_bytes: 2060
#include <iostream>
#include <vector>
#define llint long long
#define inf 10000000000

using namespace std;

struct edge{
	llint to, cost;
	edge(){}
	edge(llint a, llint b){
		to = a, cost = b;
	}
};

llint N, M, K;
vector<edge> G[2005];
vector<llint> vec;
llint link[2005], loop[2005];
bool used[2005];

llint dp[2005][2005][2][2];

void dfs(int v, int prev)
{
	used[v] = true;
	vec.push_back(v);
	for(int i = 0; i < G[v].size(); i++){
		if(prev == G[v][i].to) continue;
		if(used[G[v][i].to]){
			loop[v] = G[v][i].cost;
		}else{
			link[G[v][i].to] = G[v][i].cost;
		}
		if(!used[G[v][i].to]) dfs(G[v][i].to, v);
	}
}

int main(void)
{
	cin >> N >> M >> K;
	llint u, v, c;
	for(int i = 0; i < M; i++){
		cin >> u >> v >> c;
		if(c == 0) c = -inf;
		G[u].push_back(edge(v, c));
		G[v].push_back(edge(u, c));
	}
	
	for(int i = 1; i <= N; i++){
		if(!used[i] && G[i].size() == 1) dfs(i, -1);
	}
	for(int i = 1; i <= N; i++){
		if(!used[i]) dfs(i, -1);
	}
	
	for(int i = 0; i <= N; i++){
		for(int j = 0; j <= K; j++){
			for(int p = 0; p < 2; p++){
				for(int s = 0; s < 2; s++){
					dp[i][j][p][s] = -inf;
				}
			}
		}
	}
	dp[0][0][0][0] = 0;
	
	for(int i = 0; i < N; i++){
		int v = vec[i];
		for(int j = 0; j <= K; j++){
			for(int p = 0; p < 2; p++){
				for(int s = 0; s < 2; s++){
					if(link[v] == 0){
						dp[i+1][j][0][0] = max(dp[i+1][j][0][0], dp[i][j][p][s]);
						if(j < K) dp[i+1][j+1][1][1] = max(dp[i+1][j+1][1][1], dp[i][j][p][s]);
					}
					else{
						if(loop[v] == 0){
							dp[i+1][j][0][s] = max(dp[i+1][j][0][s], dp[i][j][p][s]);
							if(j < K) dp[i+1][j+1][1][s] = max(dp[i+1][j+1][1][s], dp[i][j][p][s] + p * link[v]);
						}
						else{
							dp[i+1][j][0][s] = max(dp[i+1][j][0][s], dp[i][j][p][s]);
							if(j < K) dp[i+1][j+1][1][s] = max(dp[i+1][j+1][1][s], dp[i][j][p][s] + p * link[v] + s * loop[v]);
						}
					}
				}
			}
		}
	}
	
	llint ans = -inf;
	for(int p = 0; p < 2; p++){
		for(int s = 0; s < 2; s++){
			ans = max(ans, dp[N][K][p][s]);
		}
	}
	
	if(ans <= -1e8) cout << "Impossible" << endl;
	else cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 128848
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int count(long long a) {
  int c = 0;
  while (a > 0) {
    a /= 10;
    c++;
  }
  return c;
}

int main() {
  long long n;
  cin >> n;
  int mini = 100;
  for (long long i = 1; i <= sqrt(n); i++) {
    if (n % i != 0) continue;
    //cout << i << endl;
    long long res = n / i;
    int res2 = max(count(i), count(res));
    if (res2 < mini) mini = res2;
  }
  cout << mini << endl;

  return 0;
}


Measured memory_bytes: 256
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
sum = 0
cnt = 0
for i in range(N):
    A = list(map(int,input().split()))
    sum = 0
    for j in range(M):
        sum += A[j] * B[j]
    if sum + C > 0:
        cnt += 1
print(cnt)

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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    int A, B;
    cin >> A >> B;
    int ans = 0;
    int cur = 1;
    while (cur < B) {
        ans++;
        cur += A - 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <map>
#include <cstdio>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  set<int> X_, Y_;
  vector< pair<int,int> > x_y(n);
  int x, y;
  for(int i = 0; i < n; ++i){
    cin >> x >> y;
    X_.insert(x);
    Y_.insert(y);
    x_y[i] = make_pair(x,y);
  }
  vector<int> X, Y;
  for(set<int>::iterator itr = X_.begin(); itr != X_.end(); ++itr)
    X.push_back(*itr);
  for(set<int>::iterator itr = Y_.begin(); itr != Y_.end(); ++itr)
    Y.push_back(*itr);

  map<int,int> M_x, M_y;
  for(int i = 0; i < X.size(); ++i) M_x[X[i]] = i;
  for(int i = 0; i < Y.size(); ++i) M_y[Y[i]] = i;
  int h = X.size(), w = Y.size();
  vector< vector<int> >  acum(h+2,vector<int>(w+2,0));
  for(int i = 0; i < n; ++i){
    int x = x_y[i].first, y = x_y[i].second;
    ++acum[M_x[x]+1][M_y[y]+1];
  }
  
  
  for(int i = 1; i <= h+1; ++i){
    //cout << acum[i][0] << " | ";
    /*
    for(int j = 1; j <= n; ++j){
      acum[i][j] += acum[i][j-1] + acum[i-1][j] - acum[i-1][j-1];
      cout << acum[i][j] << " | ";
    }
    */
    for(int j = 1; j <= w+1; ++j){
      acum[i][j] += acum[i][j-1];
    }
    for(int j = 1; j <= w+1; ++j){
      acum[i][j] += acum[i-1][j];
      //cout << acum[i][j] << " | ";      
    }
    //cout << endl;
  }
  int x_1, x_2, y_1, y_2;
  for(int i = 0; i < m; ++i){
    cin >> x_1 >> y_1 >> x_2 >> y_2;
    //--x_2;--y_2;
    int x_1_ = lower_bound(X.begin(),X.end(),x_1)-X.begin(),
      y_1_ = lower_bound(Y.begin(),Y.end(),y_1)-Y.begin(),
      x_2_ = upper_bound(X.begin(),X.end(),x_2)-X.begin(),
      y_2_ = upper_bound(Y.begin(),Y.end(),y_2)-Y.begin();
    //++x_2_;++y_2_;
    cout << acum[x_2_][y_2_] - acum[x_2_][y_1_] - acum[x_1_][y_2_] + acum[x_1_][y_1_] << endl;
  }
  return 0;
}



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

using namespace std;

const int N_MAX = 200002;

int n;

int a[N_MAX];

pair <int, int> vn[N_MAX];

vector <int> edges[N_MAX];

struct Change
{
    int time;
    int pos;
    int val;
};

stack <Change> st;

int BIT[N_MAX];

int currentTime;

void update (int pos, int val)
{
    currentTime++;
    for(int i = pos; i <= n; i += i & -i)
    {
        st.push(Change{currentTime, i, BIT[i]});
        BIT[i] = max(BIT[i], val);
    }
}

void undo ()
{
    currentTime--;
    while(!st.empty() && st.top().time > currentTime)
    {
        BIT[st.top().pos] = st.top().val;
        st.pop();
    }
}

int query (int pos)
{
    int ans = 0;
    for(int i = pos; i >= 1; i -= i & -i)
        ans = max(ans, BIT[i]);
    return ans;
}

int dp[N_MAX];
int ans[N_MAX];

void dfs (int u, int parent = -1)
{
    dp[u] = query(a[u] - 1) + 1;
    ans[u] = dp[u];
    if(parent != -1)
        ans[u] = max(ans[u], ans[parent]);
    update(a[u], dp[u]);
    for(int v : edges[u])
        if(v != parent)
            dfs(v, u);
    undo();
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    for(int i = 1; i < n; i++)
    {
        int u, v;
        cin >> u >> v;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    for(int i = 1; i <= n; i++)
        vn[i] = make_pair(a[i], i);
    sort(vn + 1, vn + n + 1);
    int nval = 1;
    for(int i = 1; i <= n; i++)
    {
        if(i > 1 && vn[i].first > vn[i - 1].first)
            nval++;
        a[vn[i].second] = nval;
    }
    dfs(1);
    for(int i = 1; i <= n; i++)
        cout << ans[i] << "\n";
    return 0;
}


Measured memory_bytes: 55584
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>()>
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
vecll dis;
vec col;
vector<bool> done;
vector<queue<pll>> v;
void func(ll k,ll d){
    dis[k]=d;
    done[k]=true;
    while(!v[k].empty()){
        ll p=v[k].front().first,di=v[k].front().second;
        v[k].pop();
        if(done[p])continue;
        func(p,di+d);
    }
    return;
}
int main(){
    int n=in();
    dis.resize(n);
    dis[0]=0;
    col.resize(n);
    col[0]=0;
    v.resize(n);
    done.resize(n,false);
    rep(i,n-1){
        int x=in()-1,y=in()-1,d=in();
        v[x].push(mp(y,d));
        v[y].push(mp(x,d));
    }
    func(0,0);
    rep(i,n){
        col[i]=dis[i]%2==0?0:1;
        cout<<col[i]<<endl;
    }
}

Measured memory_bytes: 68864
N,M =map(int,input().split())
A_list = list(map(int,input().split()))
A_sum = sum(A_list)
cnt = 0
for i in range(N):
  if A_list[i] >= A_sum/(4*M):
    cnt += 1
if cnt >= M:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#!/usr/bin/env python3

import itertools


def judge(n, m, fig_a, fig_b):
    for dr, dc in itertools.product(range(n - m + 1), repeat=2):
        g = itertools.product(range(m), repeat=2)
        if all(fig_a[r0 + dr][c0 + dc] == fig_b[r0][c0] for r0, c0 in g):
            return True
    return False


def main():
    n, m = (int(x) for x in input().split())
    fig_a = [[c == "#" for c in input()] for _ in range(n)]
    fig_b = [[c == "#" for c in input()] for _ in range(m)]
    print("Yes" if judge(n, m, fig_a, fig_b) else "No")


if __name__ == '__main__':
    main()


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

int main() {
  int N,A,B;
  cin >> N;
  cin >> A >> B;
  int answer = 0;
  for(int i = 1;i <= N;i++) {
    int C = i;
    int count = 0;
    for(int j = 0;j < 5;j++) {
      count = count + C % 10;
      C = C / 10;
    }
    if(count >= A && count <= B) {
      answer = answer + i;
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s, t string
	fmt.Scan(&s, &t)
	var a, b int
	fmt.Scan(&a, &b)
	var u string
	fmt.Scan(&u)

	data := map[string]int{s: a, t: b}
	data[u]--

	fmt.Printf("%d %d\n", data[s], data[t])
}


Measured memory_bytes: 1832
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int n = sc.nextInt();
			if(n == 0) {
				break;
			}
			int max = 0;
			int min = 1000;
			int ten = 0;
			for(int i=0; i<n; i++) {
				int s = sc.nextInt();
				ten += s;
				if(s > max) {
					max = s;
				}
				if(s < min) {
					min = s;
				}
			}
			ten = (ten - max - min) / (n - 2);
			System.out.println(ten);
		}
		sc.close();
	}
}

Measured memory_bytes: 20920
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7

N, M = MAP()

A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

if A == B:
	print("Yes")
	exit()

flg = 1
for i in range(N-M):
	for j in range(N-M):
		for k in range(M):
			if A[i+k][j:j+M] != B[k]:
				break
		else:
			print("Yes")
			exit()
else:
	print("No")


Measured memory_bytes: 60524
N, W = map(int, input().split())

weight = []
value = []
for _ in range(N):
    v, w = map(int, input().split())
    weight.append(w)
    value.append(v)

DP = [[0 for _ in range(W + 1)] for _ in range(N + 1)]

for i in range(N):
    for w in range(W + 1):
        if w >= weight[i]:
            DP[i + 1][w] = max(DP[i][w - weight[i]] + value[i], DP[i][w])
        else:
            DP[i + 1][w] = DP[i][w]

print(DP[N][W])


Measured memory_bytes: 42296
matrix = [[int(i) for i in input().split()] for i in range(3)]

A = [-1, -1, -1]
B = [-1, -1, -1]

A[0] = 0

B[0] = matrix[0][0] - A[0]
B[1] = matrix[0][1] - A[0]
B[2] = matrix[0][2] - A[0]
A[1] = matrix[1][0] - B[0]
A[2] = matrix[2][0] - B[0]

i = 0
j = 0
flag = 0

for i in range(3):
    for j in range(3):
        if(matrix[i][j] != A[i] + B[j]):
            flag = 1

if(flag == 0):
    print("Yes")
elif(flag == 1):
    print("No")

Measured memory_bytes: 3188
main = do line <- getLine
          putStrLn $ cir line

cir :: String -> String
cir args = let xs = map read $ words args :: [Int]
               w = xs!!0
               h = xs!!1
               x = xs!!2
               y = xs!!3
               r = xs!!4
               condX = r <= x && x <= (w-r)
               condY = r <= y && y <= (h-r)
               cond = condX && condY
           in  if cond then "Yes" else "No"

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

class Main{
    public static void main(String args[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final String egara ="4";
        final String number = "13";
        int[][] num = new int[Integer.parseInt(egara)][Integer.parseInt(number)];
        String[] tp = {"S","H","C","D"};
        int n = Integer.parseInt(br.readLine());
        String s;
        int count = 0;
        while((s=br.readLine())!=null || count!=n){
            count++;
            String[] str = s.split(" ");
            int x = Integer.parseInt(str[1]);
            /*
            switch(str[0]){
                case "S": num[0][x-1] = x; break;
                case "H": num[1][x-1] = x; break;
                case "C": num[2][x-1] = x; break;
                case "D": num[3][x-1] = x; break;
            }
            */
            if("S".equals(str[0])){
                num[0][x-1] = x;
            }else if("H".equals(str[0])){
                num[1][x-1] = x;
            }else if("C".equals(str[0])){
                num[2][x-1] = x;
            }else if("D".equals(str[0])){
                num[3][x-1] = x;
            }
        }
        for (int i=0;i<Integer.parseInt(egara);i++){
            for (int j=0;j<Integer.parseInt(number);j++){
                if(num[i][j]==0) {
                    System.out.println(tp[i] +" "+ (j+1));
                }
            }
        }
    }
}

Measured memory_bytes: 17004
using System;
using System.Collections.Generic;
using System.Linq;

class C
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var r = new int[n].Select(_ => Read()).ToArray();
		var b = new int[n].Select(_ => Read()).ToArray();

		int sv = 2 * n, ev = sv + 1;
		var dag = new List<long[]>();
		dag.AddRange(Enumerable.Range(0, n).Select(i => new[] { sv, i, 1L }));
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				if (r[i][0] < b[j][0] && r[i][1] < b[j][1])
					dag.Add(new[] { i, n + j, 1L });
		dag.AddRange(Enumerable.Range(n, n).Select(j => new[] { j, ev, 1L }));

		Console.WriteLine(MaxFlow(ev, sv, ev, dag.ToArray()));
	}

	static long MaxFlow(int n, int sv, int ev, long[][] dag)
	{
		var map = Array.ConvertAll(new int[n + 1], _ => new List<long[]>());
		foreach (var e in dag)
		{
			map[e[0]].Add(new[] { e[1], e[2], map[e[1]].Count });
			map[e[1]].Add(new[] { e[0], 0, map[e[0]].Count - 1 });
		}

		long Bfs()
		{
			var from = new long[n + 1][];
			var u = new bool[n + 1];
			var minFlow = Enumerable.Repeat(long.MaxValue, n + 1).ToArray();
			var q = new Queue<long>();
			q.Enqueue(sv);

			while (q.TryDequeue(out var v))
			{
				if (v == ev) break;
				foreach (var e in map[v])
				{
					if (u[e[0]] || e[1] == 0) continue;
					from[e[0]] = e;
					u[e[0]] = true;
					minFlow[e[0]] = Math.Min(minFlow[v], e[1]);
					q.Enqueue(e[0]);
				}
			}

			if (from[ev] == null) return 0;
			long tv = ev;
			while (true)
			{
				from[tv][1] -= minFlow[ev];
				var rev = map[from[tv][0]][(int)from[tv][2]];
				rev[1] += minFlow[ev];
				if ((tv = rev[0]) == sv) break;
			}
			return minFlow[ev];
		}

		long M = 0, t;
		while ((t = Bfs()) > 0) M += t;
		return M;
	}
}


Measured memory_bytes: 29444
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#include <cmath>
#define WMAX 10000
#define HMAX 10000
#define NMAX 2002

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

struct edge{
  long long to,cost;
};

long long A[NMAX],B = 0,C,N,Z,W,H,ans,dp[HMAX][WMAX];
string S;
static const long long dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){
	if(N == 1){
		ans = max(A[0]-W,W-A[0]);
	}else{
		ans = max(max(A[N-1]-W,W-A[N-1]),max(A[N-2]-A[N-1],A[N-1]-A[N-2]));
	}
}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	cin >> N >> Z >> W;
	for (long long i = 0; i < N; ++i)
	{
		cin >> A[i];
	}
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int a,b;
    string s;
    cin >> a >> b >> s;
    rep(i, a){
        if (s[i] < 48 || s[i] > 57) {
            No;
            return 0;
        }
    }
    if(s[a] != 45){
        No;
        return 0;
    }
    nfor(i, a + 1, b + a + 1){
        if (s[i] < 48 || s[i] > 57) {
            No;
            return 0;
        }
    }
    Yes;
    return 0;
}


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

ll powmod(ll x,ll y){
  ll res=1;
  rep(i,y){
    res=res*x%mod;
  }
  return res%mod;
}

int main(){
  ll n;
  cin>>n;
  ll ans=powmod(10,n)-powmod(9,n)-powmod(9,n)+powmod(8,n);
  ans%=mod;
  ans=(ans+mod)%mod;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3620
n = int(input())
dic={"AC":0, "TLE":0, "WA":0, "RE":0}
for i in range(n):
  s = input()
  dic[s]+=1
  
print("AC x " + str(dic["AC"]))
print("WA x " + str(dic["WA"]))
print("TLE x " + str(dic["TLE"]))
print("RE x " + str(dic["RE"]))


Measured memory_bytes: 9196
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;


void C_149()
{
  int X;
  cin >> X;

  while (1)
  {
    int count = 0;
    for (int i = 1; i*i <= X; ++i)
    {
      if (X%i == 0)
      {
        if (i*i != X) count += 2;
        else ++count;
      }
    }

    if (count == 2)
    {
      cout << X << endl;
      return;
    }
    ++X;
    
  }
}

int main()
{
  //C_140();
  //C_141();
  //C_142();
  //C_143();
  //C_144();
  //C_145();
  //C_146();
  //C_147();
  //C_148();
  C_149();
  return 0;
}


Measured memory_bytes: 256
#D
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())

# r=r点 s=s点 p=p点
ans = 0
for i in range(n):
    if t[i] == "r":
        if i >= k and t[i - k] == "r":
            t[i] = 'm'#iの手以外の手
        else:
            ans += p
    if t[i] == "s":
        if i >= k and t[i - k] == "s":
            t[i] = 'm'
        else:
            ans += r
    if t[i] == "p":
        if i >= k and t[i - k] == "p":
            t[i] = 'm'
        else:
            ans += s
print(ans)


Measured memory_bytes: 4084
def cmb(n, r, p):
  if (r < 0) or (n < r):
    return 0
  r = min(r, n - r)
  return fact[n] * factinv[r] * factinv[n-r] % P

N, K = map(int, input().split())
P = 10**9 + 7
r = N - K
fact = [1, 1]  
factinv = [1, 1] 
inv = [0, 1] 
 
for i in range(2, N + 1):
  fact.append((fact[-1] * i) % P)
  inv.append((-inv[P % i] * (P // i)) % P)
  factinv.append((factinv[-1] * inv[-1]) % P)

for i in range(1,K+1):
  print(cmb(r+1, i, P)*cmb(K-1, i-1, P) % P)

Measured memory_bytes: 74604
#include<cstdio>

int main(){
  int h,w;
  while(1){
    scanf("%d %d",&h,&w);
    if(h == 0 && w == 0) break;
    for(int i = 1; i <= h;i++){
      for(int u = 1; u <= w;u++){
	if(i % 2 == 1){
	  if(u % 2 == 1){
	    printf("#");
	  }  else {
	    printf(".");
	  }
	  }else{
	    if(u % 2 == 0){
	    printf("#");
	  }else{
	      printf(".");
	    }
	}
      }
      printf("\n");
    }
    printf("\n");
  }
}

Measured memory_bytes: 1000
import sys
import re


cnt = 1
input_arr = []
for l in sys.stdin:
  input_arr.append(l.split("\n")[0])
  if len(input_arr) == cnt:
      break
S = input_arr[0]
if len(re.sub(r'A[a-z]+C[a-z]+', '', S)) == 0:
    print("AC")
else:
    print("WA")

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

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++) cin >> L[i];
  
  sort(L.begin(),L.end());
  
  int count = 0;
  for (int i = 0; i < N-2; i++) {
    for (int j = i+1; j < N-1; j++) {
      if (L[j+1] >= L[i] + L[j]) count += 0;
      else if (L[N-1] < L[i] + L[j]) count += N-1-j;
      else {
        int k = lower_bound(L.begin(), L.end(), L[i] + L[j]) - L.begin();        
        count += max(k-(j+1),0);
      }
    }
  }
  
  cout << count << endl;      
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-8;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 1e2+10;
const int MAXM = (int) 1e5+10;

///--------------------START-------------------------
int N;
vector<pair<int,int> > edges;

void work(){
    scanf("%d",&N);
    int S;
    if(N&1) S=N;
    else S=N+1;
    for(int i=1;i<=N;i++){
        for(int j=i+1;j<=N;j++){
            if(i+j!=S) edges.push_back(make_pair(i,j));
        }
    }
    int siz=edges.size();
    printf("%d\n",siz);
    for(int i=0;i<siz;i++){
        printf("%d %d\n",edges[i].first,edges[i].second);
    }
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define f(i,x,n) for(int i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
const int MOD = 1e9 + 7, N = 5e5 + 10;
const int LINF = LLONG_MAX;

int32_t main() {
    int n;
    cin >> n;
    vector<int> v(n);
    f(i,0,n){
        cin >> v[i];
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            for(int k = j+1; k < n; k++){
                if(v[i] != v[j] && v[j] != v[k] && v[i] != v[k]){
                    vector<int> vv = {v[i], v[j], v[k]};
                    sort(vv.begin(), vv.end());
                    if(vv[0] + vv[1] > vv[2])
                        ans++;
                }
            }
        }
    }
    cout << ans << "\n";
}
 

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int64_t const inf = 1LL<<51;

int main() {
  int N, K; cin >> N >> K;
  vector<int> vs(N);
  rep(i, N) {
    cin >> vs[i];
  }
  int64_t ans = inf;
  rep(i, N - K + 1) {
    pair<int, int> range;
    auto dist = abs(vs[i]);
    minimize(range.first, vs[i]);
    maximize(range.second, vs[i]);
    if (range.second < vs[i + K - 1]) {
//      maximize(range.second, vs[i + K - 1]);
      dist += abs(vs[i + K - 1] - vs[i]);
      minimize(ans, abs(vs[i + K - 1]) + abs(vs[i] - vs[i + K - 1]));
    }
//    cout << range << "\n";
    minimize(ans, dist);
  }
  cout << ans << "\n";
}


Measured memory_bytes: 640
#include <cstdio>
#define LL long long
using namespace std;

const double EPS=1e-3;

int main(){
	//freopen("in.txt","r",stdin);
	int n,m; scanf("%d%d",&n,&m);
	
	double now=1.0,psb=1.0;
	for (int i=1;i<=m;i++) psb/=2.0;
	psb=1.0-psb;

	double totTime=1900.0*m+100.0*(n-m);
	double ans=0;
	while(totTime*now>EPS){
		ans+=totTime*now;
		now*=psb;
	}
	printf("%lld\n",(LL)(ans+0.5));
	
	return 0;
}

Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    seika s;
    cin >> s;
    akari<int> cnt(26);
    for (char c : s)
    {
        cnt[c - 'a'] ^= 1;
    }
    cout << (!accumulate(cnt.begin(), cnt.end(), 0) ? "Yes" : "No") << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
import sys
from collections import Counter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def main():
    N, P = map(int, readline().split())

    primes = Counter(prime_factorize(P))

    ans = 1
    for k, v in primes.items():
        ans *= k ** (v // N)

    print(ans)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 65880
def f(x,y):
    A=0
    for i in range(len(x)):
        A+=(x[i]-y[i])*(x[i]-y[i])
    return A

M=20
N,D=map(int,input().split())

X=[]
for _ in range(N):
    X.append(tuple(map(int,input().split())))

S=set()
k=0
L=4*M*M*D
while k*k<=L:
    S.add(k*k)
    k+=1
    
K=0
for i in range(N):
    for j in range(i+1,N):
        K+=(f(X[i],X[j]) in S)
print(K)


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

int main()
{
    string n;
    int k;
    cin >> n >> k;
    bool arr[10]= {};
    for(int i=0; i<k; i++)
    {
        int x;
        cin >> x;
        arr[x]=true;
    }
    vector<int>v;
    for(int i=0; i<10; i++)
    {
        if(!arr[i])
            v.push_back(i);
    }
    int val=-1;
    string ans="";
//    for(int i=0; i<n.size(); i++)
//    {
//        int cur=n[i]-'0';
//        int idx=upper_bound(v.begin(),v.end(),cur)-v.begin();
//        int tmp=v[idx];
//        if(idx!=v.size())
//        {
//            val=v[idx];
//            break;
//        }
//    }
    int first_digit_dont_like=-1;
    int idx=-1;
    for(int i=0;i<n.size();i++)
    {
        if(arr[n[i]-'0'])
        {
            first_digit_dont_like=n[i]-'0';
            idx=i;
            break;
        }

    }
    if(first_digit_dont_like==-1)
        return cout<<n<<endl,0;

    int cur=n[idx]-'0';
    int index=upper_bound(v.begin(),v.end(),cur)-v.begin();
    if(index==v.size())
    {
        for(int i=0;i<v.size();i++)
        {
            if(v[i]!=0)
            {
                cout << v[i];
                break;
            }
        }
        for(int i=0;i<n.size();i++)
            cout <<v[0];
    }
    else
    {
        for(int i=0;i<idx;i++)
            cout<<n[i];
        cout<<v[index];
        for(int i=idx+1;i<n.size();i++)
            cout << v[0];
    }




    return 0;
}


Measured memory_bytes: 256
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
int n,a[K];
bool f;
map<int,bool> mp;
int main(){
	cin>>n;
	f=true;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(!mp[a[i]])
			mp[a[i]]=true;
		else
			f=false;
	}
	if(f)
		cout<<"YES";
	else
		cout<<"NO";
	return 0;
}

Measured memory_bytes: 10368
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;
/* c++11
#include <tuple>
using std::tuple; 
using std::make_tuple;
using std::get; // tuple std::get<NUM>(t); (0 <= NUM <= 2)
 */

typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, pair<int, int> > PIII;

int main(void) {
    int a;
    int b;
    int c;
    cin >> a >> b >> c;

    int time[60] = {0};
    bool notchange = false;
    int posi = 0;

    while (!notchange) {
        notchange = true;
        while (1) {
            for (int i = posi; i< posi + a; i++) {
                if (time[i] == 0) {
                    time[i] = 1;
                    notchange = false; 
                }
            }
            posi += (a + b);
            if (posi >= 60) {
                posi = posi % 60;
                break;
            }
        }
    }
    /*
    for (int i= 0; i < 60; i++) {
        cout << time[i];
        if (i % 10 == 9) {
            cout << endl;   
        }
    }
    */
    if (time[c - 1] == 0) {
        cout << -1 << endl; 
        return 0;
    }
    int plus = 0;
    int c_temp = c;
    while (1) {
        if (c_temp <= 0) {
            c_temp += 60;    
            plus++;
        }
        if (c_temp - a <= 0) {
            cout << c + plus * 60 << endl; 
            break;
        } 
        c_temp -= (a + b);
    }
    return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int s,w;
    cin>>s>>w;
    if(w>=s)
    {
        cout<<"unsafe";
    }
    else
    {
    
        cout<<"safe";
    }
    
    
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fi first
#define sec second
#define pr priority_queue
#define ump  unordered_map
#define prg priority_queue<ll, vec<ll> ,greater<ll> >
#define pb  push_back;
//parent finding
ll find(vector<ll> &v, ll n)
{
  if (v[n] == n)
    return n;
  return v[n] = find(v, v[n]);
}
bool is(ll x, ll y, ll n, ll m)
{
  if (x >= 0 && x < n && y >= 0 && y < m)
    return true;
  return false;
}
ll dx[4] = {1, -1, 0, 0};
ll dy[4] = {0, 0, 1, -1};
void bfs(vector<vector<char> > &vec, ll st1, ll st2, vector<vector<ll> > &dist)
{
  ll n = vec.size(), m = vec[0].size();
  pair<ll, ll> p;
  p.fi = st1; p.sec = st2;
  dist[st1][st2] = 0;
  deque<pair<ll, ll> > dq;
  dq.push_back(p);
  while (!dq.empty())
  {
    pair<ll, ll> p1;
    p1.fi = dq.front().fi; p1.sec = dq.front().sec;
    dq.pop_front();
    for (ll i = 0; i < 4; i++)
    {
      ll x = p1.fi + dx[i], y = p1.sec + dy[i];
      if (is(x, y, n, m) && vec[x][y] != '#')
      {
        if (dist[x][y] > dist[p1.fi][p1.sec])
        {
          dist[x][y] = dist[p1.fi][p1.sec];
          dq.push_front({x, y});
        }
      }
    }
    for (ll i = p1.fi - 2; i <= p1.fi + 2; i++)
    {
      for (ll j = p1.sec - 2; j <= p1.sec + 2; j++)
      {
        if (is(i, j, n, m) && vec[i][j] != '#')
        {
          if (dist[i][j] > dist[p1.fi][p1.sec] + 1)
          {
            dist[i][j] = dist[p1.fi][p1.sec] + 1;
            dq.push_back({i, j});
          }
        }
      }
    }
  }
  return ;
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n, m, k; cin >> n >> m >> k;
  map<ll, ll> mp1, mp2;
  set<pair<ll, ll> > st;
  for (ll i = 0; i < k; i++)
  {
    ll x, y; cin >> x >> y;
    st.insert({x, y});
    mp1[x]++;
    mp2[y]++;
  }
  ll m1 = -1, m2 = -1;
  vector<ll> c1, c2;
  for (auto x : mp1)
    m1 = max(m1, x.sec);
  for (auto x : mp2)
    m2 = max(m2, x.sec);
  for (auto x : mp1)
    if (x.sec == m1)
      c1.push_back(x.fi);
  for (auto x : mp2)
    if (x.sec == m2)
      c2.push_back(x.fi);
  ll sz1 = c1.size(), sz2 = c2.size();
  ll ans = m1 + m2 - 1;
  for (ll i = 0; i < sz1; i++)
  {
    ll f = 0;
    for (ll j = 0; j < sz2; j++)
    {
      if (st.find({c1[i], c2[j]}) == st.end())
      {
        ans++;
        f = 1;
        break;
      }
    }
    if (f) break;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 67824
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N;cin>>N;
  vector<string>S(N);
  vector<long>T(N);
  for(int i=0;i<N;i++)cin>>S[i]>>T[i];
  string X;cin>>X;
  bool a=false;long ans=0;
  for(int i=0;i<N;i++){
    if(a)ans+=T[i];
    if(S[i]==X)a=true;
  }
  cout<<ans;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>

using namespace std;

int n,ma=-1,s;
int a[11];

int main()
{
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        ma=max(ma,a[i]);
        s+=a[i];
    }
    s-=ma;
    if(ma<s)
        cout<<"Yes";
    else
        cout<<"No";

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main{
public static void main(String[] args) throws IOException{
	//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  	//int n = Integer.parseInt(br.readLine());
  Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  	int[] h = new int[n];
  	//String[] s = br.readLine().split(" ");
  	for(int i=0;i<n;i++) h[i] = sc.nextInt();
     // h[i] = Integer.parseInt(s[i]);
      int ans = solve(n,h);
      System.out.println(ans);
    }
  
  public static int solve(int n,int h[]){
    int[] dp = new int[n];
  	dp[1] = Math.abs(h[1]-h[0]);
  	for(int i=2;i<n;i++)
      dp[i] = Math.min(Math.abs(h[i]-h[i-1])+dp[i-1],Math.abs(h[i]-h[i-2])+dp[i-2]);
    return dp[n-1];
  }
}

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

vector<string> split(string str, char del){
    int first = 0;
    int last = str.find_first_of(del);

    vector<string> result;

    while (first < str.size()){
        string subStr(str, first, last - first);
        result.push_back(subStr);

        first = last + 1;
        last = str.find_first_of(del, first);

        if (last == string::npos){
            last = str.size();
        }
    }

    return result;
}

int main (){
    string str;
    cin >> str;
    char del = ',';
    for (const auto subStr : split(str, del)){
        cout << subStr << ' ';
    }
}


Measured memory_bytes: 256