akhauriyash/Code-Regression huggingface dataset:
use std::io::*;
use std::str::FromStr;

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

fn main(){
    let r: i32 = read();
    let g: i32 = read();
    let b: i32 = read();
    let n: i32 = read();
    let mut ret: u64 = 0;
    for i in 0..(n / r + 1) {
        for j in 0..(n / g + 1) {
            let k = n - i * r - j * g;
            if k % b == 0 && k >= 0{
                ret += 1;
                //println!("{}, {}, {}", i, j, (n - i * r - j * g) / b);
            }
        }
    }
    println!("{}", ret);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <unordered_map>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
using namespace std;
 
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define ll long long
#define y1 abcde
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>
#define int long long
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int mod = 998244353;
const int inf = 2e9;
const int N = 1e6 + 15;
int n, x, p[N], d[N], rev[N], ans;
 
inline int multiply(int a, int b) {
    return (a * b) % mod;
}

inline void add(int &a, int b) {
    a = (a + b) % mod;
    a += mod;
    a %= mod;
}
 
main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; ++i) {
        cin >> x;
        add(d[x], p[x] * x);
        add(p[x], x);
    }
    for(int i = 1; i < N; ++i) {
        for(int j = i + i; j < N; j += i) {
            add(d[i], p[i] * p[j] + d[j]);
            add(p[i], p[j]);
        }
    }
    rev[1] = 1;
    for(int i = 2; i < N; ++i)
        add(rev[i], multiply(mod / i, -rev[mod % i]));
    for(int i = N - 1; i; --i)
        for(int j = i + i; j < N; j += i)
            add(d[i], -d[j]);
    for(int i = 1; i < N; ++i)
        add(ans, multiply(d[i], rev[i]));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define RS resize
#define CLR clear
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
#define LLI long long int
using namespace std;
template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;
template <typename T, typename U> P<T,U> operator+(const P<T,U> &a, const P<T,U> &b){return {a.first + b.first, a.second + b.second};}
template <typename T, typename U> P<T,U> operator-(const P<T,U> &a, const P<T,U> &b){return {a.first - b.first, a.second - b.second};}
template <typename T> void cout_join(vector<T> &v,string d=" "){REP(i,v.size()){if(i>0)cout<<d;cout<<v[i];}cout<<endl;}

template <typename T = int>
T minimum_power_2(T n){
  T i = 1;
  while(i<n) i = i<<1;
  return i;
}

template <typename T> class LazySegmentTree{
private:
  int size;
  vector<T> vec;
  function<T(T,T)> f, upd;
  T e;

  void propagate(int i){
    if(i<size/2){
      vec[i*2+1] = f(vec[i], vec[i*2+1]);
      vec[i*2+2] = f(vec[i], vec[i*2+2]);
      vec[i] = e;
    }
  }
  
  void update_aux(int s, int t, int i, int l, int r, T x){
    if(r <= s || t <= l) return;
    else if(s <= l && r <= t) vec[i] = upd(vec[i],x);
    else{
      propagate(i);
      update_aux(s,t,i*2+1,l,(l+r)/2,x);
      update_aux(s,t,i*2+2,(l+r)/2,r,x);
    }
  }
  void find_aux(int i){if(i>0) find_aux((i-1)/2); propagate(i);}

public:
  LazySegmentTree(int n, T e, function<T(T,T)> f, function<T(T,T)> upd):
    size(minimum_power_2(n)*2-1), vec(size, e), f(f), e(e), upd(upd){}
  
  void update(int s, int t, T x){update_aux(s,t,0,0,size/2+1,x);}

  T find(int i){
    int j=i+size/2;
    find_aux((j-1)/2);
    return vec[j];
  }
};

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

  const int inf = INT_MAX;

  int n,q; cin >> n >> q;
  LazySegmentTree<int> ruq(n, inf, [](int a, int b){return a==inf?b:a;}, [](int a, int b){return b;});

  REP(i,q){
    int com; cin >> com;
    switch(com){
    case 0:
      int s,t,x; cin >> s >> t >> x;
      ruq.update(s,t+1,x);
      break;
    case 1:
      int i; cin >> i;
      cout << ruq.find(i) << endl;
      break;
    }
  }
  
  return 0;
}




Measured memory_bytes: 3908
#include <iostream>
using namespace std;
int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a+b == c+d)
    {
        cout << "Balanced" << endl;
    }
    else if(a+b > c+d)
    {
        cout << "Left" << endl;
    }
    else
    {
        cout << "Right" << endl;
    }
    
    return 0;
}

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

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

Measured memory_bytes: 3560
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long int
#define MOD 1000000007
#define oo 1000000000000000000
#define forr(i,n) for(ll i=0;i<n;i++)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0) ; cout.tie(0);
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define pb push_back
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
using namespace __gnu_pbds; 
using namespace std;

ll valueOfIndex(ordered_set&s , ll i){ return *(s.find_by_order(i)); }
ll indexOfValue(ordered_set&s , ll x){ return s.order_of_key(x); }
ll add(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a+b + p)%p;}
ll mul(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a*b + p)%p;} // __int128
ll power(ll x,ll n,ll p=MOD){ if(x==0) return 0; if(n==0 || x==1) return 1LL;
    ll r = (power(x,n/2,p))%p; if(n&1) return mul(mul(r,r,p) , x,p); else return mul(r,r,p);
}
ll inv(ll x){return power(x,MOD-2);}


