akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
 
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;
}
///////////////////////////////////////////////
int main(){
    int N;
    cin >> N;
    vector<int> X(N),Y(N);
    REP(i,N){
        cin >> X[i] >> Y[i];
    }

    int mode = (abs(X[0]) + abs(Y[0])) % 2;

    REP(i,N){
        if (mode != (abs(X[i] + Y[i]) % 2)){
            cout << -1 << endl;
            return 0;
        }
    }
    vector<ll> d;
    ll now = 1;
    REP(i,39){
        d.PB(now);
        now *= 2;
    }

    reverse(ALL(d));
    if (mode == 0) d.PB(1);

    cout << d.size() << "\n";
    REP(i,d.size()){
        cout << d[i] << " ";
    }
    cout << "\n";

    REP(i,N){
        ll tarx = X[i]-Y[i];
        ll tary = X[i]+Y[i];
        ll nowx = 0;
        ll nowy = 0;

        REP(j,d.size()) {
            char next;
            ll D = d[j];
            int posx,posy;
            if (abs(tarx-(nowx-D)) < abs(tarx-(nowx+D))){
                posx = -1;
                nowx -= D;
            }else{
                posx = 1;
                nowx += D;
            }

            if (abs(tary-(nowy-D)) < abs(tary-(nowy+D))){
                posy = -1;
                nowy -= D;
            }else{
                posy = 1;
                nowy += D;
            }

            if (posx == -1 and posy == -1) next = 'L';
            if (posx == -1 and posy == 1) next = 'U';
            if (posx == 1 and posy == 1) next = 'R';
            if (posx == 1 and posy == -1) next = 'D';
            cout << next;

        }
        cout << "\n";
    }


}






Measured memory_bytes: 256
from collections import deque
N,M=map(int,input().split())
B=[[] for i in range(N)]

for i in range(M):
  a,b=map(int,input().split())
  B[a-1].append(b-1)
  B[b-1].append(a-1)
  
visited=[0]*N
d = deque()
ans=[-1]*N
d.append(0)
visited[0]=1
while d:
  c=d.popleft()
  for e in B[c]:
    if visited[e]:
      continue
      
    d.append(e)
    visited[e]=1
    ans[e]=c
    
print("Yes")
for i in range(1,N):
  print(ans[i]+1)

Measured memory_bytes: 94884
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
ll M = 1e9 + 7;
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} }


int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	int n; cin>>n;
	set <string> s;
	for(int i=0;i<n;i++)
	{
	    string h; cin>>h;
	    s.insert(h);
	}
	cout<<s.size();
	return 0;
}


Measured memory_bytes: 19284
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
                long m = 0;
                long a = 0;
                long r = 0;
                long c = 0;
                long h = 0;
                long n = 0;
                String S[] = new String [N];
                for(int i=0;i<N;i++){
                      S[i] = String.valueOf(sc.next().charAt(0));
                      if(S[i].equals("M"))
                             m++;
                      else if(S[i].equals("A"))
                             a++;
                      else if(S[i].equals("R"))
                             r++;
                      else if(S[i].equals("C"))
                             c++;
                      else if(S[i].equals("H"))
                             h++;
                 }
                 


//		System.out.println(m + " " + a + " "+ r + " "+ c + " "+ h );
               n =  m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h ;

               System.out.println(n);
	}
}

Measured memory_bytes: 46228
plant, nobiro, tidime = gets.split(' ').map(&:to_i)
days = gets.to_i

days.times do
	order = gets
	
	case order
	when "nobiro\n"
		plant += nobiro
	when "tidime\n"
		plant += tidime
	when "karero\n"
		plant = 0
	end
	if plant < 0
		plant = 0
	end
end
puts plant


Measured memory_bytes: 6876
#include <iostream>

using namespace std;

int main()
{
    int A, B, C, K;

    cin >> A >> B >> C >> K;

    int ANS = 0;

    while (true)
    {

        if (K == A)
        {
            ANS = A * 1;
            break;
        }

        if (K < A)
        {
            ANS = K * 1;
            break;
        }

        if (K > A)
        {
            if (A != 0)
            {
                ANS = A * 1;
                K -= A;
            }
        }

        if (K == B)
        {
            break;
        }

        if (K < B)
        {
            break;
        }

        if (K > B)
        {
            K -= B;
        }

        ANS -= K;
        break;
    }

    cout << ANS << endl;
}

Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==7&&b==5&&c==5){cout<<"YES";return 0;}
	if(a==5&&b==7&&c==5){cout<<"YES";return 0;}
	if(a==5&&b==5&&c==7){cout<<"YES";return 0;}
	cout<<"NO";
	return 0;
}

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

using namespace std;
const int N = 2e5 + 100;
const int M = N << 2;
const int INF = 0x3f3f3f3f;

int H, W;

int L[M], R[M], Min[M], tag[M];

#define ls (x << 1)
#define rs (x << 1 | 1)

inline void pushup(int x) {
	Min[x] = min(Min[ls], Min[rs]);
	tag[x] = 0;
}

inline void build(int x, int l, int r) {
	L[x] = l; R[x] = r; Min[x] = tag[x] = 0;
	if(L[x] == R[x]) return ;
	int mid = (L[x] + R[x]) >> 1;
	build(ls, l, mid); 
	build(rs, mid + 1, r);
}	

inline int Query(int x, int id) {
	if(L[x] == R[x]) 
		return Min[x];
	else if(tag[x]) return Min[x] + id - L[x];
	int mid = (L[x] + R[x]) >> 1;
	if(id <= mid) return Query(ls, id);
	else return Query(rs, id);
}

