akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
	while(cin>>n){
		int ans=0;
		
		for(int a=0;a<10;a++){
			for(int b=0;b<10;b++){
				for(int i=0;i<10;i++){
					for(int j=0;j<10;j++){
						if(n==a+b+i+j){
							++ans;
						}
					}
				}
			}
		}
	cout<<ans<<endl;
	}
}
		


Measured memory_bytes: 3016
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
  int i,j;
  int n,m,r;
  while(cin>>n>>m>>r,n||m||r){
    r*=4;
    int x[100000],y[100000];
    for(i=0;i<n;++i)
      cin>>x[i]>>y[i];
    vector<int> a[10000];
    for(i=0;i<m;++i){
      int p,q;
      cin>>p>>q;
      a[q].push_back(p);
    }
    for(i=0;i<10000;++i)
      sort(a[i].begin(),a[i].end());
    int b[90],c[90];
    for(i=-r;i<=r;++i){  
      for(j=-40;i*i+j*j>r*r;++j);
      b[i+40]=j;
      for(;i*i+j*j<=r*r;++j);
      c[i+40]=j;
    }
    int sm=0;
    for(i=0;i<n;++i){  
      for(j=y[i]-r;j<=y[i]+r;++j){
	if(0<=j&&j<10000){
	  vector<int>::iterator it=lower_bound(a[j].begin(),a[j].end(),x[i]+b[j-y[i]+40]);
	  sm+=lower_bound(it,a[j].end(),x[i]+c[j-y[i]+40])-it;
	}
      }
    }
    cout<<sm<<endl;
  }
  return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 3e5+23;

set<pair<int, int>> s;
pair<int, int> H[N], W[N];

