akhauriyash/Code-Regression huggingface dataset:
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	for a%b != 0 {
		a, b = b, a%b
	}
	return b
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	x := nextInt()

	ans := lcm(360, x) / x
	puts(ans)
}


Measured memory_bytes: 1784
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
const int N = 200005;
int n,x,y,ans[N];
// road
int k, knm[N],kfa[N];

int kfind(int t){
	if(t == kfa[t]) return t;
	return kfa[t] = kfind(kfa[t]);
}
// raiway
int l, lnm[N],lfa[N];
int lfind(int t){
	if(t == lfa[t]) return t;
	return lfa[t] = lfind(lfa[t]);
}

map<pair<int, int>, int> mp;

int main(){
	scanf("%d%d%d",&n,&k,&l);
	// k
	for(int i=1;i<=n;++i)
		kfa[i] = i;
	for(int i=1;i<=k;++i){
		scanf("%d%d",&x,&y);
		int tx = kfind(x), ty = kfind(y);
		if(tx != ty)
			kfa[ty] = tx;
	}
	
	// l
	for(int i=1;i<=n;++i)
		lfa[i] = i;	
	for(int i=1;i<=l;++i){
		scanf("%d%d",&x,&y);
		int tx = lfind(x), ty = lfind(y);
		if(tx != ty)
			lfa[ty] = tx;
	}
	
//for(int i=1;i<=n;++i)
//		cout<<lfa[i]<<" ";
//	cout<<endl;
	//cout<<kfa[3]<<" "<<lfa[3]<<endl;
	//cout<<kfa[5]<<" "<<lfa[5]<<endl;
	
	for(int i=1;i<=n;++i){
		++ mp[make_pair(kfind(i), lfind(i))];
	}
	for(int i=1;i<=n;++i)
		ans[i] = mp[make_pair(kfind(i), lfind(i))];
	for(int i=1;i<n;++i)
		printf("%d ", ans[i]);
	printf("%d\n", ans[n]); 
}

Measured memory_bytes: 17416
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define emp emplace
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
const ll MAXN = 510;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll H = 500;

int A[MAXN][MAXN];
int D[MAXN][MAXN];
int N,a;
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
queue<pi> Q;

void bfs(int x, int y){
	Q.push(mp(x,y));
	while(SZ(Q)){
		int x=Q.front().f;
		int y=Q.front().s;
		Q.pop();
		for (int k=0;k<4;++k){
			int cx=x+dx[k];
			int cy=y+dy[k];
			if (cx<0||cy<0||cx>=N||cy>=N)continue;
			int m=D[x][y]+A[cx][cy];
			if(m<D[cx][cy]){
				D[cx][cy]=m;
				Q.push(mp(cx,cy));
			}
		}
	}
}

int main(){
	cin>>N;
	for(int i=1;i<=N;++i)for(int j=1;j<=N;++j){
		D[i][j]=min({i-1,j-1,N-i,N-j});
	}
	// for(int i=1;i<=N;++i){
	// 	for(int j=1;j<=N;++j)cerr<<D[i][j]<<' ';
	// 	cerr<<'\n';
	// }
	int ans=0;
	for (int i=1;i<=N;++i)for(int j=1;j<=N;++j)A[i][j]=1;
	for (int i=0;i<N*N;++i){
		cin>>a;
		int row=a%N;if(row==0)row=N;
		int col=(a-1)/N+1;
		// cerr<<a<<' '<<row<<' '<<col<<' '<<D[row][col]<<'\n';
		ans+=D[row][col];
		A[row][col]=0;
		--D[row][col];
		bfs(row,col);
	}
	cout<<ans;
}

Measured memory_bytes: 5640
#include <string>
#include <iostream>
#include <vector>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long int64;

int main() {
	int A, B, C, K;
	cin >> A >> B >> C >> K;
	if (K <= A) {
		cout << K << "\n";
	} else if (K <= A+B) {
		cout << A << "\n";
	} else {
		cout << A - (K-(A+B)) << "\n";
	}
	return 0;
}


Measured memory_bytes: 3632
#[test]
fn test_solve() {
    assert_eq!(solve("3 3\n"), "2\n");
    assert_eq!(solve("2 2\n"), "0\n");
    assert_eq!(solve("999999 999999\n"), "151840682\n");
    dbg!(solve("1000000 100002\n"));
}

fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let mut pat = Finite(1);
    let x: u64 = sc.read();
    let y: u64 = sc.read();
    let n = (x+y)/3;
    if (x+y)%3 != 0 || x < n || y < n {
        return "0\n".to_string()
    }
    let x = x - n;
    let y = y - n;

    for i in 1..n+1 {
        pat = pat * Finite(i);
    }
    for i in 1..x+1 {
        pat = pat / Finite(i);
    }
    for i in 1..y+1 {
        pat = pat / Finite(i);
    }

    format!("{}\n", pat)
}

