akhauriyash/Code-Regression huggingface dataset:
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

//　セグメント木
const inf = 1100100100
const mod = 998244353

type segtree struct {
	n int
	v []int
	a []int // 加算値
}

func (s *segtree) init(n int) {
	N := 1
	for n > N {
		N *= 2
	}
	s.v = make([]int, N*2)
	s.a = make([]int, N*2)
	s.n = N
}

func (s *segtree) update() {
	K := s.n
	for K > 0 {
		K /= 2
		for i := K; i < 2*K; i++ {
			s.v[i] = s.compare(s.v[i*2], s.v[i*2+1])
		}
	}
}

func (s *segtree) lazyCalc(k int) {
	s.v[k] += s.a[k]
	s.v[k] %= mod
	if k < s.n {
		s.a[2*k] += s.a[k]
		s.a[2*k] %= mod
		s.a[2*k+1] += s.a[k]
		s.a[2*k+1] %= mod
	}
	s.a[k] = 0
}

func (s *segtree) compare(p, q int) int {
	if p > q {
		return q
	}
	return p
}

func (s *segtree) setSub(a, b, k, l, r, x int) {
	if b <= l || r <= a {
		return
	}
	if a <= l && r <= b {
		s.a[k] += x
		s.lazyCalc(k)
	} else {
		s.lazyCalc(k)
		s.setSub(a, b, k*2, l, (l+r)/2, x)
		s.setSub(a, b, k*2+1, (l+r)/2, r, x)
		s.v[k] = s.compare(s.v[2*k], s.v[2*k+1])
	}
}

// set v[k] = val
func (s *segtree) set(a, b, x int) {
	s.setSub(a, b, 1, 0, s.n, x)
}

// querySub
func (s *segtree) querySub(a, b, k, l, r int) int {
	s.lazyCalc(k)
	if b <= l || r <= a {
		return inf
	}
	if a <= l && r <= b {
		return s.v[k] + s.a[k]
	}
	return s.compare(
		s.querySub(a, b, k*2, l, (l+r)/2),
		s.querySub(a, b, k*2+1, (l+r)/2, r))
}

// query([a,b) )
func (s *segtree) query(a, b int) int {
	return s.querySub(a, b, 1, 0, s.n)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N, K := getInt(), getInt()
	l := make([]int, K)
	r := make([]int, K)
	for i := 0; i < K; i++ {
		l[i], r[i] = getInt(), getInt()
	}

	var s segtree
	s.init(2*N + 1)
	s.set(1, 2, 1)
	for i := 1; i < N; i++ {
		v := s.query(i, i+1)
		// out(i, v)
		for k := 0; k < K; k++ {
			ll := i + l[k]
			rr := i + r[k]
			s.set(ll, rr+1, v)
		}
	}
	out(s.query(N, N+1))
}


