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

template <typename T, typename U> inline void cmin(T &a, U b) {
  if (a > b) a = b;
}

template <typename T, typename U> inline void cmax(T &a, U b) {
  if (a < b) a = b;
}

template <typename T, T (*op)(T, T), T (*ie)()>
class SegmentTree {
private:
  int N, size, log;
  vector<T> D;
  void apply(int k) { D.at(k) = op(D.at(2 * k), D.at(2 * k + 1)); }
  int ceil_pow(int n) {
    int x = 0;
    while ((1U << x) < (unsigned int)(n)) x++;
    return x;
  }

public:
  SegmentTree() : SegmentTree(0) {}
  SegmentTree(int n) : SegmentTree(vector<T>(n, ie())) {}
  SegmentTree(const vector<T> &v) : N((int)v.size()) {
    log = ceil_pow(N);
    size = 1 << log;
    D = vector<T>(2 * size, ie());
    for (int i = 0; i < N; i++) D.at(size + i) = v.at(i);
    for (int i = size - 1; i >= 1; i--) apply(i);
  }
  void set(int p, T x) {
    p += size;
    D.at(p) = x;
    for (int i = 1; i <= log; i++) apply(p >> i);
  }
  T get(int p) { return D.at(p + size); }
  T query(int l, int r) {
    r++;
    T sml = ie(), smr = ie();
    l += size, r += size;
    while (l < r) {
      if (l & 1) sml = op(sml, D.at(l++));
      if (r & 1) smr = op(D.at(--r), smr);
      l >>= 1, r >>= 1;
    }
    return op(sml, smr);
  }
  T query_all() { return D.at(1); }
  template <bool (*f)(T)> int max_right(int l) {
    return max_right(l, [](T x) { return f(x); });
  }
  template <class F> int max_right(int l, F f) {
    if (l == N) return N;
    l += size;
    T sm = ie();
    do {
      while (l % 2 == 0) l >>= 1;
      if (!f(op(sm, D.at(l)))) {
        while (l < size) {
          l = (2 * l);
          if (f(op(sm, D.at(l)))) sm = op(sm, D.at(l++));
        }
        return l - size;
      }
      sm = op(sm, D.at(l++));
    } while ((l & -l) != l);
    return N;
  }
  template <bool (*f)(T)> int min_left(int r) {
    return min_left(r, [](T x) { return f(x); });
  }
  template <class F> int min_left(int r, F f) {
    if (r == 0) return 0;
    r += size;
    T sm = ie();
    do {
      r--;
      while (r > 1 && (r % 2)) r >>= 1;
      if (!f(op(D.at(r), sm))) {
        while (r < size) {
          r = (2 * r + 1);
          if (f(op(D.at(r), sm))) sm = op(D.at(r--), sm);
        }
        return r + 1 - size;
      }
      sm = op(D.at(r), sm);
    } while ((r & -r) != r);
    return 0;
  }
};

using mono = int;
mono op(mono a, mono b) { return max(a, b); };
mono ie() { return 0; };

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

  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);

  int MX = 3e5;
  SegmentTree<mono, op, ie> ST(MX + 1);
  for (int i = 0; i < N; i++) {
    int l = A.at(i) - K;
    cmax(l, 0);
    int r = A.at(i) + K;
    cmin(r, MX);
    ST.set(A.at(i), ST.query(l, r) + 1);
  }
  cout << ST.query_all() << "\n";
}

Measured memory_bytes: 9788
#include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define endl "\n"
    #define int long long int
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define f first
    #define s second

    using namespace std;
int power(int base, int exp)
{
    if (exp == 0)
       return 1;
    else if (exp == 1)
       return base;
    else
    {
       int calc;
       if (exp % 2 == 0)
       {
         calc = power(base, exp/2);
         calc =(calc* calc)%mod;
       }
       else
       {
         calc = (base*power(base, exp-1))%mod;
       }
       return calc%mod;
    }
}
    int32_t main()
    {
        std::ios::sync_with_stdio(false);
        int k;
        cin>>k;
        string s;
        cin>>s;
        int n=s.length();
        if(n>k)
        {
            for(int i=0;i<k;i++)
                cout<<s[i];
            cout<<"..."<<endl;
        }
        else
            cout<<s<<endl;
        return 0;
    }


Measured memory_bytes: 3612
#include<iostream>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cstdio>
#include<sstream>
#include<vector>
#include<algorithm>

using namespace std;
//#define read(x) scanf("%d",&x)
#define Read(x,y) scanf("%d%d",&x,&y)
#define gc(x)  scanf(" %c",&x);
#define mmt(x,y)  memset(x,y,sizeof x)
#define write(x) printf("%d\n",x)
#define pii pair<int,int>
#define INF 1e13
#define ll long long
#define mod  998244353
const int N = 1e5 + 10;
ll a[2*N];
int main()
{
  ll sum = 0;
  int n;
  cin>>n;
  for(int i = 1;i <= n;++i){
    cin>>a[i];sum += a[i];
  }
  ll Sum = sum;
  ll num = 0;
  ll MAX = -INF;
  for(int i = 1;i <= n;++i){
     num += a[i];
     sum -= a[i];
     MAX = max(MAX,min(sum,num));
  }
  cout<<Sum - MAX * 2;




}