void __sol(){
    ll n; cin >> n;
    vector<ll> v(n);
    map<ll,ll> m;
    forr(i,n){
        cin >> v[i];
        m[i - v[i]]++;
    }
    ll ans = 0;
    forr(i,n){
        m[i - v[i]]--;
        ans += m[i + v[i]];
    }
    cout << ans;

    return;
}


int main(){
    fastio
    ll tc=1; //cin >> tc;
    while(tc--) __sol();
    return 0;
}

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

const int DIM = 3e5 + 5;

bool oki[DIM][11]; vector<int> edg[DIM];
int arr[DIM], col[DIM], nod[DIM], dst[DIM], ans[DIM];

void dfs(int x, int d, int c)
{
    if (oki[x][d])
        return;
    oki[x][d] = true;
    
    if (d == 0) {
        ans[x] = c;
        return;
    }
    
    dfs(x, d - 1, c);
    for (int y : edg[x])
        dfs(y, d - 1, c);
}

int main(void)
{
    int n, m; cin >> n >> m;
    for (int i = 1; i <= m; ++i) {
        int x, y; cin >> x >> y;
        
        edg[x].push_back(y);
        edg[y].push_back(x);
    }
    
    int q; cin >> q;
    for (int i = 1; i <= q; ++i)
        cin >> nod[i] >> dst[i] >> col[i];
    
    for (int i = q; i >= 1; --i)
        dfs(nod[i], dst[i], col[i]);
    
    for (int i = 1; i <= n; ++i)
        cout << ans[i] << "\n";
    
    return 0;
}

Measured memory_bytes: 17272
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($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)*}
    };
}

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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

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

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input!(s: chars);
    let mut ok = false;
    let mut c = vec![];
    for _ in 0..6 {
        c.push('h');
        c.push('i');
        if s == c {
            ok = true;
        }
    }
    puts!("{}\n", if ok { "Yes" } else { "No" });
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
ii = lambda:int(input())
mi = lambda:list(map(int,input().split()))
ix = lambda x:list(input() for _ in range(x))
mix = lambda x:list(mi() for _ in range(x))
iix = lambda x:list(int(input()) for _ in range(x))
##########

def resolve():
    h1,m1,h2,m2,k = mi()
    res = convert(h2,m2) - convert(h1,m1) - k
    print(res)

