akhauriyash/Code-Regression huggingface dataset:
s = list(input())
q = int(input())

head = []
tail = []

mode = 0
for i in range(q):
  read = list(map(str,input().split()))
  if read[0]=='1':
    mode = (mode+1)%2
  else:
    if (read[1]=='1' and mode == 0) or (read[1]=='2' and mode == 1):
      head.append(read[2])
    else:
      tail.append(read[2])

s = head[::-1] + s
s = s + tail
if mode == 0:
  print(''.join(s))
else:
  print(''.join(s[::-1]))

Measured memory_bytes: 9308
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
//#include "library/debug.cpp"

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i, 0, n) cin >> h[i];
    sort(h.begin(), h.end());
    ll ans = 0;
    rep(i, 0, n - k) {
        ans += h[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
int main()
{
	int w,i,b,a,j,tmp=0;
	char s[2000];
	scanf("%s",s);
	scanf("%d",&w);
	for(i=0;i<strlen(s);i++)
	{
		if(i%w==0)
		{
		    printf("%c",s[i]);
		}
	}
	return 0;
} 

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
	"sort"
)

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

	var rep = make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Scan(&rep[i])
	}
	sort.Ints(rep)

	var deff []int
	for i := 0; i < len(rep)-1; i++ {
		temp := math.Abs(float64(rep[i]) - float64(rep[i+1]))
		deff = append(deff, int(temp))
	}
	sort.Ints(deff)

	ans := 0
	for i := 0; i <= len(deff)-n; i++ {
		ans += deff[i]
	}
	fmt.Println(ans)
}

Measured memory_bytes: 6784
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		int[] a=ir.nextIntArray(3);
		Arrays.sort(a);
		out.println(a[0]+a[1]);
	}

	public static void main(String[] args) throws Exception {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


Measured memory_bytes: 21332
#include <iostream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
using namespace std;
int main(){
	int n,d,i,x,j;
	int a[101]={0};
	cin>>n;
	cin>>d>>x;
	for(i=1;i<=n;i++){
		cin>>a[i];
	}
	int sum=0;
	for(i=1;i<=n;i++){
		for(j=0;j<=d;j++){
			if(j*a[i]+1<=d){
				sum++;
			}
		}
	}
	cout<<sum+x<<endl;
}

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

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

    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll ans=1000;
    rep(i,n-1){
        if(a[i]<a[i+1]){
            ll kabu=ans/a[i];
            ans-=kabu*a[i];
            ans+=kabu*a[i+1];
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF (1LL<<61 + 1<<29)
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout<< dest << (sizeof...(Args)?" ":""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define out(...) _OUTPUT_IMPL_(__VA_ARGS__)

int main() {
	in(int, r, g, b);
	YESNO(!((r * 100 + g * 10 + b) % 4));
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
using P = pair<int,int>;
const int MOD = 1e9+7;
#define rep(i,N) for(int (i) = 0; (i) < (N);++(i))

signed main(){
    long long N,A,B;
    cin >> N >> A >> B;
    long long ans = N*(B-A) - 2*(B-A) + 1;
    if(N == 1 && A != B) ans = 0;
    if(A > B) ans = 0;
    cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var s int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &s)

	mp := make(map[int]struct{})
	prev := s
	mp[prev] = struct{}{}
	for i := 2; i < 1000001; i++ {
		prev = f(prev)
		if _, e := mp[prev]; e {
			fmt.Println(i)
			return
		}
		mp[prev] = struct{}{}
	}
}

func f(n int) int {
	if n%2 == 0 {
		return n / 2
	}
	return 3*n + 1
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a-1; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define rALL(x) x.rbegin(), x.rend()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    ll x, y;    cin >> x >> y;
    if(!(x%y)) cout << -1 << endl;
    else{
        cout << x << endl;
    }
    
}


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

es = [[] for _ in range(N)]

for i in range(N-1):
    u,v,w = map(int, input().split())

    es[u-1].append((v-1,w))
    es[v-1].append((u-1,w))

ans = [-1] * N

ans[0] = 0

queue = [0]

while len(queue) > 0:
    next_queue = []
    for curr in queue:
        for next,w in es[curr]:
            if ans[next] == -1:
                    next_queue.append(next)
                    if w % 2 == 0:
                        ans[next] = ans[curr]
                    else:
                        ans[next] = 1 if ans[curr] == 0 else 0

    if len(next_queue) > 0:
        queue = next_queue
    else:
        queue = []

print(*ans, sep="\n")

Measured memory_bytes: 40364
import math

n = int(input())
x = list(map(int, input().split()))

p = sum(x) / n
p = [math.floor(p), math.ceil(p)]

min = 10000000

for a in p:
    y = list(map(lambda x: math.pow(x-a, 2), x))
    if sum(y) < min:
        min = sum(y)

print(int(min))



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<pii> a[n];
    rep(i,n){
        int x;
        cin >> x;
        rep(j,x){
            int p,q;
            cin >> p >> q;
            p--;
            a[i].pb(mp(p,q));
        }
    } 
    int mx=0;
    rep(i,bit(n)){
        set<int> justice;
        bool aljus=true;
        rep(j,n){
            if(i&(1<<j))justice.insert(j);
        }
        for(auto j:justice){
            for(auto x:a[j]){
                if(x.S==1 && justice.count(x.F)==0)aljus=false;
                if(x.S==0 && justice.count(x.F)==1)aljus=false;
            }
        }
        if(aljus)chmax(mx,sz(justice));
    }
    cout << mx;

    


}

/*



 */




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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619

map<ll ,ll> prime_factorize(long long N) {
    map<ll ,ll> res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }//Nがaで割り切れるときaは必ず素数

        // その結果を push
        res[a] = ex;
    }

    // 最後に残った数について
    if (N != 1) res[N] = 1;
    return res;
}

int main(){
    ll n;cin>> n;
    vector<ll>prime = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997};
    vector<map<ll,ll>>vec(n-1);
    for(int i=0;i<(n-1);i++){
        vec[i] = prime_factorize(n-i);
    }

    vector<ll>num((int)prime.size() ,0);
    for(int i=0;i<prime.size();i++){
        for(int j=0;j<(n-1);j++){
            if(vec[j].count(prime[i])){
                num[i] += vec[j].at(prime[i]);
            }
        }
    }

    mint ans = 1;
    for(int i=0;i<prime.size() ;i++) ans *= (mint)(num[i]+1);

    cout << ans << endl;

}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int minv = Integer.parseInt(br.readLine());
      int n1   = Integer.parseInt(br.readLine());
      int maxv = n1- minv;
      if ( n1 < minv ) minv = n1;

      for( int i=2,r,mv; i<n; i++ ) {
        r = Integer.parseInt(br.readLine());
        if ( (mv = r-minv) > maxv ) maxv = mv;
        else if ( r < minv ) minv = r; 
      }

      System.out.println(maxv);
    }
  }
}