inline void update(int x, int l, int r, int v) {
	if(l <= L[x] && R[x] <= r) {
		Min[x] = v + L[x] - l;
		tag[x] = 1;
		return ;
	}
	int mid = (L[x] + R[x]) >> 1;
	if(L[x] < R[x] && tag[x]) {
		tag[ls] = tag[rs] = 1;
		Min[ls] = Min[x];
		Min[rs] = Min[x] + mid + 1 - L[x];
	}
	if(l <= mid) update(ls, l, r, v);
	if(mid + 1 <= r) update(rs, l, r, v); 
	pushup(x);
}

void Debug() {
	for(int i = 1;i <= W; ++i)
		printf("%d ", Query(1, i));
	puts("");
}

int main() {
	scanf("%d%d", &H, &W); build(1, 1, W);
	// Debug();
	for(int i = 1;i <= H; ++i) {
		int s, t, tmp; 
		scanf("%d%d", &s, &t);
		if(s == 1) tmp = INF;
		else tmp = Query(1, s - 1);
		update(1, s, t, tmp + 1);
		printf("%d\n", Min[1] + i >= INF ? -1 : Min[1] + i);

		// Debug();
	}
	return 0;
}

Measured memory_bytes: 11984
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; scanf("%d", &N);
    vector< vector< pair<int, int> > > G(N);
    for(int i=0; i<N; i++) {
        int u, k; scanf("%d%d", &u, &k);
        for(int j=0; j<k; j++) {
            int v, c; scanf("%d%d", &v, &c);
            G[u].emplace_back(v, c);
        }
    }

    vector<int> dist(N, INF), checked(N);
    dist[0] = 0, checked[0] = true;

    int u = 0;
    for(int i=0; i<N; i++) {
        for(auto e : G[u]) {
            int v, c; tie(v, c) = e;
            chmin(dist[v], dist[u] + c);
        }

        int ma = INF, v = 0;
        for(int k=0; k<N; k++) {
            if(checked[k]) continue;
            if(ma > dist[k]) {
                ma = dist[k];
                v = k;
            }
        }
        checked[v] = true;
        swap(u, v);
    }

    for(int i=0; i<N; i++) {
        printf("%d %d\n", i, dist[i]);
    }
    return 0;
}



Measured memory_bytes: 3208
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

