akhauriyash/Code-Regression huggingface dataset:
import sys
t = 1
num = int(input())
num_list = input().split(" ")

new_list = sorted(num_list)
for i in range(num):
  try:
    if new_list[i]==new_list[i+1]:
      print("NO")
      t = 0
      break
    else:
      pass
  except:
    pass

    
if t == 1:
	print("YES")
  
  

Measured memory_bytes: 20792
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(998244353)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main() {
	int x,n; cin>>x>>n;
	VI p(n); rep(i,n) cin>>p[i]; sort(ALL(p));
	if(n==0) return cout<<x<<endl,0;
	bool used[105]; rep(i,105) used[i]=false;
	rep(i,n){
		used[p[i]]=true;
	}

	int ans=-1; int d=INF;
	rep(i,102){
		if(used[i]) continue;
		if(abs(i-x)<d){
			ans=i; d=abs(i-x);
		}
		
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define int long long int
double e = 0.000000001;
int32_t main()
{
    int n, m, sum = 0;
    cin >> n >> m;
    vector<int> v(n, 0);
    for(int i=0; i<n; i++)
    {
        cin >> v[i];
        sum += v[i];
    }

    int counts = 0;
    int vote = ceil(sum/ (double)(4 * m));

    for(int i=0; i<n; i++)
    {
        if(v[i] >= vote)
        {
            counts++;
        }
    }

    if(counts >= m)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <math.h>
#define NUM 17
 
using namespace std;
 
int main(void){
    int n, k;
    scanf("%d %d", &n, &k);
 
    long long sum = 0;
    for(int i = 1; i <= n; i++){
        long long sum_;
        if(i <= k - 1){
            sum_ = pow(2.0, NUM - ceill(log2((long double) k/i)));
            sum += sum_;
            //cout << ceill(log2((long double)k/i)) << endl;
        }else{
            //sum_ = pow(2.0, NUM);
            //cout << sum_ << endl;
        }
    }
 
    printf("%.16Lf\n", (long double) sum / powl(2, NUM) / n + (long double)(max(n-k+1,0))/n);
}


Measured memory_bytes: 256
import copy

n = int(input())
data = list(map(int, input().split()))
data.sort()

data1 = copy.copy(data)
A = data1.pop()
B = data1.pop()
n_1 = n-2

min = 100000000
for i in range(n_1 - 1) :
    if data1[i+1] - data1[i] < min :
        min = data1[i+1] - data1[i]
        C = data1[i+1]
        D = data1[i]

ans_1 = (A+B) / (C-D)

data2 = copy.copy(data)

min = 100000000
for i in range(n - 1) :
    if data2[i+1] - data2[i] < min :
        min = data2[i+1] - data2[i]
        C = data2[i+1]
        D = data2[i]

data2.remove(C)
data2.remove(D)
A = data2.pop()
B = data2.pop()

ans_2 = (A+B) / (C-D)
print(max(ans_1, ans_2))


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

int main(){
  int a,b;
  cin >> a >> b;
  string s;
  cin >> s;
  bool flg=true;
  for(int i=0; i<a+b+1; i++){
    if(i==a&&s[i]!='-') flg=false;
    if(i!=a&&s[i]=='-') flg=false;
  }    
  if(flg) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define inf std::numeric_limits<double>::infinity()
#define DECI(n) fixed<<showpoint<<setprecision(n)
#define MOD 1000000007LL
#define FOR(i,start,end) for (int i=start;i<end;i++)
#define FORR(i,end,start) for(int i=end-1;i>start;i--)
#define INPUT(arr,n) FOR(i,0,n) cin>>arr[i];
#define INPUT2d(arr,n,k) FOR(i,0,n) FOR(j,0,k) cin>>arr[i][j];
#define SIZE 100005
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define SUM cout<<sum<<endl;
#define pr(x) cout<<x<<endl;
#define prs(x) cout<<x<<" ";
#define iii(i)      cin>>i
#define ooo(i)      cout<<i
#define sss         cout<<" "
#define nnn         cout<<"\n"/**
#define iii(i)      iii<<i
#define ooo(i)      ooo<<i
#define sss         ooo<<" "
#define nnn         ooo<<"\n"*/
#define ff          first
#define ss          second
#define psb         push_back

#define maxN 20 
#define maxSum 50 
#define minSum 50 
#define base 50 

  
int main(){

ll t;cin>>t;
if(t==1){
	cout<<0<<endl;
}
else if(t==0){
	cout<<1<<endl;
}





return 0;
}

Measured memory_bytes: 3604
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Kenji
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC090A solver = new ABC090A();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC090A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            for (int i = 0; i < 3; i++) {
                String s = in.next();
                out.print(s.charAt(i));
            }
        }

    }
}



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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	if (n <= 999) cout << "ABC" << endl;
	else cout << "ABD" << endl;
	return 0;
}

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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
template <typename T> constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }

template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& a) { return is >> a.first >> a.second; }
template<typename T> istream& operator>>(istream& is, vector<T>& a) { for (T& x : a) is >> x; return is; }

void LOG(const int& x) { cerr << x << "\n"; }
template<typename T> void LOG(const vector<T>& a) { for (const T& x : a) cerr << x << " "; cerr << "\n"; }
template<typename T, std::size_t S> void LOG(const T (&a)[S]) { REP(i, S) cerr << a[i] << " "; cerr << "\n"; }
template<typename T, std::size_t S, std::size_t R> void LOG(const T (&a)[S][R]) { REP(i, S) { REP(j, R) cerr << a[i][j] << " "; cerr << "\n"; } }