def convert(h,m):
    return h*60 + m

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 9212
#include<iostream>
#include<string>
using namespace std;
main(){for(int a,b,d,n;cin>>n,n;){string r;int c[3]={1,2,3},s=1;for(;n>0&&cin>>r;n--){a=1,b=0;if(r=="East")a=0,b=2;if(r=="West")a=2,b=0;if(r=="South")a=0,b=1;if(r=="Right")a=2,b=1;if(r=="Left")a=1,b=2;d=c[a];c[a]=7-c[b];c[b]=d;s+=c[0];}cout<<s<<"\n";}}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
string s;int x,y,ans;
int main(){
    cin>>s;
    for(register int i=0;i<s.size();i++){
        if(x==y){x++;if(s[i]=='p') ans--;}
        else{y++;if(s[i]=='g') ans++;}
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>

int main(){
    long long a,b,k;
    scanf("%lld %lld %lld",&a,&b,&k);
    if(a>k){
        printf("%lld %lld",a-k,b);
    }else if(a+b>k){
        printf("%lld %lld",0,a+b-k);
    }else{
        printf("%lld %lld",0,0);
    }
    return 0;
}

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

int main(){
  int N, L;
  cin >> N >> L;
  vector<int> taste(0);
  for (int i = 0; i < N; i++){
    taste.push_back(L + i);
  }
  int sum = 0;
  for (int i = 0; i < N; i++){
    sum += taste[i];
  }
  
  for (int i = 0; i < N; i++){
    if (taste[i] == 0){
      cout << sum << endl;
      return 0;
    }
  }
  
  if (L >= 0){
    cout << sum - L << endl;
  }
  else{
    if (sum - L - sum > sum - taste[N - 1] - sum){
      cout << sum - taste[N - 1] << endl;
    }
    else{
      cout << sum - L << endl;
    }
  }
}


Measured memory_bytes: 3556
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define int long long
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min,int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}

using namespace std;
#pragma endregion
signed main() {
	string A, B;
	cin >> A >> B;
	if (A.size() > B.size()) {
		cout << "GREATER";
		return 0;
	}
	if (A.size() < B.size()) {
		cout << "LESS";
		return 0;
	}
	if (A.size() == B.size())
		rep(i, A.size()) {
		if (A[i] > B[i]) {
			cout << "GREATER";
			return 0;
		}
		if (A[i] < B[i]) {
			cout << "LESS";
			return 0;
		}
	}
	cout << "EQUAL";
}

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

int main()
{
	int n;
	cin >> n;
	n %= 10;
	switch(n){
		case 2: case 4: case 5: case 7: case 9:
			cout << "hon" << endl;
			break;
		case 0: case 1: case 6: case 8:
			cout << "pon" << endl;
			break;
		case 3:
			cout << "bon" << endl;
			break;
	}
	return 0;
}

Measured memory_bytes: 3636
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    data=[parseMap(split(readline())) for i in 1:n]
    tmp=0
    for i in n:-1:1
        data[i][1]+=tmp
        tmp+=cld(data[i][1],data[i][2])*data[i][2]-data[i][1]
    end
    println(tmp)
end
main()

Measured memory_bytes: 158816
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

//二分累乗法 xのe乗
ll binpow(ll x, ll e, ll mo=MOD) {
  ll a = 1, p = x;
  while(e > 0) {
    if(e%2 == 0) {p = (p*p) % mo; e /= 2;}
    else {a = (a*p) % mo; e--;}
  }
  return a % mo;
}

ll combi(ll N_, ll C_) {
  const int NUM_=1e5+10;
  static ll fact[NUM_+1]={},factr[NUM_+1]={},inv[NUM_+1]={};
  auto binpow = [&](ll x, ll e, ll mo=MOD) -> ll{
    ll a = 1, p = x;
    while(e > 0) {
      if(e%2 == 0) {p = (p*p) % mo; e /= 2;}
      else {a = (a*p) % mo; e--;}
    }
    return a % mo;
  };
  if (fact[0]==0) {
    fact[0] = factr[0] = inv[0] = 1;
    FOR(i, 1, NUM_+1) {
      fact[i] = fact[i-1] * i % MOD;
      inv[i] = binpow(i, MOD-2) % MOD;
      factr[i] = factr[i-1] * inv[i] % MOD;
    }
  }
  if(C_<0 || C_>N_) return 0;
  // 前計算 O(max(N,K)log(mod)) クエリ O(1)
  return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;
}

int dp1[3010], dp2[3010][3010];
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n >> MOD;

  REP(i, n+1) {
    dp2[i][0] = 1;
    FOR(j, 1, i+1) {
      dp2[i][j] = (dp2[i-1][j]*(j+1)%MOD + dp2[i-1][j-1]) % MOD;
    }
  }
  // REP(i, n+1) {
  //   REP(j, i+1) cout << dp2[i][j] << " ";
  //   cout << endl;
  // }

  REP(i, n+1) {
    REP(j, i+1) {
      (dp1[i] += dp2[i][j] * binpow(2, (n-i)*j) % MOD) %= MOD;
    }
    (dp1[i] *= binpow(2, binpow(2, n-i, MOD-1))) %= MOD;
  }
  // REP(i, n+1) cout << dp1[i] << " ";
  // cout << endl;

  int ans = 0;
  REP(i, n+1) {
    (ans += (i%2?-1:1) * combi(n, i) * dp1[i] % MOD) %= MOD;
    // cout << combi(n, i) << " " << ans << endl;
  }
  cout << (ans%MOD+MOD)%MOD << endl;

  return 0;
}


Measured memory_bytes: 70912
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	int i,j;
	cin>>n;
	int x;
	for(i=1;i<=n;i++){
		int flg=0;
		if(i%3==0){
			cout<<" "<<i;
			flg=1;
		}
		x=i;
		while(x>0){
			if(x%10==3&&flg==0){
				cout<<" "<<i;
				break;
			}
			x/=10;
		}
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 3100
object Main extends App {
  val q: Int = io.StdIn.readInt()
  (for (_ <- 0 until q) yield {
    val a: String = io.StdIn.readLine()
    val b: String = io.StdIn.readLine()
    val n: Int = a.length
    val m: Int = b.length
    val cache: Array[Array[Int]] = Array.ofDim(n+1, m+1)
    for (i <- 1 to n)
      for (j <- 1 to m)
        cache(i)(j) =
          if (a(i-1) == b(j-1)) cache(i-1)(j-1) + 1
          else cache(i)(j - 1).max(cache(i-1)(j))
    cache(n)(m)
  }) foreach println
}


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

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

  bool ans = true; 
  int count = 0;
  while(ans){
    for(int i=0; i<N; i++){
      if(vec[i]%2==1){
        ans = false;
        break;
      }
      vec[i] /= 2;
    }
    count++;
  }
  cout << count-1 << endl;

}

Measured memory_bytes: 256
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion
#define count 100001

struct pp {
    string name;
    int t;
};

pp p[count];
int head = 0,tail = 1;

void enqueue(pp &pro){
    p[tail] = pro;
    
    if(tail + 1 == count){
        tail = 0;
    }else{
        tail++;
    }
}

pp dequeue(){
    pp val = p[head];
    
    if(head + 1 == count){
        head = 0;
    }else{
        head++;
    }

    return val;
}

int main()
{
    int n,q,alltime = 0;
    cin >> n >> q;

    rep(i, n){
        cin >> p[i].name >> p[i].t;
    }
    tail = n;

    while(head != tail){
        pp x = dequeue();
        int c = min(q, x.t);
        x.t -= c;
        alltime += c;
        if(x.t > 0){
            enqueue(x);
        }else{
            cout << x.name << " " << alltime << endl;
        }
    }
}


Measured memory_bytes: 7064
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;