void solve() {
  int h, w, m; scanf("%d%d%d", &h, &w, &m);
  for (int i = 0; i < m; ++i) {
    int x, y; scanf("%d%d", &x, &y);
    s.emplace(--x, --y);
    ++H[x].first;
    ++W[y].first;
  }
  for (int i = 0; i < h; ++i)
    H[i].second = i;
  for (int i = 0; i < w; ++i)
    W[i].second = i;
  int cnt = 0, a = max_element(H, H+h)->first, b = max_element(W, W+w)->first;
  for (const auto &e: s) {
    cnt += (H[e.first].first+W[e.second].first) == (a+b);
  }
  int cntH = 0, cntW = 0;
  for (int i = 0; i < h; ++i)
    cntH += (H[i].first == a);
  for (int i = 0; i < w; ++i)
    cntW += (W[i].first == b);
  if (1LL*cntH*cntW > cnt)
    printf("%d", a+b);
  else
    printf("%d", a+b-1);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 22576
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

void rot45(int &x,int &y){
  int tmp = x + y;
  x = x - y;
  y = tmp;
}

signed main(){

  int n; cin >> n;
  vector<int> x(n),y(n);
  vector<int> s(n); //関節iとi+1の差の偶奇が等しければok
  for(int i = 0; i < n; i++){
    cin >> x[i] >> y[i];
    s[i] = x[i] + y[i];
    if((s[i] - s[0])%2 != 0){
      cout << -1 << endl;
      return 0;
    }
  }

  vector<int> v;
  for(int i = 30; i >= 0; i--) v.push_back(1 << i);
  if(s[0]%2 == 0) v.push_back(1);

  cout << v.size() << endl;
  for(int p : v) cout << p << " ";
  cout << endl;

  for(int i = 0; i < n; i++){
    rot45(x[i], y[i]);
    for(int p : v){
      if(x[i] >= 0 && y[i] >= 0){
        cout << "R";
        x[i] -= p, y[i] -= p;
      }
      else if(x[i] >= 0 && y[i] < 0){
        cout << "D";
        x[i] -= p, y[i] += p;
      }
      else if(x[i] < 0 && y[i] < 0){
        cout << "L";
        x[i] += p, y[i] += p;
      }
      else if(x[i] < 0 && y[i] >= 0){
        cout << "U";
        x[i] += p, y[i] -= p;
      }
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int a;
  cin>>a;
  cout<<a+a*a+a*a*a<<newl;
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    if (v.size() == 0) return os;
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    os << v[v.size() - 1];
    return os;
}
ll extgcd(ll a,ll b, ll &x, ll &y){ //extended Euclidean algorithm, used for modular multiplicative inverse
    ll d = a;
    if (b != 0){
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    }else{
        x = 1; y = 0;
    }
    return d; //return gcd(a,b)
}

ll mod_inv(ll a, ll m = MOD){ //return inv(a) mod m, ax+my=gcd(a,m)=1, m is prime int, ax-1=mq equiv. ax-mq=1
    ll x, y;
    extgcd(a, m, x, y);
    return (m + x % m) % m; //From (possibly) negative x to positive x
}

vector<ll> fact,invfact;
void calc_fact(int n, ll m = MOD)
{ //Calculate factorial up to n
    fact.resize(n + 1);
    invfact.resize(n + 1);
    fact[0] = invfact[0] = 1;
    REP(i, n)
    {
        fact[i + 1] = fact[i] * (i + 1) % m;
        invfact[i + 1] = invfact[i] * mod_inv(i + 1) % m;
    }
}
ll perm(int n,int k ,ll m = MOD){
    if(n<0||k<0||k>n)return 0;
    return fact[n] * invfact[n - k] % m;
}
ll comb(int n,int k, ll m = MOD){
    if(n<0||k<0||k>n)return 0;
    return (fact[n] * invfact[n - k] % m) * invfact[k] % m;
}


void solve() {
    ll s;
    cin >> s;
    ll ans = 0;
    calc_fact(5000);
    FOR(i,1,s+1) {
        ll tot = s;
        tot -= 3*i;
        if (tot < 0) break;
        ll shiki = i-1;
        ans = (ans + comb(shiki+tot, shiki)) % MOD;
    }
    cout << ans << endl;
}

int main() {
    solve();
    char tmp;
    while (cin >> tmp) {
        cin.putback(tmp);
        solve();
    }
}



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

        int main() {
          string S;
          cin>> S; 
          int c=0; 
          int M=0;
          for(int i=0; i< S.size(); i++){
          	if(S.at(i)=='A' || S.at(i)=='T' || S.at(i)=='C' || S.at(i)=='G'){
              c++;
              M=max(M,c); 
            }
          	else{
              c=0; 
            }
          }
          cout<< M << endl;
        }

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL n;
  cin >> n;
  vector<LL> a(n);
  for(auto &x:a) cin >> x;
  vector<LL> su(1);
  for(auto x:a) su.push_back(su.back()+x);
  LL answer = su[n];
  FOR(i,2,n-1) {
    LL p[2],q[2],r[2],s[2];
    auto lite = upper_bound(su.begin(),su.begin()+i,(su[i]+1)/2);
    p[0] = *lite;
    q[0] = su[i] - *lite;
    if(lite != su.begin()) --lite;
    p[1] = *lite;
    q[1] = su[i] - *lite;
    auto rite = upper_bound(su.begin()+i,su.begin()+n+1,(su[i]+su[n]+1)/2);
    if(rite == su.end()) --rite;
    r[0] = *rite - su[i];
    s[0] = su[n] - *rite;
    --rite;
    r[1] = *rite - su[i];
    s[1] = su[n] - *rite;
    REP(j,2) REP(k,2) {
      LL tmp = 0;
      tmp = max(tmp, abs(p[j]-q[j]));
      tmp = max(tmp, abs(p[j]-r[k]));
      tmp = max(tmp, abs(p[j]-s[k]));
      tmp = max(tmp, abs(q[j]-r[k]));
      tmp = max(tmp, abs(q[j]-s[k]));
      tmp = max(tmp, abs(r[k]-s[k]));
      answer = min(answer, tmp);
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3956
#include <stdio.h>
#include <math.h>

int n;
double x[150],y[150];
double pi;
#define eps 1e-7
int get(double i, double j) {
	int k,r;
	r=0;
	for(k=0;k<n;k++)if(hypot(x[k]-i,y[k]-j)-eps<=1.) r++;
	return r;
}
int main() {
	int i,j,r,t;
	pi=acos(-1.);
	while(scanf("%d",&n), n) {
		for(i=0;i<n;i++) {
			scanf("%lf,%lf",&x[i],&y[i]);
		}
		r=0;
		for(i=0;i<n;i++)for(j=0;j<1000;j++){
			t=get(x[i]+cos(j/1000.*pi*2),y[i]+sin(j/1000.*pi*2));
			if(r<t)r=t;
		}
		printf("%d\n",r);
	}
	return 0;
}

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

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

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

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        s: chars,
    }
    let xs: Vec<i64> = s
        .iter()
        .map(|&c| ((c as u8) - ('0' as u8)) as i64)
        .collect();
    for iset in 0..1 << (s.len() - 1) {
        let mut r = xs[0];
        r += if iset & 1 > 0 { xs[1] } else { -xs[1] };
        r += if iset & 2 > 0 { xs[2] } else { -xs[2] };
        r += if iset & 4 > 0 { xs[3] } else { -xs[3] };
        if r == 7 {
            println!(
                "{}{}{}{}{}{}{}=7",
                xs[0],
                if iset & 1 > 0 { '+' } else { '-' },
                xs[1],
                if iset & 2 > 0 { '+' } else { '-' },
                xs[2],
                if iset & 4 > 0 { '+' } else { '-' },
                xs[3],
            );
            return;
        }
    }
}


Measured memory_bytes: 4352
def main():
    import sys
    X, Y = map(int, sys.stdin.readline().split())
    #Y = T*2 + K*4
    #X = T+K
    a = (4*X -Y)/2
    b = (-2*X+Y)/2
    if int(a)==a and int(b)==b:
        if a>=0 and b>=0:
            print('Yes')
        else:
            print('No')
    else:
        print('No')







if __name__=='__main__':
    main()

Measured memory_bytes: 9180
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

struct BIT{
	int size;
	vector<llint> bit;
	BIT(){size = 0;}
	BIT(int s){
		size = s;
		bit.resize(size+1);
		init();
	}
	void init(){
		for(int i = 1; i <= size; i++) bit[i] = 0;
	}
	llint query(int i){
		llint ret = 0;
		while(i > 0){
			ret += bit[i];
			i -= i&(-i);
		}
		return ret;
	}
	void add(int i, llint x){
		while(i <= size){
			bit[i] += x;
			i += i&(-i);
		}
	}
};

string s;
BIT bit(1000005);

void update(llint p, llint x)
{
	llint v = bit.query(p), d = x - v;
	bit.add(p, d), bit.add(p+1, -d);
}

llint get(llint l, llint r)
{
	llint ub = r+1, lb = l-1, mid;
	while(ub-lb>1){
		mid = (ub+lb)/2;
		llint res = bit.query(mid);
		if(res > 0){
			if(res > inf/2){
				if(bit.query(mid+1) > 0 || bit.query(mid-1) > 0) lb = mid;
				else ub = mid;
			}
			else lb = mid;
		}
		else ub = mid;
	}
	return lb;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> s;
	llint n = s.size();
	s = "#" + s;
	
	bit.add(1, inf);
	update(1000002, 0);
	
	llint l = 1000002, r = 1000002, k = 1000002;
	for(int i = 1; i <= n; i++){
		if(s[i] == '0'){
			llint res = get(l, r);
			//cout << res << endl;
			if(res >= l) bit.add(l, -1), bit.add(res+1, 1);
			l--;
			update(l, inf);
		}
		if(s[i] == '1'){
			bit.add(l, 1), bit.add(r+1, -1);
			if(l < r) l++;
			llint x = min(bit.query(l-1), bit.query(l));
			update(l, x);
			update(l-1, inf);
		}
		if(s[i] == '?'){
			if(l == k){
				llint x = min(bit.query(k), bit.query(k+1))+1;
				llint res = get(l, r);
				//cout << "!" << res << endl;
				if(res >= l) bit.add(l, -1), bit.add(res+1, 1);
				l--; k--;
				update(k, x);
			}
			else{
				llint x = bit.query(k+1)+1, y = bit.query(k)+1;
				llint res = get(l, r);
				if(res >= l) bit.add(l, -1), bit.add(res+1, 1);
				l--; k-=2;
				update(k, y), update(k+1, x);
			}
		}
		k = max(l, k);
		//for(int i = l; i <= r; i++) cout << bit.query(i) << " "; cout << endl;
	}
	
	llint ans = inf;
	for(int i = l; i <= r; i++){
		ans = min(ans, bit.query(i)+(i-l));
	}
	cout << ans << endl;
	
	return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/03/03  Problem: code-festival-2016-ex-final_a / Link: https://cf16-exhibition-final.contest.atcoder.jp/tasks/cf16_exhibition_final_a?lang=en  ----- */
/* ------問題------

一次元の世界に N 個のパソコンと N 個の電源があります。 i 番目のパソコンの座標は ai であり、 i 番目の電源の座標は bi です。 これらの 2N 個の座標は相異なることが保証されています。
すぬけ君は、それぞれのパソコンをケーブルで電源につなぎたいです。 それぞれの電源は一つのパソコンにのみつなぐことができます。
何通りの方法で、ケーブルの長さの合計を最小化できるでしょうか？ 答えを modulo 109+7 で求めてください。

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	cin >> N;
	VL a(N), b(N);
	vector<PLL>v;
	FOR(i, 0, N) {
		cin >> a[i];
		v.push_back(PLL(a[i], 1));
	}
	FOR(i, 0, N) {
		cin >> b[i];
		v.push_back(PLL(b[i], -1));
	}
	SORT(v);
	ans = 1;
	int size = 0;
	FOR(i, 0, SZ(v)) {
		if (size != 0 && (size > 0) != (v[i].second > 0)) {
			ans = (ans * abs(size)) % MOD;
		}
		size += v[i].second;
		debug(ans);
		debug(size);
	}


	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 7920
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<lint> a(n);
    for (int i=0; i<n; ++i){
        cin >> a[i];
    }
    lint ans;
    int minus = 0;
    for (int i=0; i<n; ++i){
        if(a[i] < 0){
            minus++;
        }
    }
    if(minus % 2 == 0){
        ans = 0;
        for (int i=0; i<n; ++i){
            ans += abs(a[i]);
        }
    }
    else {
        ans = 0;
        int itr = -1;
        lint absmin = LINF;
        for (int i=0; i<n; ++i){
            if(absmin > abs(a[i])){
                itr = i;
                absmin = abs(a[i]);
            }
        }
        // debugpair(itr, absmin);
        bool isChecked = false;
        for (int i=0; i<n; ++i){
            if(!isChecked && abs(a[i]) == absmin){
                ans += -abs(a[i]);
                isChecked = true;
            }
            else {
                ans += abs(a[i]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#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()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    vector<vector<ll>> a(3, vector<ll>(3));
    REP(i, 3) REP(j, 3) cin >> a[i][j];
    ll n;
    cin >> n;
    vector<ll> b(n);
    REP(i, n) cin >> b[i];

    vector<vector<bool>> x(3, vector<bool>(3));
    REP(i, 3) REP(j, 3) {
        REP(k, n) if(a[i][j] == b[k]) {
            x[i][j] = true;
        }
    }

    bool flag = false;
    REP(i, 3) {
        if(x[0][i] && x[1][i] && x[2][i]) flag = true;
        if(x[i][0] && x[i][1] && x[i][2]) flag = true;
    }
    flag |= x[0][0] && x[1][1] && x[2][2];
    flag |= x[0][2] && x[1][1] && x[2][0];

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll n;
    cin >> n;
    string ans;
    while(n > 0) {
        --n;
        ans += 'a' + (n % 26);
        n /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 3656
#include <stdio.h>

int main(void){
  char S[4];
  char R[4]="ARC";
  char B[4]="ABC";
  int i;

  scanf("%s",&S);

  if(!strcmp(S,"ARC")){
printf("ABC");
  }
  else if(!strcmp(S,"ABC")){
printf("ARC");
  }
  return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  int A, B; cin >> A >> B;
  string S; cin >> S;
  
  rep(i,A) if(!('0'<=S[i]&&S[i]<='9')) {
    cout << "No" << endl;
    return 0;
  }
  if (S[A]!='-') {
    cout << "No" << endl;
    return 0;
  }
  repi(i,A+1,A+B) if(!('0'<=S[i]&&S[i]<='9')) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target ("arch=skylake-avx512")
using namespace std;
using VI = vector<int>;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define all(v) v.begin(), v.end()

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

  int n, q; cin >> n >> q;
  VI c(n); rep(i, n) cin >> c[i];
  vector<pair<int, int>> lr(q); rep(i, q) cin >> lr[i].first >> lr[i].second;
  rep(i, q) lr[i].first--;

  const int sq = 10;
  VI ri(q), lri(q);
  VI cnt(n+1);
  rep(i, q) cnt[lr[i].second]++;
  rep(i, n) cnt[i+1] += cnt[i];
  repr(i, q) ri[--cnt[lr[i].second]] = i;
  fill(all(cnt), 0);
  rep(i, q) cnt[lr[i].first >> sq]++;
  rep(i, n) cnt[i+1] += cnt[i];
  repr(i, q) lri[--cnt[lr[ri[i]].first >> sq]] = ri[i];
  fill(all(cnt), 0);

  VI ans(q);

  int prev = -1;
  int lx, rx;
  int sum = 0;
  for (auto i : lri) {
    auto [l, r] = lr[i];
    if (l >> sq != prev) {
      fill(all(cnt), 0);
      lx = rx = r;
      prev = l >> sq;
      sum = 0;
    }
    int cx;
    while (lx > l) if (cnt[cx=c[--lx]]++ == 0) sum += 1;
    while (lx < l) if (--cnt[c[lx++]] == 0) sum -= 1;
    while (rx < r) if (cnt[cx=c[rx++]]++ == 0) sum += 1;
    ans[i] = sum;
  }
  rep(i, q) cout << ans[i] << "\n";
}


Measured memory_bytes: 17404
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template<typename T> T lcm(const T a, const T b) {
    return a / gcd(a, b) * b;
}

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

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

// End of template.

int main() {
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cin.read(buf, sizeof buf); // 注意: ./a.out < in か pbp | ./a.out で入力すること

    int n, a[200];
    cin >> n;
    rep(i, n) cin >> a[i];

    bool flag = true;
    rep (i, n) {
        int x = a[i];
        if (x % 2 == 0 && (x % 3 != 0 && x % 5 != 0)) {
            flag = false;
        }
    }

    if (flag)
        print("APPROVED\n");
    else
        print("DENIED\n");


    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	void main() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i=0;i<n;i++) {
			a[i] = sc.nextInt();
		}
		System.out.print(a[n-1]);
		for(int i=n-2;i>=0;i--) {
			System.out.print(" " + a[i]);
		}
		System.out.println();
		
	}
	
	public static void main(String[] args) {
		new Main().main();
	}

}



Measured memory_bytes: 26188
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

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

func lowerBound(a []int, x int) int {
	n := len(a)
	ok := n
	ng := -1
	for ok-ng > 1 {
		mid := (ok + ng) / 2
		if a[mid] >= x {
			ok = mid
		} else {
			ng = mid
		}
	}
	return ok
}

func main() {
	var buffer []byte = make([]byte, 1024*1024)
	sc.Buffer(buffer, 1024*1024)
	s := strings.TrimSpace(next())
	t := strings.TrimSpace(next())

	idxs := make([][]int, 256)
	for i := 0; i < len(s); i++ {
		idxs[s[i]] = append(idxs[s[i]], i)
	}

	n := int64(len(s))
	cur := int64(0)
	ng := false

	for i := 0; i < len(t); i++ {
		is := idxs[t[i]]
		if is == nil || len(is) == 0 {
			ng = true
			break
		}
		base := (cur / n) * n

		nidx := lowerBound(is, int(cur%n))
		if nidx == len(is) {
			cur = base + int64(is[0]) + n + 1
		} else {
			cur = base + int64(is[nidx]) + 1
		}
	}
	if ng {
		fmt.Println(-1)
	} else {
		fmt.Println(cur)
	}
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

ll M;

void solve() {
	cin >> M;
	ll sum = 0;
	ll res = 0;
	while(M--) {
		ll d, c; cin >> d >> c;
		res += c;
		sum += d * c;
	}
	cout << res - 1 + (sum - 1) / 9 << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

ll f(ll x,ll c,ll d){
    ll res =x;
    res -=x/c;
    res -=x/d;
    res+= x/lcm(c,d);
    return res;
}

int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll>v(n+1,-1);
    v[0]=1;
    v[1]=1;
    ll a;
    rep(i,m){
       cin>>a;
       v[a]=0;
    }
    for(ll i=2;i<n+1;i++){
        if(v[i]!=0){
        v[i]=(v[i-1]+v[i-2])%1000000007;
        }
    }
    cout<<v[n]%1000000007<<endl;
}


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

void dfs(int s, vector<int > adj[],long long int val[],long long int out[],long long int ret, long long int vis[]){
	vis[s] = 1;
	out[s] = ret + val[s];
	for (int i=0;i<adj[s].size();i++){
		int v = adj[s][i];
		if (!vis[v]){
			dfs(v, adj, val, out, ret+val[s], vis);
		}
	}
}

int main(){
	int n,q, a,b;
	cin>>n>>q;
	vector<int > adj[n+1];
	long long int val[n+1] = {0}, vis[n+1]= {0};
	long long int out[n+1];
	for (int i=0;i<n-1;i++){
		cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	for (int i=0;i<q;i++){
		cin>>a>>b;
		val[a]+=b;
	}
	dfs(1, adj, val, out, 0, vis);
	for (int i=1;i<=n;i++)
		cout<<out[i]<<" ";
}

Measured memory_bytes: 33664
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


int main(){
  string s;
  cin >> s;
  int n = s.size();
  int res = 0;
  for(int i = 0; i < n/2; ++i)
  {
    if(s[i] != s[n - 1 - i])++res;

  }
  cout << res << endl;

  return 0;    
}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
map<ll,int> s;
map<ll,bool> h;
const int maxn=100000+10,maxd=2200;
int id[maxn],pri[maxn],f[maxn],p[maxn][2],sta[maxn];
ll a[maxn],b[maxn];
bool bz[maxn];
int i,j,l,n,m,tot,top,cnt,ans,ca;
ll k,t;
int main(){
    fo(i,2,maxn-10){
        if (!bz[i]) pri[++top]=i,f[i]=i;
        fo(j,1,top){
            if ((ll)i*pri[j]>maxn-10) break;
            bz[i*pri[j]]=1;
            f[i*pri[j]]=pri[j];
            if (i%pri[j]==0) break;
        }
    }
    scanf("%d",&n);
    fo(i,1,n){
        scanf("%lld",&a[i]);
        k=a[i];
        a[i]=b[i]=1;
        fo(j,2,maxd){
            if (k==1) break;
            if (bz[j]) continue;
            t=(ll)j*j*j;
            while (k%t==0) k/=t;
            t=j*j;
            if (k%t==0){
                a[i]*=t;
                b[i]*=j;
            }
            else if (k%j==0){
                a[i]*=j;
                b[i]*=t;
            }
            while (k%j==0) k/=j;
        }
        if (k>1){
            t=ll(sqrt(k));
            if (t*t==k){
                a[i]*=k;
                b[i]*=t;
            }
            else{
                a[i]*=k;
                b[i]*=k*k;
            }
        }
    }
    fo(i,1,n) s[a[i]]++;
    fo(i,1,n)
        if (!h[a[i]]){
            h[a[i]]=1;
            if (a[i]==b[i]) ans++;
            else{
                ans+=max(s[a[i]],s[b[i]]);
                h[b[i]]=1;
            }
        }
    /*ca=20;
    fo(i,1,n) id[i]=i;
    while (ca--){
        random_shuffle(id+1,id+n+1);
        tot=0;
        fo(i,1,n)
            if (!s[b[id[i]]]){
                sta[++tot]=id[i];
                s[a[id[i]]]=1;
            }
        ans=max(ans,tot);
        fo(i,1,tot) s[a[sta[i]]]=0;
    }*/
    printf("%d\n",ans);
}

Measured memory_bytes: 27392
MOD = 10**9 + 7
N = 2 * 10**6 + 10  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod MOD)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod MOD)
inv = [0, 1]  

def nCr(n, r, mod):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % mod
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    factinv.append((factinv[-1] * inv[-1]) % MOD)

k = int(input())
s = len(input())

ans = 0
for i in range(k+1):
    ansp =  pow(26,i,MOD) * pow(25,k-i,MOD) * nCr(s+k-1-i,s-1,MOD) % MOD 
    ans = (ans + ansp) % MOD
print(ans)


Measured memory_bytes: 222536
n = input()    
m = n.split()
p = [int(i) for i in m]
from collections import deque
list = []
for i in range(p[0]-1): #因数注意！
    n = input()    
    m = n.split()
    q = [int(i) for i in m] #1列の数列をリスト化
    list.append(q)
l = [[] for i in range(p[0]+1)]
for pi in list:  #0-originedに注意
    l[pi[0]].append(pi[1])
    l[pi[1]].append(pi[0])
sousa = deque([[p[2],0,0]]) #[捜査対象ノード,親ノード,そのノードの距離]
node = [[] for i in range(p[0])] #n番目のリストにn+1について[親ノード,rootからの距離,子ノード]
while len(sousa) != 0:
    a = sousa.popleft()
    b = l[a[0]]
    if a[1]!=0:
        b.remove(a[1])
    if len(b) == 0:
        pass
    else:
        for i in b:
            sousa.append([i,a[0],a[2]+1])
    node[a[0]-1] = [a[1]] + [a[2]] + b
dis = node[p[1]-1][1]
takahashi = p[1]
max = dis
hate = p[1]
for i in range((dis+1)//2):
    tansaku = deque([[takahashi,dis]])
    if i >= 1:
        kitatoko = takahashi
        takahashi = node[takahashi-1][0]
        a = tansaku.popleft()
        b = node[takahashi-1][2:]
        b.remove(kitatoko)
        if len(b) == 0:
            continue
        else:
            for j in b:
                tansaku.append([j,dis+1-i])

    while len(tansaku) != 0:
        a = tansaku.popleft()
        b = node[a[0]-1][2:]
        print()
        if len(b) == 0:
            pass
        else:
            for j in b:
                tansaku.append([j,a[1]+1])

    if max < a[1]:
        max = a[1]
        hate = a[0]
print(node[hate-1][1]-1)

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

int main() {
  int n,d,x;
  cin >>n>>d>>x;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  int sum=n;
  for(int i=0;i<n;i++){
    //cout<<(d-1)/a[i]*x<<endl;
    sum+=(d-1)/a[i];
  }
  cout<<sum+x<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4

int main(){
  int A, B, H, M; cin >> A >> B >> H >> M;

  int minute = 60*H+M;
  double thetaA = minute*2*pi/(12.0*60);
  double thetaB = minute*2*pi/60.0;

  double C = sqrt(1.0*A*A+1.0*B*B-2*A*B*cos(thetaA-thetaB));

  cout << fixed << setprecision(10);
  cout << C << endl;

  
  return 0;
}

Measured memory_bytes: 4192
// c Make a rectangle

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n, t;
	cin>>n;
	
	int arr[n];
	
	for(int i=0;i<n;i++) cin>>arr[i];
	
    
    sort(arr,arr+n);
    
    int l = 0,b = 0;
    
    bool f1 = false, f2 = false;
    
    int i=n-1;

    while(i>=1){
        if(arr[i]==arr[i-1]){
            if(!f1){
                l = arr[i];
                f1 = true;
                i--;
            }
            else if(!f2){
                b = arr[i];
                f2 = true;
                i--;
            }
            else break;
        }
        i--;
    }
    
    long long ans = 1L * l * b;
    
    printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 640
#include <iostream>

char easytolower(char in) {
  if(in <= 'Z' && in >= 'A')
    return in - ('Z' - 'z');
  return in;
}

int main()
{
    int N, K;
    std::string S;
    std::cin >> N >> K;
    std::cin >> S;
    
    for (std::size_t i = 0; i < S.size(); ++i) {
        if (i == static_cast<std::size_t>(K) - 1) {
            auto lower = easytolower(S[i]);
            S[i] = lower;
        }
    }
    std::cout << S << std::endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        class Edge
        {
            internal int to, cost, height;

            public Edge(int to, int cost, int height)
            {
                this.to = to;
                this.cost = cost;
                this.height = height;
            }
        }

        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int V = int.Parse(input[0]);
            int E = V - 1;

            Dictionary<int, List<Edge>> G = new Dictionary<int, List<Edge>>();
            for (int i = 0; i < V; i++) G.Add(i, new List<Edge>());

            for (int i = 0; i < E; i++)
            {
                input = Console.ReadLine().Split(' ');
                int s = int.Parse(input[0]);
                int t = int.Parse(input[1]);
                int w = int.Parse(input[2]);

                G[s].Add(new Edge(t, w, -1));
                G[t].Add(new Edge(s, w, -1));
            }

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < V; i++)
            {
                int height = DFS(G, -1, i);
                sb.AppendLine(height.ToString());
            }
            Console.Write(sb);
        }

        static int DFS(Dictionary<int, List<Edge>> G, int prev, int cur)
        {
            int ret = 0;

            foreach (var e in G[cur])
            {
                int next = e.to;
                if (next == prev) continue;
                if (e.height == -1) e.height = e.cost + DFS(G, cur, next);
                ret = Math.Max(ret, e.height);
            }
            return ret;
        }
    }
}

