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

//ll mat[1000][1000];
ll x = 1e9 + 7;

bool isSafe(int i, int j, int m, int n){
    if( i < 0 or i >= m or j < 0 or j >= n) return false;
    return true;
}

ll paths(int m, int n, vector<vector<char>>& v){
    // Memoization - Top Down Approach
    // if(i < 1 || j < 1 || v[i-1][j-1] == '#' ) return 0;
    // if(i == 1 && j == 1) return 1;
    
    // 
    // if(mat[i-1][j-1] != 0) return (mat[i-1][j-1])%x;
    // else{
    //     mat[i-1][j-1] = (paths(i-1,j,v))%x+(paths(i,j-1,v))%x;
    // } 
    // return (mat[i-1][j-1])%x ;
    
    
    // Bottom up Approach
    ll dp[m][n] ;
    dp[0][0] = 1;
    for(int i = 1; i < n; i++) (v[0][i] == '.') ? dp[0][i] = dp[0][i-1] : dp[0][i] = 0;
    for(int i = 1; i < m; i++) (v[i][0] == '.') ? dp[i][0] = dp[i-1][0] : dp[i][0] = 0;
    
    for(int i = 1; i < m; i++){
        for(int j = 1; j < n; j++){
            if(v[i][j] == '.') dp[i][j] = dp[i-1][j] + dp[i][j-1];
            else dp[i][j] = 0;
            dp[i][j] %= x;
        }
        
    }
    return dp[m-1][n-1] % x;
    
}

int main(){
    int m,n ; cin >> m >> n;
    vector<vector<char>> v(m, vector<char>(n));
    for(int i = 0; i < m; i++){
        for(int j = 0; j < n; j++){
            cin >> v[i][j];
        }
    }
    
    
    cout << paths(m,n,v) ;
    return 0;
}

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

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

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

	int N,M;
	
	cin >> N>>M;
	
	yn(N==M);

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int abs(int i)
{
  return i < 0 ? -i : i;
}

int main(void)
{
  int N; scanf("%d", &N);
  char S[N+1];
  scanf("%s", S);
  int dp[5001][5001];
  int max = 0;
  for(int i = 1; i < N+1; i++)
      for(int j = 1; j < N+1; j++)
          if(i != j && S[i-1] == S[j-1])
              if((dp[i][j] = dp[i-1][j-1] + 1) > max && abs(i-j+1) > dp[i][j])
                  max = dp[i][j];
  printf("%d", max);
}


Measured memory_bytes: 97792
#include <iostream>
#include <set>
#include <list>

using namespace std; 

int
main(int argc, char const *argv[])
{
    list<uint64_t> l;
    uint64_t m = 0;
    uint64_t n;
    uint64_t ans;
    cin >> n;
    ans = 0;
    for (auto i = 0; i < 5; i++) {
	uint64_t v;
	cin >> v;
	auto rest = n % v;
	auto u = n /v;
	if (rest == 0) {
	    u--;
	}
	m = max(m, u);

    }
    cout << m + 5 << endl;
    return 0;
}


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

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

    vector<double> p(3001, 0);
    cin >> p[1];
    p[0] = 1-p[1];

    double x;
    for(int i = 1; i < n; i++){
        cin >> x;
        for(int j = i; j >= 0; j--){
            p[j+1] += p[j]*x;
            p[j] *= (1-x);
        }
    }

    double ans = 0;
    for(int i = n/2+1; i <= n; i++)  ans += p[i];

    cout << fixed << setprecision(12) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (int i = (a), lim_i = (b); i < lim_i; i++)
#define REP(i, ...) REP_((i), __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sat Mar 14 21:00:01 JST 2020
 **/

signed main() {
    int N;
    cin >> N;
    set<string> ans;
    auto dfs = [&](auto f, string s, char cur) -> void {
        int n = s.size();
        if (n == N) {
            ans.insert(s);
            return;
        }
        REP(i, n) {
            string nxt = s;
            nxt.push_back(s[i]);
            f(f, nxt, cur);
        }
        s.push_back(cur + 1);
        f(f, s, cur + 1);
    };
    dfs(dfs, "", 'a' - 1);
    for (auto s : ans) cout << s << endl;
}


Measured memory_bytes: 13952
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
//#pragma comment(linker, "/STACK:1024000000,1024000000")

using namespace std;

#define ll long long
#define SZ(x) ((int)(x).size()) 
#define ALL(v) (v).begin(), (v).end()
#define foreach(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define reveach(i, v) for (__typeof((v).rbegin()) i = (v).rbegin(); i != (v).rend(); ++ i) 
#define REP(i,a,n) for ( int i=a; i<int(n); i++ )
#define FOR(i,a,n) for ( int i=n-1; i>= int(a);i-- )
#define lson rt<<1, L, m
#define rson rt<<1|1, m, R
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define fi first
#define se second
#define CLR(a, b) memset(a, b, sizeof(a))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

const int N = 3001;
int vis[N];
const int limit=3000;
bool isprime[limit+1];
vector<ll> prime;
 