Measured memory_bytes: 14924
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define N 200010
ll n,q;
unordered_map<ll,ll> mas;
struct ver{
  ll l,r,t;
  bool operator<(const ver&key)const{
      return this->t<key.t;
  }  
  ver(ll l,ll r,ll t){
      this->l=l,this->r=r,this->t=t;
  }
};
vector<ver> v;
ll ans[N];
int main(){
  cin>>n>>q;
  for(int i=0;i<n;i++){
      ll a,b,c;cin>>a>>b>>c;
      v.push_back(ver(a-c,b-c,c));
  }
  sort(v.begin(),v.end());
  set<ll> s;
  for(int i=0;i<q;i++){
      ll x;cin>>x;
      mas[x]=i;
      s.insert(x);
      ans[i]=-1;
  }
  for(auto p:v){
      ll l=p.l,r=p.r,t=p.t;
      while(s.size()>0){
	  auto it=s.lower_bound(l);
	  if(it==s.end())break;
	  if(*it>=r)break;
	  ans[mas[*it]]=t;
	  s.erase(it);
      }
  }
  for(int i=0;i<q;i++)cout<<ans[i]<<endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

int cnt[55][30];
signed main(void)
{
  int n;
  cin >> n;
  string s[55];
  REP(i, n) cin >> s[i];

  REP(i, n) {
    REP(j, s[i].size()) {
      cnt[i][s[i][j]-'a']++;
    }
  }
  string ans = "";
  REP(j, 26) {
    int tmp = INF;
    REP(i, n) {
      tmp = min(tmp, cnt[i][j]);
    }
    REP(i, tmp) {
      ans += (char)('a'+j);
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  vector<int> vec(2);
  vec = {x2 - x1, y2 - y1};
  cout << x2 - vec[1] << " " << y2 + vec[0] << " " << x1 - vec[1] << " "
       << y1 + vec[0];
}

Measured memory_bytes: 256
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let 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 run() {
    input! {
        l: usize,
        r: usize,
    }
    let p = 2019;
    let mut ans = p;
    for i in l..r {
        for j in i + 1..r + 1 {
            ans = std::cmp::min (ans, i * j % p);
            if ans == 0 {
                break;
            }
        }
        if ans == 0 {
            break;
        }
    }
    println! ("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
int K,A,B;
cin>>K>>A>>B;
bool t=false;
for(int i=A;i<=B; i++){
    if (i%K==0) t=true;
}
if(t)cout<<"OK"<<endl;
else cout<<"NG"<<endl;
}

Measured memory_bytes: 3584
#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>

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 no { cout << -1; return; }

const int N = 1e7 + 7;

int p[N], d[N];

void precalc() {
    for (int i = 2; i < N; ++i)
        if (!p[i]) {
            p[i] = i;
            for (ll j = (ll)i * i; j < N; j += i)
                p[j] = i;
        }
    d[1] = 1;
    for (int i = 2; i < N; ++i) {
        int n = i, deg = 0;
        while (n % p[i] == 0) {
            ++deg; n /= p[i];
        }
        d[i] = d[n] * (deg + 1);
    }
}

void solve() {
    int n; cin >> n;
    ll ans = 0;
    loop1(i, n)
        ans += (ll)i * d[i];
    cout << ans;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    precalc();
    solve();
    return 0;
}

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

int factor(int x)
{
    int ret = 0;
    for (int i = 1; i <= x; i++) if (x % i == 0) ret ++;
    return ret;
}
int main()
{
    int n, cnt = 0;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        if ((i & 1) && factor(i) == 8) cnt++;
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 256
#include<map>
#include<queue>
#include<time.h>
#include<limits.h>
#include<cmath>
#include<ostream>
#include<iterator>
#include<set>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define rep_1(i,m,n) for(int i=m;i<=n;i++)
#define mem(st) memset(st,0,sizeof st)
inline int read()
{
	int num=0, w=0;
	char ch=0;
	while (!isdigit(ch))
	{
		w|=ch=='-';
		ch = getchar();
	}
	while (isdigit(ch))
	{
		num = (num<<3) + (num<<1) + (ch^48);
		ch = getchar();
	}
	return w? -num: num;
}
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef pair<double,double> pdd;
const int inf = 0x3f3f3f3f;
const int N=2e5+10;
#define int long long
int n;
int k;
int ans1=0;
int ans2=0;
int ans3=0;
int dp[N];
int w[N];
int cnt=0;
const int mod=998244353;
int l[N],r[N];
int pre[N];
void solve()
{
	ans1=ans2=ans3=0;
	n=read();ans1=ans2=ans3=0;
	k=read();ans1=ans2=ans3=0;
	dp[1]=1;
	pre[1]=1;ans1=ans2=ans3=0;
	for(int i=1; i<=k; i++)
		l[i]=read(),r[i]=read();
	for(ll i=2; i<=n; i++)
	{ans1=ans2=ans3=0;
		for(int j=1;j<=k;j++)
		{ans1=ans2=ans3=0;
			if(i>=l[j])
			{ans1=ans2=ans3=0;
				dp[i]=(dp[i]+pre[i-l[j]]-pre[max(0ll,i-r[j]-1)]+mod)%mod;
			}
		}
		pre[i]=(pre[i-1]+dp[i])%mod;
	}
	ans1=ans2=ans3=0;
	cout<<dp[n]+ans2+ans1+ans3<<endl;
}
signed main()
{
	int t=1;
	while(t--)
		solve();
	return 0;
}



Measured memory_bytes: 6656
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

// 約数を列挙
func divisor(n int) []int {
	ret := []int{}
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			ret = append(ret, i)
			if i*i != n {
				ret = append(ret, n/i)
			}
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	x := divisor(N - 1)
	// out(x)
	y := divisor(N)
	// out(y)
	ans := len(x) - 1
	for _, e := range y {
		if e == 1 {
			continue
		}
		n := N
		for n%e == 0 {
			n /= e
		}
		if n%e == 1 {
			ans++
		}
	}
	out(ans)
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr << #x << ":" << (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;

	VAR(int, n);
	vector< int > cnt(26, INF);
	REP(i, n) {
		vector< int > tmp(26);
		VAR(string, s);
		REP(j, s.size()) {
			tmp[s[j] - 97]++;
		}
		REP(j, 26) {
			cnt[j] = min(cnt[j], tmp[j]);
		}
	}

	string ans = "";
	REP(i, 26) {
		if (cnt[i] == INF) continue;
		ans += string(cnt[i], (i + 97));
	}

	OUT(ans)BR;
  
  return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
S = list(input())

l = 0
r = 0
change = 0 if S[0] == '1' else 1
ans = 0
while l < N and r < N:
    #print(l, r, change)
    ans = max(ans, r-l+1)
    if r == N-1:
        break
    if S[r] == '0':
        r += 1
    else:
        if S[r+1] == '0':
            if change < K:
                change += 1
                r += 1
            else:
                if S[l] == '0' and S[l+1] == '1':
                    r += 1
                l += 1
        else:
            r += 1
print(ans)

Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
int n;
int A[100005], L[100005];

int LIS(){
    int length = 1;
    L[0] = A[0];
    for(int i=1;i<n;++i){
        if(L[length-1]<A[i]){
            L[length++] = A[i];
        }
        else{
            *lower_bound(L,L+length,A[i]) = A[i];
        }
    }
    return length;

}

int main(){
    scanf("%d",&n);
    for(int i=0;i<n;++i){
        scanf("%d",&A[i]);
    }
    int length = LIS();

    printf("%d\n",length);
}



Measured memory_bytes: 3920
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

signed main(){
    char c;
    cout << "? " << 10'000'000'000LL << endl;
    cin >> c;
    if(c == 'Y'){
        for(ll i=1'000'000'000; i>=1; i/=10){
            cout << "? " << i+1 << endl;
            cin >> c;
            if(c == 'N'){
                cout << "! " << i*10 << endl;
                return 0;
            }
        }
        cout << "! 1" << endl;
        return 0;
    }

    for(ll i=1'000'000'000; i>=1; i/=10){
        cout << "? " << i << endl;
        cin >> c;
        if(c == 'Y'){
            ll r = i*10;
            ll l = i;
            while(r-l > 1){
                ll m = (r+l)/2;
                cout << "? " << m << 0 << endl;
                cin >> c;
                if(c == 'Y') r = m;
                else l = m;
            }
            cout << "! " << r << endl;
            break;
        }
    }
}

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

int main() {
	int a, b;
	cin >> a >> b;
	int ans = 0;
	if (a == 1) ans += 300000;
	if (a == 2) ans += 200000;
	if (a == 3) ans += 100000;
	if (b == 1) ans += 300000;
	if (b == 2) ans += 200000;
	if (b == 3) ans += 100000;
	if (a == 1 && b == 1) ans += 400000;
	cout << ans << endl;
}

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

int main() {
  int N;
  std::cin >> N;
  std::vector<int> A(N);
  int sum = 0;
  for (int i = 0; i < N; ++i) {
    std::cin >> A[i];
    sum ^= A[i];
  }
  for (int i = 0; i < N; ++i) {
    std::cout << (sum ^ A[i]);
    if (i + 1 < N) {
      std::cout << ' ';
    }
  }
  std::cout << std::endl;
  return 0;
}


Measured memory_bytes: 3992
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpi(x1) fprintf(stderr, "#%s.%d (%s) = (%d)\n", __func__, __LINE__, #x1, x1);
#define dumpii(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%d, %d)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpiii(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%d, %d, %d)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};

template<typename a>
struct S001 {
  int n;
  std::vector<a> xs;
  S001(const std::vector<a>& ys) : xs(ys.size() + 1) {
    int n = (int)ys.size();
    a t = 0;
    xs[0] = 0;
    for(int i = 0; i < n; ++i) {
      t += ys[i];
      xs[i+1] = t;
    }
  }
  a operator [] (int i) {
    return xs[i];
  }
  a f(int x, int y) {
    return xs[y] - xs[x];
  }
};

struct Solver {
  long n;
  std::vector<long> xs;
  long m;
  std::vector<std::array<long, 2>> ys;
  Solver() {
    S002 r;
    r >= n >n>= xs >= m >m>= ys;
  }
  void solve() {
    S001<long> zs(xs);
    std::vector<long> ws;
    for(std::array<long, 2> t : ys) {
      long res = zs.f(0, n) - xs[t[0]-1] + t[1];
      printf("%ld\n", res);
    }
  }
};
 
int main() {
  for(;;) std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            String S = in.next();
            int[] alphabets = new int[3];
            for (int i = 0; i < S.length(); i++) {
                alphabets[S.charAt(i) - 'a']++;
            }

            boolean ok = true;
            if (alphabets[0] > alphabets[1] + 1) ok = false;
            if (alphabets[1] > alphabets[2] + 1) ok = false;
            if (alphabets[2] > alphabets[0] + 1) ok = false;
            if (alphabets[1] > alphabets[0] + 1) ok = false;
            if (alphabets[2] > alphabets[1] + 1) ok = false;
            if (alphabets[0] > alphabets[2] + 1) ok = false;
            out.println(ok ? "YES" : "NO");

        }

    }
}



Measured memory_bytes: 39388
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll ans=0;
  ll N,K;
  cin >> N >> K;
  ll N_MAX=100110;
  ll h[N_MAX];
  for(int i=1;i<=N;i++){
    cin >> h[i];
  }
  ll dp[N_MAX];
  for(int i=1;i<=N;i++){
    dp[i]=1000000030;
  }
  dp[1]=0;
  //dp[2]=abs(h[1]-h[2]);
  for(int i=1;i<N;i++){
    for(int j=1;j<=K;j++){
      if(i+j>N+1)continue;
      dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
    }
  }
  cout << dp[N] << endl;
  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
#define int long long
//for set
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   
// for multiset
typedef tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_multiset;


#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
// #define PI 3.1415926535897932384626433832795
#define PI acos(-1.0)
int MOD=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
#define pb push_back
int __set(int b, int i) {return b|(1<<i);} //set ith bit
// int __unset(int b, int i) {return b&(!(1<<i));}
int __unset(int b, int i) {return b&(~(1UL<<i));}
int __check(int b, int i) {return b&(1<<i);} //returns 0 if ith bit is 0
int mul(int a, int b) {return ((a%MOD)*(b%MOD))%MOD;}
int add(int a, int b) {return (a+b)%MOD;}
int sub(int a, int b) {return (((a-b)%MOD)+MOD)%MOD;}
int __div(int a, int b) {return mul(a, powmod(b, MOD-2, MOD));} //if MOD is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

// map<char, int> m;
// bool cmp(char a, char b) {
// 	return m[a]<m[b];
// }
int mod = 1000000007;
const int N=21;
int dp[N][(1<<N)];
int32_t main(void) {
	IOS;
	int n; cin>>n;
	int mat[n][n];
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++)
			cin>>mat[i][j];
	}
	for(int i = 0; i < (1<<n); i++) {
		for(int j = 0; j < n; j++) {
			if(__check(i, j) && mat[0][j] && __builtin_popcount(i)==1)
				dp[0][i]=1;
		}
	}
	for(int i = 1; i < n; i++) {
		for(int j = 0; j < (1<<n); j++) {
			if(__builtin_popcount(j)!=i+1) continue;
			for(int k = 0; k < n; k++) {
				if(mat[i][k] && __check(j,k))
					dp[i][j] = (dp[i][j]+dp[i-1][__unset(j,k)])%mod;
			}
		}
	}
	cout<<dp[n-1][(1<<n)-1]<<endl;
   	time();
	return 0;
}

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

ll mod = 1e9+7;
 
vector <vector<int> > adj;

ll dp[123456][2];

void dfs(int n, int p){
     dp[n][1] = 1LL;
     dp[n][0] = 1LL;

     for(auto x:adj[n]){
         if(x != p){
             dfs(x, n);
             dp[n][0] = (dp[n][0]*(dp[x][1]+dp[x][0])%mod)%mod;
             dp[n][1] = (dp[n][1]*dp[x][0])%mod;
         }
     }
}


int main()
{
  int n;
  cin >> n;
  adj.resize(n+1);
  for(int i = 0; i < n-1; i++){
      int u, v;
      cin >> u >> v;
      adj[u].push_back(v);
      adj[v].push_back(u);
  }
  dfs(1, 0);
  cout << ((dp[1][0]+dp[1][1])%mod);
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll s[51],p[51];
ll bg(int l,long long x){
  if(l == 0){
    if(x<=0){
      return 0;
    }
    else{
      return 1;
    }
  }
  if(x == 1){
    return 0;
  }
  else if(1<x && x <= 1+s[l-1]){
    return bg(l-1,x-1);
  }
  else if(x == s[l-1] + 2){
    return 1+p[l-1];
  }
  else if(3+s[l-1] <= x && x <= 2+2*s[l-1]){
    return p[l-1] + 1 + bg(l-1,x-(2+s[l-1]));
  }
  else if(x == 3+2*s[l-1]){
    return 2*p[l-1]+1;
  }
}
int main(){
  int n;
  ll x;
  cin >> n >> x;
  
  s[0] = 1;
  p[0] = 1;
  for(int i=0; i<n; i++){
    if(i>0){
      s[i] = 2*s[i-1] + 3;
      p[i] = 2*p[i-1] + 1;
    }
  }
  
  cout << bg(n,x) << endl;
}

Measured memory_bytes: 256
#![allow(clippy::needless_range_loop)]
#![allow(unused_macros)]
#![allow(dead_code)]

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        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! {
        l: usize,
        r: usize,
        d: usize,
    }
    let ans = r / d + 1 - (l + d - 1) / d;
    println!("{}", ans);
}


Measured memory_bytes: 2088
#include <iostream>
#include <string>

using namespace std;


int main()
{
	string s;
	cin >> s;
	string judge = s.substr(0, 1);
	bool yes = false;

	for (int i = 1; i < 3; i++) {
		if (s.substr(i, 1) != judge) {
			yes = true;
		}
	}

	if (yes) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

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

    vec<string> A(N);
    rep(i, N) cin >> A[i];

    vec<string> B(M);
    rep(i, M) cin >> B[i];

    rep(i, N - M + 1) rep(j, N - M + 1) {
        bool flag = true;
        rep(k, M) {
            rep(l, M) {
                if (A[i + k][j + l] != B[k][l]) {
                    flag = false;
                    break;
                }
            }
            if (!flag) break;
        }
        if (flag) { cout << "Yes" << '\n';return 0; }
    }
    cout << "No" << '\n';
}


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

unsigned GetDigit(unsigned num){
    return to_string(num).length();
}

int main(void){
 
  int N,c = 0;
  cin >> N;
  for(int i=1;i<=N;i++){
      if(GetDigit(i) %2== 1) c++;
  }
  cout << c << endl;
}

Measured memory_bytes: 3756
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    ll n;cin>>n;
    map<ll,int> m;
   // vector<ll> a,b;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){m[i]=1;m[n/i]=1;}
    }
    ll ans=0;
    for(ll i=1;i*i<=n-1;i++){
        if((n-1)%i==0){
            if(!m[i])ans++;
           if(i!=(n-1)/i)ans+=(!m[(n-1)/i]);
        }
    }
    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            ll k=n;
            while(k%i==0){
                k/=i;
            }
            if((k-1)%i==0)ans++;
            
        }
    }
    cout<<ans+1;
    
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<ctime>
#include<cmath>
#include<utility>
#include<cstdlib>
#include<bitset>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<iomanip>
using namespace std;                       