int main(){
  int x,a,b;
  cin>>x>>a>>b;
  int la,lb;
  if((a-x)>=0){
    la=a-x;
  }else{
	la=x-a;
  }
  if((b-x)>=0){
    lb=b-x;
  }else{
	lb=x-b;
  }
  if(la>lb){
    cout<<"B";
  }else{
	cout<<"A";
  }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
#define chmax(a,b) if(b>a) a = b
#define chmin(a,b) if(b<a) a = b
typedef long long ll;
using namespace std;

using namespace std;


int main(){
        ios_base::sync_with_stdio(false); 
        cin.tie(NULL);
        ll n; cin >> n;
        ll ans = 0;
        rep2(i,1,n+1) ans += i;
        rep2(i,2,n+1){
                ll base = 1;
                while(1){
                        if(i*base > n) break;
                        ans += i * base;
                        base++;
                }
        }
        cout << ans << endl;

        return 0;
}


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

const int INF = 0xfffffff;
const int MAX = 100;

struct Edge {
	int v;
	int c;
};

int main() {
	int n;
	vector<Edge> graph[MAX];
	int table[MAX];
	bool check[MAX];

	cin >> n;
	for (int i = 0; i < n; i++) {
		table[i] = INF;
		check[i] = false;
	}

	for (int i = 0; i < n; i++) {
		int u, k;
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			Edge e;
			cin >> e.v >> e.c;
			graph[u].push_back(e);
		}
	}

	int u = 0;
	table[0] = 0;
	while (true) {
		check[u] = true;

		for (int i = 0; i < graph[u].size(); i++) {
			int v = graph[u][i].v;
			int c = graph[u][i].c;
			if (table[v] > c + table[u]) {
				table[v] = c + table[u];
			}
		}

		int m = INF;
		int prev = u;
		for (int i = 0; i < n; i++) {
			if (check[i])continue;
			if (table[i] < m) {
				m = table[i];
				u = i;
			}
		}
		if (u == prev)break;
	}

	for (int i = 0; i < n; i++) {
		cout << i << " " << table[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 3196
#include <cstdio>
#include <cmath>
  
int main(){
    double x1,x2,x3,y1,y2,y3,r,xp,yp;
    int n;
    scanf("%d",&n);
    for(int i = 0 ; i < n ; i++){
	scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
 
	xp = (y2-y3)*(x1*x1+y1*y1)+(y3-y1)*(x2*x2+y2*y2)+(y1-y2)*(x3*x3+y3*y3);
	xp /= 2*(x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2));
	yp = (x2-x3)*(x1*x1+y1*y1)+(x3-x1)*(x2*x2+y2*y2)+(x1-x2)*(x3*x3+y3*y3);
	yp /= 2*(y1*(x2-x3)+y2*(x3-x1)+y3*(x1-x2));
	r = sqrt((x1-xp)*(x1-xp)+(y1-yp)*(y1-yp));
	printf("%.3lf %.3lf %.3lf\n",xp,yp,r);
    }
    return 0;
}

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

int main(){
  int n;
  int count=0;
  cin >> n;
  vector<int>a(n);
  
  for(int i=0;i<n;i++){ //input array
    cin >> a.at(i);
  }
  
  int b=1;
  while(b==1){
   for(int i=0;i<n;i++){
     if(a.at(i)%2==1){ //Odd
       b=0;
       break;
     }
     else
       a.at(i) = a.at(i)/2;
  if(i==n-1)
    count++;
   }
  }  
  cout << count << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <queue>

#define rep(i,n) for(int i=0; i<(n); i++)

using namespace std;

typedef long long int ll;

// Primal-Dual Algorithm
// ref: https://tjkendev.github.io/procon-library/python/min_cost_flow/primal-dual.html
class MinCostFlow {
public:
	const ll INF = 1e18;
	const ll MAX_COST = 1e9+9;

	struct edge {
		int to;
		ll cap;
		ll cost;
		ll res;
		int r_edge;
	};

	int N;
	vector<vector<edge>> G;

	MinCostFlow(int n): N(n), G(n) {}

	void add_edge(int from, int to, int cap, int cost){
		G[from].push_back({to, cap, cost, cap, (int)G[to].size()});
		G[to].push_back({from, 0, -cost, 0, (int)G[from].size()-1});
	}

	ll flow(int S, int T, int flow){
		ll res = 0;
		vector<ll> H(N);  // ポテンシャル
		vector<int> pre_v(N), pre_e(N);

		while(flow > 0){
			vector<ll> D(N, INF);
			priority_queue<pair<ll,int>> que;

			D[S] = 0;
			que.emplace(0, S);
			while(!que.empty()){
				ll d = que.top().first;
				ll i = que.top().second;
				que.pop();
				if(D[i] < d) continue;
				rep(v, G[i].size()) if(G[i][v].res > 0) {
					edge &e = G[i][v];
					if (D[e.to] > D[i] + e.cost + H[i] - H[e.to]) {
						D[e.to] = D[i] + e.cost + H[i] - H[e.to];
						pre_v[e.to] = i;
						pre_e[e.to] = v;
						que.emplace(D[e.to], e.to);
					}
				}
			}

			if( D[T] == INF ) return -1;

			rep(i,N) H[i] += D[i];

			ll f = flow;
			for(int i=T; i != S; i = pre_v[i]) f = min(f, G[pre_v[i]][pre_e[i]].res);

			flow -= f;
			res += f * H[T];
			for(int i=T; i != S; i = pre_v[i]){
				edge &e = G[pre_v[i]][pre_e[i]];
				e.res -= f;
				G[i][e.r_edge].res += f;
			}
		}

		return res;
	}

	void reset(){
		for(auto &g: G) for(auto &e: g) e.res = e.cap;
	}
};


// verify: AOJ GRL_6_B
#include <iostream>
int main(){
	int V, E, F;
	cin >> V >> E >> F;
	MinCostFlow fl(V);
	rep(i,E){
		int	u, v, c, d;
		cin >> u >> v >> c >> d;
		fl.add_edge(u, v, c, d);
	}

	cout << fl.flow(0, V-1, F) << endl;
}


Measured memory_bytes: 3268
from scipy.sparse import*
def main():
  f=csgraph.floyd_warshall
  n,m,l,*t=map(int,open(0).read().split())
  m*=3
  *_,=map(print,f(f(csr_matrix((t[2:m:3],(t[:m:3],t[1:m:3])),[n+1]*2),0)<=l)[t[m+1::2],t[m+2::2]].clip(0,n)%n-1)
main()

Measured memory_bytes: 40864
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int R, G, B, N;
    // スペース区切りの整数の入力
    cin >> R >> G >> B >> N;

    if(G < B)
        swap(G, B);
    if(R < G)
        swap(R, G);

    
    int num = 0;
    for(int r=0; r*R <= N; r++){
        if(r*R == N){
            num++;
            break;
        }

        for(int g=0; r*R + g*G <= N; g++){
            if(r*R + g*G == N){
                num++;
                break;
            }

            int temp = N - r*R - g*G;
            if(temp % B == 0){
                num++;
            }
        }
    }

    //cout << (a+b+c) << " " << s << endl;
    cout << num << endl;
    return 0;
}

Measured memory_bytes: 256
import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

n,s=map(int,input().split())
x=list(map(int,input().split()))
x2=[]
for i in x:
    x2.append(abs(i-s))

print(gcd_list(x2))


Measured memory_bytes: 16208
A = input()
if len(A)%2 == 0 and len(A) / 2 == 1:
  print('9')
elif len(A) % 2 == 0 and len(A) / 4 == 1:
  print('909')
elif len(A) % 2 == 0 and len(A) / 6 == 1:
  print('90909')
elif len(A)%2 == 1 and len(A) / 1 == 1:
  print(A)
elif len(A)%2 == 1 and len(A) / 3 == 1:
  A = int(A)
  p = A%100 + 9
  p += ((A//100)-1)*100
  print(p+1)
elif len(A)%2 == 1 and len(A) / 5 == 1:
  A = int(A)
  p = A%10000 + 909
  p += ((A//10000)-1)*10000
  print(p+1)

Measured memory_bytes: 3064
from bisect import bisect_left
n=int(input())
l=sorted(list(map(int,input().split())))
ans=0
for b in range(n):
    for a in range(b):
        ab=l[a]+l[b]
        x=bisect_left(l,ab)
        y=b+1
        ans+=x-y
print(ans)
#ABC143D

Measured memory_bytes: 3316
from heapq import heappop,heappush
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
p.sort(reverse=1)
q=list(map(int,input().split()))
q.sort(reverse=1)
r=list(map(int,input().split()))+[0]
r.sort(reverse=1)
h=[]
m=p[0]
for i in range(x):
  heappush(h,p[i])
  m=min(m,p[i])
for i in range(y):
  heappush(h,q[i])
  m=min(m,q[i])
i=0
while m<r[i]:
  _=heappop(h)
  heappush(h,r[i])
  m=heappop(h)
  heappush(h,m)
  i+=1
print(sum(h))

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int A, B, C; cin >> A >> B >> C;
    int K; cin >> K;
    bool flg = false;
    for(int i = 0; i <= K; i++){
        for(int j = 0; j <= K; j++){
            for(int k = 0; k <= K; k++){
                if(i+j+k <= K){
                    int ta = A, tb = B, tc = C;
                    rep(a, i) ta *= 2;
                    rep(b, j) tb *= 2;
                    rep(c, k) tc *= 2;
                    if(ta < tb && tb < tc) flg = true;
                }
            }
        }
    }
    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3648
n,k = map(int,input().split())

h = [int(input()) for i in range(n)]
h.sort()

loopn = n-k+1

ans = 10**10

for i in range(loopn):
    sa = h[i+k-1] - h[i]
    if sa < ans:
        ans = sa
        
print(ans)


Measured memory_bytes: 7384
// https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_c

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

ll k,a,b;
ll ans = 0;

void solve(){
    if(b-a<2){
        ans= k+1;
        }
    else{
        ans = max(0ll,(k-(a-1))/2)*(b-a) + a + (k-(a-1))%2;
    }
    cout << ans << endl;
}

int main(){
    cin >> k >> a >> b;
    solve();
}

Measured memory_bytes: 3676
#include<stdio.h>
int main()
{
	char n[200005];
	scanf("%s", n);
	int i, x = 0;
	for (i = 0; n[i] != '\0'; i++)
		x = (x + n[i] - '0') % 9;
	if (x == 0)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 1812
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

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

    int ans = 0;
    if(n % 2 == 0){
        ans = n / 2 - 1;
    }else{
        ans = (n - 1) / 2;
    }

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


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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
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 list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    N = I()
    s = S()
    t = [set() for _ in range(4)]
    t[0].add("")
    for c in s:
        for i in range(2,-1,-1):
            for k in t[i]:
                t[i+1].add(k+c)

    return len(t[3])


print(main())





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


int main(){
	long long n;
	while(cin >> n,n != 0){	
		int op = 0;
		while(n != 1){
			n = n % 2 == 0 ? n/2 : 3*n+1;
			op++;
		}
		cout << op << endl;
	}
	return 0;
}



Measured memory_bytes: 3000
#define ONLINE_JUDGE
#include<bits/stdc++.h>

#define HEAP priority_queue
#define rep(i, n) for(int i = 0, _end_ = (n); i < _end_; ++i)
#define per(i, n) for(int i = (n) - 1; i >= 0 ; --i)
#define forn(i, l, r) for(int i = (l), _end_ = (r); i <= _end_; ++i)
#define nrof(i, r, l) for(int i = (r), _end_ = (l); i >= _end_; --i)
#define FOR(a, b) for(auto (a): (b))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define X first
#define Y second
#define eps 1e-6
#define pi 3.1415926535897932384626433832795
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(), x.end()
#define FILL(a, b) memset((a), (b), sizeof((a)))
#define MCPY(a, b) memcpy((a), (b), sizeof((b)))

using namespace std;

typedef long long LL;
typedef double flt;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<int,LL> pil;
typedef pair<LL,int> pli;
typedef pair<LL,LL> pll;
typedef vector<pil> vil;
typedef vector<pii> vii;
typedef vector<pli> vli;
typedef vector<pll> vll;

const int iinf = 1e9 + 7;
const int oo = 0x3f3f3f3f;
const LL linf = 1ll << 60;
const flt dinf = 1e60;

template <typename T>
inline void scf(T &x)
{
	bool f = 0; x = 0; char c = getchar();
	while((c < '0' || c > '9') && c != '-') c = getchar();
	if(c == '-') { f = 1; c = getchar(); }
	while(c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); }
	if(f) x = -x; return;
}
template <typename T1, typename T2>
void scf(T1 &x, T2 &y) { scf(x); return scf(y); }
template <typename T1, typename T2, typename T3>
void scf(T1 &x, T2 &y, T3 &z) { scf(x); scf(y); return scf(z); }
template <typename T1, typename T2, typename T3, typename T4>
void scf(T1 &x, T2 &y, T3 &z, T4 &w) { scf(x); scf(y); scf(z); return scf(w); }

inline char mygetchar(){ char c = getchar(); while(c == ' ' || c == '\n') c = getchar(); return c; }

template <typename T> inline bool chkmax(T &x, const T &y){ return y > x ? x = y, 1 : 0; }
template <typename T> inline bool chkmin(T &x, const T &y){ return y < x ? x = y, 1 : 0; }

#ifdef ONLINE_JUDGE
#define debug(...) ;
#else
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define DEBUG
#endif

//---------------------------------------------------------head----------------------------------------------------

const int maxn = 66;

LL H(LL x)
{
	LL y = 1ll;
	while(y <= x) y <<= 1;
	y >>= 1;
	return y;
}

int main()
{
	LL A, B;
	scf(A, B);
	if(A == B)
	{
		puts("1");
		return 0;
	}

	bool fuck = 0;
	while(H(A) == H(B))
	{
		A ^= H(A);
		B ^= H(B);
		fuck = 1;
	}

	/*
	if(fuck)
	{
		LL ans = H(B) - A;
		LL C = B ^ H(B);

		ans += H(B) - max(A, H(C) << 1);

		ans += H(C) << 1;
		if(!H(C)) ++ans;

		printf("%lld\n", ans);
		return 0;
	}
	*/

	LL ans = H(B) - A;
	LL C = B ^ H(B);
	if(!A) A = 1;
	if(!C)
	{
		++ans;
		ans += H(B) - A;
	}
	else
	{
		ans += H(B) - max(A, H(C) << 1);
		ans += H(C) << 1;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())

    ans = 0
    for i in range(1, n + 1):
        if len(str(i)) % 2 != 0:
            ans += 1

    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 38768
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace lean {
    class Program {
        static void Main() {
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int x = a[0];
            int[] lis = new int[] { };
            if (a[1] == 0)
            {
                Console.WriteLine(a[0]);
                Environment.Exit(0);
            }
            lis = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] result = lis;

            for (int i = 0; i <= 1919; i++)
            {
                if (!result.Contains(a[0] - i))
                {
                    Console.WriteLine(a[0] - i);
                    return;
                }
                if(!result.Contains(a[0] + i)) {
                    Console.WriteLine(a[0] + i);
                    return;
                }
            }

        }
    }
}

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


struct activity
{
	int A;
	int B;
	int C;
};

int happiness(activity arr[], int n)
{
	int dp[n + 1][3];

	//Base Cases
	dp[1][0] = arr[1].A;		//Day 1 activity 1
	dp[1][1] = arr[1].B;		//Day 1 activity 2
	dp[1][2] = arr[1].C;     	//Day 1 activity 3

	for (int day = 2; day <= n; day++)
	{
		dp[day][0] = arr[day].A + max(dp[day - 1][1], dp[day - 1][2]); //on day, i do 0th activity
		dp[day][1] = arr[day].B + max(dp[day - 1][0], dp[day - 1][2]);
		dp[day][2] = arr[day].C + max(dp[day - 1][0], dp[day - 1][1]);
	}

	int res = max(dp[n][0], max(dp[n][1], dp[n][2])); //What is max at nth day
	return res;
}


int main()
{

	int n;
	cin >> n;
	activity arr[n + 1];

	for (int i = 1; i <= n; i++)
	{
		cin >> arr[i].A;
		cin >> arr[i].B;
		cin >> arr[i].C;
	}

	cout << happiness(arr, n);
}

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

int main() {
	int h, w, k; cin >> h >> w >> k;
	int s[h][w];
	for(int i = 0; i < h; ++i) {
		for(int j = 0; j < w; ++j) {
			char c; cin >> c;
			s[i][j] = c - '0';
		}
	}
	int ans = 1e9;
	for(int mask = 0; mask < (1 << (h - 1)); ++mask) {
		int anss = __builtin_popcount(mask);
		int msk = mask | (1 << (h - 1));
		int cnt[h] = {};
		bool able = true;
		for(int j = 0; j < w; ++j) {
			int idx = 0;
			for(int i = 0; i < h; ++i) {
				cnt[idx] += s[i][j];
				if(msk >> i & 1) {
					++idx;
				}
			}
			bool reset = false;
			for(int i = 0; i < h; ++i) {
				if(cnt[i] > k) {
					reset = true;
				}
			}
			if(reset) {
				anss++;
				for(int i = 0; i < h; ++i) {
					cnt[i] = 0;
				}
				int idx = 0;
				bool end = false;
				for(int i = 0; i < h; ++i) {
					cnt[idx] += s[i][j];
					if(cnt[idx] > k) {
						end = true;
					}
					if(msk >> i & 1) {
						++idx;
					}
				}
				if(end) {
					able = false;
				}
			}
		}
		if(able) {
			ans = min(ans, anss);
		}
	}
	cout << ans << '\n';
	return 0;
}

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


bool check (unsigned bitmask, const vector< vector< pair<int, int> > > &test)
{
	vector<int> v (test.size());
	for (int i = 0; i < test.size(); i++)
		if (bitmask & (1 << i))
			v[i] = 1;
		else
			v[i] = 0;
	for (int i = 0; i < test.size(); i++)
	{
		if ((bitmask & (1 << i)) == 0)
			continue;
		for (auto &p : test[i])
			if (v[p.first] != p.second)
				return false;
	}
	return true;
}

int cont (int bitmask)
{
	int c = 0;
	for (int i = 0; i < 20; i++)
		if (bitmask & (1 << i))
			c++;
	return c;
}

int main()
{
  int n, a, x, y;
  cin >> n;
  
  vector< vector< pair<int, int> > > test (n);
  
  for (int i = 0; i < n; i++)
  {
  	cin >> a;
  	while (a--)
  	{
  		cin >> x >> y;
  		test[i].push_back(pair<int, int>(x - 1, y));
  	}
  }
  
  int mx = 0;
  for (unsigned i = 0; i < (1 << (n)); i++)
  	if (check(i, test))
  	  mx = max(mx, cont(i));
  
  cout << mx << "\n";
  
  return 0;
}

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

int main() {
	// your code goes here
	int n;cin>>n;
	int a[n][n];
	int M=1e9+7;
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)cin>>a[i][j];
	int dp[1<<n]={0};
	dp[0]=1;
	for(int i=0;i<1<<n;i++){
	//	cout<<"kneffkl "<<i<<endl;
		int x=__builtin_popcount(i);
		for(int j=0;j<n;j++){
			if(a[x][j]==1 && !(i&1<<j)){
				int m2=i^1<<j;
				
				dp[m2]+=dp[i];
				dp[m2]%=M;
				//cout<<i<<" "<<m2<<" "<<dp[m2]<<endl;
				
			}
		}
	}
	
	int m=1<<n;
	m--;
	
	cout<<dp[m]<<endl;
	
	return 0;
}

Measured memory_bytes: 11796
#include<iostream>
#include<string>
#include<math.h>
using namespace std;

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	double m;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	int X[100] = { 0 };
	cin >> n >> b;
	cout << n - b + 1;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <bitset>
#include <map>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
#include <sstream>
#include <math.h>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecchar vector<char>
#define vecstr vector<string>
#define vec2str vector<vector<string>>
#define vecbool vector<bool>
#define vec2bool vector<vector<bool>>
#define pairll pair<ll,ll>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

#define Pi 3.1415926535897932384626

int main() {
	ll d, t, a;
	string s = "No";
	bool flag = false;

	cin >> d >> t >> a;

	double ans = (double)d / (double)a;

	if (ans <= (double)t)
		s = "Yes";

	cout << s;
}


Measured memory_bytes: 3580
#include<iostream>
#include<set>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int d[k];
    for(int i=0;i<k;i++){
        cin>>d[i];
    }
    for(int i=n;i<100000;i++){
        int tmp=i;
        set<int>s;
        while(tmp!=0){
            s.insert(tmp%10);
            tmp/=10;
        }
        bool flag=true;
        for(int j=0;j<k;j++){
            if(s.count(d[j])) flag=false;
        }
        if(flag){
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}

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

#define pii  pair<int, int>
#define vi vector<int >
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (x).size()
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal

#define ll long long
#define ld long double

const ld EPS = 10e-9;
const int INF = 1e9 + 5;
const long long INFLL = (ll)INF * (ll)INF;
const ll MOD = 1e9 + 7;
const ld PI = 3.14159265358979323846;

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

template <typename T>
ostream& operator<<(ostream& os, const set<T>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it;
        if (it != *v.rbegin())
            os << ", ";
    }
    os << "}\n";
    return os;
}

template <typename T>
ostream& operator<<(ostream& os, const unordered_set<T>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it;
        if (it != *v.rbegin())
            os << ", ";
    }
    os << "}\n";
    return os;
}

template <typename T, typename S>
ostream& operator<<(ostream& os, const map<T, S>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it.first << " : "
           << it.second;

        if( it != *v.rbegin())
            os  << ", ";
    }

    os << "}\n";
    return os;
}

template <typename T, typename S>
ostream& operator<<(ostream& os, const unordered_map<T, S>& v)
{
    os << "{";
    for (const auto& it : v) {
        os << it.first << " : "
           << it.second;

        if( it != *v.rbegin())
            os  << ", ";
    }

    os << "}\n";
    return os;
}

template <typename T, typename S>
ostream& operator<<(ostream& os, const pair<T, S>& v)
{
    os << "(";
    os << v.first << ", "
       << v.second << ")";
    os << "\n";
    return os;
}

#define DEBUG

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define debug(...)
#endif


// __gcd(x, y)

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

    string t;
    cin >> t;

    for(int i = 0; i < t.size(); i++)
    {
        if(t[i] == '?')
            t[i] = 'D';
    }

    cout << t << endl;

    return 0;
}


Measured memory_bytes: 3772
#include<stdio.h>
int main(){
  int a,b,n,mini;
  int i,c,shiro;
  scanf("%d",&n);
  scanf("%d%d",&a,&b);
  shiro=b-a;
  if(a<=b)mini = a;
  else mini = b;
  for(i=2;i<n;i++){
    scanf("%d",&c);
    if(c<mini)mini=c;
    else if(shiro<c-mini)shiro=c-mini;
  }    
printf("%d\n",shiro);
return 0;
}



Measured memory_bytes: 2140
#include<iostream>
#include<string>

using namespace std;

string S;
int N;

void input(){
  cin >> N;
  cin >> S;
}

void solve(){
  input();
  string tmp = "No";
  int K = N/2;
  if(N%2==0 && S.substr(0,K)==S.substr(K,K)) tmp="Yes";
  cout << tmp <<endl;
  return;
}

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

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
x1 = 0
X = [0 for i in range(N)]
for i, a in enumerate(A):
    if i % 2 == 0:
        x1 += a
    else:
        x1 -= a
X[0] = x1
for i, a in enumerate(A[:-1], 1):
    X[i] = (a - X[i-1]//2)*2
print(' '.join(map(str, X)))

Measured memory_bytes: 19096
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

/*
　　　　　　　　　　　　　　　　　　　　　__,.二ﾆ==-　　ﾆ．、_.　　　　　　　　　　　　　　　　　　　　　
　　　　　　　　　　　　　　　　.,.．‐　⌒　　　　　　　　　　　　｀`'ァ-ﾆ、.　　　　　　　　　　　　　　　
　　　　　　　　　　　　　　ィ'´.　　　　　　　　　　　　　　　　　　　　　　´丶.、　　　　　　　　　　　　
　　　　　　　　　　　.,ィ'´　　　　　　　　　　　　　　　　　　　　　　　　　　　　`.ｘ、..　　　　　　　　　
　..　　　　　　　　／.　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　､＼.　　　　　　　　
　　　　　　　　.ﾝ′.　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　￢`""冖ｰミト．
　　　　　　　,ｒ′.　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　.ﾍ、　　　　`
　　　　　　ﾂ　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`、....　　　
　　　　　./´　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　ﾍ　　　　
　.....　　/.　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　.〉.　　　
　　　´/..　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　.ｌ　　　
　　　ｨ　　　　　　　　　　　　　　　　　　　　　　　　　．　　　　　　　　　　　　　　　　　　　　　ｆ..　　
　..　.ｆ　,d.　　　　　　　　　　　　　　　　　l　　　′　」　　,.　　　　　　　　　　　　　ﾄ　　　　　！　　
　.　〕../.ｆ..　　　　　　　　　　　　　　　　　′　．.　　|　　.｝　　　　　　　　　　　　　|　　　　　　|.　　
　　.!./..f..　　　　　　　　　　　　　　　　　/　　!－　ナ丶п冖т　　　　ﾉｰ-　．　〕　　　　　　|.　　
　　|ﾒ　|　　　　　　　　　　　　　　　｜　j　　　　　　,　　┌．　|〈.　　　л`.　　　/|..　　　　　┤,..　
　...「...｜.　　　　　　|　　´　　　　　　l.　|　　j.Ｌ......ｭ.Ｌ＿└ヽ_｜Y.　　ﾒムｗ　ょ　|　　j.:　　　|　￣
　.　　｜.　　　　　　　　　　　　　　　т〕＜.ィ冖T冖..　г‐　`､　`,　/┴￢..г￣|..　.′　　｜　　
　...　　|　　　　　　　　．..　　　　　　　),|..　｀　　ﾘ　「_ﾉ.||　　　　`　V　　|!｛,｢ll　´.」.　　　　　卜　　
　.　　｜.」　　　　　　′　　　　　　　　ヽ　　　　└++〃..　　　　　　　　ﾙｗｆ　　ｶz′.　　　｜.　　
　　　　|..〕　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　｢　　　　　．|　　　
　　　　.ｌ.|.　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　′.　　　　　|　　　
　.　　　.〕..　　　　　　　　　　　　　　　`!　　　　　　　　_...．.ｰ：''　　　　　　　　　｣　´　　　　λ.　　
　　　　_｢.　　　　,　　　　　　　　　　　　┐_,、｀~‐''"´　　　　　　　　　　　　　　　　ィ　　　.､　ﾍ、　
　　　　ｆ　　　　　　:_＿..,二ュ．-i―'''^~´　　　　　　　　　　　　　　　　　　　　　　　､＼イ　ヘ．`ｘ
　.　　/　　　　　　｛　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　j　　　　.~^
　　､/　　　　　　　'ｔ..　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　丿..　　　　　
　.../.　　　　　　　,x┐..　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　∠∫　　　　　
　:^.　　　　　　　/　　￣冖ー=zzｭ┌ｰ―--　　　∟,二...＿.　　　　　　　_,､．-ｰ.'l+~.　.l｀．　　　　
　.　　　　　　　У.　　　　　　　　　⌒冖‐-=．_..　l｢.｢　　　　　　´￣｣了　　.,､-''＾　　　〉　ヽ_　　　
　　　　　　　_/.　　　　　　　　　　　　　　　　　　￣~'.ー-=．、＿,..usｧ.ｰ''"　　　　　　｛　　　＼´　
　　　　　　_ヰl'￢―-　､_　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　（　　　　.＼
*/

using namespace std;

using ll = long long int;
using ull = unsigned long long int;

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n,ll mod = MOD){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%mod;
        }
        x = (x*x)%mod;
        n >>= 1;
    }
    return ret;
}

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

