akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define endl "\n"
#define int long long int
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define mod (int)(1e9+7)
#define T int
#define pi pair<int,int>
#define umap unordered_map<T,T>
#define uset unordered_set<T>
#define ff first
#define ss second
#define vi vector<int>
#define pb push_back
#define all(v) v.begin(),v.end()
#define setbit(n) __builtin_popcount(n)
#define toUpper(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define toLower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define flash ios_base::sync_with_stdio(false);cin.tie(NULL)


int lcm(int a, int b)
{
	return (a / __gcd(a, b) * b);
}


int32_t main() {

	flash;
	cout << fixed;
	cout.precision(10);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// int t; cin >> t;
	int t=1;
	while (t--) {
		int n;cin>>n;
		if(n>=30){
			cout<<"Yes"<<endl;
		}
		else
			 cout<<"No"<<endl;

		

	}



	return 0;

}







Measured memory_bytes: 3644
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
long long k,n,a[100005],f[100005];
int main()
{
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	f[n]=0;
	for(int i=n-1;i>=0;i--)
	{
		f[i]=2e9;
		for(int j=i+1;j<=n&&j<=i+k;j++)
		{
			f[i]=min(f[i],f[j]+abs(a[i]-a[j]));
		}
	}
	printf("%lld",f[1]);
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    int a; cin>>a;
    if(a<1200){
        cout<<"ABC"<<endl;
    }else if(a<2800){
        cout<<"ARC"<<endl;
    }else{
        cout<<"AGC"<<endl;
    }
    
}


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

void solver() {
  int n, x, y;

  cin >> n >> x >> y;

  vector<int> ans(n);
  for (int i = 1; i <= n; i++) {
    for (int j = i+1; j <= n; j++) {
      int min_d = min(abs(j - i), abs(i - x) + 1 + abs(j - y));
      min_d = min(min_d, abs(j - x) + 1 + abs(i - y));
      ans[min_d]++;
    }
  }
  for (int i = 1; i < n; i++) {
    cout << ans[i] << "\n";
  }
  return;
}

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


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		int n=scanner.nextInt();
		String ans="";
		if(n==25){
			ans="Christmas";
		}else if(n==24){
			ans="Christmas Eve";
		}else if(n==23){
			ans="Christmas Eve Eve";
		}else{
			ans="Christmas Eve Eve Eve";
		}
		System.out.println(ans);
	}
}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 20564
import sys
import bisect

sys.setrecursionlimit(10**7)
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
printn = lambda x: print(*x, sep='\n')

n = ni()
a = nl()
G = [list() for _ in range(n)]

for _ in range(n-1):
    u, v = nm()
    u -= 1; v -= 1
    G[u].append(v)
    G[v].append(u)

dfsl = list()
seen = [False]*n
stack = [0]
par = [-1]*n
while stack:
    v = stack[-1]
    dfsl.append(v)
    if seen[v]:
        stack.pop()
    else:
        seen[v] = True
        for x in G[v]:
            if x == par[v]:
                continue
            par[x] = v
            stack.append(x)

ans = [0]*n
prv = [0]*n
idx = [None]*n
lis = list()
for v in dfsl:
    if idx[v] is None:
        if not lis or lis[-1] < a[v]:
            idx[v] = len(lis)
            prv[v] = -1
            ans[v] = len(lis) + 1
            lis.append(a[v])
        else:
            i = bisect.bisect_left(lis, a[v])
            idx[v] = i
            prv[v] = lis[i]
            ans[v] = len(lis)
            lis[i] = a[v]
    else:
        if prv[v] < 0:
            lis.pop()
        else:
            lis[idx[v]] = prv[v]
printn(ans)


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

using namespace std;


#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)


using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;


signed main() {
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cout << fixed << setprecision(12);

    int n, m;
    cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];
    cin >> m;
    vint b(m);
    vint c,d;
    rep(i, m) cin >> b[i];
    set_difference(all(a), all(b), inserter(c, c.end()));
//    set_difference(all(b), all(a), inserter(d, d.end()));
    for (int i :c) cout << i << endl;
//    for (int i :d) cout << i << endl;
    return 0;
}


Measured memory_bytes: 8124
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;
int main(int argc, char const *argv[]) {
  ll h, w;std::cin >> h >> w;
  vector<vector<string>> t(h, vector<string>(w));
  re(i, h) re(j, w) std::cin >> t[i][j];
  re(i, h) {
    re(j, w) {
      if(t[i][j]=="snuke"){
        char b = 'A'+j;
        std::cout <<  b;
        std::cout << i+1 << '\n';
        return 0;
      }
    }
  }
}


Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;





// 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;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    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 {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=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 {
        mint res(*this);
        return res/=a;
    }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};