#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define sc second


#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const ll M = 1e9 + 7;

ll add(ll a, ll b){
    (a += b)%=M;
    (a += M)%=M;
    return a;
}

ll mul(ll a, ll b){
    (a *= b)%=M;
    (a += M)%=M;
    return a;
}

ll fastpo(ll a, ll x){
    if(x == 0) return 1ll;
    if(x == 1) return a;
    ll y = fastpo(a, x/2);
    if(x%2 == 0){
        return y*y;
    }
    return y*y*a;
}

ll inv(ll a, ll M){
    return fastpo(a, M-2);
}

ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    ll x1, y1; 
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
  
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
}

ll modInverse(ll a, ll m) 
{ 
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
    if (g != 1) 
        return -1; 
    else
    { 
        ll res = (x%m + m) % m; 
        return res;
    } 
}


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

ll lcm(ll a, ll b){
    return (a*b)/gcd(a, b);
}

void print(vector<int> &a){
    int n = a.size();
    for(int i=0; i<n; i++){
        cout<<a[i]<<" ";
    }
    cout<<endl;
}


int main(){
//    clock_t time_req;
//     time_req = clock();
    fastio;
    int n, ans = 0;
    cin>>n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    sort(a.begin(), a.end());
    vector<pii> b;
    for(int i=0; i<n; i++){
        if(i == 0) b.pb({a[i], 1});
        else{
            if(b[b.size()-1].fi != a[i]) b.pb({a[i], 1});
            else{
                b[b.size()-1].sc++;
            }
        }
    }
    n = b.size();
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            for(int k=j+1; k<n; k++){
                if(b[k].fi < b[i].fi + b[j].fi){
                    ans += b[k].sc*b[i].sc*b[j].sc;
                }
                else{
                    break;
                }
            }
        }
    }
    cout<<ans<<endl;
    // time_req = clock()-time_req;
    // cout<<"Time taken: "<<(float)time_req/CLOCKS_PER_SEC<<"s"<<endl;
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e9;

