akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits.h>

using namespace std;
int main()
{
	long long X, Y, Z, K;
	cin >> X >> Y >> Z >> K;
	vector<long long> A(X, 0);
	vector<long long> B(Y, 0);
	vector<long long> C(Z, 0);

	for(int i = 0; i < X; i += 1) cin >> A[i];
	for(int i = 0; i < Y; i += 1) cin >> B[i];
	for(int i = 0; i < Z; i += 1) cin >> C[i];

	sort(A.begin(), A.end(), greater<long long>());
	sort(B.begin(), B.end(), greater<long long>());
	sort(C.begin(), C.end(), greater<long long>());

	K = min(K, X * Y * Z);
	vector<long long> E;
	for(int x = 0; x < min(X, K); x += 1)
	{
		for(int y = 0; y < min(Y, K); y += 1)
		{
			E.emplace_back(A[x] + B[y]);	
		}
	}
	sort(E.begin(), E.end(), greater<long long>());
	vector<long long> res;
	for(int x = 0; x < min((long long)E.size(), K); x += 1)
	{
		for(int y = 0; y < min(Z, K); y += 1)
		{
			res.emplace_back(E[x] + C[y]);	
		}
	}
	sort(res.begin(), res.end(), greater<long long>());
	for(int i = 0; i < K; i += 1)
	{
		cout << res[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 43240
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
using namespace std;

int main() {

	int n, x, count = 1;

	cin >> n >> x;

	vector<int> l(100), d(10000);

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

	d[0] = 0;
	for (int i = 1; i <= n; i++) {
			d[i] = d[i - 1] + l[i - 1];
		if (d[i] <= x) {
			count++;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	b2i := func(b bool) int {
		if b {
			return 1
		}
		return 0
	}

	prime := func(n int) []int {
		ans := make([]int, n+1)
		for i := 2; i <= n; i++ {
			b := ans[i] == 0
			ans[i] = ans[i-1] + b2i(b)
			if b {
				for j := i * 2; j <= n; j += i {
					ans[j] = 1
				}
			}
		}
		return ans
	}
	reader := bufio.NewScanner(os.Stdin)
	primeT:=prime(999999)
	for reader.Scan() {
		n, _ := strconv.Atoi(reader.Text())
		fmt.Println(primeT[n])
	}
}


Measured memory_bytes: 9444
#include <stdio.h>
int main(void)
{
    int n,i;
    unsigned long int sum=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        if( i%3!=0 && i%5!=0 ){
            sum+=i;
        }
    }
    printf("%ld",sum);
    return 0;
}


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

int main() {
    int n, m;
    while (cin >> n >> m, n || m) {
        vector<int> T(n), H(m);
        int tarou{0}, hanako{0};
        for (int i = 0; i < n; i++) {
            cin >> T[i];
            tarou += T[i];
        }
        for (int i = 0; i < m; i++) {
            cin >> H[i];
            hanako += H[i];
        }

        long long Sum = 10000000000LL;
        int a = -1, b = -1;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (tarou + H[j] - T[i] == hanako + T[i] - H[j]) {
                    if (T[i] + H[j] < Sum) {
                        a = T[i], b = H[j];
                        Sum = T[i] + H[j];
                    }
                }
            }
        }
        if (a != -1 && b != -1) {
            cout << a << " " << b << endl;
        } else {
            cout << -1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3016
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(30) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> S >> D;
  N=S.size();
  TV(DP,lli,N,D,2,0);//桁DP:=上位i桁を決めたときの総和mod4がjになるものの総数
  rep(i,0,10)if(int(S[0]-'0')==i){DP[0][i%D][0]++;break;}else DP[0][i%D][1]++;
  rep(i,1,N)rep(j,0,D)rep(f,0,2)rep(k,0,10){
    int x=(j+k)%D;
    int y=S[i]-'0';
    if(!f&&y<k)continue;
    else if(!f&&y==k){
      DP[i][x][0]+=DP[i-1][j][0];
      DP[i][x][0]%=mod;
    }
    else{
      DP[i][x][1]+=DP[i-1][j][f];
      DP[i][x][1]%=mod;
    }
  }
  Out((DP[N-1][0][1]+DP[N-1][0][0]+mod-1)%mod);//0は入らない
}


Measured memory_bytes: 55296
import sys
readline = sys.stdin.readline

S = readline().rstrip()

# パーを出せるときは必ずパーを出すのが最善
# g p g pの順で出せばよい
# 相手の手が、
# i % 2 == 0のとき
# gであれば0、pであれば-1
# i % 2 == 1のとき
# gであれば+1、pであれば0

ans = 0
for i in range(len(S)):
  if i % 2 == 0:
    if S[i] == "p":
      ans -= 1
  elif i % 2 == 1:
    if S[i] == "g":
      ans += 1
      
print(ans)

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

#define PI 3.14159265

struct __point
{
  double x;
  double y;
};

__point get_s(__point p1, __point p2)
{
  __point s;
  s.x = (2 * p1.x + p2.x) / 3;
  s.y = (2 * p1.y + p2.y) / 3;
  return s;
}

__point get_t(__point p1, __point p2)
{
  __point t;
  t.x = (p1.x + 2 * p2.x) / 3;
  t.y = (p1.y + 2 * p2.y) / 3;
  return t;
}

__point get_u(__point s, __point t)
{
  __point u;
  double d = PI * 60 / 180; // degrees
  u.x = cos(d) * (t.x - s.x) - sin(d) * (t.y - s.y) + s.x;
  u.y = sin(d) * (t.x - s.x) + cos(d) * (t.y - s.y) + s.y;
  return u;
}

void print_point(__point p)
{
  cout << p.x << " " << p.y << endl;
}

void kock(int n, __point p1, __point p2)
{
  if (!n) return;
  __point s, u, t;
  s = get_s(p1, p2);
  t = get_t(p1, p2);
  u = get_u(s, t);

  /* recusion */
  kock(n - 1, p1, s);
  print_point(s);
  kock(n - 1, s, u);
  print_point(u);
  kock(n - 1, u, t);
  print_point(t);
  kock(n - 1, t, p2);
}

int main()
{
  int n;
  cin >> n;
  __point p1, p2;
  p1.x = 0;   p1.y = 0;
  p2.x = 100; p2.y = 0;
  print_point(p1);
  kock(n, p1, p2);
  print_point(p2);
  return 0;
}

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

using namespace std;

int main(void){
    int n;
    cin >> n;
    vector<double> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    for(int i = 0; i < n-1; i++){
        a[i+1] = (a[i] + a[i+1])/2;
    }
    cout << fixed << setprecision(10) << a[n-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int             long long int
#define ld                 long double
#define ff                 first
#define ss                 second
#define P                 pair<int,int>
#define pb                 push_back
#define mod             1000000007
#define inf             1e18
#define endl            '\n'
const int N = 105;//change it when needed
const int W = 1e5;
int a[N], b[N];
int dp[W];
int n, w;
int go() {
    for (int i = 0; i < n; i++) {
        for (int j = w; j >= 0; j--) {
            if (j - a[i] >= 0) {
                dp[j] = max(dp[j], b[i] + dp[j - a[i]]);
            }
        }
    }
    return dp[w];
}
void solve() {
    cin >> n >> w;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        dp[i] = 0;
    }
    cout << go();
}

int32_t main()
{
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    // int t; cin >> t; while (t--)
    solve();
    return 0;
}

Measured memory_bytes: 1152
//Name : Rupa Dey
  //Date : 27 august 2020
//joi sri gour hori gobindo...
//gobindo ja hobe vlor jonnoi hobe..
#include<bits/stdc++.h>
#define ll long long
#define d double
#define ld long double
#define vi vector<int>
#define vul vector<ull>
#define vl vector<ll>
#define pb push_back
#define si set<int>
#define sl set<ll>
#define yes cout<<"YES\n"<<endl
#define no cout<<"NO\n"<<endl
#define ys cout<<"Yes\n"<<endl
#define n cout<<"No\n"<<endl
#define test cin>>t; while(t--)
#define for(i,a,n) for(i=a;i<n;i++)
#define mp make_pair
#define ft first
#define sc second
#define gap " ";
#define MAX 9999999
#define MOD 1000000007
#define nd endl
using namespace std;
int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int i,sum=0,x;
    string a;
    cin>>a;
    for(i,0,a.size())
    {
        sum+=(a[i]-'0');
       // cout<<sum<<nd;
    }
    //cout<<sum<<endl;
    if(sum%9==0)
        ys;
    else
        n;
}
//hare krishna...
//hey gobindo kripa koro......
//only gobindo exists..^..


Measured memory_bytes: 3716
# -*- coding: utf-8 -*-

# input
A, B = map(int, input().split())

# solve
card = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1]
if card.index(A) > card.index(B):
    ans = 'Alice'
elif card.index(A) < card.index(B):
    ans = 'Bob'
else:
    ans = 'Draw'

# output
print(ans)


Measured memory_bytes: 3060
//   PIGMEISTER™   //

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define sidha(i,x,n) for(ll i=(ll)(x);i<(ll)(n);++i)
#define ulta(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);--i)
#define sab(a) a.begin(),a.end()
#define bas(a) a.rbegin(),a.rend()
#define test ll _;cin>>_;while(_--)
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD (ll)1000000007
//#define MOD (ll)998244353
#define PI (ld)3.141592653589793238
#define MAX 100005

int main()
{
    jaldi;
    
    ll x, y;
    cin >> x >> y;

    if (y&1^1 and y >= 2*x and y <= 4*x) {
        cout << "Yes\n";
    }
    else cout << "No\n";
    
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX 1000000000
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 10010010010001;
vector<vector<bool>> graph;
vector<bool> reached;
vector<int> A,B;
int N,M;

void dfs(int v){
    reached[v] = true;
    for(int i=0;i<N;i++){
        if(graph[v][i] == false) continue;
        if(reached[i]) continue;
        dfs(i);
    }
}

//要素数が問題だったなぜか突き止める
int main(){
    cin >> N >> M;
    graph = vector<vector<bool>>(N,vector<bool>(M,false));
    reached = vector<bool>(N);
    A = vector<int>(M);
    B = vector<int>(M);
    for(int i=0;i<M;i++){
        cin >> A[i] >> B[i];
        A[i]--;B[i]--;
        graph[A[i]][B[i]] = graph[B[i]][A[i]] = true;
    }

    int ans = 0;
    for(int i=0;i<M;i++){
        graph[A[i]][B[i]] = graph[B[i]][A[i]] = false;
        for(int j=0;j<N;j++) reached[j] = false;
        dfs(0);
        bool bridge = false;
        for(int j=0;j<N;j++){
            if(reached[j] == false){
                bridge = true;
                break;
            }
        }
        if(bridge) ans++;
        graph[A[i]][B[i]] = graph[B[i]][A[i]] = true;        
    }
    cout << ans << endl;
    
}


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

int main() {
  string s;
  cin >> s;
  bool a = true;
  for(int i = 0; i < s.size(); i += 2) {
    if(s.at(i) == 'L') a = false;
  }
  for(int i = 1; i < s.size(); i += 2) {
    if(s.at(i) == 'R') a = false;
  }
  if(a) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

char a[110],b[110];

bool cmpMin(char A,char B){
	return A<B;
}

bool cmpMax(char A,char B){
	return A>B;
}

int main(){
	scanf("%s %s",a,b);
	sort(a,a+strlen(a),cmpMin);
	sort(b,b+strlen(b),cmpMax);
	if(strcmp(a,b)<0)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 764
#include <iostream>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	int x=0,y=1000000;
	for(int i=1;i<=m;i++)
	{
		int l,r;
		cin>>l>>r;
		if(l>x) x=l;
		if(r<y) y=r;
	}
	if(y-x+1<0) cout<<0;
	else cout<<y-x+1;
	return 0;
}

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

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

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

const llong inf = 1'000'000'000'000'007ll;
const llong mod = 1e9+7;

llong GCD(llong a, llong b){
	a = abs(a), b = abs(b);
	while(b){
		a %= b;
		swap(a,b);
	}

	return a;
}

map<llong, int> PrimeFact(llong n){
	map<llong, int> ret;
	while(n % 2 == 0){
		ret[2]++;
		n /= 2;
	}
	for(llong i = 3; i*i <= n; i += 2){
		while(n%i == 0){
			ret[i]++;
			n /= i;
		}
	}
	if(n != 1)
	ret[n]++;

	return ret;
}

int main() {
	llong A, B;
	cin >> A >> B;

	auto ans = PrimeFact(GCD(A, B));

	cout << ans.size() + 1 << endl;

	return 0;
}

Measured memory_bytes: 256
package main

import (
        "fmt"
)

func solution(n, m int) int {
        n = n - 2
        m = m - 2
        if n < 0 {
                n = 1
        }
        if m < 0 {
                m = 1
        }
        return n * m
}

func main() {
        var n, m int
        fmt.Scan(&n, &m)
        fmt.Println(solution(n, m))
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    char t[1000001], p[10001];
    int jt[10001];
    cin.getline(t, 1000001);
    int tl=cin.gcount()-1;
    cin.getline(p, 10001);
    int pl=cin.gcount()-1;
    if(pl>tl) return 0;

    jt[0]=-1;
    jt[1]=0;
    int i=2, j=0;
    while(i<=pl){
        if(p[i-1]==p[j]){
            jt[i]=j+1;
            ++i;
            ++j;
        } else if(j>0) j=jt[j];
        else jt[i++]=0;
    }
    i=j=0;
    while(i<tl){
        if(t[i]==p[j]){
            ++i;
            ++j;
            if(j==pl){
                cout<<i-pl<<'\n';
                j=jt[j];
            }
        }else if(j==0) ++i;
        else j=jt[j];
    }
    return 0;
}



Measured memory_bytes: 4204
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        int[] arr = new int[s.length()];
        for (int i = 0; i < s.length(); i++) {
            arr[i] = s.charAt(i) == 'B' ? 1 : 0;
        }

        long sum = 0;
        int num = 0;
        for (int i = 0; i < s.length(); i++) {
            if(arr[i] == 0){
                sum += i - num;
                num++;
            }
        }
        System.out.println(sum);
    }
}

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

int main() {
  int H,W,A,B;
  cin >> H >> W >> A >> B;
  for(int i=0;i<B;i++){
    for(int j=0;j<A;j++){
      cout << "0";
    }
    for(int j=A;j<W;j++){
      cout << "1";
    }
    cout << "" << endl;
  }
  for(int i=B;i<H;i++){
    for(int j=0;j<A;j++){
      cout << "1";
    }
    for(int j=A;j<W;j++){
      cout << "0";
    }
    cout << "" << endl;
  }

}


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

int main(){
	int N;
		cin >> N;
		int A[N];
		int m1=0,m2=0,n1;
		for(int i=0;i<N;i++){
			cin >> A[i];
			if(m1 < A[i]){m2=m1;m1=A[i];n1=i;}
			else if(m2 < A[i]) m2=A[i];
		}
		for(int i=0;i<N;i++){
			if(i != n1) cout << m1 << endl;
			else cout << m2 << endl;
		}
	return 0;
}



Measured memory_bytes: 2432
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define Reverse(x) reverse(all(x));
#define Sort(x) sort(all(x));
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    int n, m;
    cin >>n >> m;
    dsu d(n);
    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        d.merge(a, b);
    }
    vector<vector<int>> group = d.groups();
    out(group.size() - 1);
}

Measured memory_bytes: 11688
from collections import deque

# class Node():
#   def __init__(self, key):
#     self.key = key
#     self.prev = self.next = None
  
# class DoublyLinkedList():
#   def __init__(self):
#     self.head = Node(None)
#     self.head.prev = self.head
#     self.head.next = self.head

#   def keys(self):
#     cur = self.head.next
#     keys = []
#     while cur != None and cur.key != None:
#       keys.append(cur.key)
#       cur = cur.next
#     return keys

#   def search(self, key):
#     cur = self.head.next
#     while cur != None and cur.key != key and cur.key != None:
#       cur = cur.next
#     return cur

#   def insert(self, key):
#     node = Node(key)
#     node.prev = self.head
#     node.next = self.head.next
#     self.head.next.prev = node
#     self.head.next = node

#   def deleteKey(self, key):
#     node = self.search(key)
#     if node != None and node.key != None:
#       self.deleteNode(node)

#   def deleteNode(self, node):
#     if node == None and node.key == None:
#       return
#     node.prev.next = node.next
#     node.next.prev = node.prev

#   def deleteFirst(self):
#     self.deleteNode(self.head.next)

#   def deleteLast(self):
#     self.deleteNode(self.head.prev)    

n = int(input())
commands = [input() for _ in range(n)]

q = deque()
for command in commands:
  op = command.split()
  if op[0] == "insert":
    q.appendleft(op[1])
  elif op[0] == "delete":
    try:
      q.remove(op[1])
    except ValueError as err:
      pass
  elif op[0] == "deleteFirst":
    q.popleft()
  elif op[0] == "deleteLast":
    q.pop()
print(" ".join(map(str, q)))



Measured memory_bytes: 212324
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
int MOD = 10000000;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

const int MX = 100005;

int ans[MX], vst[MX];
vector<pii> G[MX];
int N, M;

int dfs(int x){
	if( vst[x] ) return true;
	vst[x] = 1;
	int ch = 1;

	for(pii c : G[x]){
		if( vst[c.second] ){
			if( ans[x] + c.first != ans[c.second] ) ch = 0;
		}
		else{
			ans[c.second] = ans[x] + c.first;
			ch &= dfs(c.second);
		}
	}
	return ch;
}

int main()
{
	scanf("%d%d", &N, &M);
	for(int i = 1; i <= M; i++){
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		G[a].emplace_back(c, b);
		G[b].emplace_back(-c, a);
	}
	int ch = 1;
	for(int i = 1; i <= N; i++){
		if( vst[i] ) continue;
		ans[i] = 0;
		ch &= dfs(i);
	}
	if( !ch ) printf("No\n");
	else printf("Yes\n");
}


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int a , b , x;

int main()
{
    _FastIO;
    cin >> a >> b >> x;
    if(x >= a && x <= (a + b)){
        cout << "YES" << endl;
    }
    else
        cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,j=0;
  cin >> N;
  for (int i=0;i<N;i++){
    string s;
    cin >> s;
    if (s=="Y"){
      cout << "Four" <<endl;
      j=j+1;
      break;
    }
  }
   if(j!=1)cout<<"Three"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#define N_MAX 100000

using namespace std;
int main(){
  int N,A[N_MAX+1],B[N_MAX];
  long long cnt=0;
  cin >> N;
  for(int i=0;i<N+1;i++)cin >> A[i];
  for(int i=0;i<N;i++)cin >> B[i];
  
  for(int i=0;i<N;i++){
    if(B[i]>A[i]){cnt+=A[i];B[i]-=A[i];}
    else {cnt+=B[i];B[i]=0;}
    if(B[i]>A[i+1]){cnt+=A[i+1];A[i+1]=0;}
    else {cnt+=B[i];A[i+1]-=B[i];}
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
using namespace std;
int main(){
    double N,K;
    cin >> N >> K;
    double ans=0;
    double count=1;
    for(int i=0;i<N;i++){
        double now = i+1;
        if(now<=K-1){
            while(1){
                count = count * ((double)1/2);
                now = now * 2;
                if(now>K-1){
                    break;
                } 
            }
        }
        ans = ans + ((double)1/N)*count;
        count = 1;
    }
    printf("%.11f\n",ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string a;
    cin>>a;
    int l,r;
    for(int i=0;i<a.size();i++)
    {
        if(a[i]=='A') 
        {
            l=i;
            break;
        }       
    } 
    for(int i=a.size()-1;i>=0;i--)
    {
        if(a[i]=='Z') 
        {
            r=i;
            break;
        }
    }
    cout<<r-l+1<<endl;  
    return 0;
}

Measured memory_bytes: 640
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto r = RD;
	auto D = RD;
	auto x2000 = RD;

	long last = x2000;
	foreach (i; 0..10)
	{
		auto x = last * r - D;
		writeln(x);
		last = x;
	}

	stdout.flush();
	debug readln();
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
	for (auto i : a) cerr << i << ' ';\
	cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, l;
	cin >> n >> l;
	vector<ll> a(n);
	forn(i, 0, n) cin >> a[i];
	vector<ll> next(n - 1), prev(n - 1), nextpos(n - 1), prevpos(n - 1);
	forn(i, 0, n - 1) nextpos[i] = i + 1;
	nextpos[n - 2] = -1;
	forn(i, 0, n - 1) next[i] = a[i + 1];
	forn(i, 0, n - 1) prevpos[i] = i - 1;
	forn(i, 0, n - 1) prev[i] = a[i];
	set<int> ok;
	forn(i, 0, n - 1) if (prev[i] + next[i] >= l) ok.insert(i);
	vector<int> ans;
	while (!ok.empty()) {
		int i = *ok.begin();
		ok.erase(i);
		ans.eb(i);
		if (prevpos[i] != -1) {
			nextpos[prevpos[i]] = nextpos[i];
			next[prevpos[i]] += next[i];
			if (next[prevpos[i]] + prev[prevpos[i]] >= l) ok.insert(prevpos[i]);
		}
		if (nextpos[i] != -1) {
			prevpos[nextpos[i]] = prevpos[i];
			prev[nextpos[i]] += prev[i];
			if (next[nextpos[i]] + prev[nextpos[i]] >= l) ok.insert(nextpos[i]);
		}
	}
	if (ans.size() == n - 1) {
		cout << "Possible\n";
		reverse(all(ans));
		for (int i : ans) cout << i + 1 << '\n';
	} else cout << "Impossible\n";
	return 0;
}

Measured memory_bytes: 9472
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int p;
    cin >> p;
    p -= p % 500;
    cout << p << endl;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};



signed main(){
  int a,b,c,d;cin>>a>>b>>c>>d;
  if(a*b>=c*d){
    cout<<a*b<<endl;
  }else{
    cout<<c*d<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string A, B;
  int a, b;
  string C;
  cin >> A >> B >> a >> b >> C;
  if(A == C) {
    cout << a - 1 << " " << b << endl;
  }
  else {
    cout << a << " " << b - 1 << endl;
  }
}


Measured memory_bytes: 3596
/*
    C - Exception Handling
    https://atcoder.jp/contests/abc134/tasks/abc134_c
*/
#include <bits/stdc++.h>
using namespace std;

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

    int n;
    cin >> n;
    vector<int> Ai(n);
    int highest = -1, second = -1;

    for (int i = 0; i < n; i++) {
        int input;
        cin >> input;
        Ai[i] = input;
        if (highest < input) {
            second = highest;
            highest = input;
        } else if (second < input) {
            second = input;
        }
    }
    // cerr << "high, secon = " << highest << ", " << second << endl;

    for (auto n : Ai) {
        if (n == highest) {
            cout << second << endl;
        } else {
            cout << highest << endl;
        }
    }
}

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



int main()
{
    ll  N, x; cin >> N >> x;
    vector<ll> A(N); for(ll i = 0; i < N; i++) cin >> A[i];
    
    ll ans = 0;
    for(ll i = 0; i < N; i++){
        if(i == 0){
            if(A[i] > x){
                int dec = A[i] - x;
                ans += dec;
                A[i] = A[i] - dec;
                //cout << dec << " " << A[i] << endl;
            }
            continue;
        }
        if(A[i-1] + A[i] > x){
            ll dec = A[i] + A[i-1] - x;
            A[i] -=  dec;
            ans += dec;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
//ABC 125 B
#include <iostream>
using namespace std;

int main() {
	int n;
	cin >> n;
	int v[n], c[n], sum=0;

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

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

	for (int i=0; i<n; i++) {
		if (v[i]-c[i]>0) {
			sum += v[i]-c[i];
		}
	}

	cout << sum;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define REP(i, n) for(int i = 0;i < n;i++)
    #define REPR(i, n) for(int i = n;i >= 0;i--)
    #define FOR(i, m, n) for(int i = m;i < n;i++)
    #define FORR(i, m, n) for(int i = m;i >= n;i--)
    #define SORT(v, n) sort(v, v+n);
    #define VSORT(v) sort(v.begin(), v.end());
    #define llong long long
    #define pb(a) push_back(a)
    #define INF 999999999
    using namespace std;
    typedef pair<int, int> P;
    typedef pair<llong, llong> LP;
    typedef pair<int, P> PP;
    typedef pair<llong, LP> LPP;

    int dy[]={0, 0, 1, -1, 0};
    int dx[]={1, -1, 0, 0, 0};

    int main()
    {
        int n;
        cin >> n;
        vector<string> blue(n);
        for (int i = 0; i < n; i++) {
            cin >> blue[i];
        }
        int m;
        cin >> m;
        vector<string> red(m);
        for (int i = 0; i < m; i++) {
            cin >> red[i];
        }

        int ans = 0;
        auto calc = [&](string s) {
            int buf = 0;
            for (string t: blue) {
                if (t == s) buf++;
            }
            for (string t: red) {
                if (t == s) buf--;
            }
            return buf;
        }; //lambda-based for

        for (string t: blue) {
            ans = max(ans, calc(t));
        }

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



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

int main() {
  string s;
  cin >> s;
  if(s.at(0) == 'a' || s.at(0) == 'i' || s.at(0) == 'u'|| s.at(0) == 'e'|| s.at(0) == 'o') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}


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

typedef long long int ll;

int main()
{
    ll n, k;
    cin >> n >> k;
    
    ll t = n;
    ll ans = 0;
    while(t >= k){
        t /= k;
        ans++;
    }
    
    cout << ans+1; 

    return 0;
}

Measured memory_bytes: 256
S = input()
if S == 'SUN':
  print("7")
if S == 'MON':
  print("6")
if S == 'TUE':
  print("5")
if S == 'WED':
  print("4")
if S == 'THU':
  print("3")
if S == 'FRI':
  print("2")
if S == 'SAT':
  print("1")


Measured memory_bytes: 3060
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const ll MAX=1e15;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	ll dp[n+1][n+1];
	ll cost[n+1][n+1];
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=n;j++)
		{
			cost[i][j]=MAX;
		}
	}
	for(int i=1;i<=n;i++)
	{
		dp[i][i]=a[i-1];
		cost[i][i]=0;
	}
	for(int i=2;i<=n;i++)
	{
		for(int l=1,r=i;r<=n;r++,l++)
		{
			//cost[l][r]=min(cost[l][r],min(a[l-1]+dp[l+1][r]+cost[l+1][r],cost[l][r-1]+dp[l][r-1]+a[r-1]));
			dp[l][r]=a[l-1]+dp[l+1][r];
			for(int j=l;j<r;j++)
			{
				cost[l][r]=min(cost[l][j]+cost[j+1][r]+dp[l][r],cost[l][r]);
			}
		}
	}
	/*int dp2[n+1];
	for(int i=0;i<=n;i++)
	{
		dp2[i]=cost[1][i];
	}*/
	cout<<cost[1][n]<<"\n";

}

Measured memory_bytes: 6088
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define FOREACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIGN(x) (((x)>0)?1:(((x)<0)?-1:0))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
#define vv(t) vector< t > 
#define CHC(mp, x) if(mp.end() != mp.find(x))
#define CHCV(mp, x) if(mp.end() != find(ALL(mp), x))
template<typename T>
inline T lcm(T a, T b) {return a / __gcd(a, b) * b;}
#define fi first
#define se second
#define el endl
#pragma endregion


void Main();
void solve(long long N, long long M, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C);

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> B(M);
    std::vector<long long> C(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&B[i]);
        scanf("%lld",&C[i]);
    }
    solve(N, M, std::move(A), std::move(B), std::move(C));
}

void solve(long long N, long long M, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C){
    priority_queue<int, vector<int>, greater<int> > que;
    REP(i, N){
        que.push(A[i]);
    }
    vector<pair<int, int> > ch(M);
    REP(i, M){
        ch[i].fi=C[i]; ch[i].se=B[i];
    }
    sort(ALLR(ch));
    REP(i, M){
        int num = ch[i].fi;
        REP(j, ch[i].se){
            int t = que.top();
            if(num <= t){
                break;
            }
            que.pop();
            que.push(num);
        }
    }
    ll sum=0;
    REP(i, N){
        sum += que.top();que.pop();
    }
    cout << sum << el;
}



Measured memory_bytes: 3960
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int inf = 1012345678;
int main() {
	vector<int> A(5);
	cin >> A[0] >> A[1] >> A[2] >> A[3] >> A[4];
	vector<int> P = { 0, 1, 2, 3, 4 };
	int final_answer = inf;
	do {
		int ans = 0;
		for (int i = 0; i < 5; ++i) {
			while (ans % 10 != 0) ans += 1;
			ans += A[P[i]];
		}
		final_answer = min(final_answer, ans);
	} while (next_permutation(P.begin(), P.end()));
	cout << final_answer << endl;
	return 0;
}


Measured memory_bytes: 256
/*program from Wolfycz*/
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define inf 0x7f7f7f7f
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
inline char gc(){
	static char buf[1000000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int frd(){
	int x=0,f=1; char ch=gc();
	for (;ch<'0'||ch>'9';ch=gc())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=gc())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline int read(){
	int x=0,f=1; char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline void print(int x){
	if (x<0)	putchar('-'),x=-x;
	if (x>9)	print(x/10);
	putchar(x%10+'0');
}
const int N=1e5;
ll stack[N+10],f[N+10],delta[N+10];
int n,m,top;
void solve(ll x,ll v){
	int tmp=upper_bound(stack+1,stack+1+top,x)-stack-1;
	if (!tmp){
		delta[1  ]+=v;
		delta[x+1]-=v;
	}else	f[tmp]+=v*(x/stack[tmp]),solve(x%stack[tmp],v);
}
int main(){
	n=read(),m=read();
	stack[++top]=n;
	for (int i=1;i<=m;i++){
		ll x; scanf("%lld",&x);
		while (top&&x<=stack[top])	top--;
		stack[++top]=x;
	}f[top]=1;
	for (int i=top;i>1;i--)	f[i-1]+=f[i]*(stack[i]/stack[i-1]),solve(stack[i]%stack[i-1],f[i]);
	delta[1]+=f[1],delta[stack[1]+1]-=f[1];
	for (int i=1;i<=n;i++)	printf("%lld\n",delta[i]+=delta[i-1]);
	return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,c,k;
  cin>>n>>c>>k;
  int a[n];
  rep(i,n) cin>>a[i];
  sort(a,a+n);
  int nex=0,now=0;
  int ans=0;
  rep(i,n){
    if(nex<a[i] || now==c){
      nex=a[i]+k;
      now=1;
      ans++;
    }else{
      now++;
    }
  }
  cout<<ans<<endl;

  return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; i = i + 1)
#define array(N, t) (t*)calloc(N, sizeof(t))
#define ll long long
#define INF ((1LL << 62) - (1LL << 31))
#define max(p, q)((p) > (q) ? (p) : (q))
#define min(p, q)((p) < (q) ? (p) : (q))

char s[200010];
int main(){
    scanf("%s",s);
 
    int sum=0;
    for(int i=0;s[i]!='\0';i++)sum+=s[i]-'0';
    if(sum%9==0){
        puts("Yes");
    }else{
        puts("No");
    }
}


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

int main() {
  int K;
  int A;
  int B;
  cin >> K >> A >> B;
  int count=0;
  
  for(int i=A;i<=B;i++){
    if(i%K==0){
      count=count+1;
    }
  }

  if (count>0) {
    cout << "OK" << endl;
  }
  else{
  cout << "NG" << endl;
  }
}


Measured memory_bytes: 3632
N = int(input())
graph = []
for _ in range(N):
    x, y = map(int, input().split())
    graph.append([x, y])
if N == 1:
    print(1)
    exit()
ans = float('inf')
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        p = graph[i][0] - graph[j][0]
        q = graph[i][1] - graph[j][1]
        vec_cnt = 0
        for k in range(N):
            for l in range(N):
                if p == graph[k][0] - graph[l][0] and q == graph[k][1] - graph[l][1]:
                    vec_cnt += 1
        ans = min(ans, N - vec_cnt)
print(ans)

Measured memory_bytes: 9236
#include<iostream>
#include<vector>
#include<algorithm>

int main(){

    size_t n;
    std::cin >> n;

    std::vector<size_t> a(n);
    for(auto&& e : a){
        std::cin >> e;
    }

    if(n == 1){
        std::cout << 1 << std::endl;
        return 0;
    }

    a.erase(std::unique(a.begin(), a.end()), a.end());

    bool flag = a.at(0) <= a.at(1);
    size_t cnt = 1;
    for(size_t i = 1; i < a.size() - 1; i++){
        if(flag){
            if(a.at(i) > a.at(i + 1)){
                cnt++;
                if(i < n - 2){
                    flag = a.at(i + 1) <= a.at(i + 2);
                }
            }
        }else{
            if(a.at(i) < a.at(i + 1)){
                cnt++;
                if(i < n - 2){
                    flag = a.at(i + 1) <= a.at(i + 2);
                }
            }
        }
    }

    std::cout << cnt << std::endl;

    return 0;
}


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


int nearest_d(vector<int> &store, int order);
int search(vector<int> &store, int order);
int dist(vector<int> &store, int s, int order);

  
int main(){
  
  int d, store_num, order_num;
  while(cin >> d, d){
    int ans = 0;
  
    vector<int> store;
    cin >> store_num;

    cin >> order_num;
    store.push_back(0);
    for(int i = 0; i < store_num-1; i++){
      int input;
      cin >> input;
      store.push_back(input);
    }
    store.push_back(d);
    sort(store.begin(), store.end());

    for(int i = 0; i < order_num; i++){
      int order;
      cin >> order;
      ans += nearest_d(store, order);
    }
    cout << ans << endl;
  }
}


int nearest_d(vector<int> &store, int order){
  int s = search(store, order);
  int d1 = dist(store, s, order);
  int d2 = dist(store, s+1, order);

  return d1 < d2 ? d1 : d2;
}

int search(vector<int> &store, int order){
  int low = 0, high = store.size();
  int mid;

  while(low <= high){
    mid = (high + low) / 2;
    if(store[mid] == order) return mid;
    if(store[mid] < order)  low = mid+1;
    else  high = mid-1;
  }
  return (high + low)/2;
}

int dist(vector<int> &store, int s, int order){
  return store[s] - order > 0 ? store[s]-order: order-store[s];
}

Measured memory_bytes: 3456
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iomanip>
# define M_PIl        3.141592653589793238462643383279502884
using namespace std;

typedef long long ll;
typedef long double ld;

int main(){
  ll n;
  cin >> n;
  cout << n+(n*n)+(n*n*n) << endl;
}

Measured memory_bytes: 3112
N = int(input())
n = N

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

s = [0]
ans = float("inf")

for i in range(N):
    s.append(s[-1] + A[i])

for i in range(N-3):

    i += 1

    l = 0
    r = i+1

    while r-l != 1:

        m = (l+r) // 2
        if s[m] <= s[i+1] / 2:
            l = m
        else:
            r = m

    if l == 0:
        b = s[1]
        c = s[i+1] - b
    elif r == i+1:
        b = s[i]
        c = s[i+1]-s[i]
    elif abs(s[l] - s[i+1]/2) < abs(s[r] - s[i+1]/2):
        b = s[l]
        c = s[i+1]-s[l]
    else:
        b = s[r]
        c = s[i+1]-s[r]

    l = i+1
    r = n

    while r-l != 1:

        m = (l+r) // 2
        if s[m]-s[i+1] <= (s[n]-s[i+1])/2:
            l = m
        else:
            r = m

    if l == i+1:
        d = s[i+2]-s[i+1]
        e = s[n] - s[i+2]
    elif r == n:
        d = s[n-1]-s[i+1]
        e = s[n]-s[n-1]
    elif abs((s[l]-s[i+1]) - (s[n]-s[i+1])/2) < abs((s[r]-s[i+1]) - (s[n]-s[i+1])/2):
        d = s[l]-s[i+1]
        e = s[n]-s[l]
    else:
        d = s[r]-s[i+1]
        e = s[n]-s[r]

    ans = min(ans, max(b,c,d,e) - min(b,c,d,e))

print (ans)
    


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

int main(){
    int n; cin >> n;
    int a[n+1], tmp[n+1];
    int sum = 0;
    for(int i=0; i<n+1; i++){
        if(i<n){
            cin >> tmp[i];
        }else{
            tmp[i] = 0;
        }
        if(i!=0){
            a[i] = tmp[i]-tmp[i-1];
        }else{
            a[i] = tmp[i];
        }
        sum += abs(a[i]); 
    }
    for(int i=0; i<n;i++){
        // cout << a[i] << " " << a[i+1] << endl;
        if(a[i]*a[i+1]<0){
            cout << sum -min(abs(a[i]), abs(a[i+1]))*2 << endl;
        }else{
            cout << sum  << endl;
        }
    }    
}

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

int main()
{
    int n;
    cin >> n;
    string s;
    int ac = 0, wa = 0, tle = 0, re = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> s;
        if(s == "AC")
        {
            ac++;
        }
        else if(s == "WA")
        {
            wa++;
        }
        else if(s == "TLE")
        {
            tle++;
        }
        else if(s == "RE")
        {
            re++;
        }
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
    return 0;
}


Measured memory_bytes: 3632
//a b c d - b/w a and b, not evenly divided by c or d
//answer = totalbyc+totalbyd-totalbycandd
//final = b-a+1-answer
#include<bits/stdc++.h>
using namespace std;

long long gcd(long long c, long long d){
    if(d==0)return c;
    else return gcd(d,c%d);
}
long long lcm(long long c,long long d){
    //cout<<gcd(c,d)<<endl;
    return (c*d)/gcd(c,d);
}
int main(){
	long long a,b,c,d;
  cin>>a>>b>>c>>d;
  //first number divisibly by c
  //a+(c-a%c);b-b%c -
  long long first ;
  long long last ;
  long long total = 0;
  long long div;
  for(int i=0;i<3;i++){
    if(i==0)div=c;
    if(i==1)div=d;
    if(i==2){div = lcm(c,d);}
  	if(a%div!=0)first = a + div-a%div;
    else first = a;
    last = b - b%div;
    if(first>last || first>b || last<a)continue;
    if(i!=2){total+=(last-first)/div+1;}
    else {total-=(last-first)/div+1;}
  }
  cout<<b-a+1-total;
}

Measured memory_bytes: 3600
#include <stdio.h>
char ans[20] = {0};
int ex(int a,int b,int sa,int sb,int n,char str[20])
{
    if(a == sa&&b == sb)
    {
        printf("%s\n",str);
        return 0;
    }
    if((sa == 5&&sa - sb > 1)||(sb == 5&&sb - sa > 1))return 0;
    if(n == a + b)return 0;
    str[n] = 'A';
    ex(a,b,sa + 1,sb,n + 1,str);
    str[n] = 'B';
    ex(a,b,sa,sb + 1,n + 1,str);
    return 0;
}
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    ex(a,b,0,0,0,ans);
   return 0;
}

Measured memory_bytes: 1012
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N,A,B; //Nは駐車する時間 Aは1時間当たりの値段、BはプランBの固定料金
	cin >> N>>A>>B;
	if(A*N>=B){
		cout << B <<endl;
	}
	else if (A*N<B){
		cout << N*A <<endl;
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  ll k;
  cin >> n >> k;
  vl p(n), c(n);
  rep(i,n)cin >> p[i];
  rep(i,n)cin >> c[i];
  rep(i,n)p[i]--;
  ll ans = -1e18;
  rep(si,n){
    int x = si;
    vl s;
    ll tot = 0;
    while(1){
      x = p[x];
      s.push_back(c[x]);
      tot+=c[x];
      if(x == si)break;
    }
    int l = sz(s);
    ll t = 0;
    rep(i,l){
      t+=s[i];
      ll now = t;
      if(i >= k)break;
      if(tot>0){
        now+=tot*((k-(i+1))/l);
      }
      maxs(ans,now);    
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3736
def sumdigit(m):
    s=str(m)
    array=list(map(int,s))
    return sum(array)

N,A,B=map(int,input().split())
ans=0
for i in range(N+1):
    if A<=int(sumdigit(i))<=B:
        ans=ans+i
print(ans)

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

/* #pragma */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int
#define endl '\n'

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/*template*/
template<class T>constexpr bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>constexpr bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
constexpr int32_t GCD(int32_t a, int32_t b){return b ? GCD(b, a%b) : a;}
constexpr int64_t GCD(int64_t a, int64_t b){return b ? GCD(b, a%b) : a;}
constexpr int32_t LCM(int32_t a, int32_t b){return a / GCD(a, b) * b;}
constexpr int64_t LCM(int64_t a, int64_t b){return a / GCD(a, b) * b;}

/* const */
constexpr int32_t INF = 1001001001;
constexpr int64_t LINF = 1001001001001001001ll;
constexpr int32_t MOD = 1e9 + 7;
constexpr int32_t EPS = 1e-9;
constexpr int32_t dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//constexpr int32_t dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};


//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

//#define int int64_t

/*global*/



signed main()
{
	int n; cin >> n;
	vector<int> a(n);
	for(int i = 0, i_len = (int)n; i < i_len; ++i)
	{
		cin >> a[i];
		a[i]--;
	}
	
	vector<int> b(n);
	for(int i = 0, i_len = (int)n; i < i_len; ++i) cin >> b[i];
	
	vector<int> c(n-1);
	for(int i = 0, i_len = (int)n-1; i < i_len; ++i) cin >> c[i];
	
	int ans{};
	int keep=-100;
	for(int i{}; i < n; ++i)
	{
		ans += b[a[i]];
		if(keep+1 == a[i])
		{
			ans += c[keep];
		}
		keep = a[i];
	}
	cout << ans << '\n';
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int m=0;
  int t=0;
  for(int i=0;i<s.size();i++)
  {
    if(s[i]=='1')
      m++;
    else
      t++;
  }
  if(m==0 || t==0)
    cout<<'0';
  else
    cout<<s.size()-fabs(m-t);
  return 0;
}

Measured memory_bytes: 512