ll twoPow(ll shiftNum){
    return (1LL << (shiftNum - 1));
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    ll n,m;
    cin >> n >> m;

    cout << (n*(n-1))/2 + (m*(m-1))/2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

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

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

    sort(a.begin(),a.end());
    ll sum = 0;
    for(int i = 0; i < n-1; i++){
        sum += a[i];
    }

    if(sum > a[n-1]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b, x int64

	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&x)

	var ans = divisions(b, x) - divisions(a-1, x)

	fmt.Println(ans)

}

func divisions(max, x int64) int64 {
	if max < 0 {
		return 0
	}
	return max/x + 1

}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int n;
  cin>>n;
  map<string,int> mp;
  for (int i = 0; i < n; ++i)
  {
    string s;
    cin>>s;
    mp[s]++;
  }
  vector<string> ans;
  int tmp=0;
  for(auto&& e: mp) 
  {
    tmp=(e.second>tmp?e.second:tmp);
  }
  for(auto&& e: mp) 
  {
    if(tmp==e.second)
    {
      ans.push_back(e.first);
    }
  }
  sort(ans.begin(), ans.end());
  for(auto&& e: ans) 
  {
    cout<<e<<endl;
  }
}

Measured memory_bytes: 26868
n = int(input())
ans_list = []
tasu = []
for i in range(1,n):

    if n%i == 0:
        ans_list.append([i,n//i])
        tasu.append(i+n//i)
    if i*i > n:
        break
ans = ans_list[tasu.index(min(tasu))]
print(ans[0] + ans[1]-2)


Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <iomanip>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll N,M;
    cin >> N >> M;
    vector<pair<ll,ll>> Stu(N);
    vector<pair<ll,ll>> Map(M);
    for (int i = 0; i < N; ++i) {
        ll a,b;
        cin >> a >> b;
        Stu[i] = make_pair(a,b);
    }
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        Map[i] = make_pair(a,b);
    }
    for (int ni = 0; ni < N; ++ni) {
        ll m = 1ll<< 50;
        ll to = -1;
        for (int mi = 0; mi < M; ++mi) {
            ll d = abs(Map[mi].first - Stu[ni].first) + abs(Map[mi].second - Stu[ni].second);
            if(m > d){
                m = d;
                to = mi;
            }
        }

        cout << to + 1 << endl;
    }

}


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

    int e0, e1, o0, o1;
    e0 = e1 = o0 = o1 = 0;
    for (int i = 0; i < S.size(); i++) {
        if (i % 2 != 0) {
            if (S[i] == '0')      o0++;
            else if (S[i] == '1') o1++;
        } else {
            if (S[i] == '0')      e0++;
            else if (S[i] == '1') e1++;
        }
    }

    int ans = 0;
    if (o0 + e1 > o1 + e0) ans = o1 + e0;
    else ans = o0 + e1;

    cout << ans << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int n,l,a[100010];
int main()
{
	scanf("%d%d",&n,&l);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<n;i++)
		if(a[i]+a[i+1]>=l)
		{
			printf("Possible\n");
			for(int j=1;j<i;j++)
				printf("%d\n",j);
			for(int j=n-1;j>=i;j--)
				printf("%d\n",j);
			return 0;
		}
	printf("Impossible");
}

