akhauriyash/Code-Regression huggingface dataset:
class Dice
  def initialize(n)
    @n = n
  end
  #     ^N
  #     [0]:top
  # [3] [1] [2] [4]  2:right 3:left 4:back
  #     [5]:bottom
  #     vS
  attr_reader :n

  def roll(d)
    case d
    when ?N
      @n = [@n[1], @n[5], @n[2], @n[3], @n[0], @n[4]]
    when ?S
      @n = [@n[4], @n[0], @n[2], @n[3], @n[5], @n[1]]
    when ?E
      @n = [@n[3], @n[1], @n[0], @n[5], @n[4], @n[2]]
    when ?W
      @n = [@n[2], @n[1], @n[5], @n[0], @n[4], @n[3]]
    else
      raise
    end
    self
  end
  def rotate_right
    @n = [@n[0], @n[2], @n[4], @n[1], @n[3], @n[5]]
    self
  end
  def rotate_left
    @n = [@n[0], @n[3], @n[1], @n[4], @n[2], @n[5]]
    self
  end
  def set_up_n_front(u, f)
    raise if u == f || (u+f) == 7
    case @n.index(u)
    when 0
      ;
    when 1
      self.roll(?N)
    when 2
      self.roll(?W)
    when 3
      self.roll(?E)
    when 4
      self.roll(?S)
    when 5
      self.roll(?N)
      self.roll(?N)
    end
    case @n.index(f)
    when 1
      ;
    when 2
      self.rotate_right
    when 3
      self.rotate_left
    when 4
      self.rotate_left.rotate_left
    when 0, 5
      raise
    end
    self
  end
end

d=Dice.new(gets.split.map(&:to_i))
gets
while gets
p d.set_up_n_front(*($_.split.map &:to_i)).n[2]
end


Measured memory_bytes: 8904
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n, k; string s;
    cin >> n >> s >> k;
    char c = s[k-1];
    rep(i, n){
        if(s[i] == c) cout << s[i];
        else cout << "*";
    }
    cout << endl;
}

Measured memory_bytes: 3584
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

#include <queue>

#define Min(a,b) ((a)<(b)?(a):(b))
#define Max(a,b) ((a)>(b)?(a):(b))
#define Mabs(a,b) ((a)>(b)?(a)-(b):(b)-(a))
#define Abs(a) (a)>0?(a):(-(a))
template <typename QvQ> inline QvQ Min2(QvQ a,QvQ b){if(a<b) return a;return b;}
template <typename QvQ> inline QvQ Max2(QvQ a,QvQ b){if(a>b) return a;return b;}
template <typename QvQ> inline QvQ Abs2(QvQ a){if(a>0) return a;return -a;}

#define n1kw 10000000
#define inf 0x7f7f7f7f
#define dinf 0x3f3f3f3f
#define llinf 0x7f7f7f7f7f7f7f7f
#define lldinf 0x3f3f3f3f3f3f3f3f

#define ll long long
#define rei register int
#define inv inline void
#define inb inline bool
#define ini inline int

#define bl putchar(' ')
#define ed putchar('\n')
#define test std::cout<<"this:"
#define card system("pause")

#define read2(a,b) read(a),read(b)
#define write2(a,b) write(a),bl,write(b)
#define read3(a,b,c) read(a),read(b),read(c)
#define write3(a,b,c) write(a),bl,write(b),bl,write(c)

//char buf[1<<23],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)