i64 ceil(i64 a, i64 b) { return (a - 1) / b + 1; }
i64 gcd(i64 a, i64 b) { while (b != 0) { i64 t = b; b = a % b; a = t; } return a; }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
i64 gcd(const vector<i64>& v) { return accumulate(ALL(v), 1LL, static_cast<i64(*)(i64, i64)>(gcd)); }
i64 lcm(const vector<i64>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<i64(*)(i64, i64)>(lcm)); }
i64 pow(i64 x, i64 y, i64 z) { i64 a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }
i64 inv(i64 x, i64 m) { return pow(x, m - 2, m); }

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } initCpp;

const i64 INF = inf<i64>;
using P = pair<i64, i64>;
using T = pair<i64, P>;
const i64 M = 1000000007;
signed main() {
  i64 N, M;
  cin >> N >> M;
  vector<i64> A(N);
  cin >> A;
  sort(ALL(A));
  vector<i64> S(N + 1);
  REP(i, N) S[i + 1] = S[i] + A[i];
  i64 h_ng = 0;
  i64 h_ok = A[N - 1] * 2 + 2;
  i64 h = h_ok;
  i64 s = 0;
  i64 q = 0;
  i64 r = 0;
  i64 ans = 0;
  while (h_ok > h_ng + 1) {
    h = (h_ok + h_ng) / 2;
    s = 0;
    q = 0;
    r = 0;
    REP(i, N) {
      i64 ge = lower_bound(ALL(A), h - A[i]) - A.begin();
      i64 gt = upper_bound(ALL(A), h - A[i]) - A.begin();
      q += N - gt;
      r += gt - ge;
      s += S[N] - S[gt] + A[i] * (N - gt);
    }
    if (q <= M) {
      h_ok = h;
      if (M <= q + r) {
        cout << (s + (M - q) * h) << endl;
        exit(0);
      }
    } else {
      h_ng = h;
    }
  }
  exit(1);
}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<int, int, int> T;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 998244353;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
int a[100100];

bool solve() {
    for (int i = 0; i < n; i++) {
        if (a[i] % 2 == 1)
            return true;
    }
    return false;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << (solve()?"first":"second") << endl;
}


Measured memory_bytes: 3508
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9
#define MAX_M 200001
#define MAX_N 100001

using namespace std;

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

struct edge { int to, diff; };

int N, M;
vector<edge> G[MAX_N];
int x[MAX_N];
bool updated[MAX_N];

bool dfs(int i){
    for (int j = 0; j < G[i].size(); ++j) {
        edge e = G[i][j];
        if (!updated[e.to]) {
            x[e.to] = x[i] + e.diff;
            updated[e.to] = true;
            if (!dfs(e.to)) {
                return false;
            }
        } else {
            if (x[e.to] != x[i] + e.diff) {
                return false;
            }
        }
    }
    return true;
}