int main(){

    int n ;
    string s;
    int ans = 0;
    cin >> n >> s;
    int i = 0;
    while(i<n){
        if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
            ans++;
            i += 3;
        }
        else i++;
    }
    
    cout << ans;
    rn 0;
    
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int m = 0, n, a[200000] = {0}, box[200000] = {0};
  scanf("%d", &n);getchar();
  for(int i = 0; i < n; i++){
    scanf("%d", &a[i]);getchar();
  }
  for(int i = n; i >= 1; i--){
    int sum = 0;
    for(int j = i - 1; j < n; j += i){
      sum += box[j];
    }
    if(sum % 2 == a[i - 1]){
      continue;
    }else{
      box[i - 1]++;
      m++;
    }
  }
  printf("%d\n", m);
  for(int i = 0; i < n - 1; i++){
    if(box[i] == 1){
      printf("%d ", i + 1);
    }
  }
  if(box[n - 1] == 1){
   	printf("%d\n", n);
  }else{
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

ll s[100001];

int main()
{
	int N;
	cin >> N;
	for (auto i = 0; i < N; ++i)
	{
		cin >> s[i];
	}

	map<ll, vector<ll>> m;

	auto result = 0ll;
	for (auto A = 2; A < N - 1; ++A)
	{
		auto remain = N - A - 1;
		for (auto d = 1; d * d <= remain && (d < A); ++d)
		{
			if ((remain % d) != 0)
			{
				continue;
			}

			for (auto d2 = d, i = 0; i < 2; d2 = remain / d, ++i)
			{
				if (d2 >= A)
				{
					continue;
				}

				auto B = A - d2;
				if ((B % d2 == 0) && (remain / d2) > (B / d2))
				{
					continue;
				}

				auto key = d2 * (ll)N;
				if (m.count(key) == 0)
				{
					auto& tempS = m[key];
					auto temp = 0ll;
					for (auto k = N - 1; k >= 0; k -= d2)
					{
						temp += s[k];
						tempS.push_back(temp);
					}
				}
				auto& sum = m[key];
				key = d2 * (ll)N + A % d2;
				if (m.count(key) == 0)
				{
					auto& tempS = m[key];
					auto temp = 0ll;
					for (auto k = N - 1 - (A % d2); k >= 0; k -= d2)
					{
						temp += s[k];
						tempS.push_back(temp);
					}
				}
				auto& sum2 = m[key];

				auto sumA = sum[remain / d2];
				auto sumB = sum2[(N - 1) / d2] - sum2[(A / d2) - 1];
				result = max(result, sumA + sumB);
			}
		}
		if(remain < A)
		{
			auto sumA = s[A];
			auto sumB = s[N - 1 - A];
			result = max(result, sumA + sumB);
		}
	}

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 32756
cards = {
        'S': [r for r in range(1,13+1)],
        'H': [r for r in range(1,13+1)],
        'C': [r for r in range(1,13+1)],
        'D': [r for r in range(1,13+1)],
        }
n = int(input())
for nc in range(n):
    (s, r) = input().split()
    index = cards[s].index(int(r))
    del cards[s][index]

for s in ['S', 'H', 'C', 'D']:
    for r in cards[s]:
        print(s, r)

Measured memory_bytes: 6724
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
using vll = V<ll>;
using vvll = V<vll>;

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n; cin >> n;
  vll a(n), b(n), ab(n);
  for (ll i=0; i<n; i++) {
    cin >> a.at(i) >> b.at(i);
    ab.at(i) = a.at(i) + b.at(i);
  }
  ll bsum = 0;
  for (ll i=0; i<n; i++) bsum += b.at(i);
  sort(ab.begin(), ab.end(), greater<ll>());
  ll ans = 0;
  for (ll i=0; i<n; i+=2) ans += ab.at(i);
  cout << ans - bsum << endl;
  return 0;
}


Measured memory_bytes: 2560
/*g++ main.cpp -o main.out*/
/*./main.out*/

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

#define LL long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int main()
{
    int n,k,d=0;
    cin>>n>>k;
    while(n>0)
    {
        d++;
        n/=k;
    }
    cout<<d<<endl;
    return 0;
}





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

void solve(){
    long long x,k,d;
    cin>>x>>k>>d;
    if(abs(x)/abs(d) < k){
        long long temp = abs(x)/abs(d);
        if(temp%2 == k%2){
            cout<<abs(x)-temp*abs(d);
        }
        else{
            cout<<abs(abs(x)-(temp+1)*abs(d));
        }
    }
    else if(abs(x)==abs(d*k)){
        cout<<0;
    }
    else{
        cout<<abs(x)-abs(d*k);
    }
}

int main() {
    int t;
    t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3628
// ABC165 - B
function main(input) {
  var inputs = input.split('\n');

  var nums = inputs[0].split(' ');
  var n = parseInt(nums[0], 10);
  var k = parseInt(nums[1], 10);

  var holders = [];

  for (var i = 2; i < inputs.length; i += 2) {
    var nums = inputs[i].split(' ').map((n) => parseInt(n, 10));

    nums.forEach((item, i) => {
      if (holders.indexOf(item) == -1) holders.push(item);
    });
  }

  console.log(n - holders.length);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 31604
#include <bits/stdc++.h>
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(i,n) rep2(i,0,n)
using namespace std;
using ll = long long;
int a[1001][999];

using unweighted_graph = vector<vector<int>>;
bool visit_dag(int n, const unweighted_graph &g, vector<int> &mark, vector<int> &l){
    if(mark[n]==1)return false;
    else if(mark[n]==0){
        mark[n]=1;
        for(auto &m:g[n])if(!visit_dag(m,g,mark,l))return false;
        mark[n]=2;
        l.push_back(n);
    }
    return true;
}
vector<int> topological_sort(const unweighted_graph &g){
    vector<int> mark(g.size(),0),l; rep(i,g.size())if(mark[i]==0&&!visit_dag(i,g,mark,l))return {}; reverse(l.begin(),l.end()); return l; }
bool is_dag(const unweighted_graph &g){ return !topological_sort(g).empty(); }
unweighted_graph inverse(const unweighted_graph &g){
    unweighted_graph h(g.size()); rep(i,g.size())rep(j,g[i].size())h[g[i][j]].push_back(i); return h; }

int longest_path_dag(const unweighted_graph &g){
    auto l=topological_sort(g);
    if(l.empty())return -1;
    auto h=inverse(g);
    vector<int> dist(g.size(),1);
    rep(i,g.size())rep(j,h[l[i]].size())dist[l[i]]=max(dist[l[i]],1+dist[h[l[i]][j]]);
    return *max_element(dist.begin(),dist.end());
}
int f(int a,int b,int n){
    return (a<b)?((a-1)*n+b-1):f(b,a,n);
}
int main(){
    int n;
    cin >> n;
    rep2(i,1,n+1)rep(j,n-1)cin >> a[i][j];
    unweighted_graph g(n*n);
    rep2(i,1,n+1)rep(j,n-2)g[f(i,a[i][j],n)].push_back(f(i,a[i][j+1],n));
    cout << longest_path_dag(g) << endl;
    return 0;
}

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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int a[n];
    int la=INT32_MAX;
    int ba=0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        la=min(la,a[i]);
        ba=max(ba,a[i]);
    }

    int ans=INT32_MAX;
    for(int i = la; i <= ba; i++) {
        int ref=i;
        int count=0;
        for(int j = 0; j < n; j++) {
            count+=(a[j]-ref)*(a[j]-ref);
        }
        ans=min(ans,count);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
    char a,b;
    scanf("%c %c",&a,&b);
        if(a=='H')
        printf("%c\n",b);
        else if(a=='D')
        {
            if(b=='H')
        printf("D\n");
        else if(b=='D')
            printf("H\n");
        }
    return 0;
}


Measured memory_bytes: 128
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


fn main () {
    input! {
        a: chars,
        b: chars,
    }
    if a[0] < b[0] {
        println!("<");
    }
    else if a[0] == b[0] {
        println!("=");
    }
    else {
        println!(">");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long h,n,ans=0,a[10005],b[10005],dp[10005]={};
  cin>>h>>n;
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i];
  }
  for(int i=1;i<=h;i++){
    dp[i]=1000000000;
  }
  for(int i=0;i<=h;i++){
    if(i==0 || dp[i]!=1000000000){
      for(int j=0;j<n;j++){
        if(a[j]+i>h)
          dp[h]=min(dp[h],dp[i]+b[j]);
        else
          dp[i+a[j]]=min(dp[i+a[j]],dp[i]+b[j]);
      }
    }
  }
  cout<<dp[h]<<endl;
  return(0);
}

Measured memory_bytes: 384
# 18:58-
n = gets.to_s.to_i
a = gets.to_s.split.map{|t| t.to_i }

m = (a.reduce(0){|s, t| s + t } / ( 1.0 * n )).round
ans = a.reduce(0){|s, t| s + ( t - m ) ** 2 }

puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef long long LL;
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef pair<double,int> PDI;
const double eps=1e-12;
const int INF=0x3f3f3f3f;
const LL inf=1e18;
const double pi=acos(-1.0);
const int mod=1e9+7;
//LL powmod(LL a,LL b) {LL res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
vector<PII>g;

const int MAXN=200010;
int a[MAXN],b[MAXN];

int Search(int num,int low,int high)
{
    int mid;
    while(low<=high)
    {
        mid=(low+high)/2;
        if(num>=b[mid])  low=mid+1;
        else   high=mid-1;
    }
    return low;
}
PII v[200010];
int DP(int n)
{
    if(n==0) return 0;
    int i,len,pos;
    b[1]=a[1];
    len=1;
    for(i=2; i<=n; i++)
    {
        if(a[i]>=b[len])//如果a[i]比b[]数组中最大还大直接插入到后面即可
        {
            len=len+1;
            b[len]=a[i];
            v[len]=g[i-1];
        }
        else
        {
            pos=Search(a[i],1,len);
            b[pos]=a[i];
            v[pos]=g[i-1];
        }
    }
    return len;
}
int main(){
//    freopen("in.txt","r",stdin);
//    freopen("outt.txt","w",stdout);
    int t;
    int sx,sy,ex,ey,n,x,y;
    cin>>sx>>sy>>ex>>ey>>n;
    if(sx>ex){
        swap(sx,ex);
        swap(sy,ey);
    }
    int f=1;
    if(sy>ey) f=-1;
    sy*=f;
    ey*=f;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        y*=f;
        if(x>=sx&&x<=ex&&y>=sy&&y<=ey) g.pb({x,y});
    }
    sort(all(g));
    n=0;
    for(auto i:g) a[++n]=i.se;
    int m=DP(n);
//    cout<<m<<endl;
    double ans=(ex-sx+ey-sy)*100.0;
    ans-=20.0*m;
    ans+=pi*5*m;
    ans+=(min(ex-sx,ey-sy)+1==m?pi*5:0);
//    if(m){
//        if((ex==sx||sy==ey)){
//            ans-=20.0;
//            ans+=pi*10;
//        }
//        else {
//            if((v[1].fi==sx&&v[m].fi==ex&&sx-ex+1==m)||(v[1].se==sy*f&&v[m].se==ey*f&&abs(ey-sy)+1==m)) ans+=pi*5;
//            else if((v[1].fi==sx&&v[m].fi==ex)||(v[1].se==sy*f&&v[m].se==ey*f)) m--;
//            ans-=m*20.0;
//            ans+=pi*5*m;
//        }
//    }
    printf("%.16f\n",ans);
    return 0;
}
/*
6 1 1 5
2
3 3
5 2
*/