template <typename QvQ>inv read(QvQ &x)
{
	x=0;int f=1;
	char c=getchar();
	for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for(;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+(c^48);
	x=x*f;
}
template <typename QvQ>inv write(QvQ x)
{
	if(x<0) x=-x,putchar('-');
	if(x>9) write(x/10);
	putchar(x%10+48);
}
using namespace std;
#define MAXN 100005
#define MAXM 200005
int a,b; 
int main()
{
	read2(a,b);
	write(max(max(a+b,a-b),a*b));
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
using namespace std;
int main()
{
  int V,E,r,cur,curD,dij,dijD;
  cin >> V >> E >> r;
  vector<int> s(E),t(E),d(E),answer(V),check(V,0);
  vector< vector< pair<int,int> > > v(V);
  for(int i = 0;i < E;++i){
    cin >> s[i] >> t[i] >> d[i];
    v[s[i]].push_back(make_pair(d[i],t[i]));
  }
  check[r] = 1;
  queue<int> q;
  q.push(r);
  while(!q.empty()){
    for(int i = 0;i < v[q.front()].size();++i)
      if(check[v[q.front()][i].second] == 0){
	check[v[q.front()][i].second] = 1;
	q.push(v[q.front()][i].second);
      }
    q.pop();
  }
  vector<int> finish(V,0);
  priority_queue< pair<int,int>,vector< pair<int,int> >,greater< pair<int,int> > > D;
  D.push(make_pair(0,r));
  while(!D.empty()){
    curD = D.top().first;
    cur = D.top().second;
    if(finish[cur] == 1){
      D.pop();
      continue;
    }
    finish[cur] = 1;
    answer[cur] = curD;
    D.pop();
    for(int i = 0;i < v[cur].size();++i){
      dijD = v[cur][i].first;
      dij = v[cur][i].second;
      if(finish[dij] == 0) D.push(make_pair(dijD + curD,dij)); 
    }
  }
  for(int i = 0;i < V;++i){
    if(check[i] == 0) cout << "INF" <<endl;
    else cout << answer[i] << endl;
  }
}

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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
    int n;
    cin >> n;
    bool ok = true;
    vector<ll> a(n);
    rep(i, n)
    {
        cin >> a[i];
        if (a[i] % 2 != 0)
            ok = false;
    }
    ll ans = 0;
    while (ok)
    {
        rep(i, n)
        {
            a[i] /= 2;
            if (a[i] % 2 != 0)
            {
                ok = false;
                break;
            }
        }
        ans++;
    }

    c(ans);
    ed;
    return 0;
}

Measured memory_bytes: 256
NumIslands, NumRequest = map(int, input().split())
ListConflict = [[int(_) for _ in input().split()] for i in range(NumRequest)]

ListConflict = sorted(ListConflict, key=lambda x: x[1])
right_island_compare = ListConflict[0][1]
total_remove = 1

for i_left_island, i_right_island in ListConflict[1:]:
    if i_left_island < right_island_compare:
        continue

    right_island_compare = i_right_island
    total_remove += 1

print(total_remove)

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

int main(){
  int N;
  cin >> N;
  vector<int64_t>L(N+1);
   L.at(0)=2;
   L.at(1)=1;
  for(int i=2;i<=N;i++){
   L.at(i)=L.at(i-1)+L.at(i-2);
  }
  printf("%ld\n",L.at(N));
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Handshake
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int MAX = 100000;

            int N = sc.nextInt();
            long M = sc.nextLong();
            int[] A = new int[N];
            for (int i = 0; i < N; i++) {
                A[i] = sc.nextInt();
            }

            long[] C = new long[MAX + 2];
            for (int a : A) {
                C[a]++;
            }
            for (int i = MAX - 1; i >= 0; i--) {
                C[i] += C[i + 1];
            }

            long[] CS = new long[MAX + 2];
            for (int a : A) {
                CS[a] += a;
            }
            for (int i = MAX - 1; i >= 0; i--) {
                CS[i] += CS[i + 1];
            }

            int min = 0;
            int max = MAX * 2 + 1;

            while (Math.abs(min - max) > 1) {
                int mid = (min + max) / 2;

                long K = 0;
                for (int a : A) {
                    if (mid - a > MAX) {
                        continue;
                    }

                    K += C[Math.max(mid - a, 0)];
                }

                if (K < M) {
                    max = mid;
                } else {
                    min = mid;
                }
            }

            long H = 0;
            long K = 0;
            for (int a : A) {
                if (max - a > MAX) {
                    continue;
                }

                H += a * C[Math.max(max - a, 0)] + CS[Math.max(max - a, 0)];
                K += C[Math.max(max - a, 0)];
            }

            H += min * (M - K);

            System.out.println(H);
        }
    }

}


Measured memory_bytes: 50704
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,K,i,a,A,m;cin>>N>>K;cin>>A;m=A;
  REP(i,N-1){cin>>a;A=__gcd(A,a);m=max(m,a);}
  if(K<=m&&K%A==0)cout<<"POSSIBLE"<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000000
#define MAX 200001