int main(){
  int N, ans=0,tmp,K;
  cin>>N>>K;
  REP(i,0,N){
    cin>>tmp;
    if(tmp>=K)ans++;
  }
  print(ans)
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, c, d, n;
  cin >> a >> b >> c >> d >> n;
  b = min(2 * a, b);
  c = min(2 * b, c);
  d = min(2 * c, d);
  cout << n / 2 * d + (n % 2) * c << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>

int gcd(int m, int n) {
  while (n) std::swap(m %= n, n);
  return m;
}

int main() {
  int N, X;
  scanf("%d %d", &N, &X);

  int D = 0;
  for (int i = 0; i < N; ++i) {
    int x;
    scanf("%d", &x);
    D = gcd(D, abs(X-x));
  }
  printf("%d\n", D);
}

Measured memory_bytes: 256
public class Main {

  private static void solve() {
    int n = ni();
    long[] count = new long[256];
    for (int i = 0; i < n; i ++) {
      char c = ns()[0];
      count[c] ++;
    }
    
    long ret = 0;
    char[] s = "MARCH".toCharArray();
    for (int i = 0; i < s.length; i ++) {
      for (int j = i + 1; j < s.length; j ++) {
        for (int k = j + 1; k < s.length; k ++) {
          ret += count[s[i]] * count[s[j]] * count[s[k]];
        }
      }
    }
    System.out.println(ret);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = System.getProperty("debug");
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


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

int main() {
	int n;cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;++i) cin>>a[i];
	a.push_back(1e9+1);
	
	int q;cin>>q;
	while(q--){
		int k;cin>>k;
		cout<<(lower_bound(a.begin(),a.end(),k) - a.begin())<<endl;
	}
  return 0;
}



Measured memory_bytes: 3624
/*
 * main.c
 *
 *  Created on: 2019/04/13
 *      Author: family
 */


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int hotel[100] = {0};

int main()
{
    int N;
    int i = 0;
    int prev = 0;
    int ans = 1;
    int currentMax = 0;
    scanf("%d", &N);
    for(i = 0; i < N; i++) {
        scanf("%d", &hotel[i]);
    }
    prev = hotel[0];
    currentMax = hotel[0];
    for(i = 1; i < N; i++) {
        if(hotel[0] > hotel[i]) {
            continue;
        }
        if(currentMax > hotel[i]) {
            continue;
        } else {
            currentMax = hotel[i];
        }
        if(prev <= hotel[i]) {
            ans++;
        }
        prev = hotel[i];
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#define MAX 30

int main(void){
	int i,tate,yoko,a,b,temp ;
	int array[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30} ;
	
	//for(i=0; i<MAX; i++){//init array
	//	array[i] = i+1;
	//}
	
	scanf("%d %d",&tate,&yoko);//get w&n
	//printf("tate: %d\n",tate);//check,ok
	//printf("yoko: %d\n",yoko);//check,ok
	
	for(i=0; i<yoko; i++){
		scanf("%d,%d",&a,&b);//read file
		//printf("%d,%d\n",a,b);//check,ok
		a--;//for array index
		b--;//for array index
		temp = array[a] ;//swap values
		array[a] = array[b] ;
		array[b] = temp ;
	}
	
	for(i=0; i<tate; i++){//show result
		printf("%d\n",array[i]);
	}
	
	return 0 ;
}

Measured memory_bytes: 596
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200000

int main() {
	long long x, y, z;
	long long s, ans;
	scanf("%lld %lld %lld", &x, &y, &z);
	if ((x + y) >= z) {
		printf("No\n");
      return 0;
	}
	s = 4 * x*y;
	ans = (z - x - y)*(z - x - y);
	if (s < ans) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}

	return 0;
}


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

using namespace std;



int main(){
 
   int a,minn,k = 0;

   cin>>a;
   int b[a];

   for (int i = 0; i < a; i++)
   {
       cin >> b[i];
       if(i == 0){
            minn = b[i];
            k++;
       }
        else if(min(b[i],minn) == b[i]){
            k++;
            minn = b[i];
        } 
        
   }
   cout<<k<<"\n";
    
    

    return 0;
}

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

using namespace std;

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

    float D,T,S;
    cin  >> D >> T >> S;

    float Treq = D/S;

    if(Treq<=T)cout << "Yes" << '\n';
    else cout << "No" << '\n'; 
    
}

Measured memory_bytes: 3692
X, Y, A, B, C = map(int, input().split())

P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))
        