Measured memory_bytes: 42912
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> p, c;
    rep(i, n){
        ll x;
        cin >> x;
        p.push_back(x-1);
    }
    rep(i, n) {
        ll x;
        cin >> x;
        c.push_back(x);
    }

    ll maxim=INT64_MIN;
    rep(i, n){
        vector<ll> sum;
        ll tmpsum=0, roop=0;
        int s = i;
        while(1){
            s = p[s];
            tmpsum += c[s];
            sum.push_back(tmpsum);
            if (++roop == k || i == s) {
              break;
            }
        }
        int len = sum.size();
        if(roop==k){
            sort(sum.begin(), sum.end());
            maxim = max(maxim, sum[len-1]);
        }else{
            if(sum[len-1]>0){
                ll tmp = sum[len-1] * (k / len);
                vector<ll> over;
                s = i;
                rep(j, k%len){
                    s = p[s];
                    tmp += c[s];
                    over.push_back(tmp);
                }
                rep2(j, k%len, len){
                    s = p[s];
                    tmp += c[s];
                    over.push_back(tmp - sum[len-1]);
                }
                sort(over.begin(), over.end());
                maxim = max(maxim, over[over.size()-1]);
            }else{
                sort(sum.begin(), sum.end());
                maxim = max(maxim, sum[len - 1]);
            }
        }
        // cout << maxim << endl;
    }
    cout << maxim << endl;
    return 0;
}

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

int main(){
string S;
  cin>>S;
  
  int ans=753;
  for(int i=0; i<S.size()-2; i++){
   int X=(S[i]-'0')*100+(S[i+1]-'0')*10+(S[i+2]-'0');
   int v=abs(X-753); // ↑文字どうしを引いてint型に入れれば数値に変換される
   ans=min(ans, v);  // 文字1はint型で数値49、文字0はint型で数値48なので、
  }                //  引くとint型表示できるようになる
  
  cout<<ans;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int K = scn.nextInt();
		int Q = scn.nextInt();
		int[] A = new int[N];
		for(int i = 0;i < Q;i++) {
			int a = scn.nextInt()-1;
			A[a]++;
		}
		int[] ans = new int[N];
		for(int i = 0;i < N;i++) {
			ans[i] = K -  Q + A[i];
		}

		for(int i = 0;i < N;i++) {
			System.out.println((ans[i] > 0)?"Yes":"No");
		}
	}

}