const ll MOD = 1000000007;

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) v += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr istream& operator >> (istream &is, Fp<MOD>& x) noexcept {
        return is >> x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

using mint = Fp<MOD>;

int main(){
    int N;
    cin >> N;
    ll ans = 0;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    ll now = A[0];
    for(int i = 1;i < N; i++){
        if(now > A[i]){
            ans += now-A[i];
        }
        else now = A[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4836
#include<bits/stdc++.h>
using namespace std;
const int MXN = 100;
int main() {
	int N;
	scanf("%d",&N);
	int H[MXN];
	for(int i = 0; i<N; i++) {
		scanf("%d",H+i);
	}
	int counter = 1;
	int j=0;
	for(int i =1; i<N; i++) {
		for(j =0; j<i; j++) {
			if(H[j]>H[i]) break;

		}
		if(j== i) counter++;
		
	}
	printf("%d", counter);
	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;
bool custom1 (pair<int, int> a, pair<int, int> b) {
  return (a.first < b.first);
}
bool custom2(pair<int, int> a, pair<int, int> b) {
  return (a.second < b.second);
}

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i, n) cin >> x[i];
  int ans = INT_MAX;
  for(int p=1;p<=100;p++) {
    int alt = 0;
    rep(i, n) {
      alt += (p - x[i]) * (p - x[i]);
    }
    if(alt < ans) ans = alt;
  }

  cout << ans << endl;
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  bool rev = false;
  int q;
  cin >> q;
  deque<char> deq(begin(s), end(s));
  while (q--) {
    int t;
    cin >> t;
    if (t == 1) {
      rev ^= true;
    } else {
      int f;
      char c;
      cin >> f >> c;
      if (f == 1) {
        if (rev) {
          deq.push_back(c);
        } else {
          deq.push_front(c);
        }
      } else {
        if (rev) {
          deq.push_front(c);
        } else {
          deq.push_back(c);
        }
      }
    }
  }
  if (rev) {
    reverse(begin(deq), end(deq));
  }
  for (auto e : deq) {
    cout << e;
  }
  cout << '\n';
}


Measured memory_bytes: 976
s = int(input())
a = []
a.append(s)
def f(n):
    if n%2 ==0:
        return int(n/2)
    else:
        return 3*n+1
i = 1        
while f(a[-1]) not in a:
    a.append(f(a[-1]))
    i+=1
#print(i,a)
print(i+1)

Measured memory_bytes: 9168
#include <iostream>
#include <string>
#include <bitset>
#include <algorithm>
using namespace std;

int main() {
    string s;
    while(cin >> s, s != "#") {
        reverse(s.begin(), s.end());
        bitset<128> bi(s);
        bool res = true;
        int idx[7][7] = {{0, 1, 2, 4, 6, 7, 9},
                         {2, 4, 5, 7, 9, 10, 12},
                         {7, 9, 10, 12, 14, 15, 17},
                         {9, 11, 12, 14, 16, 17, 18},
                         {6, 8, 9, 11, 13, 14, 16},
                         {1, 3, 4, 6, 8, 9, 11},
                         {4, 6, 7, 9, 11, 12, 14}};
        for(int i=0; i<(1 << 19); ++i) {
            bitset<19> b2(i);
            bitset<7> center;
            for(int j=0; j<7; ++j) {
                int t = 0;
                for(int k=0; k<7; ++k) {
                    t |= (b2[idx[j][k]] << k);
                }
                center[j] = bi[t];
            }
            int t = 0;
            int idx2[7] = {0, 5, 1, 6, 4, 2, 3};
            for(int j=0; j<7; ++j) {
                t |= (center[idx2[j]] << j);
            }
            res &= (bi[t] == center[idx2[3]]);
        }
        cout << (res ? "yes" : "no") << endl;
    }
}


Measured memory_bytes: 3100
N =int(input())
xy = [list(map(int,input().split())) for i in range(N)]
from itertools import permutations
res = []
for i in permutations(range(N)):
  s = 0
  for j in range(len(i)-1):
    xa,ya = xy[i[j]]
    xb,yb = xy[i[j+1]]
    s += ((xa-xb)**2+(yb-ya)**2)**(1/2)
  res += [s]
print(sum(res)/len(res))

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  string s;
  int ans = 0;
  cin >> s;
  for (int i = 0; i < s.length() / 2; ++i)
    if (s[i] != s[s.length() - i - 1]) ans++;

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


Measured memory_bytes: 256
from itertools import product

N,A,B,C=list(map(int, input().split()))
L=[int(input()) for _ in range(N)]

answer = 1e9
for X in product('ABCD', repeat=N):
  total_length={'A':0,'B':0,'C':0,'D':0}
  total_nums={'A':0,'B':0,'C':0,'D':0}
  for i, x in enumerate(X):
    total_length[x]+=L[i]
    total_nums[x]+=1
  na = total_nums['A']
  nb = total_nums['B']
  nc = total_nums['C']
  la = total_length['A']
  lb = total_length['B']
  lc = total_length['C']
  
  if na and nb and nc:
    a = (na+nb+nc -3)*10 + abs(la-A) + abs(lb-B) + abs(lc-C)
    answer = min(a,answer)
    
print(answer)
  
    
    


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

int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  if(s < t) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int n;
  cin >> n;
  map<int, int> a;
  int tmp;
  REP(i,n){
    cin >> tmp;
    a[tmp]++;
    a[tmp - 1]++;
    a[tmp + 1]++;
  }
  int ans = 0;
  for(auto itr = a.begin();itr != a.end(); itr++){
    ans = max(ans,itr->second);
  }
  cout << ans << endl;

}


Measured memory_bytes: 4736
/*Coded by::
    **Avinash Tiwary**
    **BE/10298/2015**
    **Production Engineer**
    **Producing <code>**
*/
#include<bits/stdc++.h>
#define buf ios_base::sync_with_stdio (0), cin.tie (0)
typedef long long ll;
typedef double dob;
#define MAX 50010
#define M5 200009
#define M6 2000009
#define M 1000000007
#define inf LLONG_MAX
using namespace std;
typedef vector<ll> V;
typedef queue<ll > Q;
typedef stack<ll> S;
typedef pair<ll,ll> P;
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
ll fac[M6],not_prime[M6];
ll power(ll x,ll n){
    if(n==0) return 1;
    /*while(n){
        if(n%2) x=(((x*x)%M)*x)%M; 
        else x=(x*x)%M;
        n/=2;
    }*/
    if(n%2 == 0) return power((x*x),n/2);
    else return (x*power((x*x),(n-1)/2));
}
void fact(){
    fac[0]=1;
    for(ll i=1;i<M6;i++) fac[i]=(i*fac[i-1])%M;
}
void sieve(){
    not_prime[1]=1; not_prime[0]=1;
    for(ll p=2;p*p<M6;p++){
        if(!not_prime[p]){
            for(ll i=p*2;i<=M6;i+=p) not_prime[i]=1;
        }
    }
}
ll modi(ll a, ll m){
    ll m0 = m, t, q; ll x0 = 0, x1 = 1;
    if (m == 1) return 0;
    while (a > 1){  q = a / m; t = m; m = a % m, a = t;t = x0;x0 = x1 - q * x0; x1 = t;}
    if (x1 < 0) x1 += m0;return x1;
}
ll n,m,vis[M6];
V g[M5];
/*ll solve(ll sor,ll des){
	if(sor==des) return 1;
	else return 0;
	if(dp[sor][des]!=-1) return dp[sor][des];
	ll i,ans=0;
	for(i=1;i<=n;i++){
		if(connect[i][des]){
			ans+=solve(n,i); ans%=M;
		}
	}
	return dp[sor][des]=ans;
}*/
int main(){
    //buf; 
    //fact();
    //sieve()
    ll i,j,k,l,test,flag,ans,x,y; string s;
    //cin>>test;
    test=1;
    while(test--){
    	cin>>n;
    	set<ll> ss;
    	for(i=1;i<=n;i++){ cin>>k; ss.insert(k);}
    		cout<<ss.size();
	}
    return 0;
}

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

int main()
{
    long long l,r;
    cin >> l >> r;

    if(r - l + 1 >= 2019)cout << 0 << endl;
    else
    {
        long long ans = 2020 * 2020;
        for (long long i = l; i <= r; i++)
        {
            for (long long j = i + 1; j <= r; j++)
            {
                if(ans > (i * j) % 2019)ans = (i * j) % 2019;
            }
        }
        
        cout << ans << endl;
    }
    
}

Measured memory_bytes: 256
# sys.stdin.readline()
import sys
import math
input = sys.stdin.readline

n = input()
if '000' in n or '111' in n or '222' in n or '333' in n or '444' in n or '555' in n or '666' in n or '777' in n or '888' in n or '999' in n:
    ans = 'Yes'
else:
    ans = 'No'
print(ans)

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i]
#define sq(n) (n)*(n)

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    VI(a,n);
    VI(b,n);
    int ans=0;
    int s=0;
    vi c;
    rep(i,n){
        if(a[i]<b[i]){
            ans++;
            s+=b[i]-a[i];
        }
        else c.pb(a[i]-b[i]);
    }
    RSORT(c);
    int ss=0;
    rep(i,c.size()){
        if(ss>=s)break;
        ans++;
        ss+=c[i];
    }
    if(ss<s)cout<<-1<<endl;
    else cout<<ans<<endl;
}