P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)

A=P[:X]+Q[:Y]+R

A.sort(reverse=True)

print(sum(A[:X+Y]))

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

int main() {
	int N;
	cin >> N;
	int a;
	int ans=0;
	for(int i=1;i<=N;i++){
		cin >> a;
		if(i%2 == 1 && a%2 == 1) ans++;
	}
	cout << ans << endl;

}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int calc(double x, double r){
    return (int) x*(100.0 + r)/100;
}

int main(void){
    vector<int> ans;
    while(true){
        int res = 0;
        int bef, aft, aim;
        cin >> bef >> aft >> aim;
        double rat_bef = bef, rat_aft = aft;
        if(bef == 0 && aft == 0 && aim == 0) break;
        for(int i = 1; i <= aim; i++){
            for(int j = i; j <= aim; j++){
                double a = i, b = j;
                if(calc(a, rat_bef) + calc(b, rat_bef) == aim){
                    res = max(res, calc(a, rat_aft) + calc(b, rat_aft));
                }
            }
        }
        ans.push_back(res);
    }
    rep(i, ans.size()) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define fi first
#define se second
#define All(x) (x).begin(),(x).end()
unsigned N;
char chars[4096];
unsigned posr[4096],posg[4096],posb[4096];
unsigned szr,szg,szb;
ll cnt; 
int main(){
	//freopen("rd.txt","r",stdin);
	ios::sync_with_stdio(0);
	cin>>N;
	cin>>chars;
	
	for(register unsigned i=0;i<N;++i)
	{
		if(chars[i]=='R')
			posr[szr++]=i;
		else if(chars[i]=='G'){
			posg[szg++]=i;
		}
		else {
			posb[szb++]=i;
		}
	}
	
	for(register int i=0;i<N-2;++i){
		for(register int j=i+1;j<N-1;++j){
			if(chars[j]==chars[i])continue;
			int pos=0,tp=j-i;
			if(chars[i]!='R'&&chars[j]!='R'){
				pos=upper_bound(posr,posr+szr,j)-posr;
				cnt+=(szr-pos)>0?(szr-pos):0;
				int t=lower_bound(posr,posr+szr,tp+j)-posr;
				if(t!=szr&&posr[t]==tp+j)cnt--;
			}
			else if(chars[i]!='G'&&chars[j]!='G'){
				pos=upper_bound(posg,posg+szg,j)-posg;
				cnt+=(szg-pos)>0?(szg-pos):0;
				int t=lower_bound(posg,posg+szg,tp+j)-posg;
				if(t!=szg&&posg[t]==tp+j)cnt--;
			}
			else {
				pos=upper_bound(posb,posb+szb,j)-posb;
				cnt+=(szb-pos)>0?(szb-pos):0;
				int t=lower_bound(posb,posb+szb,tp+j)-posb;
				if(t!=szb&&posb[t]==tp+j)cnt--;
			}
		}
	}
	
	cout<<cnt;
}


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

int main(){

    int N;
    cin >> N;

    int A[N];

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

    int count=0;

    while(1){

        for(int i=0;i<N;i++){
            if(A[i]%2==1){
                cout << count << endl;
                return 0;
            }
        }

        for(int i=0;i<N;i++){
            A[i] = A[i] / 2;
        }

        count++;
    }

}


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

using namespace std;

int main(){
  vector<int> h,w;
  int _h,_w;
  while(1){
    cin >> _h >> _w;
    if(_h == 0 && _w == 0){
      break;
    }
    h.push_back(_h);
    w.push_back(_w);
  }
  for(int i=0;i<h.size();i++){
    for(int w_i=0;w_i<w[i];w_i++){
      cout << "#";
    }
    cout << endl;
    for(int h_i=1;h_i<h[i]-1;h_i++){
      cout << "#";
      for(int w_i=1;w_i<w[i]-1;w_i++){
        cout << ".";
      }
      cout << "#" << endl;
    }
    for(int w_i=0;w_i<w[i];w_i++){
      cout << "#";
    }
    cout << endl << endl;
  }
  return 0;
}

Measured memory_bytes: 3120
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	//入力値
      	long n = sc.nextLong();
      
      	//入力値の平方根
      	int a = (int)Math.sqrt(n);
      
      	//移動回数
      	long b =0;
      	
      	for(long i = 1;i<a+1;++i){
          //約数だった場合
          if(n%i==0){
            
            if(b==0){
              b = (i-1)+(n/i - 1);
            }else if(b>(i-1)+(n/i - 1)){
              b = (i-1)+(n/i - 1);
            }
          }
        }
      System.out.println(b);
    }
}

