akhauriyash/Code-Regression huggingface dataset:
N = int(input())
a = list(map(int, input().split()))

n1, n2, n4 = 0, 0, 0
for i in range(N):
    if a[i] % 2:
        n1 += 1
    elif a[i] % 4:
        n2 += 1
    else:
        n4 += 1

if n2 == 0:
    if n1 <= n4 + 1:
        print('Yes')
    else:
        print('No')
else:
    if n1 <= n4:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 14252
N = int(input())
S = input().split()
a = list(map(int,S))
count = 1
broken = 0
flag = False

for i in range(N):
  if a[i] == count :
    count = count + 1
    broken = broken + 1
    flag = True

if flag :
  print(N - broken)
else :
  print(-1)

Measured memory_bytes: 24744
class Heap
  attr_reader :size
  def initialize(up: false)
    @up = up
    @heap = []
    @size = 0
  end
  def sum
    x = 0
    @size.times do |i|
      x += @heap[i]
    end
    x
  end
  def push(n)
    n = -n if @up
    i = @size
    while i > 0
      pid = (i - 1) / 2
      break if n >= @heap[pid]
      @heap[i] = @heap[pid]
      i = pid
    end
    @heap[i] = n
    @size += 1
  end
  def pop
    top = @heap[0]
    @size -= 1
    n = @heap[@size]
    i = 0
    while i * 2 + 1 < @size
      cid1 = i * 2 + 1
      cid2 = cid1 + 1
      if cid2 < @size && @heap[cid2] < @heap[cid1]
        cid1 = cid2
      end
      break if @heap[cid1] >= n
      @heap[i] = @heap[cid1]
      i = cid1
    end
    @heap[i] = n
    if @up
      -top
    else
      top
    end
  end
end

gets
a = gets.split.map(&:to_i)
h = Heap.new(up: true)
a.each do |x|
  h.push(x)
end
while h.size > 1
  u = h.pop
  v = h.pop
  h.push(u - 1) if u - 1 > 0
  h.push(v - 1) if v - 1 > 0
end
p h.pop - 1