Measured memory_bytes: 2936
fun main(args: Array<String>) {
    val S = readLine()!!
    val map = mapOf("SUN" to 7, "MON" to 6, "TUE" to 5, "WED" to 4, "THU" to 3, "FRI" to 2, "SAT" to 1)
    println(map[S])
}

Measured memory_bytes: 33912
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
  int n,h;
  cin >> n >> h;
  vector<int> a(n);
  vector<int> b(n);
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];

  }
  int amax;
  amax=*max_element(a.begin(), a.end());
  sort(b.begin(),b.end(),greater<int>());
  int result=0;

  for(int i=0; i<n;i++)
  {
    if(b[i]<amax){break;}
    h-=b[i];
    result+=1;
    if(h<=0){break;}
  }
  if(h>0){result+=h/amax+1*(h%amax!=0);}
  cout << result <<endl;

}

Measured memory_bytes: 1024
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    int m = 0;
    int j = 0;
    ll ans = 0;
    rep(i, n) {
        while( j < n && ( m & a[j] ) == 0 ) {
            m ^= a[j];
            ++j;
        }
        ans += j - i;
        m ^= a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1152
#include<iostream>
using namespace std;
int main() {
    int n, k; cin >> n >> k;
    int cnt = 0;
    for (int i = 1; i <= n; i += 2) {
        cnt++;
    }
    if (cnt >= k) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main() {
    int n;
    cin>>n;
    ll x[n],y[n],h[n];
    rep(i,n) cin>>x[i]>>y[i]>>h[i];

    rep(cx,101){
        rep(cy,101){
            bool ok=true;
            ll H=0;
            rep(i,n){
                if(h[i]==0) continue;
                H=abs(x[i]-cx)+abs(y[i]-cy)+h[i];
                break;
            }
            if(H<1) ok=false;

            rep(i,n){
            
                ll tmp=max(H-abs(x[i]-cx)-abs(y[i]-cy),0LL);
                if(tmp!=h[i]) ok=false;
            }
            if(ok){
                cout<<cx<<" "<<cy<<" "<<H<<endl;
                return 0;
            }
        }
    }
}



Measured memory_bytes: 256
a = input()
b = input()
	
ans = "EQUAL"
la, lb = len(a), len(b)
if la < lb:
	ans = "LESS"
elif la > lb:
	ans = "GREATER"
else:
	for i in range(la):
		if a[i] < b[i]:
			ans = "LESS"
			break
		elif a[i] > b[i]:
			ans = "GREATER"
			break
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define PI 3.14159265358979
#define ll long long
using namespace std;

int main()
{
	int a, b, c, k;
	cin >> a >> b >> c >> k;

	if (k <= a) {
		printf("%d", k);
	} else if (k <= a + b) {
		printf("%d", a);
	} else {
		k -= a;
		k -= b;
		printf("%d", a - k);
	}

	return 0;
}



Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define N 998244353
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vll vector<long long>
#define INF 1000000000
 
ll modInverse(ll a, ll m);
ll gcd(ll a, ll b);
ll power(ll x, unsigned ll y, unsigned ll m);
ll logint(ll x,ll y);
 
 
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b%a, a);
}
 