Measured memory_bytes: 55512
A = input().split()
N = []

for i in A:
    if i.isdigit():
        N.append(i)
    elif str(i) == '+':
        t1 = N.pop()
        t2 = N.pop()
        t3 = int(t2) + int(t1)
        N.append(t3)
    elif str(i) == '*':
        t1 = N.pop()
        t2 = N.pop()
        t3 = int(t2) * int(t1)
        N.append(t3)
    else:
        t1 = N.pop()
        t2 = N.pop()
        t3 = int(t2) - int(t1)
        N.append(t3)

print(N.pop())

Measured memory_bytes: 7728
import java.util.Scanner;

public class Main {

	public static void main(String args[]){
		
		Scanner cin = new Scanner(System.in);
		
		int count = cin.nextInt();
		long time = cin.nextLong();
		long sub;
		long sum_sub = 0L;
		long last_one=0L;
		long tmp;
		
		for(int i =0;i<count;i++){
			if(i==0){
				last_one = cin.nextLong();
			}else{
				tmp = cin.nextLong();
				sub = time+last_one-tmp;
				if(sub>0){
					sum_sub+=sub;
				}
				last_one = tmp;
			}
		}
		long result = (long)count*time-sum_sub;
		System.out.println(result);
		
	}
}


Measured memory_bytes: 63424
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
		int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).OrderByDescending(a => a).ToArray();

		int ans = 0;
		while(inpt.Distinct().Count() > 1) {
			if(inpt[0] == inpt[1]) {
				inpt[2] += 2;
			} else {
				inpt[1]++;
				inpt[2]++;
			}
			ans++;
			inpt = inpt.OrderByDescending(a => a).ToArray();
		}
		Console.WriteLine(ans);
	}

	public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"


2 6 3


";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 11476
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5)

def main():
    N = int(input())
    re = [[] for _ in range(N)]
    for i in range(N-1):
        p = int(input())
        re[p-1].append(i+1)

    def dep(x):
        if re[x] == []:
            return 0
        else:
            cl = []
            for ch in re[x]:
                cl.append(dep(ch))
            cl.sort(reverse = True)
            l = len(cl)
            return max(cl[i]+i+1 for i in range(l))
    
    print(dep(0))
    
if __name__ == "__main__":
    main()


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

int main()
{
  int n, k;	cin>>n>>k;
  int A[n];
  for(int i=0; i<n; i++)	cin>>A[i];
  sort(A, A+n);
  
  int minSum=0;
  for(int i=0; i<k; i++)	minSum+=A[i];
  cout<<minSum;
  return 0;
}

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

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

	int dan = 1;

	int mochi[100];

	for (int i = 0; i < N; i++) {
		cin >> d;
		mochi[i] = d;
	}

	sort(mochi, mochi + N,greater<int>());

	for (int i = 0; i < N-1; i++) {
		if (mochi[i] > mochi[i + 1]) {
			dan++;
		}
	}

	cout << dan << "\n";
}

Measured memory_bytes: 256
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		WriteLine((G().Sum() + 1) / 2);
	}
}


Measured memory_bytes: 13652
#include <stdio.h>
#include <string.h>

int main()
{
    int n;
    char s[120],t[120];
    while (scanf("%d",&n)!=EOF)
    {
        scanf("%s%s",&s,t);
        int lens=strlen(s);
        int lent=strlen(t);
        int i,j,ok=0;
        int ans;
        for (i=0;i<lens;i++)
        {
            if (ok==1) break;
            for (j=0;j<lent;j++)
            {
                if (s[i+j]=='\0')//超过s还是匹配
                {
                    ans=lens+lent-j;
                    ok=1;
                    break;
                }
                if (s[i+j]==t[j])
                {
                    if (s[i+j+1]=='\0')
                    {
                        ans=lens+lent-(j+1);
                        ok=1;
                    }
                    continue;
                }
                else break;
            }
        }
        if (ok==0)
            ans=lens+lent;
        printf("%d\n",ans);
    }
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

#define vint(v, n) vector<int> v(n); REP(i,n) cin >> v[i];
#define vvint(v, w, n) vector<int> v(n); vector<int> w(n); REP(i,n) cin >> v[i] >> w[i];
#define vlint(v, n) vector<ll int> v(n); REP(i,n) cin >> v[i];
#define vdouble(v, n) vector<double> v(n); REP(i,n) cin >> v[i];
#define vvdoube(v, n1, n2) vector<vector<double> > v(n1, vector<double>(n2, 0)); REP(i,n1) REP(j,n1) cin >> v[i][j];
#define string(x) string x; cin >> x;
#define vstring(v, n) vector<string> v(n); REP(i,n){string a; std::cin >> a; v.push_back(a); }

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).begin(), (v).end(), std::greater<int>()
#define len(v) (v).length()
#define FIND(s, n) (s.find(n) != s.end())
#define SORT(a) sort(all(a))