void init(){
	REP(i, 0, limit+1) isprime[i]=true;
	isprime[0]=isprime[1]=false;
	for(ll i=2;i*i<=limit;++i){
		if(isprime[i]){
			prime.push_back(i);
			for(ll j=i*i;j<=limit;j+=i)
				isprime[j]=false;
		}
	}
	return;
}
map<ll, int> cnt;
int main(){
#ifdef ac
	freopen("in.txt","r",stdin);
#endif
	//freopen("out.txt","w",stdout);
    init();
    int m = prime.size();
    int n;
    scanf("%d", &n);
    REP(i, 0, n){
        ll cur;
        scanf("%lld", &cur);
        REP(j, 0, m){
            ll cube = 1ll * prime[j] * prime[j] * prime[j];
            while(cur % cube == 0) cur /= cube;
        }
        cnt[cur] ++;
    }
    ll ans = 0ll;
    for(auto &it : cnt){
        if(it.fi == 1)
            ans += min<ll>(1ll, it.se);
        else{
            ll tar = 1ll * it.fi * it.fi;
            REP(j, 0, m){
                ll cube = 1ll * prime[j] * prime[j] * prime[j];
                while(tar % cube == 0) tar /= cube;
            }
            ans += max<ll>(it.se, cnt[tar]);
            it.se = 0ll;
            cnt[tar] = 0ll;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 21376
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

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

    Int N, K; cin >> N >> K;
    vector<pair<Int, Int>> ab;

    rep(i, 0, N) {
        Int a, b;
        cin >> a >> b;
        ab.push_back(make_pair(a, b));
    }
    sort(ab.begin(), ab.end());

    Int now = 0;
    rep(i, 0, ab.size()) {
        now += ab[i].second;
        if (now >= K) {
            cout << ab[i].first << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 2420
// https://atcoder.jp/contests/abc178/tasks/abc178_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

// https://atcoder.jp/contests/abc178/submissions/16676915
const int MOD = 1e9 + 7;
template <long long mod> class modint {
  private:
    long long a;

  public:
    constexpr modint(const long long x = 0) noexcept : a(x % mod) {}
    constexpr long long &value() noexcept { return a; }
    constexpr const long long &value() const noexcept { return a; }
    constexpr modint operator+(const modint rhs) const noexcept {
        return modint(*this) += rhs;
    }
    constexpr modint operator-(const modint rhs) const noexcept {
        return modint(*this) -= rhs;
    }
    constexpr modint operator*(const modint rhs) const noexcept {
        return modint(*this) *= rhs;
    }
    constexpr modint operator/(const modint rhs) const noexcept {
        return modint(*this) /= rhs;
    }
    constexpr modint &operator+=(const modint rhs) noexcept {
        a += rhs.a;
        if (a >= mod)
            a -= mod;
        return *this;
    }
    constexpr modint &operator-=(const modint rhs) noexcept {
        if (a < rhs.a)
            a += mod;
        a -= rhs.a;
        return *this;
    }
    constexpr modint &operator*=(const modint rhs) noexcept {
        a = a * rhs.a % mod;
        return *this;
    }
    constexpr modint &operator/=(modint rhs) noexcept {
        long long k = mod - 2;
        while (k > 0) {
            if (k & 1) {
                *this *= rhs;
            }
            rhs *= rhs;
            k /= 2;
        }
        return *this;
    }
    friend ostream &operator<<(ostream &os, const modint &X) {
        return os << X.a;
    }
    friend istream &operator>>(istream &is, modint &X) {
        is >> X.a;
        X.a %= mod;
        if (X.a < 0)
            X.a += mod;
        return is;
    }
};

// 繰り返し二乗法
template <typename T> T power(T x, long long k) {
    T ret{1};
    while (k > 0) {
        if (k & 1)
            ret *= x;
        x *= x;
        k /= 2;
    }
    return ret;
}

using mint = modint<1000000007>;

void solve() {
    int N;
    cin >> N;
    if (N == 1) {
        cout << 0 << endl;
    } else {
        cout << power<mint>(10, N) - power<mint>(9, N) * 2 + power<mint>(8, N)
             << endl;
    }
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 3612
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

n, k = Is()
A = LI()
ans = 1
tmp = n - k
if tmp > 0:
    ans += ceil(tmp/(k-1))
print(ans)

Measured memory_bytes: 77432
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

fn solve() {
    let n = get();
    let a: Vec<i64> = (0 .. n).map(|_| get()).collect();
    let mut goal = a.iter().fold(0, |x, &y| x ^ y);
    const B: usize = 32;
    let mut cnt = [0; B];
    for v in a {
        if v == 0 { continue; }
        let diff = (v ^ (v - 1)).count_ones() as usize - 1;
        cnt[diff] += 1;
    }
    let mut tot = 0;
    for i in (0 .. B).rev() {
        if (goal & 1 << i) == 0 { continue; }
        if cnt[i] == 0 { // impossible
            println!("-1");
            return;
        }
        goal ^= (1 << (i + 1)) - 1;
        tot += 1;
    }
    println!("{}", tot);
}

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
a = gets.chomp.split("").map(&:to_i)
a_len = a.length

ans = 0

for bit in 0..2**(a_len-1)-1 do
    cur = a[0]
    for i in 0..a_len-2 do
        if (bit >> i) & 1 == 1 then
            ans += cur
            cur = a[i+1]
        else
            cur *= 10
            cur += a[i+1]
        end
    end
    ans += cur
end

p ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる


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

  int a,b;
  cin>>a>>b;
  a--;//.
  b--;//#

  vector<vector<char>> p(100,vector<char>(100));
  rep(i,50) rep(j,100) p[i][j]='#';
  for(int i=50;i<100;i++) rep(j,100) p[i][j]='.';

  int x=0,y=0;
  while(a--){
    p[x][y]='.';
    if(y+2<100) y+=2;
    else {
      x+=2,y=0;
    }
  }

  x=51,y=0;
  while(b--){
    p[x][y]='#';
    if(y+2<100) y+=2;
    else {
      x+=2,y=0;
    }
  }

  cout << "100 100" << endl;
  rep(i,100){
    rep(j,100){
      cout << p[i][j];
    }
    cout << endl;
  }

}

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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

int main() {
    int n;
    cin >> n;
    V<int> a(n);
    rep(i, n) cin >> a[i];

    bool fp = 0, fn = 0;
    rep(i, n) {
        if (a[i] >= 0) {
            fp = 1;
        } else {
            fn = 1;
        }
    }

    V<pii> ope;

    if (fp && fn) {
        int maxp = max_element(ALL(a)) - a.begin();
        int minp = min_element(ALL(a)) - a.begin();
        if (a[maxp] >= -a[minp]) {
            rep(i, n) {
                a[i] += a[maxp];
                ope.eb(maxp, i);
            }
        } else {
            rep(i, n) {
                ope.eb(minp, i);
                a[i] += a[minp];
            }
        }
    }

    debug(a);

    if (a[0] >= 0) {
        rep(i, n - 1) { ope.eb(i, i + 1); }
    } else {
        for (int i = n - 1; i; --i) {
            ope.eb(i, i - 1);
            a[i - 1] += a[i];
        }
    }
    int sz = ope.size();
    cout << sz << endl;
    rep(i, sz) cout << ope[i].fi + 1 << " " << ope[i].se + 1 << endl;
    debug(a);
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
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 <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  string s,t;
  cin >> s >> t;
  ll mo;
  rep(i,s.length()){
    mo = t[0];
    rep(j,s.length()-1){
      t[j] = t[j+1];
    }
    t[s.length()-1]=mo;
    if(s==t){
      pri("Yes");
      return 0;
    }
  }
  pri("No");
  return 0;
}


Measured memory_bytes: 256
package main
 
import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)
 
func run(){
	n := nextInt()
	t := make([]int, 0)
	t = readIntArray(n)
	count := 0
	k := t[0]
	ans := 0
	for i := 1; i < n; i++ {
		if(k >= t[i]){
			count ++
			k = t[i]
		}else{
			if(ans < count){
				ans = count
			}
			k = t[i]
			count = 0
		}
	}
	if(ans < count){
		ans = count
	}
	Println(ans)
}
 
// --- template ---
// Thanks https://gist.github.com/halllllll/853ab587fd82ee3ffe6f7fb7fb499695
 
var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
 
// Caution: You will get unexpected result if a single token is larger than this size.
const BufferSize = 64 * 1024 * 1024
 
func Print(a ...interface{}) (n int, err error) {
	return fmt.Fprint(out, a...)
}

func readIntArray(n int) ([]int) {
	v := make([]int, 0)
	for i := 0; i < n; i++ {
		v = append(v, nextInt())
	}
	return v
}
 
func Printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, format, a...)
}
 
func Println(a ...interface{}) (n int, err error) {
	return fmt.Fprintln(out, a...)
}
 
func next() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int {
	a, err := strconv.Atoi(next())
	if err != nil {
		log.Fatal(err)
	}
	return a
}
 
func nextFloat() float64 {
	a, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		log.Fatal(err)
	}
	return a
}
 
func main() {
	sc.Buffer(make([]byte, 0, BufferSize), BufferSize)
	sc.Split(bufio.ScanWords)
	run()
	out.Flush()
}

Measured memory_bytes: 9344
#include <iostream>
using namespace std;
int main() {
  int n, x;
  cin >> n;
  x = n / 1.08;
  if ((int)(x * 1.08) == n) {
    cout << x << endl;
  } else if ((int)((x + 1) * 1.08) == n) {
    cout << x + 1 << endl;
  } else {
    cout << ":(" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using llong = long long;
using vi    = vector<int>;
using vvi   = vector<vi >;
using vvvi  = vector<vvi >;
using pii   = pair<int,int>;
constexpr int    INF=1e9;
constexpr double EPS=1e-9;
constexpr int    MOD=1e9+7;
template<class Type>
void line(const Type &a){int cnt=0;for(const auto &elem:a){cerr<<(cnt++?' ':'>');cerr<<elem;}cerr<<endl;}

int main(){//Refering other editorials.
	int n;
	string s;
	cin>>n>>s;
	
	vvi dp(n+1,vi(n+1,0));//dp[l][r]:=(l番目とr番目から始まる部分文字列の共通の長さ).
	for(int l=n-1;l>=0;--l)for(int r=n-1;r>l;--r){
		if(s[l]==s[r]) dp[l][r]=dp[l+1][r+1]+1;
	}
	
	int ans=0;
	REP(l,n-1)for(int r=l+1;r<n;++r){
		ans=max(ans,min(dp[l][r],r-l));
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 101192
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 
//using namespace boost::multiprecision; 
using namespace std;
#define ll long long int
#define ld long long double
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll, ll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define nl '\n'
#define mp make_pair
#define debug1(x) cout <<#x<<" "<<x<<'\n';
#define debug2(x,y) cout <<#x<<" "<<x <<" "<<#y<<" "<<y <<'\n';
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<'\n';
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inf 1e18
const int mod = (int)1e9+7;
pair<ll,ll>s4[4]={{-1,0},{1,0},{0,-1},{0,1}};
pair<ll,ll>s8[8]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,1},{1,0},{1,-1}};

void solve() {
   ll n;
   cin >> n;
   string s[n];
   for(int i=0;i<n;i++) {
       cin >> s[i];
   }
   map<string,int> m;
   for(int i=0;i<n;i++) {
       m[s[i]]++;
   }
   int mx=0;
   for(auto it =m.begin();it!=m.end();it++) {
       if(it->second > mx) {
           mx = it->second;
       }
   }
   for(auto it=m.begin();it!=m.end();it++) {
       if(it->second ==mx) {
           cout << it->first << "\n";
       }
   }
   
   
}

signed main() {
	boost;
	solve();
}

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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(v)     for(bool p=1;p;p=next_permutation(ALL(v)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<typename T>string join(const vector<T>& v, string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(d.length());}

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v)
{if(SZ(v))s<<join(v,", ");return s;}

const ll INF = 1e15;
const ll MOD = 1e9+7;
const double EPS = 1e-10;

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

int main() {
    ll N, M; cin >> N >> M;
    
    vector<ll> box(N, 1);
    vector<bool> red(N, false);
    red[0] = true;
    
    REP(i, M) {
        ll x, y; cin >> x >> y;
        x--; y--;
        
        box[x]--;
        box[y]++;
        if (red[x]) red[y] = true;
        if (!box[x]) red[x] = false;
    }
    
    ll ans = 0;
    REP(i, N) if (red[i] && box[i] > 0) ans++;
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 1024
// ALDS1_2_D Shell Sort
import java.io.*;

class Main {
   public static void main(String[] args) {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

      try {
         int n = Integer.parseInt(br.readLine());
         int[] A = new int[n];
         for (int i = 0; i < n; i++) {
            A[i] = Integer.parseInt(br.readLine());
         }
         shellSort(A, n);
      }

      catch (Exception e) {
         e.printStackTrace();
      }
   }

   static int insertionSort(int[] A, int n, int g) {
      int cnt = 0;
      for (int i = g; i < n; i++) {
         int val = A[i];
         int j = i - g;
         while (j >= 0 && A[j] > val) {
            A[j + g] = A[j];
            j = j - g;
            cnt++;
         }
         A[j + g] = val;
      }
      return cnt;
   }

   static void shellSort(int[] A, int n) {
      int cnt = 0;
      int[] G = new int[n];
      int m = 1;
      G[0] = 1;
      for (int i = 1; i < n; i++) {
         G[i] = G[i - 1] * 3 + 1;
         if (G[i] > n) break;
         m++;
      }
      for (int i = m - 1; i >= 0; i--) {
         cnt += insertionSort(A, n, G[i]);
      }
      System.out.println(m);
      for (int i = m - 1; i >= 0; i--) {
         if (i != m - 1) {
            System.out.print(" ");
         }
         System.out.print(G[i]);
      }
      System.out.println();
      System.out.println(cnt);
      for (int a : A) {
         System.out.println(a);
      }
   }
}

Measured memory_bytes: 100672
#include<stdio.h>
int main(void)
{
	char c[1];
	scanf("%s", c);
	if(c[0]=='a'||c[0]=='i'||c[0]=='u'||c[0]=='e'||c[0]=='o')
	printf("vowel\n");
	else
	printf("consonant\n");
	
	return 0;
}

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

using namespace std; 
 
double getDistance(pair<int, int> a, pair<int, int> b) { 
  int xdiff = a.first - b.first; 
  int ydiff = a.second - b.second; 
  return sqrt((double)pow(xdiff, 2) + (double)pow(ydiff, 2)); 
} 

int main() { 
  int N; cin >> N; 
  pair<int, int> Towns[N]; 
 
  for (int i = 0; i < N; i++) { 
    pair<int, int> town; 
    cin >> town.first >> town.second; 
    Towns[i] = town; 
  } 
 
  double total_distance = 0; 
 
  for (int i = 0; i < N; i++) { 
    for (int j = 0; j < N; j++) { 
      if (i == j) {} 
      else { 
        total_distance += getDistance(Towns[i], Towns[j]);
      } 
    } 
  } 
 
  std::cout << std::fixed;
  cout << std::setprecision(6) << total_distance / N << endl; 
  return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define reps(i, n) for(int i = 1; i <= n; i++)
const int    INF = 1000000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;



int main()
{
	int n, m;
	ll mx[1010], my[1010], mxn[1010], myn[1010];
	cin >> n >> m;
	ll k, a[20010], dp[20010];
	cin >> k;
	reps(i, n) cin >> a[i];	
	dp[0]=0;
	rep(i, m+1) mx[i]=INF, my[i]=0;
	reps(i, n)
	{
		for(ll l=1; l<=min(i, m); l++)
		{
			mxn[l]=min(mx[l-1], a[i]);
			myn[l]=max(my[l-1], a[i]);
			if(l==1) dp[i]=dp[i-1]+k;
			else dp[i]=min(dp[i], dp[i-l]+k+l*(myn[l]-mxn[l]));
		}
		reps(l, min(i, m)) mx[l]=mxn[l], my[l]=myn[l];
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 3432
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

//#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define mkt make_tuple
#define no {cout << "No"; return;}

void solve() {
    string s, t;
    cin >> s >> t;
    cout << (s[0] == t[0]) + (s[1] == t[1]) + (s[2] == t[2]);
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 3652
# 英小文字からなる文字列Sがあります。
# Sの長さがK以下であれば、Sをそのまま出力してください。
# Sの長さがKを上回っているならば、先頭K文字だけを切り出し、末尾に ... を付加して出力してください。

# k(Sの長さ）,S（文字列）：標準入力
k = int(input())
s = input()

def length(k: int, s:str) -> str:
    if len(s) <= k:
        return s
    else:
        return s[:k] + '...'  # 文字列：Sから先頭からk文字目を切り取る → s[:k]：最終位置のみ記述

print(length(k ,s))


Measured memory_bytes: 9156
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K = map(int, readline().split())
    point = list(map(int, readline().split()))
    T = readline().strip()

    T = list(map(int, T.translate(str.maketrans('rsp', '012'))))

    hand = [0] * N
    ans = 0
    for i, h in enumerate(T):
        win = (h - 1) % 3
        if i >= K and win == hand[i - K]:
            hand[i] = -1
        else:
            hand[i] = win
            ans += point[win]

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 10508
#include <iostream>
using namespace std;
#define N 100005

int main() {
	long long n,ni=0,a[N],b=0,c=0;
	for(cin>>n;ni<n;ni++){
		cin>>a[ni];
		a[ni]%2?b++:c++;
	}c+=b/2;
	if(!(b%2))cout<<"YES\n";
	else cout<<"NO\n";
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <stdlib.h>

using std::cout;
using std::cin;
using std::endl;
using std::vector;

int main (int args, char** argv){
    int n, m;
    cin >> n;
    cin >> m;
    vector<int> votes;
    int sum = 0;
    for (int i = 0; i < n; i++){
        int a;
        cin >> a;
        votes.push_back(a);
        sum += a;
    }
    int popular = 0;
    for (int i = 0; i < votes.size(); i++){
        if (votes.at(i) >= sum / (4.0*m))
            popular++;
    }
    if (popular >= m){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void solve()
{
	string s;
	cin >> s;
	if (s[0] == '7' || s[1] == '7' || s[2] == '7')
		cout << "Yes";
	else
	{
		cout << "No";
	}
}
int main(void)
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	solve();

	return 0;
}


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

using namespace std;

int main()
{
	string s, t;
	cin >> s >> t;
	bool ok = false;
	for (int i = 0; i < s.size(); i++)
		if (s == t.substr(i, s.size() - i) + t.substr(0, i))
			ok = true;
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] NL = sc.nextLine().split(" ");
        int n = Integer.parseInt(NL[0]);
        int l = Integer.parseInt(NL[1]);
        String[] S = new String[n];
        for (int i = 0; i < n; i++) {
            S[i] = sc.nextLine();
        }

        Arrays.sort(S);

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            sb.append(S[i]);
        }

        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 21844
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int N, Q;
int main() {
	scanf("%d%d", &N, &Q);
	vector<int> tp(Q), s(Q), t(Q), x(Q);
	for (int i = 0; i < Q; i++) {
		scanf("%d%d", &tp[i], &s[i]);
		if (tp[i] == 0) scanf("%d%d", &t[i], &x[i]), t[i]++;
	}
	vector<int> d(N, 2147483647);
	int B = sqrt(Q);
	for (int i = 0; i < B; i++) {
		int l = 1LL * i * Q / B, r = 1LL * (i + 1) * Q / B;
		for (int j = l; j < r; j++) {
			if (tp[j] == 1) {
				bool flag = false;
				for (int k = j - 1; k >= l; k--) {
					if (tp[k] == 0 && s[k] <= s[j] && s[j] < t[k]) {
						printf("%d\n", x[k]); flag = true;
						break;
					}
				}
				if (!flag) printf("%d\n", d[s[j]]);
			}
		}
		vector<int> cp = { 0, N };
		for (int j = l; j < r; j++) {
			if (tp[j] == 0) {
				cp.push_back(s[j]);
				cp.push_back(t[j]);
			}
		}
		sort(cp.begin(), cp.end());
		cp.erase(unique(cp.begin(), cp.end()), cp.end());
		vector<int> f(cp.size() - 1, -1);
		for (int j = l; j < r; j++) {
			if (tp[j] == 0) {
				int pl = lower_bound(cp.begin(), cp.end(), s[j]) - cp.begin();
				int pr = lower_bound(cp.begin(), cp.end(), t[j]) - cp.begin();
				for (int k = pl; k < pr; k++) f[k] = x[j];
			}
		}
		for (int j = 0; j < cp.size() - 1; j++) {
			if (f[j] != -1) {
				for (int k = cp[j]; k < cp[j + 1]; k++) d[k] = f[j];
			}
		}
	}
	return 0;
}

Measured memory_bytes: 4188
s=input()
n=len(s)
dp=[[0 for i in range(4)]for j in range(n+1)]
for i in range(n,-1,-1):
  for j in range(3,-1,-1):
    if i==n:
      if j==3:
        dp[i][j]=1
      else:
        dp[i][j]=0
    else:
      if j==3:
        if s[i]=='?':
          dp[i][j]=dp[i+1][j]*3
        else:
          dp[i][j]=dp[i+1][j]
      else:
        if s[i]=='?':
          dp[i][j]=dp[i+1][j]*3+dp[i+1][j+1]
        elif (j==0 and s[i]=='A') or (j==1 and s[i]=='B') or (j==2 and s[i]=='C'):
          dp[i][j]=dp[i+1][j]+dp[i+1][j+1]
        else:
          dp[i][j]=dp[i+1][j]
    dp[i][j]%=10**9+7
print(dp[0][0])

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

#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[n]; rep(i,n){ gets(x[i]);}
#define ll long long

int main(){
  int a, b, result = 0;
  cin >> a >> b;
  FOR(i, a, b+1){
    string now = to_string(i);
    if (now[0] == now[now.length()-1] && now[1] == now[now.length()-2]) {
      result += 1;
    }
  }
  puts(result)
}


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

int main(){
  int k = 700,ans;
  char S[3];
  cin >> S;
  for (int i=0;i<3;i++){
    if (S[i]=='o')
      k = k + 100;
    ans = k;
  }
  cout << ans <<"\n";
}

Measured memory_bytes: 256
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

def calc(N, p):
	n = int(N // p)
	cnt = int((n * (n + 1) * p // 2))
	return cnt


#処理内容
def main():
	N = int(input())
	ans = 0
	for i in range(1, N + 1):
		ans += calc(N, i)

	print(ans)



if __name__ == '__main__':
	main()

Measured memory_bytes: 68048
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

int gcd(int x, int y) {
  if (x < y) swap(x, y);
  while (y > 0) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}

/*迷路
const int INF = 50;

typedef pair<int,int> P;
char field[52][52];
int d[51][51];
int r,c;
int sx,sy;
int gx,gy;

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

int bfs(){
    queue<P> que;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            d[i+1][j+1] = INF;
        }
    }
    que.push(P(sy,sx));
    d[sy][sx]=0;
while(que.size()){
    P p=que.front();
    que.pop();
    if(p.second==gx&&p.first==gy) break;
    for(int i=0;i<4;i++){
        int nx=p.second+dx[i];
        int ny=p.first+dy[i];

        if(1<=nx&&nx<=c&&1<=ny&&ny<=r&&field[ny][nx]!='#'&&d[ny][nx]==INF){
            que.push(P(ny,nx));
            d[ny][nx] = d[p.first][p.second] + 1;
        }
    }
}
return d[gy][gx];
}
*/

int main(){
    string s;
    cin>>s;
    if(s[5] == '1') cout<<"TBD"<<endl;
    else{
        if(s[6]-'0'>4) cout<<"TBD"<<endl;
        else cout<<"Heisei"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define FL "a"
using namespace std;
typedef long long ll;
typedef long double dd;
const int N=305;
const int inf=2147483647;
const dd pi=acos(-1);
const ll INF=1ll<<60;
const int mod=998244353;
inline ll read(){
  ll data=0,w=1;char ch=getchar();
  while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
  if(ch=='-')w=-1,ch=getchar();
  while(ch<='9'&&ch>='0')data=data*10+ch-48,ch=getchar();
  return data*w;
}
inline void file(){
  freopen(FL".in","r",stdin);
  freopen(FL".out","w",stdout);
}

int n,m,a[N][N],now[N],in[N],p[N][N],r;
inline int poww(int a,int b){
  int res=1;
  for(;b;b>>=1,a=1ll*a*a%mod)
    if(b&1)res=1ll*res*a%mod;
  return res;
}

int main()
{
  n=read();m=read();
  for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++)a[i][j]=read();
  for(int i=1;i<=n;i++){
    memcpy(now,a[i],sizeof(now));
    for(int j=1;j<=m;j++)
      if(now[j]){
	if(in[j])for(int k=j;k<=m;k++)now[k]^=p[j][k];
	else{in[j]=1;memcpy(p[j],now,sizeof(p[j]));r++;break;}
      }
  }
  printf("%lld\n",1ll*(poww(2,n)-poww(2,n-r)+mod)%mod*poww(2,m-1)%mod);
  return 0;
}


Measured memory_bytes: 1024
import numpy as np
n, m, c = map(int, input().split())
B = np.array(list(map(int, input().split())))
t = 0
for i in range(n):
  A = np.array(list(map(int, input().split())))
  C = A * B
  test = 0
  for j in range(m):
      test += C[j] 
  test += c
  if test > 0:
    t += 1
print(t)

Measured memory_bytes: 12488
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

int main(){
    long long A,B;
    double b;

    cin >> A >> b;

    B = round(b * 100);

    long long ans = A * B / 100LL;
    cout  << ans << endl;

    return 0;
}


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

#define repo(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;

int main(){

    int X, Y, Z;
    cin >> X>> Y >> Z;

    cout << Z << " " << X << " " <<Y<< endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<map>
using namespace std;
int UF[100000];
int FIND(int a){
	if(UF[a]<0)return a;
	return UF[a]=FIND(UF[a]);
}
void UNION(int a,int b){
	a=FIND(a);b=FIND(b);
	if(a==b)return;
	UF[a]+=UF[b];UF[b]=a;
}
char in[2];
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int x[30000];
int y[30000];
char d[30000];
int main(){
	int a;
	while(scanf("%d",&a),a){
		map<pair<int,int>,int>m;
		for(int i=0;i<a*4;i++)UF[i]=-1;
		for(int i=0;i<a;i++){
			int p,q;
			scanf("%d%d%s",&p,&q,in);
			x[i]=p;y[i]=q;d[i]=in[0];
			m[make_pair(p,q)]=i*2;
			if(in[0]=='y'){
				m[make_pair(p,q+1)]=i*2+1;
			}else{
				m[make_pair(p+1,q)]=i*2+1;
			}
			UNION(i*2*2,(i*2+1)*2+1);UNION(i*2*2+1,(i*2+1)*2);
		}
		for(int i=0;i<a;i++){
			int xt=x[i];int yt=y[i];
			if(d[i]=='x')xt++;
			else yt++;
			for(int j=0;j<4;j++){
				if(x[i]+dx[j]==xt&&y[i]+dy[j]==yt)continue;
				if(!m.count(make_pair(x[i]+dx[j],y[i]+dy[j])))continue;
				UNION(i*2*2,m[make_pair(x[i]+dx[j],y[i]+dy[j])]*2);
				UNION(i*2*2+1,m[make_pair(x[i]+dx[j],y[i]+dy[j])]*2+1);
			}
			for(int j=0;j<4;j++){
				if(x[i]-dx[j]==xt&&y[i]-dy[j]==yt)continue;
				if(!m.count(make_pair(xt+dx[j],yt+dy[j])))continue;
				UNION((i*2+1)*2,m[make_pair(xt+dx[j],yt+dy[j])]*2);
				UNION((i*2+1)*2+1,m[make_pair(xt+dx[j],yt+dy[j])]*2+1);
			}
		}
		bool ok=true;
		for(int i=0;i<a*2;i++)if(FIND(i*2)==FIND(i*2+1))ok=false;
		if(ok)printf("Yes\n");
		else printf("No\n");
	}
}

Measured memory_bytes: 3960
#include<bits/stdc++.h>
#define rep(i, x) for (ll i = 0; i < (x); i++)

using namespace std;
typedef long long int ll;

int main(void) {
  char c;
  cin >> c;
  if ('a' <= c && c <= 'z') {
    cout << 'a' << endl;
  } else {
    cout << 'A' << endl;
  }
  return 0;
}


Measured memory_bytes: 3552
S=input()
count=0
for i in range(len(S)):
    cur_count=1
    if S[i]=="R":
        for j in range(i+1,len(S)):
            if S[j]!=S[i]:
                break
            cur_count+=1
        if cur_count > count : 
                count = cur_count
    
print(count)  
    

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

int main() {
    int n;
    cin >> n;
    ll c;
    cin >> c;
    ll x[n];
    ll xinv[n];
    ll v[n];
    rep(i,n){
        cin >> x[i] >> v[i];
        xinv[i]=c-x[i];
    }
    ll mx[n];
    ll mxinv[n];
    ll xn[n];
    ll xninv[n];
  	ll lz=0;
    rep(i,n){
        if(i==0){
            xn[i]=v[i];
            mx[i]=max(lz,v[i]-2*x[i]);
        }
        else{
            xn[i]=xn[i-1]+v[i];
            mx[i]=max(mx[i-1],xn[i]-2*x[i]);
        }
    }
    for(int i=n-1;i>=0;i--){
        if(i==n-1){
            xninv[i]=v[i];
            mxinv[i]=max(lz,v[i]-xinv[i]);
        }
        else{
            xninv[i]=xninv[i+1]+v[i];
            mxinv[i]=max(mxinv[i+1],xninv[i]-xinv[i]);
        }
    }
    ll sum=0;
    rep(i,n-1)chmax(sum,mx[i]+mxinv[i+1]);
  	chmax(sum,mxinv[0]);
    chmax(sum,mx[n-1]);
    rep(i,n){
        if(i==0){
            mx[i]=max(lz,v[i]-x[i]);
        }
        else{
            mx[i]=max(mx[i-1],xn[i]-x[i]);
        }
    }
    for(int i=n-1;i>=0;i--){
        if(i==n-1){
            mxinv[i]=max(lz,v[i]-2*xinv[i]);
        }
        else{
            mxinv[i]=max(mxinv[i+1],xninv[i]-2*xinv[i]);
        }
    }
    rep(i,n-1)chmax(sum,mx[i]+mxinv[i+1]);
  	chmax(sum,mxinv[0]);
    chmax(sum,mx[n-1]);
    cout << sum;
}

Measured memory_bytes: 5760
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;


int main(void) {
	long long int N,ans;
	ans=0;
	cin >> N;
	vector<long long int> a(5);
	for (int i = 0; i < 5; i++)cin >> a[i];
	sort(a.begin(), a.end());
	if(N%a[0]==0)ans += N / a[0];
	else ans += N / a[0] + 1;
	cout << ans + 4 << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[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; }
using P = pair<int, int>;
void prp(P& p) {cout << p.first << " " << p.second << endl;}
vector<string> a;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, 1, -1};
int h, w; 

bool is_allb(int i, int j){
    rep(k, 4){
        int x = i + dx[k];
        int y = j + dy[k];
        if(x < 0 || x >= h || y < 0 || y >= w) continue;
        if(a[x][y]=='.') return false; 
    }
    return true;
}

int main()
{
    cin >> h >> w;
    a.resize(h);
    rep(i, h) cin >> a[i];
    queue<P> que;
    int black = 0;
    rep(i, h) rep(j, w) if(a[i][j]=='#'){
        black++;
        if(!is_allb(i, j)) que.push({i, j});
    } 

    int cnt = 0;
    while(black<h*w){
    // while(!que.empty()){
        queue<P> tque;
        cnt++;
        while(!que.empty()){
            P p = que.front(); que.pop();
            rep(k, 4){
                int x = p.first + dx[k];
                int y = p.second + dy[k];
                if(x < 0 || x >= h || y < 0 || y >= w) continue;
                if(a[x][y]=='.') {
                    a[x][y] = '#';
                    black++;
                    if(!is_allb(x,y)) tque.push({x, y});
                }
            }
        }
        que = tque;
    }
    pr(cnt);
    return 0;}

Measured memory_bytes: 12572
from collections import defaultdict

N, Q = map(int, input().split())
edges = defaultdict(set)
for _ in range(N-1):
    a, b = map(int, input().split())
    edges[a].add(b)
    edges[b].add(a)
PX = []
for _ in range(Q):
    PX.append(list(map(int, input().split())))

direct_score = defaultdict(int)
final_score = {}

for px in PX:
    direct_score[px[0]] += px[1]

stack = [(1, 0)]

while stack:
    node, score = stack.pop()
    if node in final_score:
        continue
    score += direct_score[node]
    final_score[node] = score
    for child in edges[node]:
        stack.append((child, score))

print(' '.join([str(final_score[i]) for i in range(1, N+1)]))

Measured memory_bytes: 173096
#include <bits/stdc++.h>
#define N 2020
#define mod 924844033
#define ll long long
using namespace std;
inline int read(){
  int x=0,f=1;char ch=getchar();
  while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
  while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
  return f?x:-x;
}
bool is_end[N];
int dp[N<<1][N][2], a[N];
ll frac[N];
int main(int argc, char const *argv[]) {
  // freopen("../../temp/.in", "r", stdin);
  int n = read(), k = read();
  int top = 1;
  for (int i = frac[0] = 1; i <= n; ++ i) {
    frac[i] = frac[i - 1] * i % mod;
  }
  for (int i = 1; i <= k; ++ i) {
    int len = (n - i) / k + 1;
    is_end[top] = 1; top += len;
    is_end[top] = 1; top += len;
  }
  dp[0][0][0] = 1;
  for (int i = 1; i <= 2 * n; ++ i) {
    for (int j = 0; j <= i / 2; ++ j) {
      dp[i][j][0] = (dp[i-1][j][0] + dp[i-1][j][1]) % mod;
      if (!is_end[i]) {
        dp[i][j][1] = dp[i-1][j-1][0];
      }
    }
  }
  ll ans = 0;
  for (int i = 0; i <= n; ++ i) {
    ll value = (dp[2*n][i][0] + dp[2*n][i][1]) % mod * frac[n-i] % mod;
    if (i & 1) value = (mod - value) % mod;
    ans = (ans + value) % mod;
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 62208