ll power(ll x, unsigned ll y, unsigned ll m)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m;
 
    return (y%2 == 0)? p : (x * p) % m;
}
 
ll modInverse(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
 
    if (m == 1)
      return 0;
 
    while (a > 1)
    {
        // q is quotient
        ll q = a / m;
        ll t = m;
 
        // m is remainder now, process same as
        // Euclid's algo
        m = a % m, a = t;
        t = y;
 
        // Update y and x
        y = x - q * y;
        x = t;
    }
 
    // Make x positive
    if (x < 0)
       x += m0;
 
    return x;
}
 
void pairsort(ll a[],ll b[], ll n)
{
    pair<ll, ll> pairt[n];
 
    // Storing the respective array
    // elements in pairs.
    for (ll i = 0; i < n; i++)
    {
        pairt[i].first = a[i];
        pairt[i].second = b[i];
    }
 
    // Sorting the pair array.
    sort(pairt, pairt + n);
 
    // Modifying original arrays
    for (ll i = 0; i < n; i++)
    {
        a[i] = pairt[i].first;
        b[i] = pairt[i].second;
    }
}
 
ll logint(ll x,ll y)
{
    ll ans=0;
    ll a=1;
    for(ll i=0;i<x;i++)
    {
        if(x<=a)
        {
            return ans;
        }
        ans++;
        a*=y;
    }
    return -1;
}
bool dp[1001][1001];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */
    ll n;
    cin>>n;
    cout<<(n*(n-1))/2;
}

Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

enum OperationType : int32_t { kDouble = 0, kTriple, kQuintuple, kIncrement, kDecrement, kNumberOfOperations };

struct Operation {
  int64_t coins{0};
  int64_t ratio{-1};
};

class Solution {
 public:
  Solution() = delete;
  Solution(const int64_t A, const int64_t B, const int64_t C, const int64_t D) noexcept;
  int64_t CalculateMinimumAmountOfCoins(const int64_t goal) noexcept;

 private:
  Operation operations_[kNumberOfOperations];
  std::map<int64_t, int64_t> min_coins_;
};

Solution::Solution(const int64_t A, const int64_t B, const int64_t C, const int64_t D) noexcept {
  operations_[kDouble].coins = A;
  operations_[kDouble].ratio = 2;

  operations_[kTriple].coins = B;
  operations_[kTriple].ratio = 3;

  operations_[kQuintuple].coins = C;
  operations_[kQuintuple].ratio = 5;

  operations_[kIncrement].coins = D;

  operations_[kDecrement].coins = D;

  min_coins_[0] = 0;
  min_coins_[1] = operations_[kDecrement].coins;
}

int64_t Solution::CalculateMinimumAmountOfCoins(const int64_t goal) noexcept {
  if (min_coins_.count(goal) > 0) {
    return min_coins_[goal];
  }

  int64_t result = INT64_MAX;
  if (goal < result / operations_[kIncrement].coins) {
    result = goal * operations_[kIncrement].coins;
  }

  const OperationType next_operations[] = {kDouble, kTriple, kQuintuple};
  for (const OperationType next : next_operations) {
    const Operation &operation = operations_[next];
    if (goal % operation.ratio == 0) {
      int64_t temp_result = CalculateMinimumAmountOfCoins(goal / operation.ratio);
      if (temp_result != INT64_MAX) {
        temp_result += operation.coins;
        result = std::min(temp_result, result);
      }
    } else {
      const int64_t r = goal / operation.ratio;

      {  // Lower Bound
        const int64_t lower_bound = r * operation.ratio;
        int64_t temp_result = CalculateMinimumAmountOfCoins(lower_bound / operation.ratio);
        if (temp_result != INT64_MAX) {
          temp_result += operation.coins + (goal - lower_bound) * operations_[kIncrement].coins;
          result = std::min(temp_result, result);
        }
      }

      {  // Upper Bound
        const int64_t upper_bound = (r + 1LL) * operation.ratio;
        int64_t temp_result = CalculateMinimumAmountOfCoins(upper_bound / operation.ratio);
        if (temp_result != INT64_MAX) {
          temp_result += operation.coins + (upper_bound - goal) * operations_[kDecrement].coins;
          result = std::min(temp_result, result);
        }
      }
    }
  }
  min_coins_[goal] = result;
  return result;
}

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

  int64_t T;
  cin >> T;
  for (int64_t i = 0LL; i < T; ++i) {
    int64_t N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;

    Solution *solution = new Solution(A, B, C, D);
    const int64_t result = solution->CalculateMinimumAmountOfCoins(N);
    cout << result << endl;
    delete solution;
  }

  return 0;
}