Measured memory_bytes: 1792
#include<iostream>
#include <algorithm>
#include<string>
#include <numeric>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;

int main(void) {

    int a,b;
    cin>>a>>b;
    if((a*b)%2==0)cout<<"Even"<<endl;
    else cout<<"Odd"<<endl;
}


Measured memory_bytes: 256
import Data.Char

solve1 :: String -> Bool
solve1 (s : sx)
  | s == 'A' = (solve2 sx)
  | otherwise = False

solve2 :: String -> Bool
solve2 (s : sx)
  | s == (toLower s) = solve3 sx False
  | otherwise = False

solve3 :: String -> Bool -> Bool
solve3 [] b
  | b = True
  | otherwise = False
solve3 (s : sx) b
  | s == 'C' && (b == True || (length sx) < 1) = False
  | s == 'C' = solve3 sx True
  | s /= (toLower s) = False
  | otherwise = solve3 sx b

main = do
  s <- getLine
  if (solve1 s)
  then putStrLn "AC"
  else putStrLn "WA"
  

Measured memory_bytes: 380
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, k = map(int, readline().split())
if k > (n - 1) * (n - 2) // 2:
    print(-1)
    exit()
m = n * (n - 1) // 2 - k
print(m)
for i in range(1, n + 1):
    for j in range(i + 1, n + 1):
        print(i, j)
        m -= 1
        if m == 0:
            exit()


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

int main(){
    int n;
    cin >> n;
    int k;
    int ans;
    while(n!=0){
        vector<int> a;
        for (int i = 0; i<n; i++){
            cin >> k;
            a.push_back(k);
        }
        sort(a.begin(), a.end());
        ans = 0;
        for (int i = 1; i<n-1; i++) ans += a[i];
        cout << ans/(n-2) << endl;
        cin >> n;
    }
}