Measured memory_bytes: 35752
N = int(input())
a = list(map(int, input().split()))
b = a.copy()

for i in range(N//2, -1, -1):
    ball_sum = sum(b[i::i+1])
    if ball_sum % 2 == a[i]:
        continue
    else:
        b[i] = int(not(b[i]))

print(sum(b))
for j in range(N-1, -1, -1):
    if b[j]: print(j+1)

Measured memory_bytes: 8380
n = int(input())
s = input()
alphaList  =   ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
moji = ""
for str in s:
    index = alphaList.index(str)
    addNum = index + n
    if addNum >25:
        addNum = addNum - 26 
    moji = moji + alphaList[addNum]
print(moji)

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

#define ll long long
#define ld long double
#define COIN const int
#define ite iterator
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define sz(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/
const ll mod=1e9+7;
const ll INF=1e18;
/*****************************************************************************/

using namespace std;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n,k,a,i;
	vector <int> v;
	cin >>n >>k;
	for (i=0;i<n;i++) {
		cin >>a;
		v.pb(a);
	}
	sort(ALL(v));
	int ans=0;
	for (i=0;i<k;i++) ans+=v[i];
	cout <<ans;
	return 0;
}
/******************************************************************************
******************************************************************************/


Measured memory_bytes: 3588
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n,T;
  scanf("%d%d",&n,&T);
  int c[100];
  int t[100];
  int i;
  for(i=0;i<n;i++) scanf("%d%d",c+i,t+i);
  int min=1001;
  for(i=0;i<n;i++){
    if(t[i]<=T){
      min=MIN(min,c[i]);
    }
  }
  if(min>1000){
    printf("TLE\n");
  } else {
    printf("%d\n",min);
  }
}