Measured memory_bytes: 4292
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */

#define MAXN (100000)

char s[MAXN+1];
char t[MAXN+1];

int ci[26][MAXN+1];



int main(void)
{
    scanf("%s",s);
    scanf("%s",t);
    int slen = strlen(s);
    int tlen = strlen(t);

    for(int i=0;s[i]!='\0';i++){
        for(int j=i; (ci[s[i]-'a'][j]==0)&& j>=0; j--)
        {
            ci[s[i]-'a'][j] = i+1;
        }
    }
    for(int i=0;i<26;i++)
    {
        for(int j=slen-1;(ci[i][j]==0)&& j>=0; j--)
        {
            ci[i][j] = ci[i][0];
        }
    }

    // for(int i=0;i<26;i++)
    // {
    //     printf("%c: ",'a'+i);
    //     for(int j=0;j<slen;j++)
    //     {
    //         printf("%d ",ci[i][j]);
    //     }
    //     printf("\n");
    // }
    uint64_t ans = 0;
    int ni = slen-1;
    for(int i=0;t[i]!='\0';i++){
        int ti = ci[t[i]-'a'][(ni+1)%slen];
        if(ti==0)
        {
            printf("-1\n");
            return 0;
        }
        ti--;
        if(ti > ni)
        {
            ans += ti - ni;
        }else
        {
            ans += slen + ti - ni;
        }
        // printf("%d %d %ld\n", ni, ti, ans);
        ni = ti;
    }
    printf("%ld\n",ans);
    return 0;
}




Measured memory_bytes: 10496
a['   '],m,j;main(i){for(;i++<6e4;a[i]=m)for(!a[j=i]?m=i:0;j<6e4;a[j+=i]=1);for(;~scanf("%d",&j);printf("%d %d\n",a[j-1],m))for(m=j;a[j]==a[++m];);}

Measured memory_bytes: 0
n = int(input())
pp = list(map(int, input().split()))
cnt = 0
for i in range(n-1):
    if pp[i] == i + 1:
        pp[i], pp[i+1] = pp[i+1], pp[i]
        cnt += 1
if pp[n-1] == n:
    cnt += 1
print(cnt)

Measured memory_bytes: 14008
operator fun Pair<Int, Int>.plus(pair: Pair<Int, Int>) = Pair(first + pair.first, second + pair.second)
operator fun Pair<Int, Int>.minus(pair: Pair<Int, Int>) = Pair(first - pair.first, second - pair.second)
fun Pair<Int, Int>.manhattanTo(pair: Pair<Int, Int>) = (this - pair).manhattanLength()
fun Pair<Int, Int>.manhattanLength() = Math.abs(first) + Math.abs(second)

private fun List<IntRange>.zipWithIndices() =
        mapIndexed { first, range ->
            range.map { second -> Pair(first, second) }
        }.flatten()

fun main(args: Array<String>) {
    val (H, W, D) = readLine()!!.split(" ").map { it.toInt() }
    val A = (0 until H).map { readLine()!!.split(" ").map { it.toInt() } }
    val numberCache = {
        val result = mutableMapOf<Int, Pair<Int, Int>>()
        (0 until H).map{ (0 until W) }.zipWithIndices().forEach { pair ->
            val (h, w) = pair
            result[A[h][w]] = Pair(h, w)
        }
        result
    }()

    val mpCache: Map<Int, Int> = {
        val result = mutableMapOf<Int, Int>()
        (1 until D + 1).forEach { width ->
            var index = width
            while (index <= H * W) {
                val prevIndex = index - D
                val totalMp = result[prevIndex]?.let { previous ->
                    val diff = numberCache[prevIndex]!!.manhattanTo(numberCache[index]!!)
                    previous + diff
                } ?: 0

                result[index] = totalMp
                index += width
            }
        }
        result
    }()

    val Q = readLine()!!.toInt()
    (0 until Q).forEach {
        val (L, R) = readLine()!!.split(" ").map { it.toInt() }
        println(mpCache[R]!! - mpCache[L]!!)
    }
}

Measured memory_bytes: 110116
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int s = sc.nextInt();
    int w = sc.nextInt();
    if(s <= w){
      System.out.println("unsafe");
    }else{
      System.out.println("safe");
    }
  }
}

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

if N < 10: # 1桁
    print(N)
elif N < 100: # 2桁
    print(9)
elif N < 1000: # 3桁
    print(9 + (N - 99))
elif N < 10000: # 4桁
    print(9 + 900)
elif N < 100000: # 5桁
    print(9 + 900 + (N - 9999))