Measured memory_bytes: 1152
#include <iostream>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>
#include <cstdarg>
#include <set>

using namespace std;
#define INF 2e9 + 9
#define MOD 1000000007
#define ALL(v) v.begin() , v.end()
#define Int int64_t
#define pll pair<Int,Int>
template<class T> using pql = priority_queue<T, vector<T>>;
template<class T> using pq = priority_queue<T, vector<T>, greater<T>>;
#define ll(n) Int n; cin >> n;
#define LL(...) Int __VA_ARGS___; cin >> __VA_ARGS___;
#define OUT(...) cout << __VA_ARGS___;
#define RP(n, i, s) for(Int i = s ;i < n ;i++)
#define REP(n, i) for (Int i = 0; i < n; i++)
#define REPe(n, i) for (Int i = 1; i <= n; i++)
#define RPe(n, i, s) for (Int i = s; i <= n; i++)
#define upd_max(maxer, updater) if (maxer < updater) maxer = updater;

struct node {
    Int to;
    Int length;
};


vector<Int> divisor(Int n) {
    vector<Int> ret;
    for (Int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    return (ret);
}

/*
vector<vector<int>> to;
vector<int> flag;
vector<int> c;


Int dfs(int from, int mae) {
    flag[from] = 1;
    Int mini = 0;
    for (auto next : to[from]) {
        if (next == mae) continue;
        if (flag[next] == 1) {
            return -1;
        } else {
            mini = min(mini, dfs(next, from));
        }
    }
    return mini;
}*/

int dx8[8] = {0, -1, -1, -1, 0, 1, 1, 1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};

struct datas{
    Int max;
    Int size;
};

int main(void) {
    Int n;
    cin >> n;
    for(int i = ceil(sqrt(n)); 0 < i; i--)  {
        if (n % i == 0){
            cout << i  + n / i - 2 << endl;
            return 0;
        }
    }
    return 0;
}




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


int calc(int s, int e, int X, int Y) {
    if (e <= X) {
        return e - s;
    } else if (s >= Y) {
        return e - s;
    } else if (s > X && e < Y) {
        return min(e - s, s - X + Y - e + 1);
    } else if (s <= X && e >= Y) {
        return (X - s) + (e - Y) + 1;
    } else if (s > X && s < Y) {
        return min((s-X) + 1 + (e - Y), e - s);
    } else {
        return min(e - s, (X - s) + 1 + (Y - e));
    }
}

const int maxn = 2e3 + 100;
int res[maxn];

void solve(long long N, long long X, long long Y){
    for (int s = 1; s <= N-1; s++) {
        for (int e = s + 1; e <= N; e++) {
            int dis = calc(s, e, X, Y); 
            res[dis]++;
            // cout << s  << " to " << e << " = " << dis << endl;
        }
    }
    for (int i = 1; i <= N-1; i++) {
        cout << res[i] << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(N, X, Y);
    return 0;
}


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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define CIN(v) cin >> v;
#define COUT(v) cout << v << "\n";

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

  int H, N;

  CIN(H >> N);

  int c = 0;
  int a = 0;
  for (int i = 0; i < N; i++) {
    CIN(a);
    c += a;
  }

  if (H <= c) {
    COUT("Yes");
  } else {
    COUT("No");
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int dy[] = {-1, -1, 0, 0, 1, 1};
int dx[2][6] = {{-1, 0, -1, 1, -1, 0}, {0, 1, -1, 1, 0, 1}};
bool visited[128][128], wall[128][128];
long long h, w, ret;

void init(void)
{
	for (int i = 0; i < 128; i++){
		for (int j = 0; j < 128; j++){
			visited[i][j] = false;
			wall[i][j] = false;
		}
	}
}

void dfs(int y, int x)
{
	if (visited[y][x]) return;
	if (y < 0 || x < 0 || y > h+1 || x > w+1) return;

	visited[y][x] = true;
	for (int i = 0; i < 6; i++){
		int ny = y + dy[i];
		int nx = x + dx[y % 2][i];
		if (ny < 0 || nx < 0 || ny > h+1 || nx > w+1) continue;
		if (wall[ny][nx]) {
			ret++;
			continue;
		}
		dfs(ny, nx);
	}
	return;
}

int main(void)
{
	int a;

	init();
	cin >> w >> h;
	for (int i = 1; i <= h; i++){
		for (int j = 1; j <= w; j++){
			cin >> a;
			if (a) wall[i][j] = true;
		}
	}

	ret = 0;
	dfs(0, 0);

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 1508