const MOD: u64 = 1_000_000_007;
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
struct Finite(u64);
impl Finite {
    pub fn pow(self, mut exp: u32) -> Self {
        let mut base = self.0;
        let mut acc = 1;
        while exp > 1 {
            if (exp & 1) == 1 {
                acc = acc * base % MOD;
            }
            exp >>= 1;
            base = base * base % MOD;
        }
        if exp == 1 {
            acc = acc * base % MOD;
        }
        Finite(acc)
    }
}
impl std::fmt::Display for Finite {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        write!(f, "{}", self.0)
    }
}
impl std::ops::Mul for Finite {
    type Output = Self;
    fn mul(self, rhs: Self) -> Self {
        Finite(self.0 * rhs.0 % MOD)
    }
}
impl std::ops::Div for Finite {
    type Output = Self;
    fn div(self, rhs: Self) -> Self {
        self * rhs.pow((MOD - 2) as u32)
    }
}

fn main() {
    let mut buf = String::new();
    use std::io;
    use std::io::{Read, Write};
    io::stdin().read_to_string(&mut buf).unwrap();
    io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}

struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define ALL(a) (a).begin(),(a).end()
#define EACH(e,v) for(auto& e:v)
#define SORT(v) sort(ALL(v))
#define PERM(v) SORT(v);for(bool c##p=1;c##p;c##p=next_permutation(ALL(v)))
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = 1000'000'007;
 
signed main(){
    set<int> se;
    int a,b,c;
    cin>>a>>b>>c;
    se.insert(a);
    se.insert(b);
    se.insert(c);

    if(se.size()==2){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

}

Measured memory_bytes: 256
#include<stdio.h>


int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a<=b && b<=c){printf("%d %d %d\n",a,b,c);}
	else if(a<=c && b>=c){printf("%d %d %d\n",a,c,b);}
	else if(b<=a && a<=c){printf("%d %d %d\n",b,a,c);}
	else if(b<=c && a>=c){printf("%d %d %d\n",b,c,a);}
	else if(c<=a && a<=b){printf("%d %d %d\n",c,a,b);}
	else if(c<=b && b<=a){printf("%d %d %d\n",c,b,a);}
	return 0;
}

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

using namespace std;

const int INF = 1e9;

int main() {
  int n;
  cin >> n;
  vector<int> stones = vector<int> (n);
  vector<int> dp = vector<int> (n, INF);
  for (int i=0; i<n; ++i)
    cin >> stones[i];

  dp[0] = 0;
  for (int i=0; i<n; ++i)
    for (int j : {i+1, i+2}) 
      if (j < n)
        dp[j] = min(dp[j], dp[i] + abs(stones[i] - stones[j]));

  cout << dp[n-1] << "\n";
  return 0;
}


Measured memory_bytes: 1024
import itertools

n = int(input())
a = [i for i in range(1,n+1)]
b = list(itertools.permutations(a))
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
pi = b.index(p)
qi = b.index(q)

print(abs(pi - qi))

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

int main() {
  int a, b, c, x; cin >> a >> b >> c >> x;
  int count = 0;
  for(int i = 0; i <= a; i++){
    for(int j = 0; j <= b; j++){
      for(int k = 0; k <= c; k++){
        if(500*i + 100*j + 50*k == x) count++;
      }
    }
  }
  cout << count << endl;
}

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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

const int32_t inf = 1001001001;
const int64_t infll = 1001001001001001001ll;
const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

template <typename T> using vector2d = vector<vector<T>>;

// clang-format off
template <typename T> void sort(vector<T> &v) { sort(all(v)); }
ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  int a = in() + in(), b = in() + in();
  if (a < b)
    cout << "Right" << endl;
  else if (a > b)
    cout << "Left" << endl;
  else
    cout << "Balanced" << endl;
}


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

#define H_MAX 260

long H, A[H_MAX];

void print(long i) {
    cout << "node " << i << ": ";
    cout << "key = " << A[i] << ", ";
    if (i / 2 >= 1) {
        cout << "parent key = " << A[i / 2] << ", ";
    }
    if (i * 2 <= H) {
        cout << "left key = " << A[i * 2] << ", ";
    }
    if (i * 2 + 1 <= H) {
        cout << "right key = " << A[i * 2 + 1] << ", ";
    }
    cout << endl;
}

int main() {
    cin >> H;

    for (long i = 1; i < H + 1; i++) {
        cin >> A[i];
    }

    for (long i = 1; i < H + 1; i++) {
        print(i);
    }
}



Measured memory_bytes: 3092
# ABC 097: B – Exponential
x = int(input())

b = 2
perfect_power = 0

if x < 4:
    perfect_power = 1
else:
    while b < x:
        p = 2
        while b ** p <= x:
            perfect_power = max(perfect_power, b ** p)
            p += 1
        b += 1

print(perfect_power)

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

int main()

{
    int b1 = 10000, b2 = 5000, b3 = 1000;
    int n, y;
    cin >> n >> y;

    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= n - i; j++) {

            int tmp = b1 * i + b2 * j;
            if(tmp > y)
                break;

            if( (y - tmp) % b3 == 0) {
                int k = (y - tmp) / b3;
                if(i + j + k == n) {
                    printf("%d %d %d\n", i, j, k);
                    return 0;
                }
            }

        }
    }

    printf("-1 -1 -1\n");

    return 0;
}


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