elif N == 100000: # 6桁
    print(9 + 900 + 90000)


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

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

const int offset=30;
int xl[60];
int xr[60];

int main(void){
	int r,n;
	while(cin >> r >> n){
		if(r==0)
			break;
		rep(i,60) xl[i]=xr[i]=0;
		rep(i,n){
			int l,r,h;
			cin >> l >> r >> h;
			l+=offset,r+=offset;
			for(int j=l;j<=r;++j){
				if(j!=l)
					xl[j]=max(xl[j],h);
				if(j!=r)
					xr[j]=max(xr[j],h);
			}
		}
		double cmin=inf;
		for(int x=-r;x<=r;++x){
			int h=inf;
			if(x!=-r)h=min(h,xl[x+offset]);
			if(x!=r)h=min(h,xr[x+offset]);

			int diff=r*r-x*x;
			if(diff<0){

			}
			double y=sqrt(diff);
			double t=h-y+r;
			cmin=min(cmin,t);
		}
		cout.precision(9);
		cout << fixed << max(cmin,0.0) << endl;
	}
	return 0;
}

Measured memory_bytes: 1236
# X = [29, 20, 7, 35, 120]
# X = [101, 86, 119, 108, 57]
# X = [123, 123, 123, 123, 123]

X = []

for _ in range(5):
    X.append(int(input()))  # S += [input()] とも書ける


a = 9
last_i = 0
for i, j in enumerate(X):
    num1 = int(str(j)[-1])

    if 0 < num1 < a:
        a = num1
        last_i = i

res = []
for x, y in enumerate(X):
    if x == last_i or y % 10 == 0:
        res.append(y)
    else:
        m = 10 - int(str(y)[-1])
        # print(m)
        res.append(y + m)
# print(res)
print(sum(res))


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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define END(x) cout << x << endl; exit(0);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, minimum, maximum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
    cin >> n >> m >> x >> y;
    vl xs(n), ys(m);
    NREP() {
        cin >> xs[i];
    }

    MREP() {
        cin >> ys[j];
    }

    for (int z = -100; z <= 100; ++z) {
        bool is_ok = true;
        NREP() {
            if (xs[i] >= z) {
                is_ok = false;
                continue;
            }
        }
        if (!is_ok) continue;
        MREP() {
            if (ys[j] < z) {
                is_ok = false;
                continue;
            }
        }
        if (is_ok && x < z && z <= y) {
            END("No War")
        }
    }
    MSG("War")
}


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

int main() {
  double a, b, c, d, e, f;
  while (cin >> a >> b >> c >> d >> e >> f) {
    double x = (c * e - b * f) / (a * e - b * d);
    double y = (c - a * x) / b;
    cout << fixed << setprecision(3) << x + 0 << " " << y + 0 << endl;
  }
  return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 62;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  ll n; cin >> n;
  vector<ll> vec(5);
  rep(i, 5) cin >> vec[i];
  ll ans = (ll)ceil((double)n / *min_element(ALL(vec))) + 4;
  cout << ans << endl;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cstring>
#include <map>
#define INT long long
#define MOD 1000000007
#define oo 987654321
#define OO 99999999987654321LL
using namespace std;

INT n, s[100010], ans;
map<INT, INT> dt[100010], chk[100010];

INT dp(int x, int m, INT v)
{
    if( x == n ) return 0;
    if( chk[x][v] ) return dt[x][v];
    chk[x][v] = 1;
    INT &ret = dt[x][v];
    ret = max( dp(x+1, ((m<<1)+0)&3, s[x+1]-min(v%2, s[x+1])) + v/2 + min(v%2, s[x+1]), dp(x+1, ((m<<1)+1)&3, s[x+1]-min(v,s[x+1])) + min(v, s[x+1]) + (v - min(v, s[x+1]))/2 );
    return ret;
}

int main()
{
    scanf("%lld", &n);
    for(int i = 0 ; i  < n ; i++ )
        scanf("%lld", s+i);
    printf("%lld\n", dp(0, 0, s[0]));
    return 0;
}

Measured memory_bytes: 85888
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const ll INF = 1<<30;
const ll MOD = (ll)1e9 + 7;
const ll MAX_N = (ll)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    ll n; cin >> n;
    if(n % 2)
    {
        cout << 0 << endl;
        return 0;
    }
    vector<ll> p;
    ll k = pow(10LL, 18LL);
    for(ll f = 5; f <= k; f *= 5)
    {
        p.push_back(f);
    }
    ll ans = 0;
    for(int i = 0; i < p.size(); i++)
    {
        ans += n / (p[i] * 2);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int n=stdIn.nextInt(),t=n,s=0;
		do {
			s+=t%10;
			t/=10;
		}while(t>0);
		System.out.print(n%s!=0?"No":"Yes");
	}
}

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

using namespace std;