int main() {
    fill(updated, updated + N, false);
    cin >> N >> M;
    for (int i = 0; i < M; ++i) {
        int l, r, d;
        cin >> l >> r >> d;
        G[l].push_back(edge{r, d});
        G[r].push_back(edge{l, -d});
    }
    
    for (int i = 0; i < N; ++i) {
        if (!updated[i]) {
            x[i] = 0;
            updated[i] = true;
            if (!dfs(i)) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    
    cout << "Yes" << endl;
    
    return 0;
}


Measured memory_bytes: 12032
#include<stdio.h>
#include<math.h>
#include<string.h>
#define RAMEN 700
int main(void){
    char s[4];
    int c = 0;

    scanf("%s",s);
    for(int i=0; i<3; i++){
        if(strncmp(s+i,"o",1) == 0) c+=1;
    }
    
    printf("%d\n",RAMEN+100*c);

    return 0;
}

Measured memory_bytes: 128
S=list(input())

now=S[0]
n=0#数え
X=0
for i in S:

    if n==0:
        n+=1
        continue
    if now==i:
        if now=='1':
            S[n]='0'
        else:
            S[n]='1'
        X+=1
    now=S[n]
    n+=1

print(X)


Measured memory_bytes: 3956
integer(8) N
integer(8),allocatable,dimension(:)::work,dead
integer(8) timeline
read*,N
allocate(work(N),dead(N))
do i=1,N
  read*,work(i),dead(i)
end do

call heapsort(n,dead,work)

timeline=0
do i=1,N
  timeline=timeline+work(i)
  if(timeline>dead(i))then
    print"(A)","No"
    Stop
  end if
end do

print"(A)","Yes"

contains

subroutine heapsort(n,array,b)
  implicit none
  integer(8),intent(in) :: n
  integer(8),intent(inout) :: array(1:n),b(1:n)
  integer(8)::i,k,j,l
  integer(8):: t,tb

  l=n/2+1
  k=n
  do while(k /= 1)
     if(l > 1)then
        l=l-1
        t=array(L)
        tb=b(L)
     else
        t=array(k)
        tb=b(k)
        array(k)=array(1)
        b(k)=b(1)
        k=k-1
        if(k == 1) then
           array(1)=t
           b(1)=tb
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j<=k)
        if(j < k)then
           if(array(j) < array(j+1))j=j+1
        endif
        if (t < array(j))then
           array(i)=array(j)
           b(i)=b(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array(i)=t
     b(i)=tb
  enddo
  return
end subroutine heapsort
end

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define ll long long
#define pb push_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;


const ll modo=1e9+7;
const ll inf=2e14;
const ll ms=(1e5) +5;


int main()
{
    idfc;

    char a;
    cin>>a;
    a++;
    cout<<a;


    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

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

left = [A[0][0]]
for i in range(1, N):
  left.append(left[-1] + A[0][i])

A[1] = A[1][::-1]
right = [A[1][0]]
for i in range(1, N):
  right.append(right[-1] + A[1][i])
right = right[::-1]

answer = 0
for i in range(N):
  answer = max(answer, left[i] + right[i])

print(answer)

Measured memory_bytes: 3064
input()
a = b = c = 0
for i in raw_input().split():
	i = int(i)
	if i % 4 == 0:
		a += 1
	elif i % 2 == 0:
		b += 1
	else:
		c += 1

if a >= c or (b == 0 and a + 1 >= c):
	print "Yes"
else:
	print "No"

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,x,mi;
	mi=1000;
	cin>>n>>x;
	int m[n];
	for(int i=0;i<n;i++){
		cin>>m[i];
		x-=m[i];
		mi=min(mi,m[i]);
	}
	cout<<n+x/mi<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
    int n,m;scanf("%d %d",&n,&m);
    vector<bool> used(m,true);
    vector<queue<int>> Q(n);
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            int x;scanf("%d",&x);
            Q[i].push(--x);
        }
    }
    int ans = n;
    for (int i = 0; i < m; ++i)
    {
        if(i){
            for (int j = 0; j < n; ++j)
            {
                while(!used[Q[j].front()])Q[j].pop();
            }
        }

        vector<int> cnt(m,0);
        for (int j = 0; j < n; ++j)
        {
            cnt[Q[j].front()]++;
        }
        int mx=0,id=0;
        for (int j = 0; j < m; ++j)
        {
            if(cnt[j] > mx)mx = cnt[j],id = j;
        }
        ans = min(ans,mx);
        used[id] = false;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 768
#include<stdio.h>
#include <string>
#include <iostream>
#include <assert.h>
#include <stdio.h>
#define SIZEOF(x) (sizeof x )/(sizeof x[0])

int max(int a , int b ,int c=0){
    if(a>=b && a>=c )return a;
    else if (b >= a && b >= c)return b;
    else return c;
}

int main(){
    int a,b,c;
    scanf("%d %d %d" , &a,&b,&c);
    int count =0;
    int a_ = a;
    int b_ = b;
    int c_ = c;
    if((a%2==b%2 && c%2==b%2 && a%2 == 1 )||(a%2==b%2&& c%2==0 && a%2 == c%2)){
        while(a < max(a,b,c) ){
            a += 2;
            count += 1;
        }
        while(b < max(a,b,c) ){
            b += 2;
            count += 1;
        }
        while(c < max(a,b,c) ){
            c += 2;
            count += 1;
        }
    }else{
        if(a%2 != b%2 && a %2 != c%2){
            b+=1;
            c+=1;
            count += 1;
        }
        else if(b%2 != a%2 && b %2 != c%2){
            a+=1;
            c+=1;
            count += 1;
        }
        else if(c%2 != b%2 && c %2 != a%2){
            b+=1;
            a+=1;
            count += 1;
        }
        while(a < max(a,b,c) ){
            a += 2;
            count += 1;
        }
        while(b < max(a,b,c) ){
            b += 2;
            count += 1;
        }
        while(c < max(a,b,c) ){
            c += 2;
            count += 1;
        }

    }

    printf("%d\n" , count);
    return 0;

}

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

int main()
{
  string s;
  cin >> s;
  int hash[26] = {0};
  int length = s.length();
  for (int i = 0; i < length; i++)
  {
    hash[s[i] - 'a']++;
  }
  for (int i = 0; i < 26; i++)
  {
    if (hash[i] % 2)
    {
      cout << "No" ;
      return 0;
    }
  }
  cout << "Yes" ;
  return 0;
}


Measured memory_bytes: 256
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define fe(vec,lambda) std::for_each(vec.begin(), vec.end(), lambda );
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#define printv(val) std::for_each(val.begin(),val.end(),[](auto x){cout<<x<<"\n";});
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T chmin(T& a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T& b,T a){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template <class T> T gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T lcm(T a, T b){return a * b / gcd(a, b);}
inline bool operator<(const pii &lhs,const pii &rhs){return(lhs.second<rhs.second);}
template<class T> vector<pair<T,T>> duplicator(const vector<T>& input){vector<pair<T,T>> out(input.size()-1);rep(i,input.size()-1){out[i].first =input[i  ];out[i].second=input[i+1];}return(out);}
vector<char> String_to_vector_char(const string& input){vector<char> out(input.size());rep(i,input.size()){out[i]=input[i];}return out;}


ll a,b,c,d;
vector<ll>v;
map<ll,ll>m;
string s,s2;
void input(){
    cin>>a>>b>>c>>d;
}
void src(){
    cout<<max(a*b,c*d);
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
    //ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

 class Main
 {
   public static void main(String args[])
   { //Initial setting
    int a = 0;
    
    int b = 0;
    
    char op = '!';
    
    io(a,b,op);//Input/output
   }
   static void io(int a,int b,char op)
   {
       Scanner sc = new Scanner(System.in);
       
       while(op != '?')
       {
         a = sc.nextInt();
         
         op = sc.next().charAt( 0 );
         
         b = sc.nextInt();
         
         if(op == '+')
         {
            a = a + b;
            
            System.out.println(a);
         }
         if(op == '-')
         {
            a = a - b;
            
            System.out.println(a);
         }
         if(op == '*')
         {
            a = a * b;
            
            System.out.println(a);
         }
         if(op == '/')
         {
            a = a / b;
            
            System.out.println(a);
         }
       }
   }
 }
    


Measured memory_bytes: 26228
#include"bits/stdc++.h"
using namespace std;

typedef long long ll;
#define FOR(i, a, n) for (ll i=(ll)a;i<(ll)n;i++)
#define REP(i, n) FOR(i, 0, n)

int main(){
    int n; cin >> n;
    int n1 = n%10;
    int n2 = (n/10)%10;

    if (n1==9||n2==9){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
class dice
{
private:
	int _top, _botom, _front, _back, _right, _left;
public:
	dice(int top, int botom, int front, int back, int right, int left): _top(top), _botom(botom), _front(front), _back(back), _right(right), _left(left) {};
	void roll(char dir)
	{
		int temp;
		switch(dir)
		{
			case 'E':
				temp = _top;
				_top = _left;
				_left = _botom;
				_botom = _right;
				_right = temp;
				break;
			case 'W':
				temp = _top;
				_top = _right;
				_right = _botom;
				_botom = _left;
				_left = temp;
				break;
			case 'S':
				temp = _top;
				_top = _front;
				_front = _botom;
				_botom = _back;
				_back = temp;
				break;
			case 'N':
				temp = _top;
				_top = _back;
				_back = _botom;
				_botom = _front;
				_front = temp;
				break;
			case 'R':
				temp = _front;
				_front = _left;
				_left = _back;
				_back = _right;
				_right = temp;
				break;
			case 'L':
				temp = _front;
				_front = _right;
				_right = _back;
				_back = _left;
				_left = temp;
				break;
		}
	}
	int top()
	{
		return _top;
	}
	int botom()
	{
		return _botom;
	}
	int front()
	{
		return _front;
	}
	int back()
	{
		return _back;
	}
	int right()
	{
		return _right;
	}
	int left()
	{
		return _left;
	}
};
int main()
{
	int top, botom, front, back, right, left;
	std::cin >> top >> back >> right >> left >> front >> botom;
	dice d(top, botom, front, back, right, left);
	int q;
	std::cin >> q;
	int**num = new int*[q];
	for(int i = 0; i < q; i++)
	{
		num[i] = new int[2];
	}
	for(int i = 0; i < q; i++)
	{
		for(int j = 0; j < 2; j++)
		{
			std::cin >> num[i][j];
		}
	}
	int*result = new int[q];
	for(int i = 0; i < q; i++)
	{
		const int top_i = num[i][0], back_i = num[i][1];
		if(top_i == d.botom())
		{
			d.roll('N');
			d.roll('N');
		}
		else if(top_i == d.front())
		{
			d.roll('S');
		}
		else if(top_i == d.back())
		{
			d.roll('N');
		}
		else if(top_i == d.right())
		{
			d.roll('W');
		}
		else if(top_i == d.left())
		{
			d.roll('E');
		}
		if(back_i == d.front())
		{
			d.roll('R');
			d.roll('R');
		}
		else if(back_i == d.right())
		{
			d.roll('R');
		}
		else if(back_i == d.left())
		{
			d.roll('L');
		}
		result[i] = d.right();
	}
	for(int i = 0; i < q; i++)
	{
		std::cout << result[i] << std::endl;
	}
	return 0;
}


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

using ll = long long;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int q; cin >> q;
    while(q--) {
        int k; cin >> k;
        ll ans = 0, c = 0, m = 0;
        ll tmp = 0;
        for(int i = 0; i < k; ++i) {
            if(s[i] == 'C') {
                tmp += m;
                c += 1;
            } else if(s[i] == 'M') {
                m += 1;
            }
        }
        if(s[0] == 'D') ans += tmp;
        int l = 0, r = k;
        while(l < n) {
            if(s[l] == 'M') {
                tmp -= c;
                m -= 1;
            } else if(s[l] == 'C') {
                c -= 1;
            }
            l += 1;
            if(r < n) {
                if(s[r] == 'C') {
                    tmp += m;
                    c += 1;
                } else if(s[r] == 'M') {
                    m += 1;
                }
                r += 1;
            }
            if(l < n && s[l] == 'D') {
                ans += tmp;
            }
        }

        cout << ans << endl;
    }
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - K-City
            var line = ReadLine();
            int n = line[0];
            int m = line[1];

            Console.WriteLine((n - 1) * (m - 1));
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}


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

int main(){
  long long N,M;
  cin>>N>>M;
  vector<long long> x(N),y(N),z(N);
  for(int i=0;i<N;i++){
    cin>>x.at(i)>>y.at(i)>>z.at(i);
  }
  
  long long dp[M+1][2][2][2];
  for(int i=0;i<M+1;i++){
    for(int j=0;j<2;j++){
      for(int k=0;k<2;k++){
        for(int l=0;l<2;l++){
          dp[i][j][k][l]=-10000000000000;
        }
      }
    }
  }
  
  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      for(int k=0;k<2;k++){
        dp[0][i][j][k]=0;
      }
    }
  }
  
  for(int i=0;i<N;i++){
    for(int j=M-1;j>=0;j--){
      dp[j+1][0][0][0]=max(dp[j+1][0][0][0],dp[j][0][0][0]+x.at(i)+y.at(i)+z.at(i));
      dp[j+1][1][0][0]=max(dp[j+1][1][0][0],dp[j][1][0][0]-x.at(i)+y.at(i)+z.at(i));
      dp[j+1][0][1][0]=max(dp[j+1][0][1][0],dp[j][0][1][0]+x.at(i)-y.at(i)+z.at(i));
      dp[j+1][0][0][1]=max(dp[j+1][0][0][1],dp[j][0][0][1]+x.at(i)+y.at(i)-z.at(i));
      dp[j+1][1][1][0]=max(dp[j+1][1][1][0],dp[j][1][1][0]-x.at(i)-y.at(i)+z.at(i));
      dp[j+1][1][0][1]=max(dp[j+1][1][0][1],dp[j][1][0][1]-x.at(i)+y.at(i)-z.at(i));
      dp[j+1][0][1][1]=max(dp[j+1][0][1][1],dp[j][0][1][1]+x.at(i)-y.at(i)-z.at(i));
      dp[j+1][1][1][1]=max(dp[j+1][1][1][1],dp[j][1][1][1]-x.at(i)-y.at(i)-z.at(i));
    }
  }
    long long ans=0;
    for(int i=0;i<2;i++){
      for(int j=0;j<2;j++){
        for(int k=0;k<2;k++){
          ans=max(dp[M][i][j][k],ans);
        }
      }
    }
    
    cout<<ans<<endl;
  }
  

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{

    int a,b,c,d,e,f;
    while(~scanf("%d%d%d%d",&a,&b,&c,&d))
    {
        if(a>=b)
            e=b;
        else
            e=a;
        if(c>=d)
            f=d;
        else
            f=c;
        printf("%d\n",e+f);
    }
    return 0;
}


Measured memory_bytes: 128
from collections import deque

K = int(input())
q = deque([i for i in range(1, 10)])
for i in range(K):
    x = q.popleft()
    if x%10 != 0:
        q.append(x*10+x%10-1)
    q.append(x*10+x%10)
    if x%10 != 9:
        q.append(x*10+x%10+1)
    if i == K-1:
        print (x)

Measured memory_bytes: 11888
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000011
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
 
double log2(double pp){
  double cnt=0;
  while(pp>1){
    pp/=2.0;
    cnt++;}
  return cnt;}
  


int main(){
 int n;
   double k;
  cin>>n>>k;
  
   double kai[n];
  
for(int i=1;i<=n;i++){
  double p=k/i;
  double z=log2(p);
  int q=z-0;
  kai[i-1]=(double)1/pow(2, z);
}
    
  double ans=0;
  rep(i, n){
    ans+=kai[i];}
  
  ans/=(double)n;
  
  cout<<fixed;
  cout<<setprecision(14)<<ans<<endl;
 
}

Measured memory_bytes: 1024
// Aizu 1609: Look for the Winner!
// 2017.9.21 bal4u@uu

#include <stdio.h>
#include <string.h>

int f[30];
int c[102];

int main()
{
	int n, x, i, k, x1, x2, max1, max2;
	char b[5];

	while (scanf("%d", &n) && n) {
		for (i = 0; i < n; i++) scanf("%s", b), c[i] = *b - 'A'; 
		memset(f, 0, sizeof(f));
		max1 = max2 = 0, x1 = x2 = -1;
		for (k = n, i = 0; i < n; ) {
			x = c[i], i++, k--;
			f[x]++;
			if (f[x] > max1) {
				if (x1 < 0 || x == x1) max1 = f[x], x1 = x;
				else max2 = max1, x2 = x1, max1 = f[x], x1 = x;
			} else if (f[x] > max2) max2 = f[x]; x2 = x;
			if (max2 + k < max1) break;
		}
		if (max1 == max2) puts("TIE");
		else printf("%c %d\n", x1+'A', i);
	}
	return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(int n,int m){
    vector<string> e(n);
    string ts;
    int concatenated_len=0;
    rep(i,0,n){
        cin >> e[i];
        concatenated_len+=e[i].size();
    }
    rep(i,0,m){
        string t;
        cin >> t;
        ts+=t;
    }

    vector<int> sum_len(1<<n);
    rep(i,0,1<<n){
        rep(j,0,n){
            if(((i>>j)&1)==0) continue;
            sum_len[i]+=e[j].size();
        }
    }

    static bool p[5000][1<<12];
    fill_n((bool*)p,5000*(1<<12),false);
    vector<vector<int>> heads(ts.size());
    rep(i,0,ts.size()) p[i][0]=true;
    rep(i,0,ts.size()){
        rep(j,0,n){
            if(i+e[j].size()>ts.size() or e[j]!=ts.substr(i,e[j].size())) continue;
            p[i][1<<j]=true;
            heads[i].push_back(j);
        }
    }
    int ans=0;
    for(int i=ts.size()-1; i>=0; --i){
        rep(j,1,1<<n){
            if(p[i][j] or i+sum_len[j]>ts.size()) continue;
            for(int k:heads[i]){
                if(((j>>k)&1)==0) continue;
                int i2=i+e[k].size();
                if(p[i2][j&(~(1<<k))]){
                    p[i][j]=true;
                    break;
                }
            }
        }
        if(p[i][(1<<n)-1]) ++ans;
    }
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    for(;;){
        int n,m;
        cin >> n >> m;
        if(n==0 and m==0) break;
        solve(n,m);
    }
    return 0;
}

Measured memory_bytes: 23532
#include <bits/stdc++.h>    
using namespace std;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define int long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define fone for(i=0;i<n;i++)
#define endl "\n"
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N          = 5000*100+1;
const ll N2      = 1000*1000+5;
const ld PI  = 3.14159265;
const ll R   = 250;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;} 
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
    }


signed main ()
{
  fastio();
  int n,k;
  cin>>n;

  int a[n],b[n],c[n];
  int dp[100000][3];;
  fill(dp,0);
  for(int i=0;i<n;i++)
  {
    cin>>a[i]>>b[i]>>c[i];
  }
  dp[0][0]=a[0];
  dp[0][1]=b[0];
  dp[0][2]=c[0];
  for(int i=1;i<n;i++)
  {
    dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
    dp[i][1]=max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
    dp[i][2]=max(dp[i-1][1]+c[i],dp[i-1][0]+c[i]);
  }
  cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;

return 0;
  
}




Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
int gcd(int a,int b)
{
	if(a%b==0)
		return b;
	else
		return gcd(b,a%b);
}
int h[100007],dp[100007];
void solve()
{
    int n,sol=0,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
        dp[i]=mod;
    }
    dp[0]=0;
    dp[1]=abs(h[0]-h[1]);
    for(int i=2;i<n;i++)
    {
        for(int j=i-1;j>=max(0,i-k);j--)
        {
            if(dp[i]>dp[j]+abs(h[i]-h[j]))
            {
                dp[i]=dp[j]+abs(h[i]-h[j]);
            }
        }
    }
    cout<<dp[n-1];
}
int main()
{
	int t=1;
	//cin>>t;
	while(t--)
		solve();
	return(0);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int i, j;
  long x;
  cin >> x;
  bool flag = false;
  for (int i = -118; i < 120; i++)
  {
    for (int j = -119; j < 119; j++){
      if (pow(i,5) - pow(j,5) == x){
        cout << i << " " << j << endl;
        flag = true;
      }
    }
    if (flag)
      break;
  }
}

Measured memory_bytes: 3964
def main():
    a, b = map(int, input().split())
    count = 1
    nes = 0
    if b == 1:
        print("0")
    elif a >= b:
        print("1")
    else:   
        while count < b:
            count += a - 1
            nes += 1
        print(nes)

if __name__ == "__main__":
    main()

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

int par[100005];
int rnk[100005];
int cnt[100005];

void init(int n) {
  for (int i=0; i<n; i++) {
    par[i]=i;
    rnk[i]=0;
    cnt[i]=1;
  }
}
int find(int x) {
  if (par[x]==x) {
    return x;
  }
  else {
    return par[x]=find(par[x]);
  }
}

void unite(int x,int y) {
  x=find(x);
  y=find(y);
  if (x==y) return;
  if (rnk[x]<rnk[y]) {
    par[x]=y;
    cnt[y]+=cnt[x];
  }
  else {
    par[y]=x;
    cnt[x]+=cnt[y];
    if (rnk[x]==rnk[y]) rnk[x]++;
  }
}

bool same(int x, int y) {
  return find(x)==find(y);
}



int ans[100005];

int main(){
  int n,m,k;
  cin>>n>>m>>k;
  int a[100005],b[100005];
  init(n);
  rep(i,m){
    cin>>a[i]>>b[i]; a[i]--; b[i]--;
    unite(a[i],b[i]);
    ans[a[i]]--;
    ans[b[i]]--;
  }
  rep(i,k){
    int c,d;
    cin>>c>>d; c--; d--;
    if(same(c,d)){
      ans[c]--; ans[d]--;
    }
  }
  rep(i,n){
    ans[i]+=cnt[find(i)];
    cout<<ans[i]-1<<' ';
  }
  return 0;
}





Measured memory_bytes: 3200
/* ****GT_18**** */

#include<bits/stdc++.h>
#define	MIN(a,b,c)	min(min(a,b),c)
#define	MAX(a,b,c)	max(max(a,b),c)
#define ll          long long
#define itr         vector<int>::iterator
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--)
	{
		ll a,b;
		cin>>a>>b;
		if(a==1)a=14;
		if(b==1)b=14;
		if(a>b)cout<<"Alice";
		else if(a<b)cout<<"Bob";
		else cout<<"Draw";
	}
	return 0;
}