Measured memory_bytes: 5104
#include <stdio.h>
 
int main(){
    int a;//解毒・美味しくない
    int b;//解毒・美味しい
    int c;//毒・美味しい
    int sum = 0;
    int flag = 0;
    scanf("%d %d %d", &a, &b, &c);
    if(c > a + b + 1){
      sum = a + b + 1 + b;
    }
    else{
      sum = b + c;
    }
  
  	printf("%d\n", sum);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int a, b, c, i, n;
	scanf("%d", &n);
	
	for(i=0; i<n; i++)
	{
		scanf("%d %d %d", &a, &b, &c);
		a*=a;
		b*=b;
		c*=c;
		
		if(a+b==c || b+c==a || a+c==b)
		{
			printf("YES\n");
		} else {
			printf("NO\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  string S;
  cin >> S;
  int N = (int)S.size();
  ll ans = 0;
  int end = N-1;
  for(int i=N-1; i>=0; i--) {
    if(S[i] == 'B') {
      ans += end - i;
      end--;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
	int n,d;
  	cin>>n>>d;
  
  	int miru=0;
  while(n>0){
  	miru++;
    n -= (2*d)+1;   
  }
  
  cout<<miru<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 1001
static const int INFTY = (1<<21);

int kansu(int i){
  if(i==25964)
    return 0;
    else return i;
}

int n, M[N][N];
int color[N], d[N], f[N], tt;
int Q[N*2], head, tail;

void init(){
  head = tail = 1;
}

void enqueue(int x){
  Q[tail++] = x;
}

int empty(){
  return head == tail;
}

int dequeue(){
  int x = Q[head++];
  return x;
}

void bfs(int s){
  int i, u, v;
  init();
  enqueue(s);
  for ( i = 0; i < n; i++ )d[i] = INFTY;
  d[s] = 0;
  while(!empty()){
    u = dequeue();
    for ( v = 0; v < n; v++ ){
      if ( M[u][v] == 0 ) continue;
      if ( d[v] != INFTY ) continue;
      d[v] = d[u] + 1;
      enqueue(v);
    }
  }
  for ( i = 0; i < n; i++ ){
    printf("%d %d\n", i+1,((d[i]==INFTY)?(-1):d[i]));
  }
}

main(){
  int  u, k, v, i, j; 

  scanf("%d", &n);

  for ( i = 0; i <n; i++ ){
    for ( j = 0; j <n; j++ ) M[i][j] = 0;
  }
  
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
    u--;
    for ( j = 0; j < k; j++ ){
      scanf("%d", &v);
      v--;
      M[u][v] = 1;
    }
  }
  
  bfs(0);

  return 0;
}


Measured memory_bytes: 2248
#!/usr/bin/env python3
import sys
import math

def dfs(N: int, digit: int,cur: str):
    if len(cur) < digit:
        return dfs(N,digit,cur+"3") + dfs(N,digit,cur+"7") + dfs(N,digit,cur+"5")
    else:
        if int(cur) > N:
            return 0
        if cur.count("3") > 0 and cur.count("7") > 0 and cur.count("5"):
            return 1
        else:
            return 0


def solve(N: int):
    digit = math.ceil(math.log10(N))
    sum = 0
    for i in range(3,digit+1):
        sum += dfs(N,i,"")
    print(sum)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std; 
  
typedef long long ll; 
typedef pair<ll, ll> pll;
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
 
#define MOD 1000000007  
#define f(a, b, c) for (ll(a) = (b); (a) < (c); ++(a))  
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL)); 
#define rep(i, n) f(i, 0, n) 
#define ff first 
#define ss second  
#define pb push_back 
#define all(v) v.begin(), v.end()  
#define wh(t) while (t--) 
#define inf 1e18
#define modd 998244353
#define pp(var) cout<<var<<"\n";
#define pm(var1, var2) cout<<var1<<" "<<var2<<"\n"; 

const ll N = 2e5 + 5;

ll binpow(ll a,ll n)
{
    ll i=1;
    while(n>0)
    {
        if(n&1)
            i=(i*a);
        a=(a*a);
        n = n>>1;
    }
    return i;
}
 
ll isprime(ll n)
{
    if(n==0||n==1)
        return n;
    if(n%2==0)
        return (ll)2;
    if(n%3==0)
        return (ll)3;
    else
    {
        for(ll i=5;i*i<=n;i+=6)
        {
            if(n%i==0)
                return i;
            if(n%(i+2)==0)
                return (i+2);
        }
        return n;
    }
}


int main(){
    fast;
    ll l,r,i,j,n,m,k,a,b,c,q,x,t,y,d;
   	cin>>n>>k;
   	vl v(n+1);
   	rep(i,n) cin>>v[i+1];
   	ll last = 1;
   	unordered_map<ll,ll> mp;
   	mp[1] = 0;
   	i = 1; j = 1;
   	while(i <= k){
   		j = v[j];
   		if(mp.find(j) != mp.end()) break;
   		mp[j] = i;
    	++i;	
    	last = j;
	}
	if(i == k+1){
		pp(last); return 0;
	}
	k -= mp[j];
	x = i - mp[j];
	k = k%x;
	wh(k){
		j = v[j];
	}
	pp(j);
}

Measured memory_bytes: 11820
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fir first
#define sec second
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const int mod = 1000000007;

int main(){
    int a, b;
    cin >> a >> b;
    if((b-a)%2 == 0) cout << abs(b+a)/2 << endl;
    else cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i

n.times do
  arr = gets.split(' ').map(&:to_i)

  left, right = [], []
  arr.each do |i|
    if (left.last || 0) < i
      left << i
    elsif (right.last || 0) < i
      right << i
    end
  end
  puts (left.size + right.size) == arr.size ? 'YES' : 'NO'
end

Measured memory_bytes: 8596
X = int(input())
if X >= 400 and X <= 599:
    print('8')
elif X >= 600 and X <= 799:
    print('7')
elif X >= 800 and X <= 999:
    print('6')
elif X >= 1000 and X <= 1199:
    print('5')
elif X >= 1200 and X <= 1399:
    print('4')
elif X >= 1400 and X <= 1599:
    print('3')
elif X >= 1600 and X <= 1799:
    print('2')
elif X >= 1800 and X <= 1999:
    print('1')

Measured memory_bytes: 9196
/*
  kadai4_2 colon
  unomi
*/
#include <stdio.h>
#include <math.h>

#define PI 3.1415926535

int main(void){
    long double h_length=0, m_length=0, hour=0, minute=0, h_rad=0, m_rad=0, diff_rad=0, ans_dist=0;
    // h_length(A),m_length(B),hour(H),minute(M) の入力を取得
    scanf("%Lf %Lf %Lf %Lf",&h_length, &m_length, &hour, &minute);

    // 時針が動いた角度(ラジアン)
    h_rad = (360 * (hour/12.0 + (minute/60.0)/12.0)) * PI / 180.0;
    // 分針が動いた角度(ラジアン)
    m_rad = (360 * (minute/60.0)) * PI /180.0;
    // 時針と分針が成す角の角度(ラジアン)
    diff_rad = h_rad - m_rad;

    // 余弦定理を用いて、端点の距離を計算
    ans_dist = sqrt(h_length*h_length + m_length*m_length - 2*h_length*m_length*cos(diff_rad));

    printf("%10.10Lf\n",ans_dist);
    return 0;
}

Measured memory_bytes: 2576
def main():
    n=int(input())
    a=list(map(int,input().split(' ')))
    ans =abs(a[0]-sum(a[1:]))
    s=0
    rac=sum(a)
    for i in a[:-1]:
        s+=i
        rac-=i
        if abs(s-rac)<ans:
            ans = abs(s-rac)
    print(ans)
if __name__ == '__main__':
    main()


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

int main() {  
  vector<int> vec = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  
  int K;
  cin >> K;
  cout << vec.at(K - 1);
}


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

int main(void){
  string S;
  bool flag = false;
  cin >> S;
  sort(S.begin(), S.end());
  for(char alp = 'a'; alp <= 'z'; alp++){
    flag = false;
    for(int i = 0; i < S.size();i++){
      if(alp == S[i]){
        flag = true;
        break;
      }
    }
    if(flag == false){
      cout << alp << endl;
      flag = true;
      break;
    }
    if(alp == 'z'){
      cout << "None" << endl;
      break;
    }
  }
  return 0;
}


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

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

    int64_t cnt = 0;
    rep(i, n) {
        if(i % 3 == 0 | i % 5 == 0) {
            continue;
        } else {
            cnt += i;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3596
def main():
    x = int(input())
    for a in range(10**3):
        b = abs(a**5 - x)**0.2
        if a**5 - round(b)**5 == x:
            print(a, round(b))
            break
        if a**5 - round(-b)**5 == x:
            print(a, round(-b))
            break

if __name__ == '__main__':
    main()

Measured memory_bytes: 9452
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
// r#"2018 218"# => "Yes",
// r#"2763 0"# => "No",
r#"999"# => "ABC",

}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize,
    }

    if 1000 <= n {
        "ABD"
    } else {
        "ABC"
    }.to_string()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>

void view(const std::vector<T> &v)
{
#ifndef ONLINE_JUDGE
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
#endif
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    if (s[1] == 'R')
    {
        ans++;
        if (s[0] == 'R')
        {
            ans++;
        }
        if (s[2] == 'R')
        {
            ans++;
        }
    }
    if (ans == 0 && (s[0] == 'R' || s[2] == 'R'))
    {
        ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
N, M = map(int, input().split())
llim = 0
rlim = N + 1
for _ in range(M):
    L, R = map(int, input().split())
    llim = max(llim, L)
    rlim = min(rlim, R)
print(max(0, rlim + 1 - llim))


Measured memory_bytes: 3060
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;

template<class T> inline void chmax(T& a, const T& b) { if(b > a) a = b; }

void calc_dp(vector<int>& dp, vector<int>& degree, const vector<vector<int> >& edge) {
	const int n = dp.size();
	queue<int> que;
	for(int i = 0; i < n; ++i)
		if(!degree[i])
			que.push(i);

	while(!que.empty()) {
		const int v = que.front();
		que.pop();

		for(int i = 0; i < edge[v].size(); ++i) {
			chmax(dp[edge[v][i]], dp[v] + 1);
			if(!(--degree[edge[v][i]]))
				que.push(edge[v][i]);
		}
	}
}

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

	int n, m;
	cin >> n >> m;

	vector<int> in(n, 0), out(n, 0);
	vector<vector<int> > es(n), rev(n);
	vector<pair<int, int> > assoc;
	assoc.reserve(m);
	for(int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		--a;
		--b;

		es[a].push_back(b);
		rev[b].push_back(a);
		++out[a];
		++in[b];
		assoc.push_back(make_pair(a, b));
	}

	vector<int> dp_source(n, 0), dp_sink(n, 0);
	calc_dp(dp_source, in, es);
	calc_dp(dp_sink, out, rev);


	int length = *max_element(dp_source.begin(), dp_source.end());
	vector<pair<int, int> > candidate;
	for(int i = 0; i < m; ++i)
		if(dp_source[assoc[i].first] + 1 + dp_sink[assoc[i].second] == length)
			candidate.push_back(make_pair(dp_source[assoc[i].first], i + 1));

	vector<int> cnt(n, 0);
	for(int i = 0; i < candidate.size(); ++i)
		++cnt[candidate[i].first];

	bool exist = false;
	for(int i = 0; i < candidate.size(); ++i) {
		if(cnt[candidate[i].first] == 1) {
			cout << candidate[i].second << endl;
			exist = true;
		}
	}

	if(!exist)
		cout << -1 << endl;

	return EXIT_SUCCESS;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

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

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll h,w,n;
    cin>>h>>w>>n;
    if(h>w){
        swap(h,w);
    }
    ll ans = (n+w-1)/w;
    cout<<ans<<endl;
    return  0;
}


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

int main()
{
	int N;
	cin >> N;
	vector<int> dp(10001);
	dp[0] = 1;
	for (int i = 0, s; i < N; i++) {
		cin >> s;
		for (int j = 10000 - s; j >= 0; j--) {
			if (dp[j]) {
				dp[j + s] = 1;
			}
		}
	}
	int res = 0;
	for (int i = 0; i <= 10000; i++) {
		if (i % 10 != 0 && dp[i]) {
			res = i;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;

const int maxn = 1e5 + 10;
int n , freq[maxn];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(NULL);
	cin >> n;
	for(int i=0;i<n;i++)
	{
		int x;
		cin >> x;
		freq[x]++;
		freq[x+1]++;
		if(x) freq[x-1]++;
	}
	int mx = 0;
	for(int i=0;i<maxn;i++) mx = max(mx , freq[i]);
	cout << mx;
}

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

int main (){
	int n,k, ans = 0;
	cin >> n >> k;
	vector <int> snack(n+1,0);
    for(int i = 0; i < k; i++){
		int d;
		cin >> d;
		for (int j = 0; j < d; j++){
			int x;
			cin >> x;
			snack[x]++;			
		}
	}
	for(int i = 1; i < snack.size(); i++){
		if(snack[i] == 0)
			ans++;
	}
	cout << ans << endl;
}

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

using std::cerr;
using std::endl;

const int N = 2010, INF = 1e9;

int n, S, T, a, b, c, d;

struct Graph {
  int to, nxt, flow, cost;
} G[N * 16];

int head[N * 8], cur[N * 8], tot = 1;

inline void addedge(int x, int y, int f, int c) {
  G[++tot] = { y, head[x], f, -c }, head[x] = tot;
  G[++tot] = { x, head[y], 0, c }, head[y] = tot;
}

bool vis[N * 8];
long long dis[N * 8];
int que[N * 8], ql, qr;

inline bool spfa() {
  memset(vis, 0, sizeof(bool) * (T + 1));
  memset(dis, 0x3f, sizeof(long long) * (T + 1));
  for (int i = 1; i <= T; ++i)
    cur[i] = head[i];
  dis[S] = 0, que[ql = qr = 0] = S;
  while (ql <= qr) {
    int x = que[ql++];
    vis[x] = 0;
    for (int i = head[x]; i; i = G[i].nxt) {
      int y = G[i].to;
      if (G[i].flow && dis[y] > dis[x] + G[i].cost) {
        dis[y] = dis[x] + G[i].cost;
        if (!vis[y]) {
          vis[y] = 1;
          que[++qr] = y;
        }
      }
    }
  }
  return dis[T] != dis[0];
}

int dfs(int x, int mf) {
  if (x == T) return mf;
  int used = 0;
  vis[x] = 1;
  for (int &i = cur[x]; i; i = G[i].nxt) {
    int y = G[i].to;
    if (G[i].flow && !vis[y] && dis[y] == dis[x] + G[i].cost) {
      int tmp = dfs(y, std::min(G[i].flow, mf - used));
      if (tmp) {
        G[i].flow -= tmp;
        G[i ^ 1].flow += tmp;
        if ((used += tmp) == mf)
          break;
      }
    }
  }
  vis[x] = 0;
  return used;
}

inline long long mcmf() {
  long long ret = 0;
  int flow = 0;
  while (spfa()) {
    int tmp = dfs(S, INF);
    flow += tmp;
    ret += tmp * dis[T];
  }
  cerr << flow << endl;
  return ret;
}

int main() {
  // freopen("data", "r", stdin);
  std::ios::sync_with_stdio(0);
  std::cin.tie(0);
  std::cin >> n;
  a = n * 2 + 1, b = n * 2 + 2,
  c = n * 2 + 3, d = n * 2 + 4,
  S = n * 2 + 5, T = n * 2 + 6;
  for (int i = 1, x, y, w; i <= n; ++i) {
    std::cin >> x >> y >> w;
    addedge(S, i, w, 0);
    addedge(i, a, w, x + y);
    addedge(i, b, w, x - y);
    addedge(i, c, w, y - x);
    addedge(i, d, w, -y - x);
  }
  for (int i = 1, x, y, w; i <= n; ++i) {
    std::cin >> x >> y >> w;
    addedge(n + i, T, w, 0);
    addedge(a, n + i, w, -y - x);
    addedge(b, n + i, w, -x + y);
    addedge(c, n + i, w, x - y);
    addedge(d, n + i, w, x + y);
  }
  std::cout << -mcmf() << '\n';
  return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int, int>
#define pb(a) push_back(a)
#define all(v) v.begin(), v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	int N;
	cin >> N;

	cout << pow(N, 3) << endl;

	return 0;
}

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

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

int main(){
	int n, a[10000];
	while( cin >> n, n ){
		rep(i,n)	cin >> a[i];
		sort( a, a+n );
		long long res = 0;
		for( int i=0; i<n; i++ ){
			res += a[i]*(n-i-1);
		}
		cout << res << endl;
	}
	return 0;
}

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

int n,ji;
char s[200010];
int main()
{
	scanf("%d",&n);
	for(long long i=1;i<=100000;++i)
	{
		if(i*(i+1)/2>=n)
		{
			for(int j=1;j<=i;++j)
			s[j]=')';
			for(int j=i+1;j<=2*i;++j)
			s[j]='(';
			ji=i*(i+1)/2-n;
			int cur=i+1;
			while(ji&&cur>2)
			{
				swap(s[cur],s[cur-1]);
				cur--;
				--ji;
			}
			cur=i+2;
			while(ji&&cur>2)
			{
				swap(s[cur],s[cur-1]);
				cur--;
				--ji;
			}
			break;
		}
	}
	printf("%s",s+1);
	printf("\n");
	return 0;
}


Measured memory_bytes: 3284
S = input()

if not sum(list(map(lambda x: x == S[0], S))) == 2:
  print('No')
else:
  s = S[1:]
  idx = s.index(S[0])

  if idx == 0:
    if s[1] == s[2]:
      print('Yes')
    else:
      print('No')
  elif idx == 1:
    if s[0] == s[2]:
      print('Yes')
    else:
      print('No')
  elif idx == 2:
    if s[1] == s[0]:
      print('Yes')
    else:
      print('No')


Measured memory_bytes: 3064
n=int(input())
s = dict()
for i in range(n):
	i=input()
	if not i in s.keys():
		s[i]=1
	else:
		s[i]+=1
m = max(s.values())
l=list()
for i in s:
	if s[i] == m:
		l.append(i)
l.sort()
for i in l:
	print(i)



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

int main() {
  int N, fN=0, tmp=0, dec;
  cin >> N;
  tmp = N;
  rep(i, 8) {
    fN += tmp % 10;
    tmp /= 10;
  }
  if(N%fN == 0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  string s; cin >> s;
  cout << (s.substr(0, n / 2) == s.substr(n / 2) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
struct UnionFindTree {
    p: Vec<usize>,
    c: Vec<usize>,
}

impl UnionFindTree {
    fn new(size: usize) -> UnionFindTree {
        let mut p: Vec<usize> = vec![0; size];
        for pi in 0..size {
            p[pi] = pi;
        }
        UnionFindTree {
            p: p,
            c: vec![1; size],
        }
    }
    fn unite(&mut self, x: usize, y: usize) -> () {
        let a = self.find(x);
        let b = self.find(y);
        if a != b {
            self.p[a] = self.p[b];
            self.c[b] += self.c[a];
            self.c[a] = 0;
        }
    }
    fn find(&mut self, x: usize) -> usize {
        let y = self.p[x];
        if y != x {
            self.p[x] = self.find(y);
        }
        return self.p[x];
    }
    fn count(&mut self, x: usize) -> usize {
        let y = self.find(x);
        return self.c[y];
    }
}

fn main() {
    let (n, m) = {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let nm = line
            .split_whitespace()
            .map(|s| s.parse().unwrap())
            .collect::<Vec<usize>>();
        (nm[0], nm[1])
    };
    let (a, b) = {
        let mut a: Vec<usize> = Vec::new();
        let mut b: Vec<usize> = Vec::new();
        for _ in 0..m {
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let ab = line
                .split_whitespace()
                .map(|s| s.parse().unwrap())
                .collect::<Vec<usize>>();
            a.push(ab[0] - 1);
            b.push(ab[1] - 1);
        }
        (a, b)
    };
    let mut uf = UnionFindTree::new(n);
    let mut ans = vec![0; m];
    ans[m - 1] = n * (n - 1) / 2;
    for mi in (1..m).rev() {
        ans[mi - 1] = ans[mi];
        if uf.find(a[mi]) != uf.find(b[mi]) {
            ans[mi - 1] -= uf.count(a[mi]) * uf.count(b[mi])
        }
        uf.unite(a[mi], b[mi]);
    }
    for x in ans {
        println!("{}", x);
    }
}

Measured memory_bytes: 11516
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

count=0
for i in range(n):
    if a[i]<=b[i]:
        s=(b[i]-a[i])//2
        count+=s
    else:
        s=a[i]-b[i]
        count-=s
if count>=0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 4600