int main()
{
    string s;
    cin >> s;
    set<char> st;
    for (int i = 0; i < 4; i++){
        st.insert(s[i]);
    }
    if ((int) st.size() == 2){
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N=sc.nextInt();
    int AC=0;
    int WA=0;
    int TLE=0;
    int RE=0;
    
    for(int i=0; i<N; i++)
    {String S=sc.next();
    if(S.equals("AC"))
    	AC++;
    if(S.equals("WA"))
    	WA++;
    if(S.equals("TLE"))
    	TLE++;
    if(S.equals("RE"))
    	RE++;
    		 }
	System.out.println("AC x "+AC);
	System.out.println("WA x "+WA);
	System.out.println("TLE x "+TLE);
	System.out.println("RE x "+RE);
  }
}

Measured memory_bytes: 58244
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;
static const int MAX_N = 20;

int n;
string s[MAX_N];

int rec(int cur){
	char ch = s[cur][s[cur].length() - 1];
	if(isdigit(ch)) return ch - '0';
	int ret;
	if(ch == '+') ret = 0;
	else ret = 1;
	for(int i = cur + 1; i < n; i++){
		if(s[i].length() <= s[cur].length()) break;
		if(s[i].length() == s[cur].length() + 1){
			if(ch == '+') ret += rec(i);
			else ret *= rec(i);
		}
	}
	return ret;
}

int main(){
	for(;;){
		scanf("%d", &n);
		if(n == 0) break;
		for(int i = 0; i < n; i++) cin >> s[i];
		printf("%d\n", rec(0));
	}
	return 0;
}


Measured memory_bytes: 3352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[m];
		
		a[0] = sc.nextInt();
		for (int i = 1; i < n; i++) {
			a[i] = a[i-1] + sc.nextInt();
		}
		b[0] = sc.nextInt();
		for (int i = 1; i < m; i++) {
			b[i] = b[i-1] + sc.nextInt();
		}
		sc.close();
		
		int ans = 0;
		
		int j = 0;
		for (int i = 0; i < a.length; i++) {
			if(j > 0) j--;
			if(a[i] > k) break;
			ans = Math.max(ans, i+1);
			for (; j < b.length; j++) {
				if(a[i] + b[j] > k) {
					break;
				}
				ans = Math.max(ans, i+j+2);
			}
		}

		for (j = 0; j < b.length; j++) {
			if(b[j] > k) {
				break;
			}
			ans = Math.max(ans, j+1);
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 61652
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <cmath>
#include <queue>
#include <numeric>


int main()
{
	std::string s;

	std::cin >> s;

	for (size_t i = 0; i < s.length(); i++)
	{
		if (i == 3) {
			s[i] = '8';
		}
		std::cout << s[i];
	}

	return 0;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

constexpr llong mod = 1e9+7;
constexpr llong inf = mod * mod;

int main() {
  llong N, K;
  vector<lpair> xy;

  cin >> N >> K;
  xy.resize(N);
  for (auto &in: xy) {
    cin >> in.first >> in.second;
  }
  sort(ALL(xy));

  llong ans = LLONG_MAX;
  for (int xl = 0; xl < N; xl++) {
    for (int xr = xl + 1; xr < N; xr++) {
      vector<int> y;
      for (int i = xl; i <= xr; i++) {
        y.push_back(xy[i].second);
      }
      sort(ALL(y));
      for (int yl = 0; yl + K - 1 < y.size(); yl++) {
        int yr = yl + K - 1;
        ans = min(ans, (xy[xr].first - xy[xl].first) * (y[yr] - y[yl]));
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3552
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc090.contest.atcoder.jp/tasks/arc090_a>
問題文============================================================
 2×N のマス目があります。上から i 行目、左から j 列目 (1≤i≤2, 1≤j≤N) のマスをマス (i,j) と表すことにします。
 
 あなたははじめ、左上のマス (1,1) にいます。
 あなたは、右方向または下方向への移動を繰り返し、右下のマス (2,N) に移動しようとしています。
 
 マス (i,j) には Ai,j 個のアメが置かれています。
 あなたは移動中に通ったマスに置いてあるアメをすべて回収します。
 左上および右下のマスにもアメが置かれており、あなたはこれらのマスに置かれているアメも回収します。
 
 移動方法をうまく選んだとき、最大で何個のアメを回収できるでしょうか。
=================================================================

解説=============================================================
 dp[i][j] := マス(i,j)に到達した時点で持っている（(i,j)のあめは未回収）あめの数
================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<vector<ll>> A(2,vector<ll>(N));
    for(int i = 0; i < 2;i++)for(int j = 0; j < N;j++) cin >> A[i][j];
    vector<vector<ll>> dp(3,vector<ll>(N+1,0));
    for(int i = 0; i < 2;i++){
        for(int j = 0; j < N;j++){
            dp[i+1][j] = max(dp[i+1][j],dp[i][j]+A[i][j]);
            dp[i][j+1] = max(dp[i][j+1],dp[i][j]+A[i][j]);
        }
    }
    cout << dp[1][N-1] + A[1][N-1] << endl;
	return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;

  vector<bool> A(N, false);

  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int A_i;
      cin >> A_i;
      A_i--;
      A[A_i] = true;
    }
  }

  int sum = 0;
  for (bool item : A) {
    if (!item) sum++;
  }

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3628