int main(void)
{
	int i,j,n,a[100000],p,b[100000],mx,x;
	scanf("%d",&n);
	for(i=0;i<n;i++)	scanf("%d",&a[i]);
//	printf("aaa\n");
	p=0;
	x=1;
	for(i=1;i<n;i++)	{
		if(a[i]==a[i-1])	{
			b[p]=x;
			p++;
			x=1;
		}
		else {
			x++;
		}
	}
	b[p]=x;
	p++;
	if(p==1)	mx=b[0];
	else if(p==2)	mx=b[0]+b[1];
	else {
		mx=b[0]+b[1]+b[2];
		for(i=1;i<p-2;i++)	{
			mx=max(mx,b[i]+b[i+1]+b[i+2]);
		}
	}
	printf("%d\n",mx);
	return 0;
}


Measured memory_bytes: 3208
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
struct TT {
	long long son[2], pri[2], fa;
	bool p;
}a[200001];
long long _read() {
	long long ans, c, x = 1;
	for (c = getchar(); c != '-' && (c<'0' || c>'9'); c = getchar());
	if (c == '-') x = -1, c = getchar();
	for (ans = 0; c <= '9'&&c >= '0'; c = getchar()) ans = ans * 10 + c - '0';
	return ans * x;
}
void _write(long long ans) {
	if (ans == 0) putchar('0');
	if (ans < 0) putchar('-'), ans = -ans;
	long long a[20], i;
	for (i = 1; ans; i++, ans /= 10) a[i] = ans % 10;
	for (i--; i; i--) putchar(a[i] + '0');
}
vector<pair<long long, long long> > h[200001];
vector<long long> minn[200001];
long long n;
long long search(long long pos, long long need) {
	if (h[pos][0].first > need) return -1; 
	long long tpos = lower_bound(h[pos].begin(), h[pos].end(), make_pair(need, 0ll)) - h[pos].begin();
	if (tpos == h[pos].size() || h[pos][tpos].first > need) tpos--;
	return minn[pos][tpos];
}
bool dfs(long long x, long long lim) {
	h[x].clear(); minn[x].clear();
	vector<pair<long long, long long> > t; 	
	if (!a[x].p) {
		h[x].push_back(make_pair(a[x].fa, a[x].fa));
		minn[x].push_back(a[x].fa);
		return true;
	}
	dfs(a[x].son[0], lim); 
	dfs(a[x].son[1], lim);
	if (h[a[x].son[0]].size() == 0 || h[a[x].son[1]].size() == 0) return false;
	if (h[a[x].son[0]].size() > h[a[x].son[1]].size()) swap(a[x].son[0], a[x].son[1]), swap(a[x].pri[0], a[x].pri[1]);
	for (long long i = 0, tt; i < h[a[x].son[0]].size(); i++) {
		tt = search(a[x].son[1], lim - h[a[x].son[0]][i].second);
//		cout<<t<<endl;
		if (tt == -1) continue;
		t.push_back(make_pair(h[a[x].son[0]][i].first + a[x].fa, tt + a[x].fa));
		t.push_back(make_pair(tt + a[x].fa, h[a[x].son[0]][i].first + a[x].fa));
	}
	sort(t.begin(), t.end()); h[x].clear();
	if (t.size() == 0) return false;	
	h[x].push_back(t[0]);
	for (long long i = 1; i < t.size(); i++)
		if (t[i].first >= t[i - 1].first && t[i].second >= t[i - 1].second) continue; else h[x].push_back(t[i]);
	minn[x].push_back(h[x][0].second);
	for (long long i = 1; i < h[x].size(); i++) minn[x].push_back(min(minn[x][i - 1], h[x][i].second));	
	return true;
}
long long put(){
	for (long long i=1;i<=n;i++){
		cout<<i<<endl;
		for (long long j=0;j<h[i].size();j++) cout<<h[i][j].first<<' '<<h[i][j].second<<endl;
		cout<<endl;
	}	
	return 0;
}
int main() {
	n = _read();
	for (long long i = 2, tx; i <= n; i++) {
		tx = _read();
		a[tx].son[a[tx].p] = i;
		a[i].fa = a[tx].pri[a[tx].p] = _read();
		a[tx].p = 1;
	}
	long long l = 0, r = 100000000000000, mid;
	while (l < r) {
		mid = (l + r) >> 1;
		if (dfs(1, mid)) r = mid; else l = mid + 1;
//		put();
	}
	_write(l); putchar('\n');
//	cin.get();
	return 0;
}

Measured memory_bytes: 52852
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


class Bit:

    def __init__(self, a):
        if hasattr(a, "__iter__"):
            le = len(a)
            self.n = 1 << le.bit_length()
            self.values = values = [0] * (self.n + 1)
            values[1:le + 1] = a[:]
            for i in range(1, self.n):
                values[i + (i & -i)] += values[i]
        elif isinstance(a, int):
            self.n = 1 << a.bit_length()
            self.values = [0] * (self.n + 1)
        else:
            raise TypeError

    # A[i] += val
    def add(self, i, val):
        n, values = self.n, self.values
        while i <= n:
            values[i] += val
            i += i & -i

    # A[1, i]の累積和
    def sum(self, i):
        values = self.values
        res = 0
        while i > 0:
            res += values[i]
            i -= i & -i
        return res

    # A[1, i]の累積和 が v 以上になる最小の i
    def bisect_left(self, v):
        n, values = self.n, self.values
        if v > values[n]:
            return None
        i, step = 0, n >> 1
        while step:
            if values[i + step] < v:
                i += step
                v -= values[i]
            step >>= 1
        return i + 1


