akhauriyash/Code-Regression huggingface dataset:
N=int(input())
s=[int(input()) for i in range(N)]
s.sort()
out=sum(s)
if out%10>0:
  print(out)
  exit()
  
i=0
while i<N and s[i]%10==0:
  i+=1
if i==N:
  print(0)
else:
  print(out-s[i])

Measured memory_bytes: 3064
#include<stdio.h>
// 2*(N+k) == M-2k s*1 c*7 //2*(k+1) = 7-2k
int main(){
  long long n = 0;
  long long m = 0;
  long long hoge = 0;
  scanf("%lld %lld",&n,&m);
  if(2*n-m>0){
    hoge = m/2;
  }else{
    hoge = (m-2*n)/4 + n;
  }
  
  printf("%lld",hoge);
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a == b) {
        	System.out.println("Yes");
        }else {
        	System.out.println("No");
        }
	}
}

Measured memory_bytes: 22612
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>

using namespace std;

const int MOD = 1000000007;
typedef long long ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,P;
  ll even=0,odd=0;
  cin>>N>>P;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    if(a%2==0){
      even++;
    }else{
      odd++;
    }
  }
  if(odd==0){
    if(P==1){
      cout<<0<<endl;
    }else{
      cout<<(1ll<<N)<<endl;
    }
  }else{
    cout<<(1ll<<(N-1))<<endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <queue>

#define pb push_back

using namespace std;

int main() {
	int n, m, a, b, ans = 0;
	vector<int> v[100010];
	priority_queue<int> pq;
	scanf("%d %d", &n, &m);
	while (n--) {
		scanf("%d %d", &a, &b);
		v[a].pb(b);
	}
	for (int i = 1; i <= m; i++) {
		for (int j = 0; j < (int) v[i].size(); j++)
			pq.push(v[i][j]);
		if (pq.size()) {
			ans += pq.top();
			pq.pop();
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 5632
n = int( input() )
t_won = 0
h_won = 0

for _ in range(n):
    t, h = input().split(" ")
    if t < h:
        h_won += 1
    if t > h:
        t_won += 1
print(t_won*3 + (n - t_won - h_won), h_won*3 + (n - t_won - h_won))


    

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

int main(){
	int S;
	cin>>S;
		int h=S/3600;
		int m=(S/60)%60;
		int s=S%60;
	cout<<h<<":"<<m<<":"<<s<<endl;

	return 0;
}


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

public class Test
{
	public static void Main()
	{
		// my code goes here
		
		var a = Console.ReadLine().Split().Select(nyan => int.Parse(nyan)).ToArray(); //この呪文覚えたい
		int n = a[0];
		int k = a[1];
		var h = Console.ReadLine().Split().Select(nyaa => int.Parse(nyaa)).ToArray(); //この呪文覚えたい
		int counter = 0;
		
		
		for(int i=0; i!=n; i++){
			if(h[i] >= k){counter++;}
		}
		
		Console.WriteLine(counter);
		
		
	}
}

Measured memory_bytes: 18656
S = input()
T = input()
L,l = len(S),len(T)
ans = 1000
for i in range(l,L+1):
    s = S[i-l:i]
    cnt = 0
    for j in range(l):
        if s[j] != T[j]:
            cnt += 1
    if ans > cnt:
        ans = cnt
print(ans)

Measured memory_bytes: 67608
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using p = pair<int, int>;
 
int main() {
  ll n, a, b;

  cin >> n >> a >> b;

  ll pair = a + b;

  ll count = n / pair;
  ll i = n % pair;

  cout << ((a * count) + min(a, i)) << endl;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 100009 /// I wanna be the wind
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e17 + 9;
ll mult(ll a,ll b){
    return a*b%MOD;
}
ll fastpow(ll a, ll b){
    ll calc=1;
    for(;b>=1LL;b/=2LL){
        if((b&1LL))calc=mult(calc,a);
        a=mult(a,a);
    }
    return calc;
}
ll soma(ll a,ll b){
    if(a+b>MOD)return a+b-MOD;
    else return a+b;
}
ll subt(ll a,ll b){
    if(a-b<0)return a-b+MOD;
    else return a-b;
}
ll mat[22][22];
ll dp[22][1<<21];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    rep(i,1,n+1){
        rep(j,1,n+1){
            cin>>mat[i][j];
        }
    }
    rep(i,0,22){
        rep(j,0,1<<n){
            dp[i][j]=0;
        }
    }
    dp[0][0]=1;
    rep(i,1,n+1){
        rep(j,0,1<<n){
            if(__builtin_popcount(j)!=i-1)continue;
            rep(k,1,n+1){
                ll nst = j|(1<<(k-1));
                if(j^(1<<(k-1)) && mat[i][k]==1) dp[i][nst]=soma(dp[i][nst],dp[i-1][j]);
            }
        }
    }
    cout<<dp[n][(1<<(n))-1]<<"\n";
    return 0;  
}

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


int main()
{
    
    long long h,a;
    long long ans=0;
    
    cin >> h >> a;
    
    while(h>0)
    {
        ans += 1;
        h -= a;
    }
    
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define K 10000

int main(){
  int i,j,n,C[K+1];
  int *A,*B;

  scanf("%d",&n);

  A = malloc(sizeof(int)*(n+1));
  B = malloc(sizeof(int)*(n+1));

  for(i=0; i<= K; i++)
    C[i] = 0;

  for(j=1; j<=n; j++){
    scanf("%d", &A[j]);
    C[A[j]]++;
  }

  for(i=1; i<=K; i++)
    C[i] += C[i-1];

  for(j=n; j>=1; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for(i=1; i<=n; i++){
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 16276
n = int(input())
p = list(map(int, input().split()))

count = 0
for i in range(1, len(p)-1):
    p_min = max(p[i-1], p[i], p[i+1])
    p_max = min(p[i-1], p[i], p[i+1])
    if p_min != p[i] and p_max != p[i]:
        count += 1
print(count)


Measured memory_bytes: 9112
def resolve():
    from collections import defaultdict
    n = int(input())
    A = list(map(int, input().split()))
    q = int(input())
    S = sum(A)
    d = defaultdict(int)
    for a in A:
        d[a] += 1

    for _ in range(q):
        b, c = map(int, input().split())
        k = d[b]
        d[b] -= k
        d[c] += k
        S += k * (c - b)
        print(S)

resolve()

Measured memory_bytes: 24088
/**
 *    author: tanishq_code_c
**/
#include <bits/stdc++.h>
using namespace std;



void __print(int x) {cerr << x;}; void __print(long x) {cerr << x;}; void __print(long long x) {cerr << x;}; void __print(unsigned x) {cerr << x;}; void __print(unsigned long x) {cerr << x;}; void __print(unsigned long long x) {cerr << x;}; void __print(float x) {cerr << x;}; void __print(double x) {cerr << x;}; void __print(long double x) {cerr << x;}; void __print(char x) {cerr << '\'' << x << '\'';}; void __print(const char *x) {cerr << '\"' << x << '\"';}; void __print(const string &x) {cerr << '\"' << x << '\"';}; void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif


#define int                                         long long
#define setbits(x)                                     __builtin_popcountll(x)
#define zerobits(x)                                 __builtin_ctzll(x)
#define mod                                         1000000007
#define inf                                            1e18
#define endl                                        '\n'
#define pb                                          push_back
#define all(x)                                      x.begin(),x.end()
#define ff                                          first
#define ss                                          second
#define rep(i,n)                                    for(int i = 0; i < n; i++)



void t_c_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    /*#ifndef ONLINE_JUDGE
        freopen("inp.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif*/
    int ans = 0;
    int n; cin >> n;
    int arr[n];
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    for (int i = 0; i < n - 2; i++) {
        for (int j = i + 1; j < n - 1; j++) {
            for (int k = j + 1; k < n; k++) {
                if (arr[i] != arr[j] and arr[j] != arr[k] and arr[k] != arr[i]) {
                    if ((arr[i] + arr[j] > arr[k]) and (arr[i] + arr[k] > arr[j]) and (arr[k] + arr[j] > arr[i])) {
                        dbg(arr[i], arr[j], arr[k]);
                        ans++;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

int32_t main()
{
    t_c_c();
    return 0;
}


Measured memory_bytes: 3640
n,m=map(int,input().split())
xyz=[list(map(int,input().split())) for i in range(n)]
ans=-10**18
tmp=[1,-1]
for i in range(2):
  for j in range(2):
    for k in range(2):
      xyz.sort(key=lambda x:x[0]*tmp[i]+x[1]*tmp[j]+x[2]*tmp[k],reverse=True)
      foo=sum([x[0]*tmp[i]+x[1]*tmp[j]+x[2]*tmp[k] for x in xyz][:m])
      ans=max(ans,foo)
print(ans)

Measured memory_bytes: 3356
#include<bits/stdc++.h>
using namespace std;
const int N = 5e3+100;
const int P = 1e9+7;
#define fr(i,a,b) for(int i = a;i <= b; ++i)
#define nfr(i,a,b) for(int i = a;i >= b; --i)

int n,m;
int p[N],f[N];

inline void add(int &x,int y){
   x += y; if(x >= P)x -= P;
}

inline int pow_mod(int x,int k){
   int res = 1,base = x;
   while(k){
      if(k&1)res = 1LL*res*base%P;
      k >>= 1; base = 1LL*base*base%P;
   }
   return res;
}

int dp[2][N];
inline int find(int x){
   return (x == f[x]) ? x : f[x] = find(f[x]);
}
int ct[N],num[N];
int a[N];

int cur = 1;

int main(){
   scanf("%d",&n);
   fr(i,1,n)scanf("%d",p+i);
   fr(i,1,n)f[i] = i;

   fr(i,1,n){
      if(p[i] == -1){
         cur = 1LL*cur*(n-1)%P;
         continue ;
      }
      int z1 = find(i),z2 = find(p[i]);
      if(z1 == z2)++ct[z1];
      else {
         ct[z1] += ct[z2]+1;
         f[z2] = z1;
      }
   }

   fr(i,1,n){
      ++num[find(i)];
   }

   int tot = 0,ans = 1LL*n*cur%P;
   fr(i,1,n){
      if(f[i] == i){
         if(ct[i] == num[i]){
            add(ans,P-cur);
         } else a[++tot] = num[i];
      }
   }

   dp[0][0] = 1;
   fr(i,1,tot){
      int id = i&1;
      memset(dp[id],0,sizeof dp[id]);
      fr(j,0,i-1){
         add(dp[id][j+1],1LL*dp[id^1][j]*a[i]%P);
         add(dp[id][j],1LL*dp[id^1][j]*(n-1)%P);
      }
   }

   fr(i,1,tot){
      add(ans,P-1LL*(a[i]-1)*pow_mod(n-1,tot-1)%P);
   }

   cur = 1;
   fr(i,2,tot){
      add(ans,P-1LL*dp[tot&1][i]%P*cur%P);
      cur = 1LL*cur*i%P;
   }
   printf("%d\n",ans); return 0;
}


Measured memory_bytes: 3948
#include <iostream>
#include <vector>
#include<algorithm>
#include<math.h>
#include<iomanip>
#define ff(i,m,n) for(int i=m;i<n;i++)
#define i64 int64_t
using namespace std;


int main() {
	int a;
	cin >> a;
	a = (1 + a) * a / 2;
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 256
# Disjoint sparse table (GCD)
from math import gcd


class DisjointSparseTable:
    _f = None
    _data = None
    _lookup = None

    def __init__(self, a, f):
        self._f = f
        b = 0
        while (1 << b) <= len(a):
            b += 1
        _data = [[0] * len(a) for _ in range(b)]
        _data[0] = a[:]
        for i in range(1, b):
            shift = 1 << i
            for j in range(0, len(a), shift << 1):
                t = min(j + shift, len(a))
                _data[i][t - 1] = a[t - 1]
                for k in range(t - 2, j - 1, -1):
                    _data[i][k] = f(a[k], _data[i][k + 1])
                if t >= len(a):
                    break
                _data[i][t] = a[t]
                r = min(t + shift, len(a))
                for k in range(t + 1, r):
                    _data[i][k] = f(_data[i][k - 1], a[k])
        self._data = _data
        _lookup = [0] * (1 << b)
        for i in range(2, len(_lookup)):
            _lookup[i] = _lookup[i >> 1] + 1
        self._lookup = _lookup

    def query(self, start, stop):
        stop -= 1
        if start >= stop:
            return self._data[0][start]
        p = self._lookup[start ^ stop]
        return self._f(self._data[p][start], self._data[p][stop])



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

st = DisjointSparseTable(A, gcd)

result = st.query(1, N)
for i in range(1, N - 1):
    result = max(result, gcd(st.query(0, i), st.query(i + 1, N)))
result = max(result, st.query(0, N - 1))
print(result)


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

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MAX 1000000007
#define MAX_V 2*100000+10

using namespace std;



bool cmpf(const pair<lli, lli> left, const pair<lli, lli> right) {
	return left.first < right.first;
}
bool cmps(const pair<lli, lli> left, const pair<lli, lli> right) {
	return left.second < right.second;
}
using namespace std;
lli k, n, m, e;


int main() {
	lli x, y, z;
	cin >> x >> y>>z;
	cout << ( z - x + y<0?0: z - x + y);
	

}




Measured memory_bytes: 256
integer N
integer,allocatable,dimension(:)::A,B,C
integer ans
read*,N
allocate(A(N),B(N),C(N-1))
read*,A
read*,B
read*,C
ans=0
do i=1,N
  if(A(i)/=N)then
    if(A(i)+1==A(i+1))ans=ans+C(A(i))
  endif
end do
ans=ans+sum(B)
print"(I0)",ans
end

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

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

int main() {
  ll n;
  cin >> n;

  vector<ll> a(n);
  for (ll i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());

  vector<ll> sum;
  ll prev = a[0];
  sum.push_back(1);
  for (ll i = 1; i < n; ++i) {
    if (prev == a[i]) {
      sum[sum.size()-1]++;
    } else {
      sum.push_back(1);
      prev = a[i];
    }
  }

  ll gu = 0;
  for (ll i = 0; i < sum.size(); ++i) {
    if (sum[i] % 2 == 0) gu++;
  }

  ll ans = sum.size();
  if (gu % 2 != 0) ans -= 1;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2296
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    if (v.size() == 0) return os;
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    os << v[v.size() - 1];
    return os;
}

void solve() {
    int x;
    cin >> x;
    if (x >= 30) {
        cout <<"Yes"<<endl;
    } else {
        cout << "No" << endl;
    }
}

int main() {
    char tmp;
    while (cin >> tmp) {
        cin.putback(tmp);
        solve();
    }
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

int main(){
    int n;
    cin>>n;
    int a=0,b=0,c=0;
    ll ans=1;
    for(int i=0;i<n;i++){
        int m;
        cin>>m;
        if(m!=a&&m!=b&&m!=c){
            cout<<0<<endl;
            return 0;
        }
        ll t=0;
        int cnt=0;
        if(m==a){
            t+=ans;
        }
        if(m==b){
            t+=ans;
        }
        if(m==c){
            t+=ans;
        }
        ans=t%MOD;
        if(m==a){
            a++;
            continue;
        }
        if(m==b){
            b++;
            continue;
        }
        if(m==c){
            c++;
            continue;
        }
    }
    cout<<ans<<endl;
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int a[5][5];
int n;
int b[10];
bool s[5][5];
void solve() {
    rep(i, 3) rep(j, 3) cin >> a[i][j];

    cin >> n;
    rep(i, n) cin >> b[i];
    rep(i, 3) rep(j, 3) {
        rep(k, n) if (a[i][j] == b[k]) s[i][j] = true;
    }

    bool ok = false;
    rep(i, 3) {
        bool res = true, res2 = true;
        rep(j, 3) {
            if (!s[i][j]) res = false;
            if (!s[j][i]) res2 = false;
        }
        ok |= res;
        ok |= res2;
    }

    ok |= s[0][0] && s[1][1] && s[2][2];
    ok |= s[2][0] && s[1][1] && s[0][2];

    if (ok) cout << "Yes" << endn;
    else cout << "No" << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


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

class Main {
	public static void main(String[] $) {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		long N=sc.nextLong();
		long X=sc.nextLong();
		long M=sc.nextLong();
		long ans=0;
		long[][] pre=new long[(int)M][2];
		for (int i=0;i<M;++i) for (int j=0;j<2;++j) pre[i][j]=-1;
		for (long i=0;i<N;++i) {
			ans+=X;
			if (pre[(int)X][0]!=-1) {
				long period=i-pre[(int)X][0];
				long sum=ans-pre[(int)X][1];
				long res=N-1-i;
				ans+=res/period*sum;
				i+=res/period*period;
			}
			pre[(int)X][0]=i;
			pre[(int)X][1]=ans;
			X=X*X%M;
		}
		System.out.println(ans);
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}


Measured memory_bytes: 39856
'use strict';

waterfall([
  function(next) {
    lineReader(4, next);
  }, function(line, next) {
    var toInt = function(s) {
      return parseInt(s);
    }
    var s = line[1].split(' ').map(toInt);
    var t = line[3].split(' ').map(toInt);
    next(t.reduce(function(sum, i) {
      return s.some(function(test) {
        return test === i;
      }) ? sum + 1 : sum;
    }, 0));
  }], function(result) {
    console.log(result);
    process.exit(0);
  });

function strMap(str, map) {
  var newStr = '';
  for (var i = 0; i < str.length; i++) {
    newStr += map(str.charAt(i), i);
  }
  return newStr;
}

function lineReader(limit, cb) {
  var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout,
  });
  var lines = [];
  var counter = 0;
  reader.on('line', function(line) {
    lines.push(line);
    ++counter;
    if (counter === limit) {
      reader.close();
      return cb(lines);
    }
  });
  reader.on('close', function() {});
  reader.on('error', function(err) {
    cb(err);
  });
}

function waterfall(tasks, cb) {
  var taskIndex = 0;
  function nextTask(args) {
    if (taskIndex === tasks.length)
      return cb.apply(null, args);

    var taskCallback = function() {
      var _arguments = arguments;
      nextTask(Object.keys(_arguments).reduce(function(memo, key) {
        memo.push(_arguments[key]);
        return memo;
      }, []));
    };
    args.push(taskCallback);
    var task = tasks[taskIndex++];
    task.apply(null, args);
  }
  nextTask([]);
}

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

int main()
{
    int i, j, k;
    int n, m, l;
    long a[100][100], b[100][100], c[100][100] = {0};
    cin >> n >> m >> l;
    
    for (i = 0; i < n; i++)
        for (j = 0; j < m; j++)
            cin >> a[i][j];
    for (i = 0; i < m; i++)
        for (j = 0; j < l; j++)
            cin >> b[i][j];

    for (i = 0; i < n; i++)
        for (j = 0; j < l; j++)
            for (k = 0; k < m; k++)
                c[i][j] += a[i][k] * b[k][j];
    
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < l; j++)
        {
            if (j) cout << " ";
            cout << c[i][j];
        }
        cout << endl;
    }
    return 0;
}



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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> ab(m * 2);
  vector<int> result(n, 0);
  int i;
  for (i = 0; i < ab.size(); i++) {
    cin >> ab[i];
    result[ab[i] - 1]++;
  }
  for (i = 0; i < result.size(); i++) {
    cout << result[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
x,y,a,b,c = map(int,input().split())
r = sorted([i for i in map(int,input().split())],reverse = True)[0:x]
g = sorted([i for i in map(int,input().split())],reverse = True)[0:y]
n = sorted([i for i in map(int,input().split())],reverse = True)
com = sorted(r + g + n,reverse = True)
print(sum(com[0:x + y]))


Measured memory_bytes: 22432
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;
int32_t main()
{
    IOS;
    char s;
    cin>>s;
    if(s>='a'&&s<='z')
    {
      cout<<'a'<<endl;
    }
    else
      cout<<'A'<<endl;


  
}

Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		int n = Integer.parseInt(N);

		char[] c = N.toCharArray();

		int result = 0;

		for (char m : c) {
			result += Character.getNumericValue(m);
		}

		if (n % result == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();
	}

}


Measured memory_bytes: 21844
/*
    Author: MEHXM
*/
#include <bits/stdc++.h>
using namespace std;

#define cp_io ios_base::sync_with_stdio(0);cin.tie(0)
#define ll long long int
#define oo 1000000010
#define MAX 1000000
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define nl "\n"

int main()
{
    cp_io;
    #ifndef ONLINE_JUDGE
    freopen("z_input.txt","rt",stdin);
    freopen("z_output.txt","wt",stdout);
    #endif
    int n;
    cin >> n;
    ll a[n];

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

    ll ans = 0;
    ll mx = INT_MIN;
    for(int i=0; i<n; i++)
    {
        if(mx > a[i])
            ans += mx - a[i];
        
        mx = max(a[i], mx);
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 5168
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int N;
vector<int> ans;

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

  cin >> N;

  if (N == 3) {
      cout << 2 << ' ' << 3 << ' ' << 25 << endl;
      return 0;
  }

  ans.push_back(2);
  ans.push_back(3);
  ans.push_back(8);
  ans.push_back(9);
  int count = 4;
  if (count < N) {
      ans.push_back(10);
      ++count;
  }
  if (count < N) {
      ans.push_back(12);
      ++count;
  }

  for (int i = 16; i <= 30000; i += 2) {
      if (count == N) break;
      ans.push_back(i);
      ++count;
  }

  for (int i = 12; i <= 30000; i += 3) {
      if (count == N) break;
      if (i%2 == 0) continue;
      ans.push_back(i);
      ++count;
  }

  if (count < N) {
      if (N == 19998) {
          ans.push_back(6);
      } else if (N == 19999) {
          ans.push_back(4);
          ans.push_back(14);
      } else {
          ans.push_back(4);
          ans.push_back(6);
          ans.push_back(14);
      }
  }

  
  ll sum = 0;
  for (int i = 0; i < len(ans); ++i) {
      sum += ans[i];
  }

  switch (sum%6) {
      case 1:
          ans[3] = 14;
          break;
      case 2:
          ans[2] = 6;
          break;
      case 3:
          ans[3] = 6;
          break;
      case 4:
          ans[2] = 4;
          break;
      case 5:
          ans[3] = 4;
          break;
  }

  sum = 0;
  for (int i = 0; i < len(ans); ++i) {
      sum += ans[i];
  }

  for (int i = 0; i < len(ans); ++i) {
      cout << ans[i] << (i+1 == len(ans) ? '\n' : ' ');
  }

  return 0;

}



Measured memory_bytes: 560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair < int, int >;

const int inf = 1e9;

int main() {
	int n;
	scanf ("%d", &n);
	vector < int > h (n);
	for (int & x : h) scanf ("%d", &x);
	vector < int > dp (n);
	for (int i = 1; i < n; i++) {
		dp[i] = dp[i - 1] + abs (h[i] - h[i - 1]);
		if (i - 2 >= 0) {
			dp[i] = min (dp[i], dp[i - 2] + abs (h[i] - h[i - 2]));
		}
	}
	printf ("%d\n", dp[n - 1]);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define REP(i, n) for (Int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (Int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<Int, Int>;
template <class T> inline bool chmax(T& a, const T& b) {
    if (a >= b) return false;
    a = b;
    return true;
}
template <class T> inline bool chmin(T& a, const T& b) {
    if (a <= b) return false;
    a = b;
    return true;
}
struct SetupIO {
    SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(20); }
} setup_io;

template <template <class, class...> class TT, class... Args>
ostream& operator<<(ostream& out, TT<Args...> const& cont) {
    for (auto&& elem : cont) out << elem << " ";
    return out;
}
template <class T> ostream& operator<<(ostream& out, const vector<vector<T>>& vs) {
    for (auto&& v : vs) cout << v << endl;
    return out;
}
template <class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> const& val) {
    return (out << "{" << val.first << " " << val.second << "}");
}

void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) {
    cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...);
}
#ifdef _MY_DEBUG
#define dump(...)                                                                                                    \
    cerr << "/* " << #__VA_ARGS__ << " [" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), \
        cerr << "*/\n\n";
#else
#define dump(...)
#endif

/**
 *    author:  knshnb
 *    created: Sun Nov 24 22:57:07 JST 2019
 **/

struct in {
    int n;
    in() {}
    in(int n_) : n(n_){};
    template <class T> operator T() {
        T ret;
        cin >> ret;
        return ret;
    }
    template <class T> operator vector<T>() {
        vector<T> ret(n);
        for (int i = 0; i < n; i++) cin >> ret[i];
        return ret;
    }
};
signed main() {
    Int n = in(), m = in();
    string s = in();
    Int cur = n;
    vector<Int> ans;
    while (cur > 0) {
        REPI(i, max(0LL, cur - m), cur + 1) {
            if (i == cur) {
                cout << -1 << endl;
                return 0;
            }
            if (s[i] == '0') {
                ans.push_back(cur - i);
                cur = i;
                break;
            }
        }
    }
    for (Int i = ans.size() - 1; i >= 0; i--) {
        cout << ans[i] << " ";
    }
    cout << endl;
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int M = int.Parse(input[1]);
            int X = int.Parse(input[2]);
            int Y = int.Parse(input[3]);

            string[] StrX = Console.ReadLine().Split(' ');
            string[] StrY = Console.ReadLine().Split(' ');

            List<int> ListX = new List<int>();
            List<int> ListY = new List<int>();

            for (int i = 0; i < N; i++)
            {
                ListX.Add(int.Parse(StrX[i]));
            }
            ListX.Add(X);

            for (int j = 0; j < M; j++)
            {
                ListY.Add(int.Parse(StrY[j]));
            }
            ListY.Add(Y);

            if (ListX.Max()<ListY.Min())
            {
                Console.WriteLine("No War");
            }
            else
            {
                Console.WriteLine("War");
            }
        }
    }
}


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

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  
  string ans = "NO";
  if (A == 5 && B == 7 && C == 5 ||
      A == 5 && B == 5 && C == 7 ||
      A == 7 && B == 5 && C == 5) ans = "YES";
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>

#define rep(i, a) for(int i = 0; i < a; i++)
#define llint long long int
using namespace std;

const int MAX_x = 100005;
const llint INF = 999999999999999;

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

    int dvs[5] = { 105, 135, 165, 189, 195 };
    rep(i, 5) if (n >= dvs[i]) ans++;

    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.HashMap;
import java.util.Objects;
import java.math.BigInteger;
import java.util.Collection;


public class Main {
	public static void main(String[] args) {
		
		SunukeColoring sc = new SunukeColoring();
		sc.run();
		
	}
}

class SunukeColoring {
	
	int H;
	int W;
	int N;
	Point[] points;
	
	SunukeColoring() {
		Scanner cin = new Scanner(System.in);
		this.H = cin.nextInt();
		this.W = cin.nextInt();
		this.N = cin.nextInt();
		this.points = new Point[N];
		for (int i = 0; i < N; i++) {
			int x = cin.nextInt();
			int y = cin.nextInt();
			points[i] = new Point(x, y);
		}
	}
	
	void run() {
		
		HashMap<Point, Long> map = new HashMap<Point, Long>();
		for (Point point: points) {
			for (int i = -1; i <= 1; i++) {
				for (int j = -1; j <= 1; j++) {
					
					Point target = new Point(point.x + i, point.y + j);
					
					if (target.invalid()) {
						continue;
					}
					
					if (map.containsKey(target)) {
						long count = map.get(target);
						map.put(target, count + 1);
					} else {
						map.put(target, (long)1);
					}
					
				}
			}
		}
		
		Collection<Long> values = map.values();
		BigInteger[] ans = new BigInteger[10];
		for (int i = 0; i < ans.length; i++) {
			ans[i] = new BigInteger("0");
		}
		
		
		long allCount = 0;
		for (long num: values) {
			ans[(int)num] = ans[(int)num].add(new BigInteger("1"));
			allCount++;
		}
		
		BigInteger width = new BigInteger(String.valueOf(W - 2));
		BigInteger height = new BigInteger(String.valueOf(H - 2));
		BigInteger all = width.multiply(height);
		ans[0] = all.subtract(new BigInteger(String.valueOf(allCount)));
		
		for (BigInteger a: ans) {
			System.out.println(a);
		}
	}
	
	class Point {
		
		int x;
		int y;
		
		Point(int x, int y) {
			this.x = x;
			this.y = y;
		}
		
		boolean invalid() {
			return x <= 1 || H <= x || y <= 1 || W <= y;
		}
		
		@Override
		public boolean equals(Object obj) {
			if (obj instanceof Point) {
				Point point = (Point) obj;
				return this.x == point.x && this.y == point.y;
			} else {
				return false;
			}
		}
		
		@Override
		public int hashCode() {
			return Objects.hash(x, y);
		}
	}
}


Measured memory_bytes: 210044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define TEST cout << "ococo" << endl;
using namespace std;

int main(void){
	int n;
	cin >> n;
	vector<int> arr(n);
	int count = 0;
	for(int i = 0; i != n; i++){
		cin >> arr[i];
		if(arr[i] != i + 1)count++;
	}
	if(count <= 2)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (A, B, C, D) = readLine()!!.split(" ").map(String::toInt)
    val aoki_turn = A / D + if (A % D == 0) { 0 } else { 1 } 
    val takahashi_turn = C / B + if (C % B == 0) { 0 } else { 1 }
if(aoki_turn >= takahashi_turn) { "Yes" } else { "No" }.run(::println) 
}

Measured memory_bytes: 36380
from collections import deque
H,W,K=map(int,input().split())
A=[list(input())for _ in range(H)]
y,x=(0,0)
for i, a in enumerate(A):
	if"S"in a:y,x=(i,a.index("S"))
d=1e9
Q=deque([(0,y,x)])
while Q:
	c,i,j=Q.popleft()
	d=min(d,i,j,H-i-1,W-j-1)
	if d<1:break
	if c>=K:continue
	for ni,nj in((i+1,j),(i,j+1),(i-1,j),(i,j-1)):
		if 0<=ni<H and 0<=nj<W and A[ni][nj]==".":
			A[ni][nj]="#"
			Q.append((c+1,ni,nj))
print(-(-d//K)+1)

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


int main(){
    int N;
    cin>>N;
    if(N%10==3){
        cout<<"bon"<<endl;
    }else if(N%10==0||N%10==1||N%10==6||N%10==8){
        cout<<"pon"<<endl;
    }else{
        cout<<"hon"<<endl;
    }
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ll long long
#define all(_v) _v.begin(), _v.end()

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll x;
	cin >> x;
	ll t = 100, ans = 0;
	while(t < x) {
        t += t / 100;
        ans++;
	}
	cout << ans;
	return 0;
}


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

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

int main(){
    int N;
    cin >> N;
    int sum=0;
    REP(i,int(log10(N)+1)){
        sum += (N%int(pow(10,i+1)))/int(pow(10,i));
    }
    if(N%sum==0){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

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

#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
#define rsort(n) sort((n).begin(),(n).end(),greater<ll>())

using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n-1);
    rep(i,n)cin >> a[i];
    ll sum=0;
    FOR(i,n,1){
        b[i-1]=a[i];
    }
    for(int i=n-2;i>0;--i){
        b[i-1]+=b[i];
        b[i-1]%=1000000007;
    }
    rep(i,n-1){
        sum+=(a[i]*b[i])%1000000007;
        sum%=1000000007;
    }
    cout << sum << endl;
}

Measured memory_bytes: 6348
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
#define int long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)
#define min(a,b) (a>b?b:a)
#define max(a,b) (a>b?a:b)
#define yn(f) (f?"Yes":"No")
#define YN(f) (f?"YES":"NO")
#define pro "はいプロ　世界一○○が上手　○○界のtourist　○○時代の終焉を告げる者　実質○○　○○するために生まれてきた男"
#define Answer_to_the_Ultimate_Question_of_Life_the_Universe_and_Everything 42

signed main(){
	cout<<fixed<<setprecision(7);
	bool f = false, flag = true;
	int n, m;
	int a, b, c, d;
	string str, S, T;
	char x, y;
	
	cin>>x>>y;
	
	if(x>y) cout<<">"<<endl;
	else if(x==y)cout<<"="<<endl;
	else cout<<"<"<<endl;
	
	// cin>>n>>m;
	
	
	
	// cout<<yn(f)<<endl;
	
	
	
	return 0;
}

Measured memory_bytes: 256
def get_isPrime(n):         #1~nまでの数で、素数は1、それ以外は0となるようなリストを返す
    isprime=[1]*(n+1)
    isprime[0]=0
    isprime[1]=0
    for i in range(2, int(n**0.5)+1):
        if not isprime[i]:
            continue
        for j in range(i*2, n+1, i):
            isprime[j]=0
    return isprime

max_n=100000
isprime=get_isPrime(max_n)

ruiseki=[]
for i in range(max_n+1):
    if i==0 or i==1 or i==2:
        ruiseki.append(0)
    else:
        if i%2==0:
            ruiseki.append(ruiseki[i-1])
        else:
            if isprime[i] and isprime[int((i+1)/2)]:
                ruiseki.append(ruiseki[i-1]+1)
            else:
                ruiseki.append(ruiseki[i-1])

q=int(input())
for _ in range(q):
    left, right=map(int,input().split())
    print(ruiseki[right]-ruiseki[left-1])

Measured memory_bytes: 5144
n = int(input())
lst = []
for i in range(50001) :
    lst += [int(i*1.08)]

if n in lst :
    if int(n/1.08)*1.08 == n :
        print(int(n/1.08))
    else :
        print(int(n/1.08)+1)

else :
    print(":(")

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

using namespace std;

int main(){
	string s;
	vector<int> a(26,0);
	
	cin>>s;
	for(auto c:s){
		a[c-'a']++;
	}
	
	bool flag=true;
	for(auto i:a){
		if(i&1){
			flag=false;
			break;
		}
	}
	
	if(flag){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
} 

Measured memory_bytes: 256
<?php
list($N,$K) = explode(" ",trim(fgets(STDIN)));
for($i = 0 ;$i<$N;$i++){
$h[$i] = trim(fgets(STDIN));
}
sort($h);
$mm = $h[$i-1]-$h[0];

for($i=0;$i<$N-$K+1;$i++){
$val = $h[$i+$K-1]-$h[$i];
  if ($val<$mm){
  $mm = $val;
  }
}
echo $mm;


Measured memory_bytes: 22004
#include <iostream>
#include <cstring>
#include <cstdio>
#include <stdio.h>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <algorithm>


//My Answer；
using namespace std;

//Problem C
map<int, int> mp;
int n, a;
int main()
{
    if (scanf("%d", &n) != 0)
    {
        for (register int i = 1; i <= n; i++)
        {
            if (scanf("%d", &a) != 0)
            {

                if (mp[a] == 0)
                {
                    mp[a] = 1;
                }
                else
                {
                    printf("NO");
                    return 0;
                        
                }
            }
        }
    }
    printf("YES");
    return 0;
}

Measured memory_bytes: 9600
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();

		BigDecimal nums[] = new BigDecimal[n];
		for(int i=0; i<n; i++) {
			nums[i]=new BigDecimal(sc.nextInt());
		}

		Arrays.sort(nums, Collections.reverseOrder());

		BigDecimal denominator = new BigDecimal(Math.pow(2, n-1));

		BigDecimal molecule = new BigDecimal(0);

		for(int i=0; i<n; i++) {
			if(i != n-1) {
				molecule=molecule.add(nums[i].multiply(new BigDecimal(Math.pow(2, n-i-2))));
			} else {
				molecule=molecule.add(nums[i]);
			}

		}

		System.out.println(molecule.divide(denominator, 10, BigDecimal.ROUND_HALF_UP));

	}
}

Measured memory_bytes: 21844
#include <stdio.h>
int main(){
  int i ,tmp ,pasta ,juice ,total=0;
  scanf( "%d" ,&pasta );
  for( i=0 ; i<2 ; i++ ){
    scanf( "%d" ,&tmp );
    if( tmp < pasta ){
      pasta = tmp;
    }
  }
  scanf( "%d" ,&juice );
  scanf( "%d" ,&tmp );
  if( tmp < juice ){
    juice = tmp;
  }
  total = pasta + juice;
  printf( "%d\n" ,total-50 );
  return 0;
}

Measured memory_bytes: 592
N = int(input())

xyh = []
for _ in range(N):
    x, y, h = map(int, input().split())
    if h != 0:
        xx, yy, hh = x, y, h
    xyh.append((x, y, h))

# print(xyh)

# h = max(H - |x - Cx| - |y - Cy|, 0)

'''
  0 1 2 3
0
1     5
2   5   5
3     5

   99 100
0 192
1 191 192
'''


def f():
    for tx in range(101):
        for ty in range(101):
            th = hh + abs(xx - tx) + abs(yy - ty)
            if all(h == max(th - abs(tx - x) - abs(ty - y), 0) for x, y, h in xyh):
                return tx, ty, th

print(*f())


Measured memory_bytes: 46172
# /usr/bin/python
# -*- coding: utf-8 -*-
import math





def main():
  N = int(input())
  Sn = [int(input()) for _ in range(N)]
  mn = sum(Sn)
  for s in Sn:
    if s%10 != 0:
      mn = min(mn,s)

  if sum(Sn)%10 != 0:
    return sum(Sn)
  else:
    return sum(Sn)-mn


if __name__ == "__main__":
  ret = main()
  print(ret)


Measured memory_bytes: 38256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        String[] line = br.readLine().split("");
        for (String word: line) {
            if (word.equals("9")) {
                out.print("1");
            } else if (word.equals("1")) {
                out.print("9");
            }
        }
        out.println("");
        out.close();
    }
}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int h[n],cost[n],temp,min = 1000000000;
	for(int i=0; i<n; i++)
		cin>>h[i];
	cost[0]=0;
	cost[1]=abs(h[1]-h[0]);
	for(int i=1; i<n; i++)
	{
		min = 1000000000;
		for(int j=1; j<=k; j++)
		{
			if(i-j<0)continue;
			//cout<<"i,j : "<<i<<","<<j<<endl;
			//cout<<"Cost[i-j] : "<<cost[i-j]<<" Added more: "<<abs(h[i]-h[])
			temp = cost[i-j] + abs(h[i] - h[i-j]);
			//cout<<"Temp : "<<temp<<endl;
			if(temp < min)
			{
				min = temp;
				cost[i] = temp;
				//cout<<"Cost of "<<i<<" :"<<cost[i]<<endl;
			}
		}
	}
	//cout<<cost[1]<<endl;
	cout<<cost[n-1]<<endl; 
}


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


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

  string s;
  cin >> s;

  s[1] ^= 'R' ^ 'B';
  cout << s << "\n";

}


Measured memory_bytes: 3648
#include<cstdio>
#include<cctype>
#include<cstring>
char str[1000000] = {0};
using namespace std;
int main(){
    int f = 0;
    while(scanf("%[^\n]",str)!=EOF){
        getchar();
        for(int i = 0;i <= 25; i++){
            for(int j = 0;j < strlen(str); j++){
                if(str[j] == ' ' || str[j] == '.')continue;
                str[j]++;
                if(str[j] > 122)str[j] = str[j]-26;
            }
            for(int j = 0;j < strlen(str); j++){
                if(str[j] == 't' && str[j+1] == 'h' && str[j+2] == 'e')goto hoge;
                if(str[j] == 't' && str[j+1] == 'h' && str[j+2] == 'i' && str[j+3] == 's')goto hoge;
                if(str[j] == 't' && str[j+1] == 'h' && str[j+2] == 'a' && str[j+3] == 't')goto hoge;
            }
        }
        for(int i = 0;i < strlen(str); i++){
            if(str[i] == ' ' || str[i] == '.')continue;
            str[i] -= 25;
        }
        for(int i = 0;i <= 25; i++){
            for(int j = 0;j < strlen(str); j++){
                if(str[j] == ' ' || str[j] == '.')continue;
                str[j]--;
                if(str[j] < 97)str[j] = str[j]+25;
            }
            for(int j = 0;j < strlen(str); j++){
                if(str[j] == 't' && str[j+1] == 'h' && str[j+2] == 'e')goto hoge;
                if(str[j] == 't' && str[j+1] == 'h' && str[j+2] == 'i' && str[j+3] == 's')goto hoge;
                if(str[j] == 't' && str[j+1] == 'h' && str[j+2] == 'a' && str[j+3] == 't')goto hoge;
            }
        }
        hoge:
        printf("%s\n",str);
        memset(str,0,sizeof(str));
    }
    return 0;
}

Measured memory_bytes: 1932
#include <cstdio>
#include <algorithm>
using namespace std;
int a[200];
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	sort(a, a+n);
	int ans = 0; 
	while (ans<n&&m>=a[ans]) {m-=a[ans];ans++;}
	if (ans==n&&m>0) ans--;
	printf("%d\n", ans);
	return 0;
} 

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

int main(void){
    int i, N, V, j, k;
    int *In;
    
    scanf("%d",&N);
    In = (int*)malloc(sizeof(int)*N);
      for(k=0 ; k<N ; k++){
            scanf("%d",&In[k]);
        }
  printf("%d",In[0]);
             for(k=1 ; k<N ; k++){
            printf(" %d",In[k]);
        }
        printf("\n");
  
    
    for(i=1 ; i<N ; i++){
        V=In[i];
        j=i-1;
        while(j>=0 && In[j]>V){
            In[j+1] = In[j];
            j--;
            In[j+1]=V;
        }
        printf("%d",In[0]);
        for(k=1 ; k<N ; k++){
            printf(" %d",In[k]);
        }
        printf("\n");
    }
    
    return 0;
}



Measured memory_bytes: 2064
from collections import deque

N, Q = map(int, input().split())
Tree = [[] for _ in range(N)]
Query = [0] * N
for _ in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    Tree[a].append(b)
    Tree[b].append(a)
for _ in range(Q):
    p, x = map(int, input().split())
    p -= 1
    Query[p] += x
Ans = [-1] * N
A = deque()
A.append(0)
Ans[0] = Query[0]
while len(A) > 0:
    now = A.pop()
    num = Ans[now]
    for next in Tree[now]:
        if Ans[next] >= 0:
            continue
        else:
            Ans[next] = num + Query[next]
            A.append(next)

ans = ''
for aa in Ans:
    ans += str(aa) + ' '
ans = ans[:-1]
print(ans)

Measured memory_bytes: 62708