static const string abet("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
static const long long MOD = 1000000007;
static const double PI=3.1415926535897932;
static const int INF = 0x3f3f3f3f;
static const int INFTY = (1 << 29);
static const long long LINFTY = (1LL << 32);

static const int dy4[]={0, 0, 1, -1};
static const int dx4[]={1, -1, 0, 0};
static const int dx8[] = {1, 1, 1, 0, 0, -1, -1, -1};
static const int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};



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

  long long A[3]={};
  cin >> A[0] >> A[1] >> A[2];
  sort(A, A+3);
  if(A[0]%2==0 || A[1]%2 == 0 || A[2]%2 == 0) cout << 0 << endl;
  else cout << A[1]*A[0] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;


int main(){
    int r;
    cin >> r;
    if (r < 1200){
        cout << "ABC" << endl;
    }else if (r < 2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }
} 


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

int main(){
  int a, b, c, d, e, k;
  string re;
  
  cin >> a >> b >> c >> d >> e >> k;
  if(e - a <= k){
    re = "Yay!";
  } else {
    re = ":(";
  }
  
  cout << re << endl;
  return 0;
}

Measured memory_bytes: 256
n=int(input())
num = [1,2,4,7,8,11,13,14]
total=0
total2=0
tmp=0
if n%15!=0:
  for i in range((15*(n//15))+1,n+1):
    if i%15 in(num):
      total+=i
for i in range(n//15):
  total2+=60+tmp
  tmp+=120
print(total+total2)


Measured memory_bytes: 9132
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            //// 文字列の入力
            //string s = Console.ReadLine();

            //// 整数の入力
            //long n = long.Parse(Console.ReadLine());

            //// 文字列配列の入力
            //string[] inputStrArray = Console.ReadLine().Split(' ');

            //// 整数配列の入力
            //var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            long n = long.Parse(Console.ReadLine());
            var datas = Console.ReadLine().Split(' ').Select(m => long.Parse(m)).ToArray();

            int count = 0;

            foreach (var a in datas) {
                if (a % 2 != 0) {
                    count++;
                }
            }

            string result = "";

            if (count % 2 == 0) {
                result = "YES";
            } else {
                result = "NO";
            }


            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 22880
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  long long X, Y;

  std::cin >> X >> Y;

  int c = 0;

  for (long long x = X; x <= Y; x += x, c ++)
    ;

  std::cout << c << std::endl;

  return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
#include<string.h>
int main()
{
    char x,s,a[111],b[111];
    scanf("%s %s",a,b);
    int l,i,r=1,j;
    l=strlen(a);
    for(i=0;i<l;i++)
    {
        s=a[l-1];
        for(j=l-1;j>=0;j--)
        {
            a[j]=a[j-1];
        }
        a[0]=s;
        r=strcmp(a,b);
        if(r==0)
        {
            break;
        }
    }
    if(r==0)
        printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
 
  int N,K,X,Y;
  cin >> N;
  cin >> K;
  cin >> X;
  cin >> Y;
  if(N>=K){
  cout << K*X+(N-K)*Y <<endl;
  }else{
	cout << N*X<<endl;
  }
    return 0;
}


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

int N, A[1 << 18];
int dp[509][509];
bool used[509][509];

void update(int vx, int vy) {
	int dx[4] = { -1, 0, 1, 0 };
	int dy[4] = { 0, 1, 0, -1 };
	
	queue<pair<int, int>> Q; Q.push(make_pair(vx, vy));
	while (!Q.empty()) {
		int px = Q.front().first;
		int py = Q.front().second;
		Q.pop();
		for (int i = 0; i < 4; i++) {
			int sx = px + dx[i], sy = py + dy[i];
			if (sx <= 0 || sy <= 0 || sx > N || sy > N) continue;
			int cost = dp[px][py] + (int)used[px][py];
			if (dp[sx][sy] <= cost) continue;
			dp[sx][sy] = cost;
			Q.push(make_pair(sx, sy));
		}
	}
}

int main() {
	cin >> N;
	for (int i = 1; i <= N * N; i++) cin >> A[i];
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			dp[i][j] = min({ i - 1,j - 1,N - i,N - j });
			used[i][j] = true;
		}
	}

	long long sum = 0;
	for (int i = 1; i <= N * N; i++) {
		int rx = ((A[i] - 1) / N) + 1, ry = ((A[i] - 1) % N) + 1;
		used[rx][ry] = false;
		sum += dp[rx][ry];
		update(rx, ry);
	}
	cout << sum << endl;
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    set<int> s;
    int A;
    for (int i=0; i<N; i++) {
        cin >> A;
        if (s.count(A)) {
            s.erase(A);
        } else {
            s.insert(A);
        }
    }
    cout << s.size() << endl;
    return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x1, x2, x3, x4, x5;
  cin >> x1 >> x2 >> x3 >> x4 >> x5;
  if(x1 == 0) cout << 1 << endl;
  else if(x2 == 0) cout << 2 << endl;
  else if(x3 == 0) cout << 3 << endl;
  else if(x4 == 0) cout << 4 << endl;
  else if(x5 == 0) cout << 5 << endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
// #include <boost/math/common_factor.hpp> 
#pragma GCC optimize ("-O3")
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define int long long
#define double long double
#define pb push_back
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define diff(a,b) (a>b?a-b:b-a)
#define F first
#define S second

int32_t main()
{
    IOS;

    int n,w;
    cin>>n>>w;
    vector<int>wt(n+1);
    vector<int>v(n+1);

    for(int i=1;i<=n;i++){
        cin>>wt[i]>>v[i];
    }
    vector<vector<int>> dp(n+1, vector<int>(w+1));
    for(int i=1;i<=n;i++){
        for(int j=1;j<=w;j++){
            if(wt[i]>j){
                // exclude the item.
                dp[i][j] = dp[i-1][j];
            }
            else{
                //max(include the item , exclude the item)
                dp[i][j] = max(dp[i-1][j-wt[i]]+ v[i] , dp[i-1][j]);
            }
        }

    }
    cout<<dp[n][w]<<endl;
    return 0;
}


Measured memory_bytes: 80256
a,b,m = map(int,input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
mn = min(a) + min(b)
for i in range(m):
    x,y,c = map(int,input().split())
    xx = x-1
    yy = y-1
    price = a[xx] + b[yy] - c
    if price < mn:
        mn = price
print(mn)


Measured memory_bytes: 18488
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
#define int long long int
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);

template <class T>
class segtree
{
public:
  lli n;
  vector<T> dat;
  function<T(T, T)> func;
  T dummy;
  segtree<T>(lli _n, T ini, function<T(T, T)> f, T dummy) : func(f), dummy(dummy)
  {
    n = 1;
    while (n < _n)
    {
      n = n * 2;
    }
    dat.assign(2 * n - 1, ini);
  }
  void update(lli k, T a)
  {
    k += n - 1;
    dat[k] = a;
    while (k > 0)
    {
      k = (k - 1) / 2;
      dat[k] = func(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
  }
  T query(int a, int b)
  {
    return query(a, b, 0, 0, n);
  }
  // [a,b)の何かを求める.
  T query(int a, int b, int k, int l, int r)
  {
    //交差しないときはダミー
    if (r <= a || b <= l)
      return dummy;
    if (a <= l && r <= b)
      return dat[k];
    else
    {
      T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
      T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
      return func(vl, vr);
    }
  }
  T get(int a)
  {
    return query(a, a + 1, 0, 0, n);
  }
};

lli dp[100005];
// iを最後に使ったときの最大
void solve(long long N, std::vector<long long> h, std::vector<long long> a)
{
  // dp[i] = max_{j<i, h[i]>h[j]} dp[j]
  using p = lli;
  auto f = [](p a, p b) -> p { return max(a, b); };
  p first = 0;
  segtree<lli> seg(N, first, f, first);
  vector<int> v(N);
  iota(v.begin(), v.end(), 0);
  sort(v.begin(), v.end(), [&](int l, int r) { return h[l] < h[r]; });
  lli ans = 0;
  rep(i, N)
  {
    lli d = seg.query(0, v[i]) + a[v[i]];
    chmax(ans, d);
    seg.update(v[i], d);
  }
  cout << ans << endl;
}

signed main()
{
  long long N;
  scanf("%lld", &N);
  std::vector<long long> h(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &h[i]);
  }
  std::vector<long long> a(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &a[i]);
  }
  solve(N, std::move(h), std::move(a));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}


Measured memory_bytes: 9088
#include<stdio.h>

int main(void)
{
        int n, m, k, a[1000]={0}, r, b=0;
        int i, j;

        scanf("%d%d", &n,&m);

        for(i = 0; i < n; i++) {
                scanf("%d", &k);
                for(j = 0; j < k; j++) {
                        scanf("%d", &r);
                        a[r]++;
                }
        }

        for(i = 0; i <= m; i++) {
                if(a[i] == n) {
                        b++;
                }
        }
        printf("%d", b);
        return 0;
}

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

#define loop(n) for(int i = 0;i < (int)(n);++i)
#define rep(i,n) for(int i = 0;i < (int)(n);++i)
#define all(vec) (vec).begin(),(vec).end()
#define Sort(vec) sort(all(vec))
#define Rev(vec) reverse(all(vec))

using Graph = vector<vector<int>>;

namespace Input
{
                
    void input(){return;}
    template<typename First,typename... Rest> void input(First &first,Rest&... rest){
    std::cin >> first;
    input(rest...);
}
    
    void inputVec(){return;}
    template<typename First,typename... Rest> void inputVec(vector<First> &first,Rest&... rest){
        int N = first.size();
        for(int i = 0;i < N;i++){
            cin >> first[i];
        }
        inputVec(rest...);
    }
    
    template<typename First,typename Second> void inputTwoVec(vector<First> &first,vector<Second>& second){
        int N = first.size();
        for(int i = 0;i < N;i++){
            cin >> first[i] >> second[i];
        }
    }

    void inputGraph(Graph &g,int path_num,bool isdirected){
        for(int i = 0;i < path_num;i++){
            int a,b;
            cin >> a >> b;
            a--;b--;
            if(isdirected){
                g[a].push_back(b);
            }
            else{
                g[a].push_back(b);
                g[b].push_back(a);
            }
        }
    }
}

void calculate(){
    string s;
    Input::input(s);
    if(s == "ABC") cout << "ARC\n";
    else cout << "ABC\n";
}

int main(int,char**){
    calculate();    
}




Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
  
  string s;
  cin >> s;
  
  if(s=="Sunny"){
    cout << "Cloudy" << endl;
    
  }
  
  if(s=="Cloudy"){
    cout << "Rainy" << endl;
    
  }
  
  if(s=="Rainy"){
    cout << "Sunny" << endl;
    
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  for (int i=0; i<n; i++) {
    a[i].second = i+1;
    cin >> a[i].first;
  }
  sort(a.begin(), a.end());
  for (int i=0; i<n; i++) {
    cout << a[i].second << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define fs first
#define sc second
using namespace std;
typedef double D;
typedef complex<D> P;
typedef pair<D,D> pdd;
const D EPS = 1e-8;
const D PI = acos(-1);

int n,k;
pdd p[2000];
vector<pdd> v;
int max_r[2000], max_l[2000];

inline D modify(D seta){
  if(seta>PI)seta-=2*PI;
  if(seta<-PI)seta+=2*PI;
  return seta;
}

inline bool in_upper(D seta){
  seta = modify(seta);
  return (EPS<seta && seta<PI-EPS);
}

bool comp(const pdd &a, const pdd &b){
  return abs(a.fs-b.fs)<EPS?a.sc+EPS<b.sc:a.fs<b.fs;
}

int main(){
  cin >> n >> k;
  rep(i,n){
    D x,y,r;
    cin >> x >> y >> r;
    P c = P(x,y);
    D d = abs(c), s = arg(c), a = sqrt(d*d-r*r);
    D ds = acos( (d*d + a*a - r*r)/(2*d*a) );
    
    D start = modify(s-ds), end = modify(s+ds);
    pdd tmp = pdd(in_upper(start)?start:0, in_upper(end)?end:PI);
    if(tmp.fs<EPS && PI-EPS<tmp.sc)continue;
    v.push_back(tmp);
  }

  sort(v.begin(),v.end(),comp);

  rep(i,v.size())rep(j,v.size()){
    if(i==j)continue;
    if(v[j].fs-EPS<v[i].fs && v[i].sc<v[j].sc+EPS){
      v.erase(v.begin()+i);
      i--;
      break;
    }
  }

  rep(i,v.size()){
    pdd dummy(v[i].sc,0);
    max_l[i] = upper_bound(v.begin(),v.end(),dummy,comp) - v.begin();
    max_r[i] = max_l[i]-1;
  }
  
  vector< vector<D> > dp1(v.size()+1,vector<D>(k+1,0));
  vector< vector<D> > dp2(v.size()+1,vector<D>(k+1,0));

  rep(i,v.size()){
    rep(j,k+1){
      dp1[i+1][j] = max(dp1[i+1][j], dp1[i][j]);
      if(j+1<=k){
	D use = max(dp1[i][j], dp2[i][j]);
	dp1[max_l[i]][j+1] = max(dp1[max_l[i]][j+1], use + v[i].sc-v[i].fs);
	if(max_r[i]!=i){
	  dp2[max_r[i]][j+1] = max(dp2[max_r[i]][j+1], use + v[max_r[i]].fs-v[i].fs);
	}
      }
    }
  }

  D ans = 0;
  rep(i,k+1){
    ans = max(ans, max(dp1[v.size()][i], dp2[v.size()][i]) );
  }
  cout << fixed << setprecision(10) << ans/PI << endl;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> T(N);
	for (int i = 0;i < N;++i) {
		cin >> T[i];
	}
	int M;
	cin >> M;
	vector<pair<int, int>> drink(M);
	for (int i = 0;i < M;++i) {
		cin >> drink[i].first >> drink[i].second;
	}
	for (int i = 0;i < M;++i) {
		int count = 0;
		for (int j = 0;j < N;++j) {
			if (j + 1 == drink[i].first) {
				count += drink[i].second;
			}
			else {
				count += T[j];
			}
		}
		cout << count << endl;
	}
	return 0;
}

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

int w, h, ans = 0, map[N][N];

void search_zahyou(int w, int h);

int main(){
	while(cin >>w >>h){
		ans = 0;
		if(w == 0 && h == 0) break;
		for(int i = 0; i < h; i++){
			for(int k = 0; k < w; k++){
				cin >>map[i][k];
			}
		}
		for(int i = 0; i < h; i++){
			for(int k = 0; k < w; k++){
				if(map[i][k] == 0){
					continue;
				}
				else{
					ans++;
					search_zahyou(i, k);
				}
			}
		}
		cout <<ans <<endl;
	}
	return 0;
}

void search_zahyou(int inh, int inw){
	int searchh[8] = {-1, -1, -1, 0, 1, 1, 1, 0}, searchw[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
	if(h <= inh || w <= inw || inh < 0 || inw < 0){
	} else{
		map[inh][inw] = 0;
		for(int i = 0; i < 8; i++){
			if(map[inh + searchh[i]][inw + searchw[i]] == 1){
				search_zahyou(inh + searchh[i], inw + searchw[i]);
			}
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
#include <utility>
#include<iomanip>
// #include <numeric>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef vector<string> vstring;
typedef vector<vector<string>> vvstring;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<long double> vdouble;
typedef vector<vector<long double>> vvdouble;
typedef vector<vector<vector<long double>>> vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define LLONG_MAX 9223372036854775807
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define DIVIDER 1000000007


//
// struct Node{
//   vint children;
//   ll index;
//   ll prop;
// };
// struct edge{ll to; ll cost;};



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

// ll X,Y,Z,K;
// ll pmax = 30000000000;
// vint A,B,C;




// struct UnionFind {
//     vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
//
//     UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
//         for(int i = 0; i < N; i++) par[i] = i;
//     }
//
//     int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
//         if (par[x] == x) return x;
//         return par[x] = root(par[x]);
//     }
//
//     void unite(int x, int y) { // xとyの木を併合
//         int rx = root(x); //xの根をrx
//         int ry = root(y); //yの根をry
//         if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
//         par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
//     }
//
//     bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };
//
// vint divisor(ll n){ // nの約数
//   vint ret;
//   for(ll i=1;i*i<=n;i++){
//     if(n%i == 0){
//       ret.pb(i);
//       if(i*i!=n) ret.pb(n/i);
//     }
//   }
//   vsort(ret);
//   return ret;
// }
//
// ll get_digits_num(ll n){
//   ll ret=0;
//   while(n){
//     n/=10;
//     ret++;
//   }
//   return ret;
// }



int main() {
  cout<<fixed<<setprecision(10);

  string S;cin>>S;
  ll a,b,c;
  a=0;b=0;c=0;
  rep(i,S.size()){
    if(S[i]=='a') a++;
    else if(S[i]=='b') b++;
    else c++;
  }
  ll minval = min(a, min(b,c));
  string ans;
  // cout << a << b << c <<endl;
  a-=minval;
  b-=minval;
  c-=minval;
  if(a>1||b>1||c>1) ans="NO";
  // else if(a+b+c>1) ans="NO";
  else ans="YES";
  cout << ans << endl;

}

















//


Measured memory_bytes: 512
#include <bits/stdc++.h> 
using namespace std; 
  
typedef long long int ll;
typedef set <int> se;

ll gcd(ll a,ll b)
{
	if(a%b==0)
		return b;
	else
		return gcd(b,a%b);
}
int main()
{
	ll k,rem,flag=0,sum=0;
	cin>>k;
	for (int i = 1; i < k+1; ++i)
	{
		for (int j = 1; j<k+1; ++j)
		{
			flag=gcd(i,j);
			for (int l = 1; l<k+1; ++l)
			{
				sum+=gcd(flag,l);
			}
		}
	}
	cout<<sum<<"\n";
}

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

#define   DEBUGG	0
#ifdef    DEBUGG
#define   VAR(x)    cout<<"L"<<__LINE__<<" | "<<#x<<" "<<x<<"\n";
#else
#define   VAR(x);
#endif
#ifdef    DEBUGG
template<typename T>void VARS(T a){cout<<a<<"\n";}
template<typename T,typename...Types>void VARS(T a,Types...bs){cout<<a<<" ";VARS(bs...);}
#else
#define   VARS(...);
#endif
#define    INF       3e9
typedef long long ll;
template<typename T> istream& operator>> (istream& is, vector<T>& the_vector) {
    for (int i = 0; i < (int)the_vector.size(); i++){
        is >> the_vector[i];
	} /*for(T& ele:the_vector)is>>ele;*/
    return is;
}
template<typename T> ostream& operator<< (ostream& os, vector<T>& the_vector) {
    for (int i = 0; i < (int)the_vector.size(); i++) {
        os << the_vector[i] << (i + 1 == (int)the_vector.size() ? "" : " ");
    }
    return os;
}
template<typename T> string join(vector<T>& the_vector, string mid = " ") {
    stringstream ss;
    for (int i = 0; i < (int)the_vector.size(); i++) {
        ss << the_vector[i] << (i + 1 == (int)the_vector.size() ? "" : mid);
    }
    return ss.str();
}


int main(){
	int n; cin >> n;
	vector<int> a(n-1);
	cin >> a;
	map<int, int> cnt;
	for(auto& ele: a){
		cnt[ele]++;
	}
	int i = 1;
	while(i <= n){
		if(cnt.find(i) != cnt.end()){
			cout << cnt[i] << "\n";
		}else{
			cout << 0 << "\n";
		}
		++i;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

#define int long long

int PlusTax(int n, int tax)
{
	return (int)(n * (100 + tax) / 100.0);
}

int GetBase(int n, int tax)
{
	int l = 0, r = 1000;
	while (r - l > 1)
	{
		int mid = (l + r) / 2;
		if (PlusTax(mid, tax) > n) r = mid;
		else l = mid;
	}
	if (PlusTax(l, tax) != n) return 0;
	return l;
}

signed main()
{
	int X, Y, S;
	while (cin >> X >> Y >> S, X || Y || S)
	{
		int ans = 0;
		for (int i = 1; i < S; i++)
		{
			int a = GetBase(i, X);
			int b = GetBase(S - i, X);
			if (a == 0 || b == 0) continue;
			ans = max(ans, PlusTax(a, Y) + PlusTax(b, Y));
		}
		printf("%lld\n", ans);
	}
	return 0;
}

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

int main()
{
  int n;
  
  scanf("%d",&n);
  
  int a[n];
  int i,j=1;
  int count[100001]={};
  int ans=0;
  
  for(i=0;i<n;i++)
  {
    scanf("%d",&a[i]);
    if(a[i]<100001)
    {
      count[a[i]]++;
    }
    else
    {
      ans++;
    }
  }
  
  for(i=1;i<100001;i++)
  {
    if(count[i]<i)
    {
      ans+=count[i];
    }
    else
    {
      ans+=count[i]-i;
    }
  }
  
  printf("%d\n",ans);
  
  return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <deque>
#include <cassert>
#define pb push_back
#define point pair <int, int>
#define files(FileName) read(FileName); write(FileName)
#define read(FileName) freopen((FileName + ".in").c_str(), "r", stdin)
#define write(FileName) freopen((FileName + ".out").c_str(), "w", stdout)
using namespace std;
template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; }

const string FILENAME = "input";

long long n, k;

long long f(long long a, long long b) {
	if (a > b) swap(a, b);
	if (a == 0) return -b;
	long long k = b / a;
	return f(b % a, a) + a * k * 2;
}

int main() {
	ios::sync_with_stdio(false);
	srand(time(0));
	//read(FILENAME); 
	cin >> n >> k;
	cout << f(n - k, k) + n << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int a,b;
    cin>>a>>b;
    if(a<10&&b<10)cout<<a*b<<endl;
    else cout<<-1<<endl;
}

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

int main(){
	int N;cin>>N;
	string s;cin>>s;
	vector<vector<int> > dp(N+1,vector<int>(N+1,0));
	for (int i=N-1;i>=0;--i){
		for (int j=N-1;j>=0;j--){
			dp[i][j]=(s[i]==s[j]?dp[i+1][j+1]+1:0);
		}
	}
	int res=0;
	for (int i=0;i<N;++i)for(int j=0;j<N;++j){
		if(j>i)res=max(res,min(j-i,dp[i][j]));
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 98176