Measured memory_bytes: 256
//while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

const int nax=200*1007;

int n;

char wcz[nax];

int dp[nax];

int maska;

int mapa[1<<26];

void dorzuc(int v, int w)
{
	mapa[v]=min(mapa[v], w);
}

int pyt(int v)
{
	return mapa[v];
}

int main()
{
	for (int i=0; i<(1<<26); i++)
		mapa[i]=nax;
	scanf("%s", wcz+1);
	n=strlen(wcz+1);
	dorzuc(0, 0);
	for (int i=1; i<=n; i++)
	{
		maska^=(1<<(wcz[i]-'a'));
		dp[i]=pyt(maska);
		for (int j=0; j<26; j++)
			dp[i]=min(dp[i], pyt(maska^(1<<j)));
		dp[i]++;
		dorzuc(maska, dp[i]);
	}
	printf("%d\n", dp[n]);
	return 0;
}


Measured memory_bytes: 263424
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int n,k;
vi h;
int dp[302][302];
int f[302][302];

signed main(){
    I(n); I(k);
    h.resize(n+1);
    REP(i,n) I(h[i+1]);
    h.pb(0);
    REP(i,n+2) REP(j,n+2)
        f[i][j] = max(0LL, h[j]-h[i]);
    REP(i,302) REP(j,302) dp[i][j] = INT64_MAX / 2;
    dp[0][0] = 0;
    REP(i,n+1){
        REP(j,k+1){
            REPS(skip, k-j+1){
                if (i+skip > n+1) break;
                dp[i+skip][j+skip-1] = min(dp[i+skip][j+skip-1], dp[i][j] + f[i][i+skip]);
            }
        }
    }
    // REP(j,k+1) { REPS(i,n+1) cerr << dp[i][j] << " "; cerr << endl;}  

    int ret = INT64_MAX;
    REP(j,k+1) ret = min(ret, dp[n+1][j]);
    cout << ret << endl;
}