int main(){
    int n,l;
    cin >> n >> l;
    string s[n];
    for(int i = 0; i<n; ++i){
        cin >> s[i];
    }
    sort(s, s+n);
    for(int i = 0; i<n; ++i){
        cout << s[i];
    }
    cout << endl; return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const int inf=0x3f3f3f3f;
const unsigned long long mod=1e18;
long long a[maxn];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;
	cin>>n;
	long long x=1;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	if(a[1]==0)
	{
		cout<<"0"<<endl;
		return 0;
		
	}
	for(int i=1;i<=n;i++)
	{
		long long y=mod/x;
		if(a[i]>y)
		{
			cout<<"-1"<<endl;
			return 0;
		}
		x*=a[i];
		if(x>mod)
		{
			cout<<"-1"<<endl;
			return 0;
		}
	}
	if(x<0)
		cout<<"-1"<<endl;
	else
		cout<<x<<endl;
	return 0;
}




Measured memory_bytes: 4396
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

int main( void )
{
    long long N;
    cin >> N;

    long long A[N] = {};
    long long absmin = 1000000000LL;
    long long result = 0;
    int hugou = 1; // now only positive
    for(int i=0;i<N;i++){
        cin >> A[i];
        long long tmp = abs(A[i]);
        if(tmp < absmin){
            absmin = tmp;
        }
        if(A[i] < 0){
            hugou *= -1;
        }
        result += tmp;  
    }

    if(hugou == -1){
        result -= 2*absmin;
    }

    cout << result;


	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    set<string> s;
    for (int i = 0; i < N; i++) {
        string S;
        cin >> S;
        s.insert(S);
    }
    cout << s.size() << "\n";
    return 0;
}

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

ll solve(ll a[], ll i, ll k, ll n, vector<ll>& dp){
	if(i==(n-1)) return 0;
	if(i>=n) return INT_MAX;
	
	if(dp[i] != -1)
		return dp[i];
		
	ll mn=LONG_MAX;
	
	for(ll step=1; step<=k; step++){
		if(i+step < n)
			mn=min(mn, abs(a[i]-a[i+step]) + solve(a, i+step, k, n, dp) );
	}
	
	return dp[i]=mn;
}

ll topdown(ll a[], ll n, ll k){
	vector<ll> dp(n, INT_MAX);
	dp[0]=0;
	
	for(ll i=0; i<n; i++) {
		for(ll j=i+1; j<=i+k; j++) {
			if(j<n)
				dp[j]=min(dp[j], dp[i] + abs(a[i] - a[j]) );
		}
	}
	cout << dp[n-1] << "\n";
}

void solve() {
	ll n, k;
	cin >> n >> k;
	
	ll h[n]={};
	
	vector<ll> dp(n+1, -1);
	
	for(ll i=0; i<n; i++)
		cin >> h[i];
		
	topdown(h, n, k);
//	cout << solve(h, 0, k, n, dp) << "\n";
}

int main(){
	solve();
}

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

typedef long long ll;

int main() {
	// string s;
	int n;
	cin >> n;
	vector<int> a(n);
	for(auto& e:a) cin >> e;
	
	ll ans = 0;
	
	for(int i=1;i<n;i++) {
		if (a[i] >= a[i-1]) continue;
		ans += a[i-1] - a[i];
		a[i] = a[i-1];
	}
	cout << ans << '\n';
	
	return 0;
}