int main(void){
  run();
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

int d[17][17], f[17];
signed main(void)
{
  int v, e, tot = 0;
  cin >> v >> e;
  REP(i, v) REP(j, v) d[i][j] = INF;
  REP(i, e) {
    int a, b, c;
    cin >> a >> b >> c;
    d[a][b] = min(d[a][b], c); d[b][a] = min(d[b][a], c);
    f[a]++; f[b]++;
    tot += c;
  }
  VI o;
  REP(i, v) if(f[i]%2) o.push_back(i);
  REP(k, v) REP(i, v) REP(j, v) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  int dp[1<<16], os = o.size();
  fill(dp, dp+(1<<os), INF);
  dp[0] = 0;
  REP(s, 1<<os) REP(i, os) if(~s>>i&1) REP(j, i) if(~s>>j&1) {
    dp[s|1<<i|1<<j] = min(dp[s|1<<i|1<<j], dp[s] + d[o[i]][o[j]]);
  }
  cout << tot + dp[(1<<os)-1] << endl;
  return 0;
}

Measured memory_bytes: 3164
#include <iostream>

int main(){
    int a, b, c;
    std::cin >> a >> b >> c;

    bool flg = false;
    for(int i = 1; i <= b; ++i){
        if(c == (i * a) % b){
            flg = true;
            break;
        }
    }

    if(flg){
        std::cout << "YES" << std::endl;
    }else{
        std::cout << "NO" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 384
import java.lang.StringBuilder

fun main(args: Array<String>) {
    val (sx, sy, tx, ty) = readLine()!!.split(" ").map { it.toInt() }

    val answer = StringBuilder()

    answer.append("U")
    answer.append(getPath(sx, sy + 1, tx -1, ty))
    answer.append("R")
    answer.append("D")
    answer.append(getPath(tx, ty -1, sx + 1, sy))
    answer.append("L")
    answer.append("L")
    answer.append(getPath(sx - 1, sy, tx, ty + 1))
    answer.append("D")
    answer.append("R")
    answer.append(getPath(tx + 1, ty, sx, sy - 1))
    answer.append("U")

    println(answer.toString())
}
// UURDDLLRRUUUDRLLDDDU
// UURDDLLUUURRDRDDDLLU

fun getPath(fromX: Int, fromY: Int, toX: Int, toY: Int) : String {
    val diffX = toX - fromX
    val diffY = toY - fromY
    val xSymbol = if (diffX >= 0) 'R' else  'L'
    val ySymbol = if (diffY >= 0) 'U' else  'D'

    val str = StringBuilder()
    
    for (i in 0 until Math.abs(diffY)) {
        str.append(ySymbol)
    }


    for (i in 0 until Math.abs(diffX)) {
        str.append(xSymbol)
    }

    return str.toString()
}

Measured memory_bytes: 37872