Measured memory_bytes: 1664
from collections import *
from itertools import *
from bisect import *
from heapq import *
import copy
#import math

#N=int(input())
#X,Y=map(int,input().split())
#S=list(map(int,input().split()))
#S=[list(map(int,input().split())) for i in range(N)]




sc=[list(map(int,input().split())) for i in range(3)]
N=int(input())
B=[int(input()) for i in range(N)]
data=[[0 for i in range(3)] for x in range(3)]

for b in B:
    for i in range(3):
        for x in range(3):
            if sc[i][x]==b:
                data[i][x]=1

for nlst in ([[[i,x] for i in range(3)] for x in range(3)],\
[[[x,i] for i in range(3)] for x in range(3)],\
[[[i,i] for i in range(3)]],\
[[[i,2-i] for i in range(2,-1,-1)]]):

    for lst in nlst:
        count=0
        for i,x in lst:
            count+=data[i][x]

        if count==3:
            print("Yes")
            exit()
print("No")


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

int main(){
int a[101]={0};
int b[51]={0};
int N,M,i;

cin>>N>>M;

for(i=0;i<M*2;i++){
    cin>>a[i];
}
for(i=0;i<M*2;i++){
  if(b[a[i]]==0){
    for(int j=0;j<M*2;j++){   
        if(a[i]==a[j]){    
            b[a[i]]++;
        }
    }
  }
}

for(i=1;i<=N;i++){
  cout<<b[i]<<endl; 
}

}



Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=[0]
for i in range(n):
  b.append(b[-1]+a[i])