Measured memory_bytes: 3136
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize
    }
    let mut ans = 0;
    for i in 1..n + 1 {
        let mut d = 0;
        let mut m = i;
        while m > 0 {
            d += 1;
            m /= 10;
        }
        if d % 2 == 1 {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
N, M, X = map(int, input().split())
A = list(map(int, input().split()))

to_left =[1 for i in range(X-1, 0, -1) if i in A] 
to_right =[1 for i in range(X+1, N, 1) if i in A]
print(min(sum(to_left), sum(to_right)))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <set>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll bit[100010], num;
ll n, d[100010], par[100010];

ll sum(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(ll i, ll x)
{
	while (i <= num)
	{
		bit[i] += x;
		i += i & -i;
	}
}

ll po(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return po(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = po(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll div(ll x)
{
	return po(x, mod - 2);
}

int main(void)
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> d[i];
	}
	sort(d, d + n);
	cout << max((ll)0, d[n / 2] - d[n / 2 - 1]) << endl;
	int www;
	cin >> www;
}


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

using namespace std;

#define SEGTREE_MAX_N (1<<17)

class SegmentTree {
private:
  
  int size;
  vector<int> dat;
  
  int query(int a, int b, int k, int l, int r) {
    if( r <= a || b <= l ) return INT_MAX;
    
    if( a <= l && r <= b ) return dat[k];
    int vl = query(a, b, k*2+1, l, (l+r)/2);
    int vr = query(a, b, k*2+2, (l+r)/2, r);
    
    return min(vl, vr);
  }
  
public:
  
  SegmentTree(int n_) {
    size = 1;
    while(size < n_) size *= 2;
    dat.resize(2*size-1, INT_MAX);
  }
  
  void update(int k, int a) {
    k += size-1;
    dat[k] = a;
    while(k>0) {
      k = (k-1) / 2;
      dat[k] = min(dat[k*2+1], dat[k*2+2]);
    }
  }
  
  // RangeMinimumQuery
  // input: [s, t)
  int find(int s, int t) {
    return query(s, t, 0, 0, size);
  }
};

int main() {
    
  int nn, q;
  int c;
  cin >> nn >> q;
  
  SegmentTree stree(nn);
  
  for(int i=0; i<q; i++) {
    cin >> c;
    
    if(c) {
      int s, t; cin >> s >> t;
      cout << stree.find(s, t+1) << endl;
    }
    else {
      int i, x; cin >> i >> x;
      stree.update(i, x);
    }
  }
  
  return 0;
}

Measured memory_bytes: 2060
#include "bits/stdc++.h"
#include "sstream"
#define EPS 1e-9
using namespace std;
const int N=1e5,OO=0x3f3f3f3f;
typedef long long ll;
int main() {
 int x,y,z; cin>>x>>y>>z;
 cout<<z<<" "<<x<<" "<<y;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int n;
  scanf("%d", &n);
  
  int i, cnt_odd = 0;
  for (i = 1; i <= n; ++i) {
    if (i % 2) ++cnt_odd;
  }
  
  printf("%lf\n", (double)cnt_odd / n);
  
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<utility>
#include<math.h>

using namespace std;

typedef long long int64;

int main(void){

    int64 X;
    cin>>X;

    bool flag=false;

    for(int64 i=X;i<=100003;i++){
        flag=false;
        for(int64 j=2;j<sqrt(i);j++){
            if(i%j==0){
                flag=true;
                continue;
            }
        }
        if(flag==false){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<100003<<endl;
    
    return 0;
}

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

int main(){
  int n;
  cin >>n;
  int num[100100] = {0};
  int M = 0;
  rep(i,n){
    int a; cin >>a; 
    a++;
    num[a-1]++; num[a]++;
    num[a+1]++;
    if(a+1>M) M = a+1;
  }
  int ans = 0;
  for(int i = 1; i<=M; i++){
    ans = max(ans, num[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
import bisect

def is_prime(x):
    if x==1:
        return False
    for i in range(2,int(x**0.5)+1):
        if x%i==0:
            return False
    return True

lst = [] 
for x in range(1,10**5,2):
    if is_prime(x):
        lst.append(x)

lst_dash = []
for x in lst:
    if is_prime((x+1)//2):
        lst_dash.append(x)

q = int(input())
ans = []
for i in range(q):
    l,r = map(int,input().split())
    left = bisect.bisect_left(lst_dash, l)
    right = bisect.bisect_right(lst_dash, r)
    ans.append(right - left)

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

Measured memory_bytes: 9748
//============================================================================
//Everyone has a different way of thinking, so God Created us
//   Hope You Respect My Way..,Thank You ):
// Author      : Murad
// Name        : Codeforces.cpp & Atcoder.cpp
// Description : Problem name
//============================================================================
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define ULL unsigned long long
#define MP make_pair
#define ff first
#define ss second
#define endl '\n'
#define INF 1e9 + 1
#define _INF INT32_MIN
#define pq priority_queue
#define MM multimap
#define PB push_back
#define vii vector<int>
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
char alphz[27] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
float Euclidean(LL x1, LL x2, LL y1, LL y2) {
	return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}
LL gcd(LL a,LL b) {
	return !b ? a : gcd(b, a % b);
}
LL LCM(LL a, LL b) {
	return (a*b) / gcd(a, b);
}
void PrimeFactor(LL n)
{
	while (n % 2 == 0) {
		printf("%d ", 2);
		//aa.insert(2);
		n /= 2;
	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		if (n%i == 0) {
			printf("%d ", i);
	//		aa.insert(i);
			n /= i;
		}
	}
	if (n > 2){
		printf("%d ", n);
		//aa.insert(n);
	};
}
bool is_square(LL x) {
	LL l = 0, r = x;
	while (l <= r) {
		LL mid = l + (r - l) / 2;
		if (mid*mid == x)return true;
		if (mid*mid > x)r = mid - 1;
		else l = mid + 1;
	}
	return false;
}
LL power(LL x, LL y)
{
	LL temp;
	if (y == 0)return 1;
	temp = power(x, y / 2);
	if (y % 2 == 0)
		return temp*temp;
	else return x*temp*temp;
}
bool is_Prime(int x) {
	if (x == 2)return 1;
	else if (x % 2 == 0 || x < 2)return 0;
	for (int i = 3; i*i <= x; i += 2)
		if (x%i == 0)return 0;
	return 1;
}
map<int, bool>mpp;
vector<ipair>adj[100005];
const int N = 100005;
vector<bool>vis(N);
void dfs(int src)
{
	vis[src] = 1;
	for (int i = 0; i < adj[src].size(); i++)
	{
		if (!vis[adj[src][i].ff]) {
			if (adj[src][i].ss % 2 == 0)
				mpp[adj[src][i].ff] = mpp[src], vis[adj[src][i].ff] = 1,dfs(adj[src][i].ff);
			else {
				if (mpp[src] == 1)
				{
					mpp[adj[src][i].ff] = 0;
					vis[adj[src][i].ff] = 1;
					dfs(adj[src][i].ff);
				}
				else
				{
					mpp[adj[src][i].ff] = 1;
					vis[adj[src][i].ff] = 1;
					dfs(adj[src][i].ff);
				}
			}
		}
	}
}
int main()
{
	El3zba;
	/***  بسم الله الرحمن الرحيم   ***/
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; i++)
	{
		int a, b, w;
		cin >> a >> b >> w;
		adj[a].PB({ b,w });
		adj[b].PB({ a, w });
	}
	dfs(1);
	for (auto&x : mpp)
	{
		if (x.ff > 0)
			cout << x.ss << endl;
	}
	return 0;
}

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

using namespace std;

const int mod = 1007050321;
const int base = 521;
const int N = 4e5 + 5;
const int MOD = 1e9 + 7;
const int inf = 2e9;

int n,K,a[N];

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

    cin >> K >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        a[i+n] = a[i] + K;
    }

    int ans = inf;
    for (int i = 1; i <= n; ++i)
        ans = min(ans,a[i+n-1] - a[i]);

    cout << ans;
    return 0;
}


/// a[i] -> a[n] -> a[i] -> a[1]
/// a[n] - a[i-1] + a[n] - a[i-1] + a[i] - a[1]

/// a[i] -> a[n] -> a[1] -> a[i-1]
/// a[n] - a[i-1] + K - a[n] + a[1] + a[i-1] - a[1]


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >> a>>b;
  if(a <=0&&b>=0){
    cout <<"Zero";
    return 0;
  }
  if(a<0){
    b= min(b,-1);
  cout << ((b-a+1) %2==0?"Positive":"Negative");
  }
  else{
    cout << "Positive";
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

int64_t get_comb(int64_t n) {
    return n * (n - 1) / 2;
}

int main(void) {
    int64_t result = 0;
    int n;
    cin >> n;
    int64_t cum[200001] = {};
    int64_t m1;
    for (int i = 1; i <= n; i++) {
        cin >> m1;
        cum[i] = cum[i - 1] + m1;
    }
    std::vector<int64_t> veccum;
    for (int i = 0; i <= n; i++) {
        veccum.push_back(cum[i]);
    }
    std::sort(veccum.begin(), veccum.end());

    int64_t prev  = veccum[0];
    int64_t count = 1;
    for (int i = 1; i <= n; i++) {
        if (prev == veccum[i]) {
            count++;
        } else {
            result += get_comb(count);
            prev  = veccum[i];
            count = 1;
        }
    }
    result += get_comb(count);
    cout << result << endl;

    return 0;
}


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

int main() {
  string a,s;
  cin>>a>>s;
  int ans=0;
  for (int i=0;i<3;++i) {
    if (a[i]==s[i]) {
      ans+=1;
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 256
n,m=map(int,input().split())

AC=[0]*n
WA=[0]*n

for i in range(m):
    t=input().split()
    p, s= int(t[0]), t[1]
    if s=='AC':
        AC[p-1]=1
    elif s=='WA' and AC[p-1]==0:
        WA[p-1]+=1

ac, wa=0,0

for i in range(n):
    if AC[i]:
        ac+=1
        wa+=WA[i]

print(ac, wa)

Measured memory_bytes: 10460
#include<iostream>
#include<cstring>
#include<cstdio>
#define N (1000009)
using namespace std;

int n,p,ans,head=1,tail,q[N];
char s[N],t[N];

int main()
{
	scanf("%d%s%s",&n,s+1,t+1); p=n;
	if (!strcmp(s+1,t+1)){puts("0"); return 0;}
	for (int i=n; i>=1; --i)
	{
		if (t[i]==t[i-1]) continue;
		p=min(p,i);
		while (p && t[i]!=s[p]) p--;
		if (!p) {puts("-1"); return 0;}
		
		while (head<=tail)
			if (q[head]-(tail-head+1)>=i) head++;
			else break;
		q[++tail]=p;
		if (i!=p) ans=max(ans,tail-head+1);
	}
	printf("%d\n",ans+1);
}

Measured memory_bytes: 6144
#include<stdio.h>

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

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
const int nMax=1e5+1, MOD=1e9+7;
ULL inv[nMax], fct[nMax], ivf[nMax];
ULL Comb(int n, int r){ return (r<=n)?(((fct[n]*ivf[r])%MOD)*ivf[n-r])%MOD:0; }
int main(){
  int n, i, l, r; cin >> n; int a[n+1], b[n+1]={};
  for(i=0; i<=n; i++){ cin >> a[i]; b[i]=-1; }
  for(i=0; i<=n; i++){ if(b[a[i]]>=0){ l=b[a[i]]; r=i; break; }else{ b[a[i]]=i; } }
  inv[1]=fct[0]=fct[1]=ivf[0]=ivf[1]=1;
  for(i=2; i<nMax; i++){ 
    inv[i]=((MOD-MOD/i)*inv[MOD%i])%MOD;
    fct[i]=(fct[i-1]*i)%MOD; ivf[i]=(ivf[i-1]*inv[i])%MOD;
  }
  ULL ans=0;
  for(i=1; i<=n+1; i++){
    ans=(Comb(n-1, i)+Comb(n-1, i-2)+2*Comb(n-1, i-1)+MOD-Comb(n+l-r, i-1))%MOD;
    cout << ans << "\n";
  }
}

Measured memory_bytes: 4352
n,z,w = map(int,input().split())
a = list(map(int,input().split()))

#初手で全部引く
ans1 = a[-1]-w
#初手で一枚残して引く
if len(a) > 1:
  ans2 = a[-2]-a[-1]
else:
  ans2 = 0

print(max(abs(ans1),abs(ans2)))

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

using namespace std;

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

int main() {
    int N, L;
    cin >> N >> L;
    vector<string> strings(N);
    rep(i, N){
        cin >> strings.at(i);
    }
    sort(strings.begin(), strings.end());
    string ans = "";
    rep(i, N){
        ans += strings.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = gets.to_i

ans = [0] * (n+1)

1.upto(100) do |x|
  1.upto(100) do |y|
    s = x ** 2 + y ** 2 + x * y
    break if s > n
    1.upto(100) do |z|
      t = s + z ** 2 + y * z + z * x
      break if t > n
      ans[t] += 1
    end
  end
end

puts ans[1, n]

Measured memory_bytes: 14284
use std::io::*;
use std::str::FromStr;

#[test]
fn test() {
    assert_eq!(a_137(-13, 3), -10);
    assert_eq!(a_137(1, -33), 34);
    assert_eq!(a_137(13, 3), 39);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
            .bytes()
            .map(|c| c.expect("failed to read char") as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
    token.parse().ok().expect("failed to parse token")
}

fn a_137(a: i32, b: i32) -> i32 {
    let mut ans;
    ans = a + b;
    if a - b > ans {
        ans = a - b;
    }
    if a * b > ans {
        ans = a * b;
    }
    ans
}
fn main() {
    let a: i32 = read();
    let b: i32 = read();

    println!("{}", a_137(a, b));

}



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



int main(void){
    cin.tie(0);
	ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  int c=0;
  
  while(1){
  if(n>9){
  	c+=9;
  }else{
  	c=n;
    break;
  }
  if(n>999){
  	c+=900;
  }else if(n<100){
    break;
  }else{
  	c+=n-99;
      break;
  }
  if(n>99999){
  	c+=90000;
    break;
  }else if(n<10000){
  	break;
  }else{
  	c+=n-9999;
      break;
  }
  }
  
  
  cout << c << "\n";
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e6 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	ld n;
	cin >> n;
	ld ans = (n / 3.0) * (n / 3.0) * (n / 3.0);
	cout << fixed << setprecision(10) << ans;

	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (h, w) = (v[0], v[1]);
    if h == 1 || w == 1 {
        println!("1");
        return;
    }
    let ans = (h * w + 1) / 2;
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

using namespace std;
#define int long long
#define double long double
#define rep(i, n) for(int i=0;i<(n);++i)
#define INF (1ll<<60)
#define FI first
#define SE second
typedef pair<int, int> pii;
#define l_b lower_bound
#define u_b upper_bound

int N;


signed main() {
    cin >> N;
    for (int h = 1; h <= 3500; ++h) {
        for (int n = 1; n <= 3500; ++n) {
            int a = N * h * n;
            int b = (4 * h * n - n * N - h * N);
            if (b > 0 && a % b == 0) {
                int w = a / b;
                cout << h << " " << n << " " << w << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }
    }

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        int cnt = 0;
        for (int i = 0; i < n; i++) {
           if ( arr[i] >= k){
               cnt++;
           }
        }
        System.out.println(cnt);
    }
}


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

int main() {
  int H,W;
  cin >> H >>W;

vector<vector<char>> data(H, vector<char>(W));

for (int i = 0; i<H; i++){
  for (int j = 0; j<W; j++){
    cin >> data.at(i).at(j);
  }
}
vector<bool> white_H(H,false),white_W(W,false);
for(int i=0; i<H; i++){
  for(int j=0; j<W; j++){
   if(data.at(i).at(j) == '#'){
     white_H.at(i) = true;
     white_W.at(j) = true;
   }
  }
 }

for(int i=0; i<H; i++){
  if(white_H.at(i)){
    for(int j=0; j<W; j++){
      if(white_W.at(j)){
        cout << data.at(i).at(j);
      }
    }
    cout << endl;
  }
}
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<62)           //1LL<<63でオーバーフロー

int main(int argc,char* argv[]){
    int n;
    double d;
    cin >> n >> d;

    vector<pair<long double,long double>> xy(n);

    for(auto &x:xy)
        cin >> x.first >> x.second;

    int count=0;
    for(int i=0;i<n;i++){
        long double distance;
        long double x=xy.at(i).first,y=xy.at(i).second;
        distance=sqrtl(x*x+y*y);
        if(distance<=d)count++;
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 9712
s = gets.chomp.reverse
a = ["resare","esare","remaerd","maerd"]

a.each do |aa|
  if s.include?(aa)
    while s.include?(aa)
      s.slice!(aa)
      # p s
    end
  end

  if s.empty?
    puts 'YES'
    exit
  end
end
puts 'NO'


Measured memory_bytes: 29564
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    S = input().rstrip()
    Q = int(input())
    k = list(map(int, input().split()))

    for l in k:
        D = 0
        M = 0
        tmp = 0
        ans = 0
        for i in range(N):
            if i >= l:
                if S[i-l] == 'D':
                    tmp -= M
                    D -= 1
                if S[i-l] == 'M':
                    M -= 1
            if S[i] == 'D':
                D += 1
            if S[i] == 'M':
                M += 1
                tmp += D
            if S[i] == 'C':
                ans += tmp
        print(ans)

main()

Measured memory_bytes: 61224
def main():
  
    K, S = map(int, input().split())
    count = 0
    for x in range(K + 1):
        for y in range(S - x + 1):
            z = S - x - y
            if x <= K and y <= K and z <= K:
                count += 1
    print(count)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
from collections import Counter

class UnionFind:
    #n個の要素を初期化
    def __init__(self, n):
        self.n = n
        self.par = [i for i in range(n)]
        self.rank = [0] * n
    
    #木の根を求める
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    
    #xとyの属する集合を併合
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    
    #xとyが同じ集合に属するか判定
    def same(self, x, y):
        return self.find(x) == self.find(y)

    #要素xが属するグループに属する要素をリストで返す
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]


N, K, L = map(int, input().split())
roads = [list(map(int, input().split())) for i in range(K)]
trains = [list(map(int, input().split())) for i in range(L)]

uf_road = UnionFind(N)
uf_train = UnionFind(N)

for road in roads:
    x, y = road
    uf_road.unite(x-1, y-1)

for train in trains:
    x, y = train
    uf_train.unite(x-1, y-1)

pairs = []
for i in range(N):
    pairs.append((uf_road.find(i), uf_train.find(i)))

cnt = Counter(pairs)

ans = [cnt[pair] for pair in pairs]
print(*ans)

Measured memory_bytes: 94768
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    if(n&1){
    	ll sum = 0;
    	for(int i=0;i<n;i+=2) sum += a[i];
    	vector<ll> dp(n,0);
    	for(int i=2;i<n;i+=2) dp[i] = max(dp[i-2] - a[i-2] + a[i-1], 0LL);
    	ll m=-1e18;
    	for(int i=0;i<n;i+=2) m = max(dp[i]-a[i], m);
    	cout << sum + m <<endl;
    }
    else{
    	vector<ll> b(n+1,0);
    	for(int i=n-2;i>=0;i-=2) b[i] = b[i+2] + a[i+1];
    	ll sum=0,ans=-1e18;
    	for(int i=0;i<n;i+=2) ans = max(ans,sum+b[i]), sum += a[i];
    	ans = max(ans,sum);
        cout << ans <<endl;
    }
    return 0;
}


Measured memory_bytes: 6308
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String s;
		int lengh;

		s = scanner.next();

		lengh = s.length();

		String ans = "";

		for (int i = 0; i < lengh; i++) {
			ans += "x";
		}

		System.out.println(ans);

	}

}

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

using namespace std;

#define INF 1000007
#define MOD 998244353
#define int long long int
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0)
    {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}
signed main()
{
    int N;
    string S;
    cin >> N >> S;
    if (N % 2 == 1)
    {
        cout << "No" << endl;
        return 0;
    }
    else
    {
        for (int i = 0; i < N / 2; i++)
        {
            if (S[i] != S[i + N / 2])
            {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
n=int(input())
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
ans=0
for i in range(n):
    a=0
    a+=sum(a1[:i+1])
    a+=sum(a2[i:])
    ans=max(ans,a)
print(ans)

Measured memory_bytes: 9164
import sys

dishes = map(int, sys.stdin.read().split())
ans = 0
d = 0
for dish in dishes:
    wait_time = 10 - dish % 10
    if wait_time == 10:
        wait_time = 0
    if wait_time > d:
        ans += dish + d
        d = wait_time
    else:
        ans += dish + wait_time
print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)

string nums[9][5] = {
  {
    ".....",
    "...|.",
    ".....",
    "...|.",
    ".._.."
  },
  {
    ".._..",
    "...|.",
    ".._..",
    ".|...",
    ".._.."
  },
  {
    ".._..",
    "...|.",
    ".._..",
    "...|.",
    ".._.."
  },
  {
    ".....",
    ".|.|.",
    ".._..",
    "...|.",
    "....."
  },
  {
    ".._..",
    ".|...",
    ".._..",
    "...|.",
    ".._.."
  },
  {
    ".._..",
    ".|...",
    ".._..",
    ".|.|.",
    ".._.."
  },
  {
    ".._..",
    "...|.",
    ".....",
    "...|.",
    "....."
  },
  {
    ".._..",
    ".|.|.",
    ".._..",
    ".|.|.",
    ".._.."
  },
  {
    ".._..",
    ".|.|.",
    ".._..",
    "...|.",
    ".._.."
  }
};

string field[21];
int dice[2][6];
int y[6] = {0, 7, 7, 7, 7, 14};
int x[6] = {7, 0, 7, 14, 21, 7};

bool ok(char f[5][5], int num){
  rep(i, 5)rep(j, 5){
    if(f[i][j] != nums[num][i][j]) return false;
  }
  return true;
}

int getn(int y, int x, int id){
  char f[5][5];
  char f2[5][5];
  if(id == 1){
    rep(i, 5)rep(j, 5){
      char c = field[y+i][x+j];
      if(c == '|') c = '_';
      else if(c == '_') c = '|';
      f[j][4-i] = c;
    }
  }else if(id == 3){
    rep(i, 5)rep(j, 5){
      char c = field[y+i][x+j];
      if(c == '|') c = '_';
      else if( c== '_') c = '|';
      f[4-j][i] = c;
    }
  } else if(id == 5){
    rep(i, 5)rep(j, 5){
      f[i][j] = field[y+4-i][x+j];
    }
  }else{
    rep(i, 5)rep(j, 5){
      f[i][j] = field[y+i][x+j];
    }
  }


  rep(i, 5){
    rep(j, 5){
      f2[i][j] = f[i][4-j];

    }

  }

  rep(j, 9){
    if(ok(f2, j)){
         return j + 1;
    }
  }
  return -1;
}

int main(){
  while(cin >> field[0] && field[0] != "0"){

    rep(i, 20){
      cin >> field[i+1];
    }
    rep(i, 21)rep(j, 57) if(field[i][j] == '-') field[i][j] = '_';
    rep(i, 2){
      rep(j, 6){
	dice[i][j] = getn(y[j] + 1, x[j] + 1 + i * 29, j);
	//cout << dice[i][j] << " ";
      }
      //      cout << endl;
    }
    int hcnt = 0;
    int lcnt = 0;
    rep(i, 6){
      rep(j, 6){
	if(dice[0][i] > dice[1][j]) hcnt++;
	if(dice[0][i] < dice[1][j]) lcnt++;
      }
    }
    if(hcnt < lcnt) cout << "LOW" << endl;
    else cout << "HIGH" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
s = input()
g = 'g'
p = 'p'

last_p = s.rfind(p)
if last_p == -1:
    print(len(s) // 2)
else:
    tail_g_num = len(s) - last_p - 1
    s_to_last_p = s[:last_p+1]
    diff = s_to_last_p.count(g) - s_to_last_p.count(p)
    print((diff + tail_g_num) // 2)


Measured memory_bytes: 3316
#include <fstream>
#include <iostream>
// #include <cassert>

// BE CAREFUL WITH HASH TABLE & UNORDERED MAP
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define MOD 998244353
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= (a); i--)
#define RF0(i,b) RFO(i,0,b)
#define lli long long int
#define pii pair<int,int>
#define add(a,b) ((int) (((lli) (a) + (b))%MOD))
#define mul(a,b) ((int) (((lli) (a) * (b))%MOD))
#define PB emplace_back
#define F first
#define S second

// ifstream cin ("cinput.in");
// ofstream cout ("coutput.out");

int N, L;
int lens [100000];

// Helper Functions

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> L;
    int msum = 0, ind = -1;
    F0R(i, N) {
        cin >> lens[i];
        if (i > 0) {
            if (lens[i] + lens[i-1] > msum) {
                msum = lens[i] + lens[i-1];
                ind = i;
            }
        }
    }
    if (msum < L) {cout << "Impossible\n"; return 0;}
    cout << "Possible\n";
    FOR(i, 1, ind) cout << i << '\n';
    RFO(i, ind, N) cout << i << '\n';
}

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

// nice things
typedef long long lglg;
#define len(x) ((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x])))))

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

    lglg N, M; cin >> N >> M;
    priority_queue<lglg> q;
    for (lglg i=0; i<N; ++i) {
        lglg x; cin >> x;
        q.push(x);
    }
    for (lglg i=0; i<M; ++i) {
        lglg a = q.top();
        q.pop();
        q.push(a/2);
    }
    lglg result = 0;
    while (!q.empty()) {
        result += q.top();
        q.pop();
    }
    cout << result;
}

Measured memory_bytes: 1400
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"
 
#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
typedef long long ll;
using namespace std;

double x[3],y[3];
double abc[3],s;
int main(){
	lp(3)
		cin>>x[i]>>y[i];
	lp(3){
		abc[i]=sqrt((x[i]-x[(i+1)%3])*(x[i]-x[(i+1)%3])+(y[i]-y[(i+1)%3])*(y[i]-y[(i+1)%3]));
	}
	s=abs((x[1]-x[0])*(y[2]-y[0])-(x[2]-x[0])*(y[1]-y[0]))/2;
	printf("%.10f",2*s/(abc[0]+abc[1]+abc[2]+(4*s)/max({abc[0],abc[1],abc[2]})));
	return 0;
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int a, b;
  cin >> a >> b;

  int diff = b - a;
  int sum = 0;
  for (int i = 0; i <= diff; ++i) {
    sum += i;
  }

  cout << sum - b << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};


int main(){
    ll n; cin >> n;
    ll cnt = 0;
    rep(i, n){
        ll d1, d2; cin >> d1 >> d2;
        if(d1 == d2) cnt++;
        else cnt = 0;
        if(cnt == 3){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <utility>
#include <stdlib.h>
#include <fstream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

void solve()
{
    int n;
    cin >> n;
    map<int, int> m;
    for(int i=1; i<=n; i++) {
        m[i] = 0;
    }
    for(int i=0; i<n-1; i++) {
        int x;
        cin >> x;
        m[x]++;
    }
    for(auto i : m) {
        cout << i.second << "\n";
    }
    return;  
}

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

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

//vector…可変長、データの大きさに合わせてサイズを変える
//list…双方向リスト、要素を挿入、削除の多いとき
//forward_list
//array…固定長配列
//set…集合
//multiset
//bitset…2進数、固定長ビット列
//map…連想配列、キーと値を関連付ける
//multimap
//deque
//stack…FILO
//queue…FIFO
//priority_queue…格納された最大値から順に取り出す
//pair…二つの値を一組
//tuple…複数の値を一組

template<typename T>
void remove(std::vector<T>& vector, char index) {
    vector.erase(vector.begin() + index);
}

template<class T>
T ma(std::vector<T> &v) {
    T maxi = 0;
    for(auto &i:v) maxi = max(maxi, i);
    return maxi;
}

template<class T>
T mi(std::vector<T> &v) {
    T mini = 0;
    for(auto &i:v) mini = min(mini, i);
    return mini;
}

template <class T>
T pow(T x, T y, T n = numeric_limits<T>::max()) {
    if(y == 0) return 1;
    if(y % 2 == 0) return pow((x * x) % n, y / 2);
    return (x * pow(x, y - 1)) % n;
}

#define rep(i, n, m) for (int i = n; i <= m; i++)
#define Rep(i, n, m) for (int i = m; i >= 1; i--)

typedef long long ll;
typedef unsigned long long ull;

ll ans = 0;
/*
int gcd(int x, int y) {
    if (x < y) swap(x, y);
    return !y ? x : gcd(x % y, y);
}
*/
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b) {
        cout << c << endl;
    } else if (b == c) {
        cout << a << endl;
    } else {
        cout << b << endl;
    }
}

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

using namespace std;

int main()
{
    string s;
    long long int n;

    cin >> s >> n;

    for (int i = 0; i < s.size(); i++) {
        int cnt = 'z' - s[i] + 1;
        if (s[i] == 'a') continue;
        
        if (cnt <= n) {
            n -= cnt;
            s[i] = 'a';
        }
    }

    n %= 26;

    for (int i = 0; i < n; i++) {
        if (s[s.size()-1] != 'z') {
            s[s.size()-1]++;
        }
        else {
            s[s.size()-1] = 'a';
        }
    }
    cout  << s << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+5000;
double  a[N];
char s[100],t[100];
int main(){
cin>>s>>t;

for(int i=0;i<strlen(s);i++){
	if(s[i]!=t[i]){
		printf("No\n");
		return 0;
	}
	else if(i==strlen(s)-1)printf("Yes\n");
}

return 0;
}


Measured memory_bytes: 3592
N = int(input())
S = input()

s = set()
L = [[set() for i in range(2)] for j in range(N+1)]

ans = set()

for i in range(N):
    L[i+1][0].add(S[i])
    for k in L[i][0]:
        L[i+1][0].add(k)
        L[i+1][1].add(k + S[i])
    for k in L[i][1]:
        L[i+1][1].add(k)
        ans.add(k + S[i])

print(len(ans))

Measured memory_bytes: 301720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    int N, M;
    cin >> N >> M;
    multiset<double> st;
    for(int i=0;i<N;i++){
        double tmp;
        cin >> tmp;
        st.insert(tmp);
    }

    
    for(int i=0;i<M;i++){
        auto itr = st.end();
        itr--;
        double v = *itr;
        auto itr2 = st.find(v);
        if(itr2!=st.end()){
            st.erase(itr);
        }
        st.insert(v/2);
    }
    
    ll ans = 0;
    for(auto itr = st.begin(); itr != st.end();itr++)
        ans += (ll)(*itr);
    
    cout << ans << endl;
    //printf("%.10lf\n", ans);
    

}

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

typedef long long ll;

struct UnionFind
{
    int i;
    vector<int> par;
    vector<int> size;
    UnionFind(int n): par(n),size(n,1){
        for(i = 0;i < n;++i){
            par.at(i) = i;
        }
    }
    
    int root(int x){
        if(par.at(x) == x){
            return x;
        }else{
            return par.at(x) = root(par.at(x));
        }
    }
    
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry){
            return;
        }else{
            if(size.at(x) < size.at(y)){
                swap(x,y);
            }
            par.at(rx) = ry;
            size.at(rx) += size.at(ry);
            return;
        }
    }
    
    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    
    int get_size(int x){
        return size.at(root(x));
    }
};

int main()
{
    ll i,j;
    ll n,m;
    cin >> n >> m;
    vector<ll> a(m);
    vector<ll> b(m);
    for(i = 0;i < m;++i){
        ll s,g;
        cin >> s >> g;
        --s;
        --g;
        a.at(i) = s;
        b.at(i) = g;
    }
    ll ans = 0;
    for(i = 0;i < m;++i){
        UnionFind uf(n);
        for(j = 0;j < m;++j){
            if(j == i){
                continue;
            }
            uf.unite(a.at(j), b.at(j));
        }
        ll root = uf.root(0);
        bool flag = false;
        for(j = 1;j < n;++j){
            if(root != uf.root(j)){
                flag = true;
                break;
            }
        }
        if(flag){
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int w, h, n;
    cin >> w >> h >> n;
    int mx_x = 0, mn_x = w;
    int mx_y = 0, mn_y = h;
    int x, y, a;
    for(int i = 0; i < n; i++) {
        cin >> x >> y >> a;
        if (a == 1) {
            mx_x = max(mx_x, x);
        } else if (a == 2) {
            mn_x = min(mn_x, x);
        } else if (a == 3) {
            mx_y = max(mx_y, y);
        } else {
            mn_y = min(mn_y, y);
        }
    }
    cout << max(0, mn_x-mx_x) * max(0, mn_y-mx_y) << endl;

    return 0;
}


Measured memory_bytes: 3596
N = int(input())
sequence = list(range(1, N + 1))
for i in range(len(sequence)):
    num = sequence[i]
    if num % 3 == 0 and num % 5 == 0:
        sequence[i] = "FizzBuzz"
    elif num % 3 == 0:
        sequence[i] = "Fizz"
    elif num % 5 == 0:
        sequence[i] = "Buzz"
total = 0
for i in sequence:
    if isinstance(i, int):
        total += i
print(total)

Measured memory_bytes: 48392
import java.util.*;
public class Main {
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		//入力
		int D = sc.nextInt();
		//変数
		String answer="";
		//処理
		if(D==25)
		{
			answer="Christmas";
		}else if(D==24)
		{
			answer="Christmas Eve";
		}else if(D==23)
		{
			answer="Christmas Eve Eve";
		}else if(D==22)
		{
			answer="Christmas Eve Eve Eve";
		}
		// 出力
		System.out.println(answer);
	}
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	string t, str2 = "D";
    cin >> t;

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

    for (int i = 0; i < t.size(); i++)
    {
    	cout << t[i];
    }

    return 0;
}

Measured memory_bytes: 3756