Measured memory_bytes: 1788
#include<stdio.h>
int main(void)
{
	int a,b,c,x,y,z,ans;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b){
		x=a-b;
	}
	else{
		x=b-a;
	}
	if(b>c){
		y=b-c;
	}
	else{
		y=c-b;
	}
	if(a>c){
		z=a-c;
	}
	else{
		z=c-a;
	}
	if(x>=y && x>=z){
		ans=y+z;
	}
	else if(y>=x && y>=z){
		ans=x+z;
	}
	else if(z>=x && z>=y){
		ans=x+y;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long
inline int read(){
	char c=getchar();while (c!='-'&&(c<'0'||c>'9'))c=getchar();
	int k=1,kk=0;if (c=='-')c=getchar(),k=-1;
	while (c>='0'&&c<='9')kk=kk*10+c-'0',c=getchar();return kk*k;
}using namespace std;
void write(int x){if (x<0)putchar('-'),x=-x;if (x)write(x/10),putchar(x%10+'0');}
void writeln(int x){write(x);if (x==0)putchar('0');puts("");}
int n,a[1000000],f[1000000],l,r,ll,rr;
signed main(){
	n=read();for (int i=1;i<=n;i++)a[i]=read(),f[i]=max(f[i-1]/a[i]*a[i],a[i]);l=2;r=3;
	if (a[n]!=2||f[n]>2)return puts("-1"),0;
	for (int i=n-1;i>=1;i--){
		ll=l/a[i]*a[i];if (ll<l)ll+=a[i];l=ll;
		rr=r/a[i]*a[i];r=rr+a[i]-1;if (l>r)return puts("-1"),0;
	}if (l<=r)cout<<l<<' '<<r<<endl;else puts("-1");
}

Measured memory_bytes: 5120
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define SIZE_OF_ARRAY(a) (sizeof(a)/sizeof(a[0]))



int main(){
    int ans;
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int a[N];
    for(int i = 0;i < N;i++){
        cin >> a[i] ;
    }
    int flag = 0;
    for(int i = 0;i < 100000000;i++){
        for(int i = 0;i < N;i++){
            if(a[i] % 2 == 1){
                flag = 1;
            }
        }
        if(flag == 1){
            break;
        }else{
            for(int i = 0;i < N;i++){
                a[i] = a[i] / 2;
            }
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define deb(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;

typedef long long int ll;
typedef string str;

ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;     
  
    x = x % p;   
    while (y) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;  
        x = (x*x) % p; 
    } 
    return res; 
} 
 
ll nCrModP(ll n, ll r, ll p) 
{ 
    if (!r) 
      return 1; 
  
	ll fac[n+1]; 
   	fac[0] = 1; 
    for (ll i=1 ; i<=n; i++) 
        fac[i] = fac[i-1]*i%p; 
  
    return (fac[n]* power(fac[r], p-2,p) % p * power(fac[n-r], p-2,p) % p) % p; 
}

ll gcd(ll a, ll b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);
}

void fast(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}



int main ()
{
	
	ll t,n,m,k,i,j;
	cin >> t;
    ll arr[5]={0};
    str s;
    while(t--)
    {
        cin >> s;
        if(s[0]=='A')
            arr[0]++;
        if(s[0]=='W')
            arr[1]++;
        if(s[0]=='T')
            arr[2]++;
        if(s[0]=='R')
            arr[3]++;
    }
    cout << "AC x " << arr[0] << "\n";
    cout << "WA x " << arr[1] << "\n";
    cout << "TLE x " << arr[2] << "\n";
    cout << "RE x " << arr[3] << "\n";
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>

int main() {
    int N;
    std::string c;
    std::cin >> N >> c;
    int ans = 0;
    int right = N - 1;
    for (int left = 0; left < N; left++) {
        if (c[left] == 'W') {
            while (c[right] == 'W') {
                right--;
            }
            if (right <= left) {
                std::cout << ans << std::endl;
                exit(0);
            }
            else {
                ans++;
                right--;
            }
        }
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 3936
#include <cstdint>

using namespace std;

#define MEMO_SIZE 45
int64_t memo[MEMO_SIZE];

void fib_init()
{
  for (uint32_t i = 0; i < MEMO_SIZE; i++) {
    memo[i] = -1;
  }
}

uint32_t fib(uint32_t i)
{
  if (i == 0) {
    return memo[0] = 1;
  } else if (i == 1) {
    return memo[1] = 1;
  } else {
    if (memo[i] != -1)
      return memo[i];
    else {
      return memo[i] = fib(i - 1) + fib(i - 2);
    }
  }
}

#include <iostream>

int32_t main()
{
  fib_init();
  uint32_t i;
  cin >> i;
  cout << fib(i) << endl;
  return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N;
    cin >> N;
    vector<double> t(N), v(N);
    REP(i, N) { cin >> t[i]; }
    REP(i, N) { cin >> v[i]; }
    int T = accumulate(t.begin(), t.end(), 0);
    // maxv i t=iのときの最大
    vector<double> maxv(2 * T + 1, 10000000);
    int time = 1;
    int nowT = 0;
    REP(i, N) {
        for(int ti = 0; ti < t[i]; ti++) {
            int t1 = nowT + ti * 2;
            int t2 = nowT + ti * 2 + 1;
            maxv[t1] = min(maxv[t1], v[i]);
            maxv[t2] = min(maxv[t2], v[i]);
        }
        nowT += t[i] * 2;
        maxv[nowT] = min(maxv[nowT], v[i]);
    }
    maxv[0] = 0;
    maxv[2 * T] = 0;
    // cout << "T " << T << endl;
    for(int i = 0; i < 2 * T + 1; i++) {
        maxv[i + 1] = min(maxv[i + 1], maxv[i] + 0.5);
    }
    for(int i = 2 * T - 1; i >= 0; i--) {
        maxv[i] = min(maxv[i], maxv[i + 1] + 0.5);
    }
    double ans = 0;
    for(int i = 0; i < 2 * T; i++) {
        // cout << i << ":::" << maxv[i] << endl;
        ans += (maxv[i] + maxv[i + 1]) / 2 / 2;
    }
    printf("%.4f\n", ans);
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner  scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }
        int[] dp = new int[n];
        dp[0] = 0;
        dp[1] = Math.abs(arr[1]-arr[0]);
        for (int i = 2; i < n; i++) {
            dp[i] = Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));
        }
        System.out.println(dp[n-1]);
    }
}

Measured memory_bytes: 59704
N = int(input())
d = [int(input()) for i in range(N)]
a = 0
b = 0
e = sorted(d)

while b == 0:
    for l in range(N):
        if e[l-1] < e[l]:
            a += 1
        else:
            b += 1

print(a+1)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};