#print(b)
ans = 0
b.sort()
for i in range(n+1):
  if i == 0:
    x=b[0]
    m=1
  else:
    if x==b[i]:
      m+=1
      if i==n:
        ans += m*(m-1)//2
    else:
      if m!=1:
        ans += m*(m-1)//2
        m=1
      x=b[i]
print(ans)

Measured memory_bytes: 25724
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int INF = 1000100000;
#define rep(i,n) for(int i=0;i<n;++i)


int main(){
  int n;
  cin >>n;
  int dp[100100]={};
  dp[1]=1;
  int res;
  for(int x=1;x<=n;x++){
    res=dp[x-1];
    for(int po6=6;po6<=x;po6*=6){
      res=min(res,dp[x-po6]);
    }
    for(int po9=9;po9<=x;po9*=9){
      res=min(res,dp[x-po9]);
    }
    dp[x]=res+1;
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 640
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,k=LI()
  l=[False for _ in range(n)]
  l2=[0 for _ in range(n)]

  ans1=ans2=0
  for _ in range(k):
    a,b=LS()
    a=int(a)

    if b=='WA':
      if l[a-1]==False:
        l2[a-1]+=1
    else:
      if l[a-1]==False:
        l[a-1]=True
        ans1+=1
        ans2+=l2[a-1]

  return str(ans1)+' '+str(ans2)

# main()
print(main())


Measured memory_bytes: 7360
#include <bits/stdc++.h>
#define MAX 100000
using namespace std;
int main() {
	long long int n, k;
	cin >> n >> k;
	long long int array[MAX + 1];
	for(int i = 0; i <= MAX; i++) {
		array[i] = 0;
	}

	for(int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		array[a] += b;
	}

	for(int i = 1; i <= MAX; i++) {
		if(k <= array[i]) {
			cout << i << endl;
			break;
		}
		k -= array[i];
	}

	return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define SZ(x) ((int)((x).size()))

template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
    bool done_something = false;
    stringstream res;
    res << "[";
    for (; begin_iter != end_iter and counter; ++begin_iter) {
        done_something = true;
        counter--;
        res << *begin_iter << ", ";
    }
    string str = res.str();
    if (done_something) {
        str.pop_back();
        str.pop_back();
    }
    str += "]";
    return str;
}

vector<int> SortIndex(int size, std::function<bool(int, int)> compare) {
    vector<int> ord(size);
    for (int i = 0; i < size; i++) ord[i] = i;
    sort(ord.begin(), ord.end(), compare);
    return ord;
}

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

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

template <typename S, typename T>
ostream& operator <<(ostream& out, const pair<S, T>& p) {
    out << "{" << p.first << ", " << p.second << "}";
    return out;
}

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& v) {
    out << "[";
    for (int i = 0; i < (int)v.size(); i++) {
        out << v[i];
        if (i != (int)v.size()-1) out << ", ";
    }
    out << "]";
    return out;
}

template<class TH>
void _dbg(const char* name, TH val){
    clog << name << ": " << val << endl;
}
template<class TH, class... TA>
void _dbg(const char* names, TH curr_val, TA... vals) {
    while(*names != ',') clog << *names++;
    clog << ": " << curr_val << ", ";
    _dbg(names+1, vals...);
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file

    #define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
    #define dbg_arr(x, len) clog << #x << ": " << print_iterable(x, x+len, -1) << endl;
#else
    #define dbg(...)
    #define dbg_arr(x, len)
#endif

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////

void evolve(int N, vector<int>& A) {
    vector<int> pref(N+1);
    for (int i = 0; i < N; i++) {
        pref[max(0, i-A[i])]++;
        pref[min(N, i+A[i]+1)]--;
    }
    int curr = 0;
    for (int i = 0; i < N; i++) {
        curr += pref[i];
        A[i] = curr;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Remove in problems with online queries!

    int N, K;
    cin >> N >> K;
    
    vector<int> A(N, 0);
    for (int i = 0; i < N; i++) cin >> A[i];
    
    for (int k = 0; k < K; k++) {
        evolve(N, A);
        bool finished = true;
        for (int i = 0; i < N; i++) finished &= A[i] == N;
        if (finished) break;
        // dbg(k);
    }
    for (int i = 0; i < N; i++) cout << A[i] << " ";
}


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

int main(){
    string s,t;
    cin >> s >> t;
    int a=0;
    rp(i,3){
        if(s.at(i)==t.at(i)) a++;
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

int n;
int p[2005];
int a[2005];
int lvl[2005];
int wh[2005];
int leafish_factor[2005];
bool active[2005];
int cnt_active;

vector<int> moves;

void move(int node){
	moves.push_back(node);
	vector<int> tmp;
	
	while(node){
		tmp.push_back(node);
		node = p[node];
	}
	
	tmp.push_back(0);
	
	reverse(tmp.begin(),tmp.end());
	for(int i = 0;i < (int)tmp.size() - 1;i++){
		swap(wh[a[tmp[i]]],wh[a[tmp[i + 1]]]);
		swap(a[tmp[i]],a[tmp[i + 1]]);
	}
}

int main(){
	
	scanf("%d",&n);
	
	for(int i = 1;i < n;i++){
		scanf("%d",&p[i]);
		lvl[i] = 1 + lvl[p[i]];
	}
	
	for(int i = 0;i < n;i++){
		scanf("%d",&a[i]);
		wh[a[i]] = i;
		active[i] = true;
		cnt_active++;
	}
	
	while(cnt_active > 0){
		// printf("stage\n");
		for(int i = 0;i < n;i++){
			leafish_factor[i] = 0;
		}
		
		for(int i = n - 1;i >= 0;i--){
			if(!active[i]){
				continue;
			}
			leafish_factor[i] = max(leafish_factor[i],1);
			if(i){
				leafish_factor[p[i]] += leafish_factor[i];
			}
		}
		
		vector< vector<int> > batch;
		vector< vector<int> > c_batch;
		vector< vector<bool> > inserted;
		for(int i = n - 1;i >= 0;i--){
			if(active[i] && leafish_factor[i] == 1){
				int nod = i;
				vector<int> path;
				while(leafish_factor[nod] == 1 && nod){
					path.push_back(nod);
					active[nod] = false;
					cnt_active--;
					nod = p[nod];
				}
				if(nod == 0 && leafish_factor[nod] == 1){
					cnt_active--;
					active[0] = false;
					path.push_back(0);
				}
				batch.push_back(path);
				inserted.push_back(vector<bool>(path.size(),false));
			}
		}
		c_batch = batch;
		
		while(1){
			// for(auto it:batch){
				// for(auto it2:it)printf("%d ",it2);printf("\n");
			// }
			// for(int i = 0;i < n;i++)printf("%d ",a[i]);printf("\n");
			// printf("\n\n\n\n");
			bool break_cond = true;
			for(auto it:batch){
				break_cond &= it.empty();
			}
			if(break_cond){
				break;
			}
			
			bool found = false;
			
			for(int i = 0;!found && i < (int)c_batch.size();i++){
				int ins = 0;
				for(int j = 0;j < (int)c_batch[i].size();j++){
					ins += inserted[i][j];///inserted lower than you
					if(a[0] == c_batch[i][j]){
						inserted[i][j] = true;
						// printf("this\n");
						move(c_batch[i][ins]);
						for(int k = 0;k < (int)batch[i].size();k++){
							if(batch[i][k] == c_batch[i][j]){
								swap(batch[i][k],batch[i].back());
								break;
							}
						}
						batch[i].pop_back();
						found = true;
						break;
					}
				}
			}
			
			if(!found){
				int node = 0;
				for(auto it:batch){
					for(auto it2:it){
						node = (lvl[wh[it2]] > lvl[node] ? wh[it2]:node);
					}
				}
				// printf("that\n");
				move(node);
			}
		}
		
	}
	
	printf("%d\n",moves.size());
	
	for(auto it:moves){
		printf("%d\n",it);
	}
	
	return 0;
}

Measured memory_bytes: 640