Measured memory_bytes: 14396
n = gets.to_i
a = gets.split.map(&:to_i).sort
b = gets.split.map(&:to_i).sort
c = gets.split.map(&:to_i).sort
count = 0

b.each do |j|
  x = a.bsearch_index { |i| j <= i } || n
  y = n - (c.bsearch_index { |k| j < k } || n)
  count += x * y
end

puts count

Measured memory_bytes: 27324
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
typedef long long ll;
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;
int D;
long long G;
vector<long long> p, c;

int main() {
	cin >> D >> G;
	p.resize(D); c.resize(D);
	for (int i = 0; i < D; ++i) cin >> p[i] >> c[i];

	long long res = 1 << 29;
	for (int bit = 0; bit < (1 << D); ++bit) {
		long long sum = 0;
		long long num = 0;
		for (int i = 0; i < D; ++i) {
			if (bit & (1 << i)) sum += c[i] + p[i] * 100 * (i + 1), num += p[i];
		}
		if (sum >= G) res = min(res, num);
		else {
			for (int i = D - 1; i >= 0; --i) {
				if (bit & (1 << i)) continue;
				for (int j = 0; j < p[i]; ++j) {
					if (sum >= G) break;
					sum += 100 * (i + 1);
					++num;
				}
			}
			res = min(res, num);
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	long a,b,c,d;
	cin >> a >> b >> c >> d;

	long counta,countb,count,tmp,lcm=c*d;
	countb=b/c+b/d;
	counta=(a-1)/c+(a-1)/d;
	if(c<d){
		tmp=c;
		c=d;
		d=tmp;
	}
	long r=c%d;
	while(r!=0){
		c=d;
		d=r;
		r=c%d;
	}
	lcm=lcm/d;

	countb-=b/lcm;
	counta-=(a-1)/lcm;
	count=countb-counta;
	cout << b-(a-1)-count << endl;
	return 0;
}

Measured memory_bytes: 256
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
        Scanner sc = new Scanner(System.in);
        Scanner input = new Scanner(System.in);
        int t = input.nextInt();
        int ans = t/2;
        ans+=t%2;
            System.out.println(ans);
        }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int K;
  int ans;
  int a=0;
  cin >> N >> K;
  vector<int>vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
 vector<int>count(N);
 vec.push_back(N+1);
  sort(vec.begin(),vec.end());
  for (int i=1; i<N+1; i++){
    for (int j=a; j<N+1; j++){
      if(i != vec.at(j)){
        count.at(i-1) = j-a;
        a = j;
        break;
      }
      }
    }
  sort(count.begin(),count.end());
  reverse(count.begin(),count.end());
  for (int i=0; i<K; i++){
    ans = ans + count.at(i);
  }
  cout <<N - ans<<endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
long long ans=1,N;
int main(){
    cin>>N;
    while(N--){
        long long x,a,b;
        cin>>x;
        a=x;
        b=ans;
        while(a&&b)a>b?a%=b:b%=a;
        ans/=(a+b);
        ans*=x;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <tuple>
#include <algorithm>
#include <limits>
#include <map>

using namespace std;
using lli = long long int;
using pllilli = std::pair<lli, uint32_t>;

lli N,K;
pllilli a[100010] = {};

int t[100010] = {};

int main() {

	cin >> N >> K;

	for (int i = 0; i < N; i++) {
		cin >> a[i].second >> a[i].first;
	}

	sort(a, a + N);

	lli max_score = 0, now_score = 0, kind = 0;
	uint32_t upper = N - K;

	for (int i = N - 1; i >= N - K; i--) {
		if (t[a[i].second] == 0) {
			kind++;
		}
		now_score += a[i].first;
		t[a[i].second]++;
	}

	now_score += kind * kind;
	max_score = now_score;

	//kind
	for (int i = N - K - 1; i >= 0 && upper < N; i--) {

		if (t[a[i].second] >= 1) {
			continue;
		}

		while (true) {

			if (upper == N) {
				cout << max_score << endl;
				return 0;
			}

			pllilli tmp = a[upper];
			upper++;


			if (t[tmp.second] == 1) {
				continue;
			}
			else {
				now_score -= tmp.first;
				t[tmp.second]--;
				break;
			}

		}

		t[a[i].second]++;
		now_score -= kind * kind;
		kind += 1;
		now_score += kind * kind;
		now_score += a[i].first;

		max_score = max(max_score,now_score);

	}

	cout << max_score << endl;

	return 0;
}

Measured memory_bytes: 2176
# ARC076C - Reconciled?
def main():
    n, m = list(map(int, input().rstrip().split()))
    MOD = 10 ** 9 + 7
    n, m = min(n, m), max(n, m)
    dif = m - n
    if dif > 1:  # must be ...DDM...
        print(0)
    else:
        prod = 1
        for i in range(1, n + 1):  # the factorial of n
            prod = (prod * i) % MOD

        if dif == 0:  # start with either D or M (DM..., MD...)
            ans = (prod ** 2 * 2) % MOD
        else:  # sandwich (DMD or MDM)
            ans = (prod ** 2 * m) % MOD
        print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<stdio.h>
using namespace std;
int n,m,s=1,sum;
bool f(int x)
{
	return floor(sqrt(x))*floor(sqrt(x))==x;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=m;i>=1;i/=10) s*=10;
	sum=m+n*s;
	f(sum)?printf("Yes\n"):printf("No\n"); 
}


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

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> v(n);
    ll ans = 0;
    for (int i = 0; i < n; i++) cin >> v[i];
    for (int l = 0; l <= min(n, k); l++) {
        for (int r = 0; l + r <= min(n, k); r++) {
            ll tmp = 0;
            vector<ll> sub;
            for (int i = 0; i < l; i++) {
                tmp += v[i];
                sub.push_back(v[i]);
            }
            for (int i = 0; i < r; i++) {
                tmp += v[n - i - 1];
                sub.push_back(v[n - i - 1]);
            }
            sort(sub.begin(), sub.end());
            int m = min((int)sub.size(), k - l - r);
            for (int i = 0; i < m; i++) {
                if (sub[i] < 0) tmp -= sub[i];
            }
            ans = max(ans, tmp);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	foreach (line; stdin.byLine) {
		auto x = line.split;
		long cost, sum;
		cost += x[1].to!long * 200 + x[2].to!long * 300;
		sum = x[1].to!long + x[2].to!long;
		writeln(x[0], " ", sum, " ", cost);
	}
}

Measured memory_bytes: 1060
import sys

class Node:
    __slots__ = ['key', 'left', 'right']
    def __init__(self, key):
        self.key = key
        self.left = self.right = None

root = None

def insert(key):
    global root
    x, y = root, None
    while x != None: x, y = x.left if key < x.key else x.right, x
    if y == None: root = Node(key)
    elif key < y.key: y.left = Node(key)
    else: y.right = Node(key)

def find(target):
    result = root
    while result and target != result.key:
        result = result.left if target < result.key else result.right
    return result == None

def inorder(node):
    return inorder(node.left) + f' {node.key}' + inorder(node.right) if node else ''
def preorder(node):
    return f' {node.key}' + preorder(node.left) + preorder(node.right) if node else ''

input()
for e in sys.stdin:
    if e[0] == 'i': insert(int(e[7:]))
    elif e[0] == 'f': print(['yes','no'][find(int(e[5:]))])
    else: print(inorder(root)); print(preorder(root))


Measured memory_bytes: 55620