Measured memory_bytes: 4004
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
#define int long long
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
inline int rnd(int x){
	return (rand()<<16|rand())%x;
}
const int N=100005;
multiset< pair<int,int> > s[2];
ll ans,a[N],b[N];
int n;
inline int chu(int now,int l,int r){
	if(now>=l&&now<=r)return now;
	else{
		if(now<l){
			ans+=l-now;
			now=l;
		}else{
			ans+=now-r;
			now=r;
		}
		//cout<<now<<" "<<l<<" "<<r<<" "<<ans<<endl;
	}
	return now;
}
ll solve(int x){
	int now=ans=0,dq=x;
	//sort(&a[1],&a[x+1],cmp);
	for(int i=1;i<=n;i++){
		s[0].insert(mp(a[i],b[i]));
		s[1].insert(mp(b[i],a[i]));
	}
	while(s[0].size()){
		if(dq){
			int l=(*s[0].rbegin()).first,r=(*s[0].rbegin()).second;
			//cout<<l<<" "<<r<<endl;
			now=chu(now,l,r);
			s[0].erase(s[0].find(mp(l,r))); s[1].erase(s[1].find(mp(r,l)));
		}else{
			int r=(*s[1].begin()).first,l=(*s[1].begin()).second;
			//cout<<l<<" "<<r<<endl;
			now=chu(now,l,r);
			s[0].erase(s[0].find(mp(l,r))); s[1].erase(s[1].find(mp(r,l)));
		}
		dq^=1;
	}
	return ans+abs(now);
}
signed main(){
	n=read();
	for(int i=1;i<=n;i++){
		a[i]=read(); b[i]=read();
	}
	cout<<max(solve(0),solve(1))<<endl;
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;


    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	class A {
		int d, p;
		A(int d, int p) {
			this.d = d;
			this.p = p;
		}
	}
	
	void sort(A[] a) {
		int n = a.length;
		for (int i = n-1; i > 0; i--) {
			for (int j = 0; j < i; j++) {
				if (a[j].p < a[j+1].p) {
					A temp = a[j];
					a[j] = a[j+1];
					a[j+1] = temp;
				}
			}
		}
	}
	
	void run() {
		int n, m;
		while (true) {
			n = sc.nextInt(); m = sc.nextInt();
			if (n == 0) break;
			A[] a = new A[n];
			int sum = 0;
			for (int i = 0; i < n; i++) {
				int d = sc.nextInt(), p = sc.nextInt();
				a[i] = new A(d, p);
				sum += d*p;
			}
			
			sort(a);
			int guard = 0;
			int index = 0;
			while (m >= a[index].d) {
				m -= a[index].d;
				guard += a[index].d*a[index].p;
				index++;
				if (index == n) {
					break;
				}
			}
			if (index < n)
				guard += m*a[index].p;
			out.println(sum-guard);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

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

namespace program
{
    class Program
    {
        static void Main()
        {
          int[] n=Input.ScanIntArray();
          Array.Sort(n);
          if(n[0]==n[1]&&n[1]==n[2])
          Console.WriteLine("Yes");
          else
            Console.WriteLine("No");
          
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


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

AC_list = []
WA_list = []
TLE_list = []
RE_list = []

for _ in range(N) :
    S = str(input())
    if S == 'AC' :
        AC_list.append(S)
    elif S == 'WA' :
        WA_list.append(S)
    elif S == 'TLE' :
        TLE_list.append(S)
    elif S == 'RE' :
        RE_list.append(S)

print('AC x ' + str(len(AC_list)))
print('WA x ' + str(len(WA_list)))
print('TLE x ' + str(len(TLE_list)))
print('RE x ' + str(len(RE_list)))


Measured memory_bytes: 16296
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define repr(i,l,r) for(int i=(r)-1,i##_left=(l);i>=i##_left;--i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail) { cin >> head; in(move(tail)...); }
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
template<class T>
string join(vector<T>& v, string delim="") { ostringstream os; rep(i,v.size())i?os<<delim<<v[i]:os<<v[0]; return os.str(); }
#pragma endregion RegionDefs

void solve()
{
    IN(x);
    cout << (1999-x)/200+1 << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll inf = 100000000000000;
#define F(i, j, k) for(ll i = j; i <= k; ++i)
#define pp pair<ll, ll>
#define mp make_pair
const ll maxn = 6e2+5;
ll n, m, cnt, x, y, z;
ll r[maxn], g[maxn][maxn], dist[maxn][maxn];
struct edge{
    ll to, w;
    edge(ll a, ll b):to(a), w(b){}
    edge(){}
}E[maxn];
vector<ll> to[maxn];
void add_edge(ll u, ll v, ll w) {
    E[++cnt] = edge(v, w);
    to[u].push_back(cnt);
}
void add(ll u, ll v, ll w) {
    add_edge(u, v, w);
    add_edge(v, u, w);
}
ll read() {
    char ch = getchar();
    ll x = 0,f = 1;
    while(!isdigit(ch)) {
	if(ch == '-') f = -1;
	ch = getchar();
    }
    while(isdigit(ch)) {
	x = x * 10 + ch - '0';
	ch = getchar();
    }
    return x * f;
}
int main() {
#ifdef orz
    freopen("input", "r", stdin);
#endif
    cin >> n >> m >> cnt;
    F(i, 1, n) F(j, 1, n) dist[i][j] = inf;
    F(i, 1, cnt) r[i] = read();
    F(i, 1, m) {
	cin >> x >> y >> z;
	dist[x][y] = min(dist[x][y], z);
	dist[y][x] = min(dist[y][x], z);
    }
    F(i, 1, n) dist[i][i] = 0;
    F(k, 1, n) F(i, 1, n) F(j, 1, n) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    ll a[maxn];
    F(i, 1, cnt) a[i] = i;
    ll tt = inf;
    do{
	ll ans = 0;
	F(i, 1, cnt - 1) ans += dist[r[a[i]]][r[a[i+1]]];
	tt = min(ans, tt);
    }while(next_permutation(a+1, a+1+cnt));
    printf("%lld\n", tt);
}


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

#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()

using namespace std;

bool solve() {
    int H, W;

    cin >> H >> W;
    vector<string> A(H);
    REP(i, H) cin >> A[i];

    int cnt = 0;
    REP(i, H) {
        cnt += count(all(A[i]), '#');
    }

    if (cnt != H + W - 1) return false;

    int x = 0;
    int y = 0;
    while (x != H - 1 || y != W - 1) {
        bool can_move_x = x + 1 < H && A[x + 1][y] == '#';
        bool can_move_y = y + 1 < W && A[x][y + 1] == '#';
        if (can_move_x && !can_move_y) {
            ++x;
        } else if (!can_move_x && can_move_y) {
            ++y;
        } else {
            return false;
        }
    }
    return true;
}

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

    cout << (solve() ? "Possible" : "Impossible") << endl;

    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define in_range(x, y, r, c) (x <= r && y <= c && x >= 0 && y >= 0)
using namespace std;
const int mod = 1e9+7;

int main(){
	long long w ,h, x, y;
	cin >> w >> h >> x >> y;
	long double area = w*h;
	cout.precision(6);
	int ans;
	
	if (x == w/2.0 and y == h/2.0) ans = 1;
	else ans = 0;
	cout << area/2.0 << " " << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b)for(int i=a;i<b;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define clr1(arr) memset(arr,-1,sizeof(arr));
#define clr0(arr) memset(arr,0,sizeof(arr));
#define pi pair<int,int>
#define pii pair<int,pi>
#define sortV(v) v.begin(),v.end()
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
// DSU
/*
const int maxn=100009;
int arr[maxn];
int sz[maxn];
void init(){rep(i,maxn){arr[i]=i;sz[i]=1;}}
int root(int a){while(a!=arr[a]){arr[a]=arr[arr[a]];a=arr[a];}return a;}
int check(int a,int b){if(root(a)==root(b))return 1;return 0;}
int un(int a,int b)
{
  int roota=root(a);int rootb=root(b);
  if(sz[roota]>=sz[rootb]){sz[roota]+=sz[rootb];arr[rootb]=roota;}
  else {sz[rootb]+=sz[roota];arr[roota]=rootb;}
}
*/
int32_t main()
{
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
   fastio
   int n,k;
   cin>>n>>k;
   int arr[n];
   int sum=0;
   rep(i,n)
   {
     cin>>arr[i];
     sum+=arr[i];
   }
   vector<int>div;
   for(int i=1;i*i<=sum;i++)
   {
     if(sum%i==0)
     {
       if(i==sum/i)div.pb(i);
       else
       {
         div.pb(i);
         div.pb(sum/i);
       }
     }
  }
  int ans=0;
  rep(i,div.size())
  {
    multiset<int>s;
    int totalCost=0;
    int used=0;
    rep(j,n)
    {
      s.insert(arr[j]%div[i]);
      totalCost+=div[i]-(arr[j]%div[i]);
    }
    for(auto it=s.begin();it!=s.end();it++)
    {
      used+=*it;
      totalCost-=div[i]-*it;
      if(used==totalCost && used<=k)ans=max(ans,div[i]);
    }
  }
  cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    static bool isOdd(int x)
    {
	return ((x&1)==1);
    }
    
    public static void Main()
    {
	int n = int.Parse(ReadLine());
	int[] a = ReadIntArray();
	Array.Sort(a);

	// Check
	if (isOdd(n))
	{
	    for (int i = 0; i < n; i++)
	    {
		int expected = isOdd(i) ? i + 1 : i ;
		if (a[i] != expected)
		{
		    WriteLine(0);
		    return;
		}
	    }
	}
	else
	{
	    for (int i = 0; i < n; i++)
	    {
		int expected = i | 1;
		if (a[i] != expected)
		{
		    WriteLine(0);
		    return;
		}
	    }
	}

	// Calculate
	int ans = 1;
	int m = n / 2;
	for (int i = 0; i < m; i++)
	{
	    ans = (ans * 2) % 1000000007;
	}
	WriteLine(ans);
    }
}


Measured memory_bytes: 20064
#include<stdio.h>
#define N n
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF&&n>=1&&n<=100)
    {
        int data[N];
        int i,j,k,temp,s=0;
        for(i=0;i<N;i++) {
        scanf("%d",&data[i]);
    }
    for(j=0;j<N-1;j++) {
        for(i=0;i<N-j-1;i++) {
            if(data[i]>data[i+1]) {
                temp = data[i];
                data[i] = data[i+1];
                data[i+1] = temp;
                s++;
            }
        }
    }
    for(k=0;k<N-1;k++) {
        printf("%d ", data[k]);
    }
    printf("%d", data[N-1]);
    printf("\n");
    printf("%d\n",s);
    }

}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;


int H,W;
vector<vector<int> > a;
vector<vector<bool> > f;

vector<int> dx = {1, 0, -1, 0};
vector<int> dy = {0, 1, 0, -1};

vector<int> ans;


void bfs(int x, int y){
    
    rep(i,4){
        int nx = x + dx[i];
        int ny = y + dy[i];
        if (0 <= nx && nx <= H-1 && 0 <= ny && ny <= W-1 && a[nx][ny]%2 == 1 && f[nx][ny]) {
            ans.push_back(x+1);
            ans.push_back(y+1);
            ans.push_back(nx+1);
            ans.push_back(ny+1);
            f[x][y] = false;
            a[x][y]--;
            a[nx][ny]++;
            return;
        }
        
    }
    rep(i,4){
        int nx = x + dx[i];
        int ny = y + dy[i];
        if(0 <= nx && nx <= H-1 && 0 <= ny && ny <= W-1 && f[nx][ny]){
            ans.push_back(x+1);
            ans.push_back(y+1);
            ans.push_back(nx+1);
            ans.push_back(ny+1);
            f[x][y] = false;
            a[x][y]--;
            a[nx][ny]++;
            return;
        }
        
    }
    
    
    
}



int main()
{
    cin >> H >> W;
    a.assign(H,vector<int>(W, 0));
    f.assign(H,vector<bool>(W, true));
    
    rep(i,H){
        rep(j,W) cin >> a[i][j];
    }
    
    rep(i,H){
        rep(j,W){
            
            if (a[i][j]%2 == 1) {
                bfs(i,j);
            }
            
        }
    }
    
    cout << int(ans.size())/4 << endl;
    
    rep(i,ans.size()){
        cout << ans[i];
        if ((i+1)%4==0) {
            cout << endl;
        }else{
            cout << " ";
        }
    }
    
    
    return 0;
}





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


int y, m, d;

int main() {
  scanf("%d/%d/%d", &y, &m, &d);
  if (m < 4 || (m == 4 && d <= 30)) {
    cout << "Heisei";
  } else {
    cout << "TBD";
  }
  return 0;
} 

Measured memory_bytes: 256
n=int(input())

num=int(n**0.5)+1
mini=float('inf')
for k in range(1,num+1):
    i=k
    j=0
    if n%i==0:
        j=n//i
    if j!=0 and len(str(j))<=mini:
        mini=len(str(j))
print(mini)

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

int main()
{
    string s;
    cin >> s;
    int N = s.size();
    int start, end;
    for (int i = 0; i < N; ++i)
    {
        if (s[i] == 'A')
        {
            start = i;
            break;
        }
    }
    for (int i = 0; i < N; ++i)
    {
        if (s[N - 1 - i] == 'Z')
        {
            end = N - 1 - i;
            break;
        }
    }
    cout << end - start + 1 << endl;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
ll power(ll a, ll b) { //a^b
	ll res = 1;
	a = a % MOD;
	while (b > 0) {
		if (b & 1) {res = (res * a) % MOD; b--;}
		a = (a * a) % MOD;
		b >>= 1;
	}
	return res;
}

ll gcd(ll a, ll b) {return (b == 0) ? a : gcd(b, a % b);}

vl p(100005);
vl siz(100005);

ll get(ll u) {
	return p[u] = (p[u] == u ? u : get(p[u]));
}

void unions(ll u, ll v) {
	u = get(u);
	v = get(v);
	if (u == v)
		return;
	if (siz[u] > siz[v])
		swap(u, v);
	p[u] = v;
	siz[v] += siz[u];
}

int main() {
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, m;
	cin >> n >> m;
	for (ll i = 1; i <= n; i++) {
		p[i] = i;
		siz[i] = 1;
	}
	for (ll i = 0; i < m; i++) {
		ll u, v;
		cin >> u >> v;
		unions(u, v);
	}
	set <ll> s;
	for (ll i = 1; i <= n; i++) {
		ll z = get(p[i]);
		s.insert(z);
	}
	cout << (ll)s.size() - 1 << "\n";

}


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

using namespace std;

//typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)

bool isprime(ll  n){
	if (n < 2) return false;
	else if (n == 2) return true;
	else if (n % 2 == 0) return false;
	else
		for (int i = 3; i*i <= n; i++)
			if (n%i == 0) return false;

	return true;
}

signed main(){

	int N,P;
	int a[1000001] = { 0 };

	cin >> N >> P;

	if (isprime(P)){
		if (N == 1){
			cout << P << endl;
			return 0;
		}
		else{
			cout << 1 << endl;
			return 0;
		}
	}
	if (N == 1){
		cout << P << endl;
		return 0;
	}
	for (int i = 2; i <= 1000000; i++){
		while (P%i == 0){ P /= i; a[i]++; }
	}
	int ans = 1;
	for (int i = 2; i <= 1000000; i++){
		while (a[i] >= N){ ans *= i; a[i] -= N; }
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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 = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe


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

int n,m,c,s=0,ans=0;
cin >> n >> m>> c;
int b[m],a[n][m];
rep(i,m){
    cin >> b[i];
}
rep(i,n){
    rep(k,m){
        cin >> a[i][k];   
    }
}

rep(i,n){
    rep(k,m){
       s += b[k]*a[i][k];

    }
    if((s+c)>0){
        ans++;
    }
    s = 0;
}

cout << ans << endl;

//////////////////////////////////////////////////////
return 0;}

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

string IntToString(int num){
  stringstream ss;
  ss << num;
  return ss.str();
}

bool search(int n, char d[]){
  string strn = IntToString(n);
  bool judge = true;
  for(int i = 0; i < strn.size(); i++){
    for(int j = 0; j < strlen(d); j++){
      if(strn[i] == d[j]) judge = false;
//      cout << d[j] << strn[i] << judge <<  endl;
    }
  }
  return judge;
}

int main(){
  int n, k;
  cin >> n >> k;
  char d[k];
  for(int i = 0; i < k; i++){
    cin >> d[i];
  }
  while(true){
    if(search(n, d) == false) n++;
    else{
      cout << n << endl;
      break;
    }
  }
}



Measured memory_bytes: 256
fun main(args: Array<String>)
{
    val (k, x) = readNInts()

    val min = x - (k - 1)
    val max = x + (k - 1)

    var s = ""
    for (i in min..(max-1))
    {
        s += "$i "
    }
    s += "$max"

    println(s)
}

// Read an integer
// Usage: val a = readInt()
fun readInt() = readLine()!!.toInt()

// Read N integers separated by " "
// Usage: val (a, b, c) = readNInts()
fun readNInts() = readLine()!!.split(" ").map(String::toInt)

// Read a string
// Usage: val a = readString()
fun readString() = readLine()!!


Measured memory_bytes: 36284
from itertools import product

def main():
  N = int(input())

  results = list()
  ans = 0

  for i in range(1, 10):
    for j in list(product(['3', '5', '7'], repeat=i)):
      results.append(''.join(map(str, list(j))))
  
  for result in results:
    if int(result) > N:
      break
    if '3' in result and '5' in result and '7' in result:
      ans +=1

  print(ans)


main()

Measured memory_bytes: 8360
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long N = sc.nextLong();
		long A = sc.nextLong();
		long B = sc.nextLong();

		if(A==0) {
			System.out.println(0);
			return;
		} else if(B==0) {
			System.out.println(N);
			return;
		}

		long J = N/(A+B);
		long K = N%(A+B) >= A ? A : N%(A+B);

		long result = (J*A) + K;
		System.out.println(result);
	}
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

template<typename T> class segtree {
private:
    int n,sz,h; vector<T> node, lazy;
    vector<bool> lazyFlag;
    void eval(int k) {
        if(lazyFlag[k]){
            node[k] = lazy[k];
            if(k < n) {
                lazy[k*2] = lazy[k*2+1] = lazy[k];
                lazyFlag[k*2] = lazyFlag[k*2+1] = true;
            }
            lazyFlag[k] = false;
        }
    }

public:
    segtree(const vector<T>& v) : n(1), sz((int)v.size()), h(0){
        while(n < sz) n *= 2, h++;
        node.resize(2*n, numeric_limits<T>::max());
        lazy.resize(2*n); lazyFlag.resize(2*n, false);
        for(int i = 0; i < sz; i++) node[i+n] = v[i];
        for(int i = n - 1; i >= 1; i--) node[i] = min(node[i*2], node[i*2+1]);
    }
    void range(int a, int b, T x, int k=1, int l=0, int r=-1){
        if(r < 0) r = n;
        eval(k);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b){
            lazy[k] = x, lazyFlag[k] = true; eval(k);
        }else{
            range(a, b, x, 2*k, l, (l+r)/2);
            range(a, b, x, 2*k+1, (l+r)/2, r);
            node[k] = min(node[2*k], node[2*k+1]);
        }
    }
    T query(int a, int b) {
        a += n, b += n - 1;
        for(int i = h; i > 0; i--) eval(a >> i), eval(b >> i);
        b++;
        T res1 = numeric_limits<T>::max(), res2 = numeric_limits<T>::max();
        while(a < b) {
            if(a & 1) eval(a), res1 = min(res1, node[a++]);
            if(b & 1) eval(--b), res2 = min(res2, node[b]);
            a >>= 1, b >>= 1;
        }
        return min(res1, res2);
    }
    //void print(){for(int i = 0; i < sz; i++) cout<<query(i,i+1)<< " ";cout<<endl;}
};

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n, q, f, iq, l, r;
	char c;
	string s;
	cin >> n >> s >> q;
	
	vector<segtree<int>> sg;
	zep(i, 0, 26){
		vector<int> buf(n, 0);
		segtree<int> bufbuf(buf);
		sg.push_back(bufbuf);
	}
	
	zep(i, 0, n){
		sg[s[i]-'a'].range(i, i+1, -1);
	}
	
	zep(i, 0, q){
		cin >> f;
		if(f == 1){
			cin >> iq >> c; iq--;
			if(c != s[iq]){
				sg[s[iq]-'a'].range(iq, iq+1, 0);
				s[iq] = c;
				sg[s[iq]-'a'].range(iq, iq+1, -1);
			}
		}
		else{
			cin >> l >> r; l--;
			ll ans = 0;
			zep(j, 0, 26){
				if(sg[j].query(l, r) < 0){
					ans++;
				}
			}
			print(ans)
		}
	}
	return 0;
}

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

vector<int> bfs(vector<vector<int>> g,int N)
{
	vector<int> ans(N,-1);
	ans[0]=0;
	queue<int> que;
	que.push(0);
	while(!que.empty())
	{
		int p=que.front();que.pop();
		for(int v : g[p])
		{
			if(ans[v]!=-1) continue;
			ans[v]=p;
			que.push(v);
		}
	}
	return ans;
}
int main()
{
	int N,M;
	cin>>N>>M;
	vector<vector<int>> g(N);
	rep(i,M)
	{
		int a,b;
		cin>>a>>b;
		a--;b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	vector<int> ans=bfs(g,N);
	cout<<"Yes"<<endl;
	for(int i=1;i<N;i++)
	{
		cout<<ans[i]+1<<endl;
	}
	return 0;
}


Measured memory_bytes: 15756
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n,ans=0; 
    cin>>n;
    int A[30];
    for(int i=0;i<n;i++) cin>>A[i];
    for(int i=1;i<n-1;i++){
        if(max(A[i],A[i-1])==min(A[i+1],A[i]) || max(A[i],A[i+1])==min(A[i],A[i-1])) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;

ll modx(ll a)
{
    return (a%MOD+MOD)%MOD;
}

ll times(ll a, ll b)
{
    return modx(modx(a)*modx(b));
}

ll add(ll a, ll b)
{
    return modx(modx(a)+modx(b));
}

ll sub(ll a, ll b)
{
    return modx(MOD+modx(a)-modx(b));
}

ll fastExp(ll base, ll exp)
{
    if(exp == 0LL)
    {
        return 1LL;
    }

    if(exp%2==0)
    {
        return fastExp(times(base, base), exp/2);
    }
    else
    {
        return times(exp, fastExp(times(base, base), exp/2));
    }
}


const int MAXN = (int)5e3+1;
int N, dp[MAXN][MAXN];


int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    string S;
    cin >> N >> S;
    int ans = 0;
    for(int i=0; i<N; i++)
    {
        for(int j=i+1; j<N; j++)
        {
            if(S[i] == S[j] && dp[i][j] < (j-i))
            {
                dp[i+1][j+1] = dp[i][j]+1;
                ans = max(ans, dp[i+1][j+1]);
            }
            else
            {
                dp[i+1][j+1] = 0;
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 96768
import sys
n,k=map(int,input().split())
A=[int(i) for i in input().split()]
Z=[n]*n
class BIT():
    """区間加算、一点取得クエリをそれぞれO(logN)で答える
    add: 区間[l, r)にvalを加える
    get_val: i番目の値を求める
    i, l, rは0-indexed
    """
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (n + 1)

    def _add(self, i, val):
        while i > 0:
            self.bit[i] += val
            i -= i & -i

    def get_val(self, i):
        """i番目の値を求める"""
        i = i + 1
        s = 0
        while i <= self.n:
            s += self.bit[i]
            i += i & -i
        return s

    def add(self, l, r, val):
        """区間[l, r)にvalを加える"""
        self._add(r, val)
        self._add(l, -val)
for _ in range(k):
    tree = BIT(n)
    for i in range(n):
        l = max(0,i-A[i])
        r = min(n,i+A[i]+1)
        #print(l,r)
        tree.add(l,r,1)
        #print([tree.get_val(i) for i in range(n)])
    A=[tree.get_val(i) for i in range(n)]
    #print(A)
    if A == Z:
        break
        #print(*Z)
print(*A)

Measured memory_bytes: 176388
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))


n=ni()
a = nl()
j= True

for i in a:
    if i%2==0:
        if i%3!=0 and i%5!=0:
            j=False
            


if j:
    print("APPROVED")
else:
    print("DENIED")



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

long long beki(long long x)
{
    long long ans = 1;
    long long i;
    for(i = 0;i < x;++i){
        ans *= 2;
    }
    return ans;
}

int main()
{
    long long n,k;
    long long i,j;
    cin >> n >> k;
    vector<long long>a(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    long long temp0 = 0,temp1 = 0;
    long long max1 = 0;
    for(i = 0;i < n;++i){
        if(a.at(i) > max1){
            max1 = a.at(i);
        }
    }
    if(k > max1){max1 = k;}
    long long keta = 0;
    while(max1){
        max1 /= 2;
        ++keta;
    }
    --keta;
    vector<long long> aboutk(keta+1);
    for(i = 0;i <= keta;++i){
        if(k % 2){
            aboutk.at(i) = 1;
        }else{
            aboutk.at(i) = 0;
        }
        k /= 2;
    }
    bool flag = true;
    long long ans = 0;
    for(i = keta;i >= 0;--i){
        long long t = 1; t = t << i;
        for(j = 0;j < n;++j){
            if(a.at(j) & t){
                ++temp1;
            }else{
                ++temp0;
            }
        }
        if(flag && aboutk.at(i) == 0){
            ans += beki(i)*temp1;
        }else{
            ans += beki(i)*max(temp1,temp0);
            if(flag){
                if(temp1 >= temp0){
                    flag = false;
                }
            }
        }
        temp0 = 0; temp1 = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
 
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n;
    cin>>n;
    vector<int> v(n);
    for(auto &i:v)        cin>>i;
 
    vector<int> dp(n);
    dp[n-1]=0;
    dp[n-2]=abs(v[n-1]-v[n-2]);
 
    for(int i=n-3 ; i>=0 ; i--)
    {
        int a = abs(v[i]-v[i+1]);
        int b = abs(v[i]-v[i+2]);
        dp[i] = min(a+dp[i+1] , b + dp[i+2]);
    }
    cout<< dp[0];
 
 
}

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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

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

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int a,b;
	cin >> a >> b;
	if((ll)a * b <= 0){
		ANS("Zero");
		return 0;
	}
	if(a > 0){
		ANS("Positive");
		return 0;
	}
	if((b-a) % 2 == 0){
		ANS("Negative");
	}else{
		ANS("Positive");
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i,a,b) for(ll i=a;i<b;i++)

int main()
{  
   ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   
   ll n=0,k=0;
   
   cin>>n>>k;
   ll a[n];
   ll dp[k+1]={0};
  
   f(i,0,n)
    cin>>a[i];

   f(i,1,k+1)
    {
      for(auto j : a)
       {
         if((i-j)>=0 && dp[i-j]==0)
            dp[i]=1;
       }
    }

   if(dp[k]==1)
     cout<<"First";
   else cout<<"Second";

  return 0;
}


Measured memory_bytes: 4304