def main():

    N, K = in_nn()
    LR = []
    for i in range(K):
        l, r = in_nn()
        LR.append((l, r))

    init_dp = [0] * N
    init_dp[0] = 1
    init_dp[1] = -1
    bit = Bit(init_dp)

    mod = 998244353
    for i in range(1, N + 1):
        for k in range(K):
            l, r = LR[k]
            now = bit.sum(i) % mod
            bit.add(i + l, now)
            bit.add(i + r + 1, -now)

    print(bit.sum(N) % mod)


if __name__ == '__main__':
    main()


Measured memory_bytes: 72632
#include<bits/stdc++.h>
#define N 1005
using namespace std;
long long a,b,c,d;
void solve(){
	scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
	a--;
	printf("%lld\n",(b-b/c-b/d+b/(c*d/__gcd(c,d)))-(a-a/c-a/d+a/(c*d/__gcd(c,d))));
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 384
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    if (A%2 != B%2){
      System.out.println("IMPOSSIBLE");
    }else{
      System.out.println((A+B)/2);
    }
  }
}

Measured memory_bytes: 23252
#define _CRT_SECURE_NO_WARNINGS

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

typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mii;
typedef pair<int, ii> edge;


#define sc(x)  scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(arr,val) memset(arr,val,sizeof arr)
#define sz(v) (int)v.size()
#define rsz(v) v.resize
#define clr(v) v.clear()
#define rev(v) reverse(all(v))
#define lop(i,end) for(int i=0; i<end; i++)
#define rlop(i,start) for(int i=start-1; i>=0; i--)
#define loop(i,start,end) for(int i=start; i<end; i++)
#define rloop(i,start,end) for(int i=start-1; i>=end; i--)
#define PB push_back
#define pb pop_back
#define mP make_pair
#define f first
#define s second

const ll OO = (ll)(4e18) + 9;
const int MOD = (int)(1e9) + 7;
const int oo = 2147483647;
const double EPS = 1e-8;
const double PI = acos(-1.0);