int main(){
	const int MAX=100001;
	int N;
	cin>>N;
	ll A[MAX]={};
	ll S[MAX]={};
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	sort(A,A+N);
	for(int i=0;i<N;i++){
		S[i]=A[i];
	}
	for(int i=1;i<N;i++){
		S[i]+=S[i-1];
	}
	for(int i=N-1;i>=0;i--){
		if(2*S[i-1]<A[i]){
			cout<<N-i<<endl;
			return 0;
		}
	}
	return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int64_t> h(N);
  for (int i=0; i<N; i++) {
    cin >> h.at(i);
  }
  sort(h.begin(), h.end());
  int64_t remainder = 1000000000;
  for (int i=0; i<N-K+1; i++) {
    remainder = min(remainder, h.at(i+K-1)-h.at(i));
  }
  cout << remainder << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  int n,k;
  cin>>n>>k;
  cout<<(n+k-3)/(k-1)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const int inf = 0x3f3f3f3f;
const int N = 1e5 + 5;
int ap[N], bp[N];

int main() {
	int a, b, m, x, y, c = inf, ans = 0;
	std::cin >> a >> b >> m;
	for (int i = 1; i <= a; ++i) {
		std::cin >> ap[i];
		c = std::min(c, ap[i]);
	}
	ans += c, c = inf;
	for (int i = 1; i <= b; ++i) {
		std::cin >> bp[i];
		c = std::min(c, bp[i]);
	}
	ans += c;
	for (int i = 1; i <= m; ++i) {
		std::cin >> x >> y >> c;
		ans = std::min(ans, ap[x] + bp[y] - c);
	}
	std::cout << ans;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(){
  int n;
  cin >> n;
  int k = n%10;
  if (k == 2 || k == 4 || k == 5 || k == 7 || k == 9){
    cout << "hon\n";
  }
  else if (k == 0 || k == 1 || k == 6 ||  k == 8){
    cout << "pon\n";
  }
  else {
    cout << "bon\n";
  }
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    string s;
    cin >> s;
    string ans = "";
    rep(i,s.length()){
        if(i == 4) {
            ans += " ";
            ans += s[i];
        }else{
            ans += s[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3664
N=int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = sum(B)
for i in range(1, N):
    if A[i] - A[i-1] == 1:
        ans = ans + C[A[i]-2]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  ll h,k,w;
  cin >> h >> w >> k;
  vector<vector<ll>> vec(h,vector<ll>(w));
  string str;
  rep(i,h){
    cin >> str;
    rep(j,w){
      if(str[j] == '.'){
        vec[i][j] = 0;
      }else{
        vec[i][j] = 1;
      }
    }
  }
  vector<ll> vec1(h);
  vector<ll> vec2(w);
  ll sum;
  ll ans = 0;
  rep(i,1<<h){
    rep(j,1<<w){
      //cout << i << j << endl;
      t1 = i;
      t2 = j;
      rep(p,h){
        if(t1 & 1){
          vec1[p] = 1;
        }else{
          vec1[p] = 0;
        }
        t1 = t1/2;
      }
      rep(q,w){
        if(t2 & 1){
          vec2[q] = 1;
        }else{
          vec2[q] = 0;
        }
        t2 = t2/2;
      }
      sum = 0;
      rep(p,h){
        rep(q,w){
          //cout << vec[p][q] << " " << vec1[p] << " " << vec2[q] << endl;
          if(vec[p][q] && vec1[p] && vec2[q]){
            sum++;
          }
        }
      }
      if(sum == k){
        ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3624
//Created by Young Charlie
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ar array
 

int main() {
	ios::sync_with_stdio(0);	cin.tie(0);
	int n; cin>>n;
	vector<pair<int, int>> a(n);
	for(int i = 0; i < n; i++){
		int x; cin>>x;
		a[i] = make_pair(x, i + 1);
	}
	sort(a.begin(), a.end());
	for(auto x: a){
		cout<<x.second<<" ";
	}
}


Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    using p = array<bool, 255>;
    stack<p> s;
    map<string, p> v;
    int m;
    cin >> m;
    for (int i = 0; i < m; ++i) {
        string x; int a, b;
        cin >> x >> a >> b;
        p k{};
        for (int j = a; j <= b; ++j) {
            k[j] = true;
        }
        v[x] = k;
    }
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string t;
        cin >> t;
        if(v.count(t)){
            s.emplace(v[t]);
        }else if(t.size() == 1 && (t[0] < '0' || t[0] > '9')){
            p b = s.top(); s.pop(); p a = s.top(); s.pop();
            p c{};
            if(t[0] == '+'){
                for (int j = 0; j < 256; ++j) {
                    if(!a[j]) continue;
                    for (int k = 0; k < 256; ++k) {
                        if(!b[k]) continue;
                        c[(j+k)%256] = true;
                    }
                }
            }else if(t[0] == '-'){
                for (int j = 0; j < 256; ++j) {
                    if(!a[j]) continue;
                    for (int k = 0; k < 256; ++k) {
                        if(!b[k]) continue;
                        c[(j+256-k)%256] = true;
                    }
                }
            }else if(t[0] == '*'){
                for (int j = 0; j < 256; ++j) {
                    if(!a[j]) continue;
                    for (int k = 0; k < 256; ++k) {
                        if(!b[k]) continue;
                        c[(j*k)%256] = true;
                    }
                }
            }else {
                for (int j = 0; j < 256; ++j) {
                    if(!a[j]) continue;
                    for (int k = 0; k < 256; ++k) {
                        if(!b[k]) continue;
                        if(k == 0) {
                            puts("error");
                            return 0;
                        }
                        c[(j/k)%256] = true;
                    }
                }
            }
            s.emplace(c);
        }else {
            int k = stoi(t);
            p x{};
            x[k] = true;
            s.emplace(x);
        }
    }
    puts("correct");
    return 0;
}


Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

template <class T>
class SegTree {
    using F = function<T(T, T)>;
    int n;
    vector<T> data;
    const F f;
    const T e;
    
    int find(int a, int b, const T& x, int k, int l, int r) {
        if (data[k] > x || r <= a || b <= l) return -1;
        if (k >= n) {
            return k - n;
        }
        int t = find(a, b, x, 2 * k + 1, (l + r) >> 1, r);
        if (t != -1) return t;
        return find(a, b, x, 2 * k, l, (l + r) >> 1);
    }
    
public:
    SegTree(const vector<T>& as, const F f, const T& e) : f(f), e(e) {
        n = 1;
        while (n < as.size()) n <<= 1;
        data.assign(2 * n, e);
        for (int i = 0; i < as.size(); i++) {
            data[n + i] = as[i];
        }
        for (int i = n - 1; i > 0; i--) {
            data[i] = f(data[2 * i], data[2 * i + 1]);
        }
    }
    
    void update(int k, const T& x) {
        k += n;
        data[k] = x;
        while (k >>= 1) {
            data[k] = f(data[2 * k], data[2 * k + 1]);
        }
    }
    
    T query(int a, int b) {
        T L = e, R = e;
        for (a += n, b += n; a < b; a >>= 1, b >>= 1) {
            if (a & 1) {
                L = f(L, data[a++]);
            }
            if (b & 1) {
                R = f(data[--b], R);
            }
        }
        return f(L, R);
    }
    
    // [a, b)でx以下の値をもつ最右の要素の位置
    int find(int a, int b, const T& x) {
        return find(a, b, x, 1, 0, n);
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.setf(ios::fixed);
    cout.precision(10);
    int n, q;
    cin >> n >> q;
    vi sum(n + 1);
    for (int i = 0; i < n; i++) {
        cin >> sum[i + 1];
        sum[i + 1] += sum[i];
    }
    SegTree<i64> tree(sum, [](i64 a, i64 b){return min(a, b);}, 1e18);
    while (q--) {
        i64 x;
        cin >> x;
        i64 ret = 0;
        for (int i = 1; i <= n; i++) {
            int k = tree.find(i, n + 1, x + sum[i - 1]);
            if (k != -1) {
                assert(k >= i && k <= n);
                ret += k - i + 1;
            }
        }
        cout << ret << endl;
    }
}



Measured memory_bytes: 5748
from collections import deque


def main():
    n, m = map(int, input().split())
    g = [[] for _ in range(n)]
    edge = []
    answer = 0
    for _ in range(m):
        a, b = map(lambda x: int(x) - 1, input().split())
        g[a].append(b)
        g[b].append(a)
        edge.append([a, b])
    for ng in edge:
        ng.sort()
        visited = [0 for _ in range(n)]
        q = deque([0])
        while q:
            now = q.pop()
            if visited[now] == 0:
                visited[now] = 1
                for next_v in g[now]:
                    if ng != sorted([next_v, now]):
                        q.append(next_v)
        if sum(visited) < n:
            answer += 1
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3436
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iterator>
#include <unordered_map>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;

#define mem(a, b) memset(a, b, sizeof(a))
#define REP(i, a) for (int i = 0; i < a; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(a) a.begin(), a.end()

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout << fixed << setprecision(10);
}

inline void print_vector(vector<int> &A){
    for (auto&& x : A){
        cout << x << " ";
    }
    cout << endl;
}

inline void print_array(const int A[], int n) {
    REP(i, n) {
        if (i < n - 1) {
            cout << A[i] << " ";
        } else {
            cout << A[i] << endl;
        }
    }
}

inline void solve() {
    string s;

    cin >> s;

    int res = 0;

    for (auto& x : s) {
        res += x - '0';
    }

    if (res % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    int t = 1;
    // cin >> t;

    for (int _ = 0; _ < t; _++) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3700
#include<iostream>
using namespace std;
int n;
int point[100];
int ranks(int a) {
	int count = 0;
	int smval_c=0;
	for (int i = 0; i < n; i++) {
		if (point[i] >= point[a])count++;
		if (point[i] == point[a])smval_c++;
	
	}
	
	return count-smval_c+1;
}

int main()
{
	int a, b, c, d;
	cin >> n;
	for (int i = 0; i < n*(n-1)/2; i++) {
		cin >> a >> b >> c >> d;
		if (c > d)point[a-1] += 3;
		if (c < d)point[b-1] += 3;
		if (c == d) {
			point[a-1] += 1;
			point[b-1] += 1;
		}
	}
	for (int i = 0; i < n; i++) {
		cout << ranks(i)<<endl;
	}

    return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main(void){
  int N;
  cin >> N;
  int K;
  cin >> K;
  int result = 0;
  vector<int> count(N);
  for(int i = 0; i < N; i++){
    cin >> count.at(i);
    if(count.at(i) >= K){
      result++;
    }
  }
  cout << result;
}

Measured memory_bytes: 640
//https://atcoder.jp/contests/abc122/tasks/abc122_a
#include<iostream>
#include<string>
using namespace std;
int main()
{
	char c;
	cin >> c;
	if (c == 'A') cout << "T";
	if (c == 'T') cout << "A";
	if (c == 'G') cout << "C";
	if (c == 'C') cout << "G";
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    int sum = 0;
    while(m--){
        int a;
        cin>>a;
        sum+=a;
    }
    if(n-sum>=0){
        cout<<n-sum<<endl;
    }
        else{
        cout<<-1<<endl;
    }

}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
const int MN=3005;
const int mod=1e9+7;
const int two=5e8+4;
int n,q,a[MN],X[MN],Y[MN];
int f[MN][MN];
inline ll qpow(ll a,ll b){
	reg ll res=1;
	while(b){
		if(b&1)res=res*a%mod;
		a=a*a%mod;b>>=1;
	}
	return res;
}
int main(){
	scanf("%d%d",&n,&q);
	for(reg int i=1;i<=n;i++)scanf("%d",a+i);
	for(reg int i=1;i<=q;i++)scanf("%d%d",X+i,Y+i);
	for(reg int i=1;i<=n;i++)
		for(reg int j=1;j<=n;j++)
			if(a[i]>a[j])f[i][j]=1;
	for(reg int i=1;i<=q;i++){
		f[X[i]][Y[i]]=f[Y[i]][X[i]]=1ll*(f[X[i]][Y[i]]+f[Y[i]][X[i]])*two%mod;
		for(reg int j=1;j<=n;j++){
			if(j==X[i]||j==Y[i])continue;
			f[X[i]][j]=f[Y[i]][j]=1ll*(f[X[i]][j]+f[Y[i]][j])*two%mod;
			f[j][X[i]]=f[j][Y[i]]=1ll*(f[j][X[i]]+f[j][Y[i]])*two%mod;
		}
	}
	reg ll Ans=0;
	for(reg int i=1;i<=n;i++)
		for(reg int j=i+1;j<=n;j++)
			Ans=(Ans+f[i][j])%mod;
	printf("%d\n",1ll*Ans*qpow(2,q)%mod);
	return 0;
}


Measured memory_bytes: 35456
#include<cstdio>
#include<cstring>
using namespace std;
int d[4][2]={0,1,0,-1,1,0,-1,0};
int b[110][110];
char a[110][110];
void dfs(int x,int y){
	int i;
	int x1,y1;
	for(i=0;i<4;i++){
		x1=x+d[i][0];
		y1=y+d[i][1];
		if(a[x1][y1]==a[x][y]&&b[x1][y1]==0){
			b[x1][y1]=1;
			dfs(x1,y1);
		}
	}
}
int main(){
	int n,m,i,j,ans;
	scanf("%d%d\n",&n,&m);
	while(n!=0){
		memset(a,0,sizeof(a));
		memset(b,0,sizeof(b));
		for(i=1;i<=n;i++){
			scanf("%s",a[i]);
			for(j=m;j>0;j--)
				a[i][j]=a[i][j-1];
			a[i][0]='0';
		}
		ans=0;
		for(i=1;i<=n;i++)
			for(j=1;j<=m;j++)
				if(b[i][j]==0){
					b[i][j]=1;
					dfs(i,j);
					ans++;	
				}
		printf("%d\n",ans);
		scanf("%d%d",&n,&m);
	}
} 


Measured memory_bytes: 3088
def resolve():
    N = int(input())


    def f(x,y,z):
        return x*x + y*y + z*z + x*y + y*z + z*x

    hist = [0] * 100*100*100

    for x in range(1, 100):
        for y in range(1, 100):
            for z in range(1, 100):
                n = f(x,y,z)
                hist[n] += 1

    for i in range(1, N+1):
        print(hist[i])


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 76380
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(char &c){
  int i;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = my_getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    my_putchar_unlocked(c[i]);
  }
}
char S[5];
int main(){
  int i;
  rd(S);
  for(i=(0);i<(3);i++){
    if(S[i]=='7'){
      wt_L("Yes");
      wt_L('\n');
      return 0;
    }
  }
  wt_L("No");
  wt_L('\n');
  return 0;
}
// cLay varsion 20200412-1

// --- original code ---
// char S[5];
// {
//   rd(S);
//   rep(i,3) if(S[i]=='7') wt("Yes"), return 0;
//   wt("No");
// }


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;

int main()
{
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
#include <stdio.h>

static const int MAXNUMOFINPUT = 100;

int bubbleSort(int A[], int N);
int printArray(int A[], int N);

int main()
{
    int i;
    int N;
    int A[MAXNUMOFINPUT];
    int cnt = 0;

    scanf("%d", &N);
    for (i = 0; i < N; i++)
    {
        scanf("%d", &A[i]);
    }

    cnt = bubbleSort(A, N);
    printArray(A, N);
    printf("%d\n", cnt);

    return 0;
}

int bubbleSort(int A[], int N)
{
    int i = 0;
    int j;
    int flag = 1;
    int tmp;
    int cnt = 0;

    while (flag)
    {
        flag = 0;
        for (j = N - 1; j > i; j--)
        {
            if(A[j] < A[j - 1])
            {
                tmp = A[j];
                A[j] = A[j - 1];
                A[j - 1] = tmp;
                flag = 1;
                cnt++;
            }
        }

        i++;
    }

    return cnt;
}

int printArray(int A[], int N)
{
    int i;

    for (i = 0; i < N; i++)
    {
        printf("%d", A[i]);
        if (i < N - 1)
        {
            printf(" ");
        }
    }

    printf("\n");

    return 0;
}



Measured memory_bytes: 2112
#include<stdio.h>
int main()
{
  int H,W;
  char C[180][180];
  int a;
  
  scanf("%d %d",&H,&W);
  for(int i=0;i<H;i++)
    scanf("%s",C[i]);
      
  for(int i=0;i<H*2;i++){
    printf("%s\n",C[i/2]);
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int h,w,x,y,sum,i,sign;
    for(;scanf("%d %d",&h,&w),w;){
        sum=0;
        sign=0;
        char map[100][101]={0};
        for(i=0;i<h;i++)
            scanf("%s",map[i]);
        for(x=0,y=0;map[y][x] != '.';sum++){
            if(map[y][x] == '>')
                x++;
            else if(map[y][x] == '^')
                y--;
            else if(map[y][x] == 'v')
                y++;
            else if(map[y][x] == '<')
                x--;
            if(sum >= h*w){
                sign=1;
                break;
            }
        }
        if(sign == 1)
            printf("LOOP\n");
        else
            printf("%d %d\n",x,y);
    }
    return 0;
}

Measured memory_bytes: 632
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds

def main():
    mod = 10**9+7
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    K,S = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    count=0
    for X in range(0,K+1):
        for Y in range(0,K+1):
            if 0<=S-X-Y<=K:
                count+=1
    print(count)




if __name__ == "__main__":
    main()

Measured memory_bytes: 40556
if __name__ == "__main__":
    n, m, x = map(int, input().split())
    a = list(map(int, input().split()))

    # 左に移動したときと右に移動した時のコストを比較する
    left = 0
    right = 0

    for i in range(m):
        if a[i] < x:
            left += 1

    for i in range(m):
        if a[i] > x:
            right += 1

    print(min([left, right]))


Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var NM = Sarray();
            var N = NM[0];
            var M = NM[1];
            var pathArray = new long[N];
            for (var i = 0; i < M; ++i)
            {
                var ab = Sarray();
                ++pathArray[ab[0] - 1];
                ++pathArray[ab[1] - 1];
            }
            foreach (var p in pathArray)
                WriteLine(p);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
 
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
#define pii pair<ll int, ll int>
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define repi(i, n) for(ll i=0; i<n; i++)
#define rep(i, a, b) for(ll i=a; i<=b; i++)
#define M 1000000007
#define INF 1e18

using namespace std;

int main() {
    ios
    ll n; cin>>n;
    vector <ll> a(n);
    repi(i, n) cin>>a[i];
    ll pre[n];
    pre[0] = a[0];
    rep(i, 1, n-1) pre[i] = pre[i-1] + a[i];
    ll dp[n][n];
    repi(i, n) dp[i][i] = 0;
    repi(i, n-1) dp[i][i+1] = a[i]+a[i+1];
    rep(j, 2, n-1){
        for(ll i=0; i+j<n; i++){
            dp[i][i+j] = INF;
            rep(k, i, i+j){
                dp[i][i+j] = min(dp[i][i+j], dp[i][k] + pre[i+j] - (i>0 ? pre[i-1] : 0) + dp[k+1][i+j]);
            }
        }
    }
    cout<<dp[0][n-1];
    return 0;
}


Measured memory_bytes: 4836
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int const INF = 1001001001;


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

ll n,k;
cin >> n >> k;

vl h(n);
rep(i,n) cin >> h[i];

sort(all(h));

if (n <= k){
    cout << 0 << endl;
    return 0;
}

ll sum = 0;
rep(i,n - k){
    sum += h[i];
}

cout << sum << endl;



return 0;
}

Measured memory_bytes: 1792
x = input()
n = int(x[-1])

if n == 2 or n == 4 or n == 5 or n == 7 or n == 9:
  print("hon")
elif n == 0 or n == 1 or n == 6 or n == 8:
  print("pon")
else:
  print("bon")

Measured memory_bytes: 9132
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0;
#define HERE cout<<"    "<<"HERE"<<en

int main(){
  int n,m;
  cin>>n>>m;
  
  int a[105];
  for(int i=1; i<=n; i++){
    cin>>a[i];
  }
  
  for(int i=1; i<=m; i++){
    for(int j=1; j<=n-1; j++){
      if(a[j]%i>a[j+1]%i) swap(a[j], a[j+1]);
    }
  }
  
  for(int i=1; i<=n; i++){
    cout<<a[i]<<en
  }
}




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

int main() {
  int n, a, b;
  cin>>n>>a>>b;
  if (n == 2) {
    cout<<"Borys"<<endl;
  } else if (abs(a - b) % 2 == 1) {
    cout<<"Borys"<<endl;
  } else {
    cout<<"Alice"<<endl;
  }
}

Measured memory_bytes: 256
package main
import (
  "bufio"
  "fmt"
  "strings"
  "os"
)

func main() {
  solve()
}

func solve() {
  input := bufio.NewScanner(os.Stdin)
  input.Scan()
  
  var five, seven int
  for _, v := range strings.Split(input.Text(), " ") {
    if string(v) == "5" {
      five++
    } else if string(v) == "7" {
      seven++
    }
  }
    if five == 2 && seven == 1 {
      fmt.Println("YES")
    } else {
      fmt.Println("NO")
    }
}
  

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N,M;
  cin>>N>>M;
  vector<int> H(N);
  vector<int> A(M);
  vector<int> B(M);
  rep(i,N){
    cin >> H.at(i);
  }
  vector<int> toudai(N,1);
  rep(i,M){
    int A,B;
    cin>>A>>B;
    if(H.at(A-1)>=H.at(B-1)){
      toudai.at(B-1)=0;
    }
    if(H.at(B-1)>=H.at(A-1)){
      toudai.at(A-1)=0;
    }
  }
  
  int ans=0;
  rep(i,N){
    if(toudai.at(i)==1){
      ans++;
    }
  }
  cout<<ans<<endl;
}


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

int N,Q;
Graph G;
vector<int> res;
void dfs(int s, int p){
    if(s != 0)res[s] += res[p];
    for(auto v : G[s]){
        if(v == p)continue;
        dfs(v,s);
    } 
}

int main(){
    cin >> N >> Q;
    G.resize(N);
    res.resize(N,0);
    rep(i,N-1){
        int u,v;
        cin >> u >> v;
        u--;v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    rep(i,Q){
        int u,cost;
        cin >> u >> cost;
        u--;
        res[u] += cost;
    }
    dfs(0,-1);
    for(auto e : res) {
        cout << e << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 23424
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int k,n;
  cin>>k>>n;
  vector<int> a(n);
  vector<int>b(n);
  for (int i=0;i<n;i++){
    cin>>a[i];
  }
  for (int i=0;i<n;i++){
    if(i==0){
    b[i]=a[n-1]-a[i];
    }
    if (i>0){
     b[i]=a[n-1]-a[i]+k-a[n-1]+a[i-1];
    }
  }
  sort(b.begin(),b.end());
  cout <<b[0]<<endl;
    
}

Measured memory_bytes: 1792
import sys
from itertools import permutations
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    P=tuple(map(int,input().split()))
    Q=tuple(map(int,input().split()))
    p_list=list(permutations(range(1,n+1)))
    print(abs(p_list.index(Q)-p_list.index(P)))

if __name__=='__main__':
    main()

Measured memory_bytes: 8052
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int gcd(int a, int b)
{
  if (a%b==0){
    return(b);
  }
  else{
    return(gcd(b,a%b));
  }
}

int main(){
  int A , B;
  cin >> A >> B;
  if(A == B) cout << 2*A << endl;
  else cout << max(A,B) + max(A-1,B-1) << endl;
  return 0;
}




Measured memory_bytes: 256
#include<stdio.h>
#define NIL -1

typedef struct{
  int depth;
  int parent;
  int left_leaf;
  int sibling;
}node;
 
node A[100000];
int n;

int depth(int now){
  int dep=0;
  while(1){
    if(A[now].parent==NIL)return dep;
    else {
      now=A[now].parent;
      dep++;
    }
  }
}

void init(){
  int i;
  for(i=0;i<n;i++){
    A[i].parent=NIL;
    A[i].left_leaf=NIL;
    A[i].sibling=NIL;
  }
  return;
}

int main(){
  int i,j,now,leaf,k;
  
  scanf("%d",&n);
  init();
  for(i=0;i<n;i++){
    scanf("%d",&now);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&leaf);
      if(j==0){
	A[now].left_leaf=leaf;
	A[leaf].parent=now;
      }
      else {
	A[now].sibling=leaf;
	A[leaf].parent=A[now].parent;
      }   
      now=leaf;
    } 
  } 
  for(i=0;i<n;i++){
    A[i].depth=depth(i);
  } 
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,A[i].parent,A[i].depth);
    if(A[i].parent==NIL)printf("root, ");
    else if(A[i].left_leaf==NIL)printf("leaf, ");
    else printf("internal node, ");
    printf("[");
    for(j=A[i].left_leaf;j!=NIL;j=A[j].sibling){
      if(j==A[i].left_leaf)printf("%d",j);
      else printf(", %d",j); 
    }
    printf("]\n"); 
  }
  return 0;
}

Measured memory_bytes: 1984
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n=scan.nextInt();
		int k=scan.nextInt();
		int h[]=new int[n];
		int cnt=0;
		for(int i=0;i<n;i++) {
			h[i]=scan.nextInt();
			if(k<=h[i])cnt++;
		}
		scan.close();
		System.out.println(cnt);
	}

}

Measured memory_bytes: 51260
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
using namespace std;
typedef long long ll;

#define _SI(arr) (sizeof(arr)/sizeof(arr[0])

int main() {
	ll N;
	cin >> N;
	ll x, y = 0;
	vector<ll> a(N);

	cin >> x;
	a[0] = x;
	for (ll i = 1; i < N; i++)
	{
		cin >> a[i];
		y += a[i];
	}

	ll ans = abs(x - y);
	for (ll i = 1; i < N - 1; i++)
	{
		x += a[i];
		y -= a[i];
		ans = ans > abs(x - y) ? abs(x - y) : ans;
	}

	cout << ans << endl;
}

Measured memory_bytes: 1792
// Mahesh Sharma
// Beauty is in the struggle!
#include<bits/stdc++.h>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <cstring>
#include <memory.h>
#include <cassert>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

#define ford(i, a, b, c)        for(int i=(a); i<(b); i+=(c))
#define fori(i, a, b)           ford(i,a,b,1)
#define rep(i, n)               fori(i,0,n)
#define ifor(i, a, b)           for(int i=(a); i>=(b); i--)
#define si(x)                   ((int)x.size())
#define SS                      ({int x;scanf("%d",&x);x;})
#define pb                      push_back
#define mp                      make_pair
#define all(a)                  a.begin(),a.end()
#define inf                     (int)1e9
#define linf                    (long long)1e18
#define V                       vector
#define S                       string
#define XX                      first
#define YY                      second
#define PVI(v)                  rep(i, si(v)) cout<<v[i]<<" "; puts("")
#define PPI(p)                  cout<<"("<<p.first<<", "<<p.second<<")\n"
#define PVPI(v)                 rep(i, si(v)) cout<<"("<<v[i].first<<", "<<v[i].second<<")"<<(i==si(v)-1?"":", ");puts("")
#define PA(arr1, arr2)          for(auto it = arr1; it != arr2; it++) cout<<*it<<" "; puts("");

typedef V<int> vi;
typedef V<S> vs;
typedef long long ll;
typedef pair<int,int> pii;
const int MOD7 = 1000000000+7;
const int MOD9 = 1000000000+9;
/* ################### Program Body starts here ################ */


int main() {
    int h = SS, n = SS;
    vi a(n);
    rep(i, n) a[i] = SS;
    cout<<(accumulate(all(a), 0) >= h ? "Yes" : "No");
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
#define ll long long
#define ld long double
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define mkp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
#define ssp(i,n) (i==n-1?"\n":" ")
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll Inf = 3 * 1e18;
const int inf = 15 * 1e8;
ll read() {
	ll u, k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}
ll bcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
/*const int fn_ = 2000000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % Mod;
			comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}*/
//---------------------------------------------------
signed main() {
	int n = read();
	set<int>a;
	for (int i = 0; i < n; i++) a.insert(read());
	cout << a.size() << endl;
}


Measured memory_bytes: 7824
N, K = map(int, input().split())
A = [int(a) for a in input().split()]

S = sum(A)
def primeFactor(N):
    i, n, ret, d, sq = 2, N, {}, 2, 99
    while i <= sq:
        k = 0
        while n % i == 0: n, k, ret[i] = n//i, k+1, k+1
        if k > 0 or i == 97: sq = int(n**(1/2)+0.5)
        if i < 4: i = i * 2 - 1
        else: i, d = i+d, d^6
    if n > 1: ret[n] = 1
    return ret

def divisors(N):
    pf = primeFactor(N)
    ret = [1]
    for p in pf:
        ret_prev = ret
        ret = []
        for i in range(pf[p]+1):
            for r in ret_prev:
                ret.append(r * (p ** i))
    return sorted(ret)

D = divisors(S)

def chk(n):
    global K
    B = sorted([A[i]%n for i in range(N)])
    r = 0
    i, j = 0, N-1
    k = 0
    while i <= j:
        if r > 0:
            k += n-B[j]
            r -= n-B[j]
            j -= 1
        else:
            k += B[i]
            r += B[i]
            i += 1
    return 1 if k <= K*2 else 0

for d in D[::-1]:
    if chk(d):
        print(d)
        break

Measured memory_bytes: 3188
<?php
$left = "qwertasdfgzxcvb";

while (fscanf(STDIN, "%s", $str) && $str != '#') {
  $bef = 0; // left = 1, right = 2;
  $cnt = 0;
  for ($i = 0; $i < strlen($str); $i++) {
    if (strstr($left, $str[$i])) {
      if ($bef == 2) $cnt++;
      $bef = 1;
    } else {
      if ($bef == 1) $cnt++;
      $bef = 2;
    }
  }
  print $cnt . "\n";
}

Measured memory_bytes: 6568
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define LINF (ll)1e17
#define INF 1e9
#define MOD 1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
}


signed main(){
	
	ll a,b,c,d,e,n,m,ans = 0;
	ll A[100000],B[100000],C[100000];
	string s,t;
	bool flag1 = false,flag2 = false,flag3 = false;
	
	cin >> a >> b >> c ;
	
	ans = min(b/a,c);
	
	cout << ans << endl;
	return 0;

}

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


class Program
{
    static void Main(string[] args)
    {
        var nkq = Console.ReadLine().Split(' ');
        var n = int.Parse(nkq[0]);
        var k = long.Parse(nkq[1]);
        var q = int.Parse(nkq[2]);

        var man = new long[n];

        for (var i = 0; i < q; i++)
        {
            var tmp = int.Parse(Console.ReadLine());
            man[tmp - 1]++;
        }

        for (var i = 0; i < n; i++)
        {
            if (k - q + man[i] <= 0)
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }
        }
    }
}




Measured memory_bytes: 18140
#include <bits/stdc++.h>
using namespace std;
using LL = int64_t;
using ULL = int64_t;
const LL LLHUGE = numeric_limits<LL>::max() / 5; // for int64_t: 1.8 * 10^18
using P = pair<LL, LL>;
#define rep(i, n) for (LL i = 0; i < (n); ++i)
#define all(v) (v).begin(), (v).end()
#define DEBUG

template <typename V>
void print_all(const V& v) {
  for (const auto e: v) {
    cout << e << "\t";
  }
  cout << endl;
}

int main() {
  LL a, b;
  cin >> a >> b;
  cout << a * b << endl;

  #ifdef DEBUG
  // cout << 123 << endl;
  #endif
}



Measured memory_bytes: 3620
N = int(input())
A = []
B = []
for i in range(N):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)

A.sort()
B.sort()
#print(A)
#print(B)
if N % 2 == 1:
    AA = A[(N+1)//2-1]
    BB = B[(N+1)//2-1] 
    print(BB-AA+1)
else:
    AA = (A[N//2-1]+A[N//2])/2
    BB = (B[N//2-1]+B[N//2])/2
    print(int((BB-AA)*2+1))

Measured memory_bytes: 98992
#include<bits/stdc++.h>
 
#define REP(i,s,n) for(int (i)=s; (i)<(int)(n);(i)++)
#define RIT(it,c) for(__typeof(c.begin()) it = c.begin();it!=c.end();it++)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)(x).size()
#define MSET(m,v) memset(m,v,sizeof(m))
 
 
using namespace std;
 
 
typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<LL> vL;
typedef vector<bool> vb;
typedef pair<int,vi> iv;
typedef pair<LL,LL> pLL; 
typedef long double LD;
typedef unordered_set<int> ui;

int N;
string s;


int main(){
	std::ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	int A,B,C;
	cin>>A>>B>>C;
	cout<<(A^B^C)<<endl;
	return 0;
}

Measured memory_bytes: 256