//enum dir { D, R, U, L , dr, ur, dl, ul };
int dx[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

string abc = "abcdefghijklmnopqrstuvwxyz";
string vowels = "aeiouy"; //and sometimes "aeiouy"

template<typename X, typename Y> bool ckmin(X& a, Y b) { return a > b ? a = b, true : false; }
template<typename X, typename Y> bool ckmax(X& a, Y b) { return a < b ? a = b, true : false; }
bool cklex(string &a, string b) {
	if (b == "") return false;
	if (a == "") return a = b, true;
	if (sz(a) < sz(b)) return false;
	if (sz(b) < sz(a)) return a = b, true;
	if (a < b) return false;
	return a = b, true;
}

int dcmp(ld d1, ld d2) { return fabs(d1 - d2) <= EPS ? 0 : d1 > d2 ? 1 : -1; } //Compare Double Numbers
ll gcd(ll x, ll y) { return !y ? x : gcd(y, x%y); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
int conv_2_1(int r, int c, int nCol) { return (nCol*r) + c + 1; } //convert index from 2D array to 1D array. (Zero-indexed)
ii conv_1_2(int n, int nCol) { return{ n / nCol, n % nCol }; } //convert index from 1D array to 2D array (row, col). (Zero-indexed)
template<typename T> void inter(T X) { cout << X << endl; fflush(stdout); }


void solveF() {

}

void solveE() {

}

void solveD() {

}

void solveC() {

}

void solveB() {

}

void solveA() {
	int n, a, b;
	string s;
	cin >> n >> a >> b >> s;
	int rank = 1, cnt = 0;
	lop(i, n) {
		if (s[i] == 'c') {
			cout << "No\n";
		}
		else if (s[i] == 'a') {
			if (cnt < a + b) cnt++, cout << "Yes\n";
			else cout << "No\n";
		}
		else {
			if (cnt < a + b and rank <= b) cout << "Yes\n", cnt++;
			else cout << "No\n";
			rank++;
		}
	}
}


int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int t = 1;
	//cin >> t;
	while (t--) {
		solveA();
		//solveB();
		//solveC();
		//solveD();
		//solveE();
		//solveF();
	}


	return 0;
}


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

int main()
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    for(int i = 1; i <= 3; i++)
    {
        if(i != A && i != B){
            cout << i << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define pll pair <ll, ll>
#define mp make_pair
#define pyshnapyshnakaa ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define x first
#define y second
#pragma GCC optimize("O3")
#define plll pair <pair <ll, ll>, ll>
#define pllll pair <pair <ll, ll>, pair <ll, ll> >
#define psl pair <string, ll>
#define all(a) a.begin(), a.end()
// #pragma comment(linker, "/stack:2000000000")
 
typedef long long ll;
 
typedef long double ld;
 
using namespace std;
 
const ll maxn = 1e6;
const ll inf = 1e9;
 
ll n, m, k, t;

vector <ll> A ={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main() {
    ll q, w, e, a, b, c, d;
    string s;
    cin >> n;
    cout << A[n - 1];
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<int> vec(n);
  for(int i=0;i<n;i++){cin >> vec[i];}
  sort(vec.begin(),vec.end());
  int sum=0;
  for(int i=0;i<n-1;i++){sum += vec[i];}
  if( vec[n-1]<sum ){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  return 0;
}
  


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

typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n + 1, 0);
    vector<int> ans(n + 1, 0);
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = n; i >= 1; i--) {
        int q = n / i;
        int s = a[i];
        int c = 0;
        for (int m = q; m >= 1; m--) {
            if (m == 1) {
                ans[i] = (s + c) % 2;
            } else {
                c += ans[i * m];
                c %= 2;
            }
        }
    }
    vector<int> out;
    for (int i = 1; i <= n; i++) {
        if (ans[i] % 2 != 0) {
            out.push_back(i);
        }
    }
    cout << out.size() << endl;
    if (out.size()) {
        for (int i = 0; i < out.size(); i++) {
            if (i == 0) cout << out[i];
            else cout << " " << out[i];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3192
import java.io.*;
import java.util.*;
import java.util.Arrays;
import java.util.Collections;
// import java.io.BufferedReader;
// import java.io.IOException;
// import java.io.InputStreamReader;
// import java.util.ArrayList;
// import java.util.Arrays;
// import java.util.Collections;
// import java.util.List;
// import java.util.HashSet;
// import java.util.Set;
// import java.util.Map;
// import java.util.HashMap;

import java.math.*;

public class Main {
    private static Scanner sc;
    private static final long mod = 1000000007;

    public static void main(final String[] args) {
        final Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private static String getUpperAlpha(int i) {
        return String.valueOf((char) (i + 64));
    }

    /* i=1 return a */
    private static String getLowerAlpha(int i) {
        return String.valueOf((char) (i + 96));
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null)
                br.close();
        }

        public String next() throws IOException {
            if (i < s.length)
                return s[i++];
            String st = br.readLine();
            while (st == "")
                st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }

        public long[] nextLongArray(int n) throws NumberFormatException, IOException {
            long[] ret = new long[n];
            for (int i = 0; i < n; i++) {
                ret[i] = nextLong();
            }
            return ret;
        }

        public int[] nextIntArray(int n) throws NumberFormatException, IOException {
            int[] ret = new int[n];
            for (int i = 0; i < n; i++) {
                ret[i] = nextInt();
            }
            return ret;
        }
    }

    private void solve() {
        try {
            int d = sc.nextInt();
            int t = sc.nextInt();
            int s = sc.nextInt();
            if (d <= t * s) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        } catch (

        Exception e) {
            e.printStackTrace();
        }

    }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;
const int MAX_N = 300000;

ll fact[MAX_N+100];
ll frev[MAX_N+100];

ll rev(ll a, ll p){
    if(p == 0) return 1;
    ll tmp = rev(a, p/2);
    tmp = tmp * tmp % MOD;
    if(p % 2 == 1) tmp = tmp * a % MOD;
    return tmp;
}


void calc_fact(){
    fact[0] = frev[0] = 1;
    for(int i = 1; i <= MAX_N; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        frev[i] = rev(fact[i], MOD-2);
    }
}


ll comb(int n, int k){
    if(n < 0 || k < 0 || n < k) return 0;
    if(n == 0 || k == 0) return 1;
    return fact[n] * frev[k] % MOD * frev[n-k] % MOD;
}

//O(logn)
//return x**n % mod
ll mod_pow(ll x, ll n, ll mod){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main(){

    ll N, A, B, C;
    cin >> N >> A >> B >> C;


    //in main function
    fact[0] = frev[0] = 1;
    for(int i = 1; i <= MAX_N; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        frev[i] = rev(fact[i], MOD-2);
    }

    ll ans = 0;
    for(ll m = N; m <= 2*N-1; m++){
        ll tmp1 = comb(m-1, N-1);
        tmp1 %= MOD;

        ll tmp2 = (mod_pow(A, N, MOD) * mod_pow(B, m-N, MOD)) % MOD +
                    (mod_pow(A, m-N, MOD) * mod_pow(B, N, MOD)) % MOD;
        tmp2 %= MOD;

        ll tmp3 = (A+B) * mod_pow(A+B, m, MOD);
        tmp3 %= MOD;

        ll tmp = (tmp1 * tmp2) % MOD;
        tmp *= mod_pow(tmp3, MOD-2, MOD);
        tmp %= MOD;
        tmp *= m;
        tmp %= MOD;
        tmp *= 100;
        tmp %= MOD;

        ans += tmp;
        ans %= MOD;
        //cout << ans << endl;

    }

    //for (ll i = N; i <= 2 * N - 1; ++i)
    //{
    //    ll bunsi = (mod_pow(A, N, MOD) * mod_pow(B, i - N, MOD) % MOD + mod_pow(A, i - N, MOD) * mod_pow(B, N, MOD) % MOD) * i * 100 % MOD;
    //    ll bunbo = mod_pow(A + B, i, MOD) * (100 - C) % MOD;
    //    (ans += comb(i - 1, N - 1) * bunsi % MOD * mod_pow(bunbo, MOD-2, MOD) % MOD) %= MOD;
    //}

    //ans += MOD;
    //ans %= MOD;

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


Measured memory_bytes: 4992
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt(), m = stdIn.nextInt();
		while( n != 0 || m != 0 ){
			List<String> remain = new ArrayList<String>();
			for(int i = 1; i <= n; i++){
				remain.add(Integer.toString(i));
			}
			int del = m-1;
			while( remain.size() > 1 ){
				remain.remove(del);
				n--;
				del = (del+m-1)%n;
			}
			System.out.println(remain.get(0));
			n = stdIn.nextInt();
			m = stdIn.nextInt();
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb emplace_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(0);
 
int32_t main(){
	fast;
   int  n,m;
   cin >> n >> m;
   
   vector<vector<int> > a(n,vector<int>(2));
   for(int i=0; i<n ; i++)    cin >> a[i][0] >> a[i][1];
   sort(a.begin(),a.end());
   multiset <int> mset ; 
   int ans = 0;
   int i=0;
   for(int j=1 ; j<=m ; j++)
   {
        for( ; i <n && a[i][0] <= j ; i++)
               mset.insert(a[i][1]);
               
          if(!mset.empty())
          {
            	auto itr = mset.end();
                itr--;
            	ans += *itr;
                mset.erase(itr);    
          }
     
   }
   cout << ans;
}
 
 

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

int main(){
  int a,b,c,d,res;
  cin >> a;
  b=a%1000/100;
  c=a%100/10;
  d=a%10;
  a/=1000;
  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      for(int k=0;k<2;k++){
        for(int l=0;l<2;l++){
          res=a;
          res+=(j)?-b:b;
          res+=(k)?-c:c;
          res+=(l)?-d:d;
          if(res==7){
            printf("%d%c%d%c%d%c%d=7\n",a,(j)?'-':'+',b,(k)?'-':'+',c,(l)?'-':'+',d);
            return 0;
          }
        }
      }
    }
  }
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>

#define INF 100000000

using namespace std;

int front_number = 0, ans = 0, n, same_color_count;
int a[100];

int next_color_check()
{
    if (front_number + 1 < n)
    {
        if (a[front_number] == a[front_number + 1])
        {
            front_number++;
            same_color_count++;
            next_color_check();
        }
        else
        {
            front_number++;
        }
    }
}
int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    while (front_number != n - 1)
    {
        same_color_count = 1;
        next_color_check();
        if (same_color_count % 2 == 0)
        {
            ans += same_color_count / 2;
        }
        else
        {
            ans += (same_color_count - 1) / 2;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ar=array<int,26>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,a,n) for(int i=a;i<n;i++)
int main(){
	string s1,s2;
	while(cin>>s1>>s2){
		if(s1.size()>s2.size()) swap(s1,s2);
		int n1=s1.size(), n2=s2.size();
		
		set<ar> list1;
		for(int l=n1;l>=1;l--){
			list1.clear();
			ar tmp;
			tmp.fill(0);
			rep(i,n1) {
				tmp[s1[i]-'a']++;
				if(i>=l) tmp[s1[i-l]-'a']--;
				if(i>=l-1) list1.insert(tmp);
			}
			tmp.fill(0);
			rep(i,n2){
				tmp[s2[i]-'a']++;
				if(i>=l) tmp[s2[i-l]-'a']--;
				if(i>=l-1) {
					if(list1.find(tmp) != list1.end()){
						cout<<l<<endl;
						goto end;
					}
				}
			}
		}
		cout<<0<<endl;
		end: ;
	}
	return 0;
}



Measured memory_bytes: 3604
void main() {
	auto ip = readAs!(int[]), H = ip[0], W = ip[1];
	auto ip2 = readAs!(int[]), h = ip2[0], w = ip2[1];
	writeln((H-h)*(W-w));
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        var S = ReadLine().Split();
        WriteLine(S[0][0].ToString() + S[1][0].ToString() + S[2][0].ToString());
    }
}


Measured memory_bytes: 25800
#include <iostream>
#include <string.h>
#include <algorithm>

using namespace std;

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

    int N, M;
    cin >> N >> M;

    long long cakes[N][3];
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> cakes[i][j];
        }
    }

    if (M == 0) {
        cout << 0 << endl;
        return 0;
    }

    long long ans = 0LL;
    for (int i = 0; i < N; ++i) {
        long long res = abs(cakes[i][0]) + abs(cakes[i][1]) + abs(cakes[i][2]);
        long long c[N - 1];
        memset(c, 0, sizeof(c));
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < N; ++k) {
                if (i == k) continue;
                if (i > k) {
                    if (cakes[i][j] >= 0) {
                        c[k] += cakes[k][j];
                    } else {
                        c[k] -= cakes[k][j];
                    }
                } else {
                    if (cakes[i][j] >= 0) {
                        c[k - 1] += cakes[k][j];
                    } else {
                        c[k - 1] -= cakes[k][j];
                    }
                }
            }
        }

        sort(c, c + N - 1, greater<>());
        for (int j = 0; j < M - 1; ++j) {
            res += c[j];
        }
        ans = max(ans, res);
    }

    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;

#define int long long

string S;
set<char> r;

signed main()
{
	r.insert('y');
	r.insert('u');
	r.insert('i');
	r.insert('o');
	r.insert('p');
	r.insert('h');
	r.insert('j');
	r.insert('k');
	r.insert('l');
	r.insert('n');
	r.insert('m');
	while (cin >> S, S != "#")
	{
		int ans = 0;
		bool last;
		for (int i = 0; i < S.size(); i++)
		{
			bool res = r.find(S[i]) != r.end();
			if (i > 0) ans += last != res;
			last = res;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()

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

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

	return 0;
}


Measured memory_bytes: 384
unittest
{
	assert( [ "8" ].parse.expand.solve == 5 );
	assert( [ "7" ].parse.expand.solve == 18 );
	assert( [ "54" ].parse.expand.solve == 114 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( long );
	return tuple( s );
}

auto solve( long s )
{
	auto as = [ s ];
	for( auto i = 2L; true; i++ )
	{
		auto ai = f( as[ $ - 1 ] );
		foreach( a; as )
		{
			if( ai == a ) return i;
		}
		as ~= ai;
	}
	
	assert( false );
}

auto f( long n )
{
	if( n % 2 == 0 ) return n / 2;
	else             return 3 * n + 1;
}


Measured memory_bytes: 256
a=list(input())
x=len(a)
b=[""]*(x-1)

c=[]
for aa,bb in zip(a,b):
    c.append(aa)
    c.append(bb)
c.append(a[-1])

import copy
ans=0
for i in range(2**(x-1)):
    cc=copy.deepcopy(c)
    for j in range(x-1):
        if (i>>j&1):
            cc[(j+1)*2-1]="+"
    ccc="".join(cc)
    ans+=eval(ccc)
print(ans)

Measured memory_bytes: 41712
import java.util.Scanner;

 
public class Main {
 
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();

		if((A == B && B != C)||(A != B && B == C)||(A == C && A != B)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		sc.close();
	}
	
}

Measured memory_bytes: 21716
S = list(map(int, list(input())))

n = len(S)-1
for i in range(2 ** n):
    out = S[0]
    op = []
    for j in range(n):
        if (i>>j) & 1:
            out += S[j+1]
            op.append("+")
        else:
            out -= S[j+1]
            op.append("-")
    if out == 7:
        print(S[0], end='')
        for i in range(n):
            print(op[i], end='')
            print(S[i+1], end='')
        print("=7")
        exit()

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

int main(){
     int num[3];

     for(int i=0;i<3;i++){
          cin >> num[i];
     }
     for(int i=0;i<3;i++){
          for(int j=i;j<3;j++){
               if(num[i]>num[j]){
                    int a;
                    a=num[i];
                    num[i]=num[j];
                    num[j]=a;
               }
          }
     }
     for(int i=0;i<3;i++){
          cout << num[i];
          if(i!=2){
               cout << " "; 
          }
          else{
               cout << endl;
          }
     }

     return 0;
}

Measured memory_bytes: 3064
#include <vector>
#include <stack>
#include <string>
#include <cstdio>
using namespace std;
const int S = (1<<20)+5;
char buf[S],*H,*T;
inline char Get()
{
    if(H==T) T=(H=buf)+fread(buf,1,S,stdin);
    if(H==T) return -1;return *H++;
}
inline int read()
{
    int x=0;char c=Get();
    while(!isdigit(c)) c=Get();
    while(isdigit(c)) x=(x*10)+c-'0',c=Get();
    return x;
}
inline long long relo()
{
    long long x=0;char c=Get();
    while(!isdigit(c)) c=Get();
    while(isdigit(c)) x=(x*10)+c-'0',c=Get();
    return x;
}
int main(){
    long long marxism = -10000000000000;
    vector<stack<int> > ms;
    vector<long long> cf;
    vector< vector<int> > tickets;
    int shop = read(),tic = read();
    cf.reserve(shop-1);
    tickets.assign(tic,vector<int>());
    ms.assign(tic,stack<int>());
    for (register int i = 1;i<shop;++i)cf.push_back(-relo());
    for (register int i = 0;i<shop;++i)for (register int j = 0;j<tic;++j)tickets[j].push_back(read());
    for (register int i = shop-1;i>=0;--i){
	long long result = 0;
        for (register int j = 0;j<ms.size();++j){
            int cur = tickets[j][i],prev = 0;
            while (!ms[j].empty()){
                if (cur>tickets[j][ms[j].top()]){
                    cf[ms[j].top()-1] -=(tickets[j][ms[j].top()]-prev);
                    prev = tickets[j][ms[j].top()];
                    ms[j].pop();
                }
                else{
                    cf[ms[j].top()-1] -=(cur-prev);
                    break;
                }
            }
	    result += cur;
	    if (i) cf[i-1] +=cur;
            ms[j].push(i);
        }
        marxism = max(marxism,result);
        for (register int j = i;j<shop-1;++j){
            result +=  cf[j];
            marxism = max(marxism,result);
        }
    }
    printf("%lld",marxism);
}


Measured memory_bytes: 7168