akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(long long &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
int N;
long long X[50];
long long Y[50];
int main(){
  int a, b, i, j, k, res, tmp;
  long long p, q;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<(N);Lj4PdHRW++){
      rd(X[Lj4PdHRW]);
      rd(Y[Lj4PdHRW]);
    }
  }
  res = N;
  for(a=0;a<(N);a++){
    for(b=(a+1);b<(N);b++){
      p = X[b] - X[a];
      q = Y[b] - Y[a];
      tmp = N;
      for(i=0;i<(N);i++){
        for(j=0;j<(N);j++){
          if(X[j]-X[i]==p && Y[j]-Y[i]==q){
            tmp--;
          }
        }
      }
      chmin(res, tmp);
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190902-1

// --- original code ---
// int N;
// ll X[50], Y[50];
// {
//   int i, j, k, a, b;
//   int res, tmp;
//   ll p, q;
// 
//   rd(N,(X,Y)(N));
//   res = N;
// 
//   rep(a,N) rep(b,a+1,N){
//     p = X[b] - X[a];
//     q = Y[b] - Y[a];
// 
//     tmp = N;
//     rep(i,N) rep(j,N) if(X[j]-X[i]==p && Y[j]-Y[i]==q) tmp--;
//     res <?= tmp;
//   }
// 
//   wt(res);
// }


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

int  main()
{
	int n, m;
	cin >> n >> m;
	int sum = 0;
	vector<int> x(m);
	rep(i , m)
		cin >> x[i];
	pq q;
	sort(x.begin(), x.end());
	rep(i, m - 1)
	{
		q.push(abs(x[i] - x[i+1]));
		sum += abs(x[i] - x[i+1]);
	}
	// cout << sum;
	rep(i, n - 1)
	{
		if (!q.empty())
		{
			sum -= q.top();
			q.pop();
		}
	}
	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 1276
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.List (unfoldr)
import Data.Maybe (fromMaybe)
import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Maybe
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS

-- 有向グラフに閉路があるか判定し、閉路があれば Nothing を返す。
-- 閉路がなければ最長路の長さを返す。
solve :: V.Vector [Int] -> Maybe Int
solve edges = fmap U.maximum $ runST $ runMaybeT $ do
  let !n = V.length edges  -- 頂点の個数
  vec <- UM.replicate n (-2 :: Int) -- -2: new, -1: DFSの最中, 正: チェック済み
  let dfs !x = do
        s <- UM.read vec x
        case s of
          -2 -> do
            -- x を通る閉路があるかチェックする
            UM.write vec x (-1)
            v <- (+ 1) <$> foldM (\a y -> max a <$> dfs y) 0 (edges V.! x)
            UM.write vec x v
            return v
          -1 -> mzero  -- コールスタックのどこかで dfs x が呼ばれている。閉路
          v -> return v
  mapM_ dfs [0..n-1]
  U.unsafeFreeze vec

main = do
  n <- readLn
  xs <- V.replicateM n $ do
    U.map (subtract 1) . U.unfoldrN (n-1) (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let m = n * (n - 1) `quot` 2  -- グラフの頂点数
  let -- (i,j) (0 <= i < j < n) を 0 以上 m 未満の整数値にコードする
      makePair :: Int -> Int -> Int
      makePair i j | i' < j' = n * i' - (i' + 1) * i' `quot` 2 + j' - i' - 1
                   | otherwise = undefined
        where i' = min i j; j' = max i j
  -- 「試合 (i,j) よりも試合 (i',j') の方を後に行う場合に辺 makePair i j → makePair i' j' が存在する」ようなグラフを作る
  let edges :: V.Vector [Int]
      edges = V.create $ do
        e <- VM.replicate m []
        V.forM_ (V.indexed xs) $ \(i,ys) -> do
          U.forM_ (U.zip ys (U.tail ys)) $ \(a,b) -> do
            -- (i,a) -> (i,b)
            let !b' = makePair i b
            -- VM.modify e (b' :) (makePair i a)
            t <- VM.read e (makePair i a)
            VM.write e (makePair i a) $! b' : t
        return e
  print $ fromMaybe (-1) $ solve edges


Measured memory_bytes: 103036
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(2*n);
    for(int i=0; i<n; i++){
        cin >> a[i];
        a[i+n] = a[i];
    }
    int ans = 0;
    int num = 0;
    do{
        int b = num%n;
        int e = (num+m)%n;
        if(e < b) e += n;
        ans += *max_element(a.begin()+b, a.begin()+e)
                - *min_element(a.begin()+b, a.begin()+e);
        num += m;
    }while(num%n != 0);
    cout << ans << endl;
    return 0;
}


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

int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  double result;
  double round = abs(30 * h - 5.5 * m);
  if (fmod(round, 360) > 180) {
    round = fmod(round, 360);
    round = 360 - round;
  } else {
    round = fmod(round, 360);
  }
  result = sqrt(a * a + b * b - 2 * a * b * cos(round * M_PI / 180));
  printf("%5.9lf", result);
}

Measured memory_bytes: 4208
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const ll MOD = 1e9+7;

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

//********************************template END****************************************//

//階乗とその逆元
ll fac[MAX+1],facInv[MAX+1];

ll power(ll e, ll x){ //e^x % MOD
	if (x == 0) return 1LL;
	if (x % 2 != 0) return ((power(e, x-1) * e) % MOD);
	ll temp = power(e, x / 2);
	return (temp * temp) % MOD;
}

ll nck(ll n, ll k){
	if (!(n >= k && k >= 0)) return 0;
	ll temp = (fac[n] * facInv[n-k]) % MOD;
	return ((temp * facInv[k]) % MOD);
}

void fact(void){
	//階乗とその逆元
	fac[0] = facInv[0] = 1; //0! = 1
	//(x!)^(-1) ≡ (x!)^(p-2) (mod p)
	Rep(1, MAX, i) fac[i] = (fac[i-1] * i) % MOD;
	facInv[MAX] = power(fac[MAX], MOD-2);
	Rep(1, MAX-1, i) facInv[MAX-i] = (facInv[MAX-i+1] * (MAX-i+1)) % MOD;
}

void solve(void){

	ll N, M;
	cin >> N >> M;

	ll ans = 1;

	fact();

	for (ll f = 2; f <= M; f++)
	{
		ll cnt = 0;
		while(M % f == 0)
		{
			cnt++;
			M /= f;
		}
		ans *= nck(cnt+N-1, cnt);
		ans %= MOD;
	}

	cout << ans << endl;

}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m;
  cin>>n>>m;
  cout<<(n-1)*(m-1)<<endl;
  return 0;

}


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

int main(){
    string s;
    cin >> s;
    int u = 0, v= 0;
    for(int i = 0; i < s.size(); i++){
        if(s.at(i) == '0') u++;
        else v++;
    }
    cout << 2*min(u,v) << endl;    
}

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

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int k = scanner.nextInt();
		int n = scanner.nextInt();
		int[] a = new int[n+1];
		int min = Integer.MAX_VALUE;
		for(int i=0; i<n; i++) {
			a[i] = (scanner.nextInt())%k;
		}
		a[n] = Integer.MAX_VALUE;
		a[n] = k+a[0];

		for(int i=0; i<n; i++) {
			min = Math.min(min, k - a[i+1] + a[i]);
		}

		System.out.println(min);
	}
}

Measured memory_bytes: 65808
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a,b;

ll dfs(ll d,ll h){
  if(d==n)return b;
  ll H=(1LL<<(n-1-d));
  ll W=(1LL<<d);
  if(h<H){
    ll f=dfs(d+1,H-1-h);
    if( f < W ){
      printf("L");
      return W-1-f;
    }else{
      printf("R");
      return W+W-f-1;
    }
  }else{
    ll f=dfs(d+1,h-H);
    if( f < W ){
      printf("R");
      return f;
    }else{
      printf("L");
      return f-W;
    }
  }
}

int main(){
  while(1){
    scanf("%lld %lld %lld",&n,&a,&b);
    if(n==0&&a==0&&b==0)break;
    a--;
    b--;
    dfs(0,a);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 3068
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int main() {

int n,m,aa,h,p,q;

while(cin>>n>>m>>aa && n){

vector< pair<pair<int,int>,int > > ve;
int a[101];
for(int i=1;i<101;i++) a[i]=i;

for(int i=0;i<m;i++){
	cin>>h>>p>>q;
	ve.push_back(make_pair(make_pair(h,p),q));
}
sort(ve.begin(),ve.end());
for(int i=0;i<m;i++){
	int z=ve[i].first.second,x=ve[i].second;
	int y;
	y=a[z];
	a[z]=a[x];
	a[x]=y;
}
cout<<a[aa]<<endl;
}
	return 0;
}

Measured memory_bytes: 3120
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <time.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 2020000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n,k; cin >> n >> k;
    if(n < 2*k-1){
        puts("-1");
        return 0;
    }
    ll t = 2*n;
    vpl ab;
    for(int i=k+n-1; i>=k; i--){
        ab.emplace_back(i,t);
        if(t == k+n) t = k+2*n-1;
        else t--;
    }
    sort(all(ab),[](P a, P b){return a.first+a.second < b.first+b.second;});
    for(int i=k+2*n; i<k+3*n; i++){
        print3(ab[i-k-2*n].first, ab[i-k-2*n].second, i);
    }
}

Measured memory_bytes: 5372
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  int a[n]={};
  int b[n]={};
  for(int i=0;i<n;i++)cin>>b[i];
  while(m--){
    int p;
    cin>>p;
    for(int j=0;j<n;j++)
      if(b[j]<=p){
        a[j]++;
        break;
      }
  }
  int x=0,p=0;
  for(int i=0;i<n;i++){
    if(a[i]>x){
      x=a[i];
      p=i;
    }
  }
  cout<<p+1<<endl;
}

Measured memory_bytes: 3076
#include <cstdio>
#include <cstring>
#include <cstdint>

using namespace std;

int main() {
    int x, y;
    scanf("%d %d", &x, &y);

    if (x == y) return !printf("0\n");
    if (x + y == 0) return !printf("1\n");

    int64_t g[4][4]={};
    memset(g, 0x3f, sizeof g);
    g[0][1] = g[1][0] = g[2][3] = g[3][2] = 1;

    if (x < y) {
        g[0][2] = g[3][1] = y - x;
    } else {
        g[2][0] = g[1][3] = x - y;
    }

    if (-x < y) {
        g[1][2] = g[3][0] = x + y;
    } else {
        g[2][1] = g[0][3] = -(x + y);
    }

    for (size_t k=0; k<4; ++k)
        for (size_t j=0; j<4; ++j)
            for (size_t i=0; i<4; ++i)
                if (g[i][j] > g[i][k] + g[k][j])
                    g[i][j] = g[i][k] + g[k][j];

    printf("%lld\n", g[0][2]);
    return 0;
}


Measured memory_bytes: 128
// AOJ 1524 Rolling Block
// 2019.2.28 bal4u

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

#define QMAX 1000000
typedef struct { char r, c, d, sw; int s; } Q;
Q q[QMAX + 2]; int top, end;
int mv[3][4][3] = {
	{{-1,0,2},{1,0,2},{0,-1,1},{0,1,1}},  // 直列状態から上下左右に転ぶ
	{{-1,0,1},{1,0,1},{0,-1,0},{0,1,0}},  // 横（東西方向）の状態から
	{{-1,0,0},{1,0,0},{0,-1,2},{0,1,2}}   // 縦（南北方向）の状態から
};

int H, W, L;
char map[30][30];
int SR, SC, GR, GC;
char visited[30][30][128];

void add(int r, int c, int d, int sw, int s)
{
	if (visited[r][c][(d << 5) | sw]) return;
	q[end].r = r, q[end].c = c, q[end].d = d, q[end].sw = sw, q[end].s = s;
	if (++end == QMAX) end = 0;
}

int bfs()
{
	int i, j, r, c, d, rr, cc, dd, s, sw;

	q[0].r = SR, q[0].c = SC, q[0].d = 0, q[0].sw = 0, q[0].s = 0;
	top = 0, end = 1;
	while (top != end) {
		r = q[top].r, c = q[top].c, d = q[top].d, sw = q[top].sw;
		s = q[top].s;
//		printf("(%d,%d) dir=%d, sw=%d, step=%d, top=%d, end=%d\n", r, c, d, sw, s, top, end);
		if (++top == QMAX) top = 0;
		if (r == GR && c == GC && d == 0) return s;
		if (visited[r][c][(d << 5) | sw]) continue;
		visited[r][c][(d << 5) | sw] = 1;

		s++;
		for (i = 0; i < 4; i++) {
			rr = r + mv[d][i][0], cc = c + mv[d][i][1], dd = mv[d][i][2];
			if      (i == 0 && dd == 2) rr -= L - 1;
			else if (i == 1 && dd == 0) rr += L - 1;
			else if (i == 2 && dd == 1) cc -= L - 1;
			else if (i == 3 && dd == 0) cc += L - 1;

			if (dd == 0) {  // 直列状態になった
				if (rr < 0 || rr >= H || cc < 0 || cc >= W) continue;
				if (map[rr][cc] == '^' || map[rr][cc] == '#') continue;
				if (map[rr][cc] >= 'a' && map[rr][cc] <= 'e') {
					if ((sw & (1 << (map[rr][cc] - 'a'))) == 0) continue;
				}
				if (map[rr][cc] >= 'A' && map[rr][cc] <= 'E') {
					int a = sw ^ (1 << (map[rr][cc] - 'A'));
					add(rr, cc, dd, a, s);
				}
				else add(rr, cc, dd, sw, s);
			}
			else if (dd == 1) {  // 横（東西方向）に転んだ
				if (rr < 0 || rr >= H || cc < 0 || cc + L-1 >= W) continue;
				for (j = 0; j < L; j++) {
					if (map[rr][cc + j] == '#') break;
					if (map[rr][cc + j] >= 'a' && map[rr][cc + j] <= 'e') {
						if ((sw & (1 << (map[rr][cc + j] - 'a'))) == 0) break;
					}
				} if (j < L) continue;
				add(rr, cc, dd, sw, s);
			}
			else {  // 縦（南北方向）に転んだ
				if (rr < 0 || rr + L-1 >= H || cc < 0 || cc >= W) continue;
				for (j = 0; j < L; j++) {
					if (map[rr + j][cc] == '#') break;
					if (map[rr + j][cc] >= 'a' && map[rr + j][cc] <= 'e') {
						if ((sw & (1 << (map[rr + j][cc] - 'a'))) == 0) break;
					}
				} if (j < L) continue;
				add(rr, cc, dd, sw, s);
			}
		}
	}
	return -1;
}

int main()
{
	int r, c;

	scanf("%d%d%d", &H, &W, &L);
	for (r = 0; r < H; r++) {
		scanf("%s", map[r]);
		for (c = 0; c < W; c++) {
			if (map[r][c] == 'S') SR = r, SC = c, map[r][c] = '.';
			else if (map[r][c] == 'G') GR = r, GC = c, map[r][c] = '.';
		}
	}
	printf("%d\n", bfs());
	return 0;
}


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

using namespace std;
using LL = long long int;

string S;
vector<int> SS;

bool check(int mid)
{
  if(mid == 0) {
    return true;
  }
  for(int k = 0; k < 2; k++) {
    int s = 0;
    for(int i = 0; i < SS.size(); i++) {
      if(s < mid) {
        s += SS[i];
      } else {
        int tmp = 0;
        for(int j = i; j < SS.size(); j++) {
          tmp += SS[j];
        }
        if(tmp + SS[i-1] >= mid) {
          return true;
        }
        break;
      }
    }
    reverse(begin(SS), end(SS));
  }
  return false;
}

int main()
{
  cin >> S;
  int c = S[0] - '0';
  int count = 0;

  for(int i = 0; i < S.length(); i++) {
    if(S[i]-'0' == c) {
      count++;
    } else {
      c++; c %= 2;
      SS.push_back(count);
      count = 1;
    }
  }
  if(count > 0) {
    SS.push_back(count);
  }
/*
  for(int s : SS) {
    cout << s << " ";
  }
  cout << endl;
*/
  if(SS.size() == 1) {
    cout << S.length() << endl;
    return 0;
  } else if(SS.size() == 2){
    cout << max(SS[0], SS[1]) << endl;
    return 0;
  } else {
    int l = 0, r = S.length();
    while(r-l > 1) {
      int mid = (l+r)/2;
      if(check(mid)) {
        l = mid;
      } else {
        r = mid;
      }
    }
    cout << l << endl;
  }

  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define NIL -1
typedef long long ll;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll MOD = 1000000007;


void solve() {

    int a, b, result;
    cin >> a >> b;
    for(int i = 1; i <=3; ++i){
        if(i != a && i != b) result = i;
    }
    cout << result << endl;
    return;
}

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

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

void chmin(int& t, int f) { if (f < t) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int D[1024], C[1024], dp[1024][1024];

int main() {
  int N = in();
  int M = in();

  for (int i = 0; i < N; ++i) {
    D[i] = in();
  }
  for (int j = 0; j < M; ++j) {
    C[j] = in();
  }

  memset(dp, 0x3f, sizeof(dp));
  dp[0][0] = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < M; ++j) {
      chmin(dp[i][j + 1], dp[i][j]);
      chmin(dp[i + 1][j + 1], dp[i][j] + D[i] * C[j]);
    }
  }

  int res = 1001001001;
  for (int j = 1; j <= M; ++j) {
    chmin(res, dp[N][j]);
  }
  printf("%d\n", res);

  return 0;
}

Measured memory_bytes: 6828
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;
using ld = long double;
int main()
{
    while (true) {
        int N;
        cin >> N;
        if (N == 0) {
            break;
        }
        vector<ld> X(N);
        vector<ld> R(N);
        for (int i = 0; i < N; i++) {
            cin >> X[i] >> R[i];
        }
        auto ok = [&](const ld S) {
            const ld s = S / 2;
            using P = pair<ld, ld>;
            vector<P> r;
            for (int i = 0; i < N; i++) {
                if (R[i] > s) {
                    const ld l = sqrt(R[i] * R[i] - s * s);
                    r.push_back({X[i] - l, X[i] + l});
                }
            }
            const int size = r.size();
            sort(r.begin(), r.end());
            vector<P> ans;
            int start = 0;
            ld maxi = 0;
            for (; start < size;) {
                ld L = r[start].first;
                ld R = r[start].second;
                for (; start < size;) {
                    if (r[start].first <= R) {
                        R = max(R, r[start].second);
                        maxi = max(maxi, R - L);
                        start++;
                    } else {
                        break;
                    }
                }
            }
            return maxi >= S;
        };
        ld inf = 0;
        ld sup = 1000000;
        for (int i = 0; i < 100; i++) {
            const ld mid = (inf + sup) / 2;
            if (ok(mid)) {
                inf = mid;
            } else {
                sup = mid;
            }
        }
        cout << fixed << setprecision(15) << inf << endl;
    }
    return 0;
}



Measured memory_bytes: 8264
#include <stdio.h>

int main() {
    int a, b, c, x;
    scanf("%d %d %d", &a, &b, &c);
    x = 0;
    for(int i=a; i<=b; i++) {
        if(c%i == 0) x++;
    }
    printf("%d\n", x);
}


Measured memory_bytes: 2740
main :: IO ()                                                                                                              
main = getLine >>= putStrLn . f                                                                                            
                                                                                                                           
f :: String -> String                                                                                                      
f [] = []                                                                                                                  
f [x] = [x]                                                                                                                
f (x:_:xs) = x:f xs

Measured memory_bytes: 4988
#include <bits/stdc++.h>
using namespace std;
using ll= long long ;
using P = pair<ll,ll>;
#define rep(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<ll> vcl;

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}
ll c2(ll n){
    return n*(n-1)/2;
}

int main() {
ll n,k;
cin>>n>>k;
vector<double>p(n+1),q(n+1),r(n+1),s(n+1);
rep(i,n)cin>>p[i];
rep(i,n) q[i]=0.5+0.5*p[i];
for(ll i=0; i < n; i++) s[i+1] = s[i] + q[i+1];
for(ll j=0; j<=n-k;j++) r[j]=s[j+k]-s[j];
 sort(r.begin(), r.end()); 
 reverse(r.begin(),r.end());
 printf("%.12lf\n",r[0]);

return 0;
}


Measured memory_bytes: 6528
#include<stdio.h>
#include<algorithm>
using namespace std;

int main() {
  int n, x;
  scanf("%d %d", &n, &x);
  int m[n];
  int sum = 0;
  for (int i=0 ; i<n ; i++) {
    scanf("%d", &m[i]);
    sum += m[i];
  }
  sort(m, m+n);
  
  int res = sum;
  int cnt = 0;
  while (res + m[0] <= x) {
    res += m[0];
    cnt++;
  }
  printf("%d\n", n+cnt);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) { cin >> a[i]; }
  ll ans = 1e18;

  FOR(c, -100, 101) {
    ll s = 0;
    REP(i, n) {
      ll d = abs(a[i] - c);
      s += d * d;
    }
    ans = min(ans, s);
  }
  cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

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

    vector<long double> v(n);

    REP(i, n) cin >> v.at(i);
    
    sort(v.begin(), v.end());

    long double ans = v.at(0);
    for (int i = 1; i < v.size(); i++) {
        ans = (ans + v.at(i)) / 2;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BTwoContests {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        vector<P> v(N);
        REP(i, N) {
            int l, r;
            cin >> l >> r;
            v[i] = {l, r};
        }
        sort(v.begin(), v.end());

        multiset<int> LL, RL;
        multiset<int> LR, RR;
        multiset<int> L, R;
        int maxv = 0;
        REP(i, N) {
            RL.insert(-v[i].first);
            RR.insert(v[i].second);
            L.insert(-v[i].first);
            R.insert(v[i].second);
        }

        int res = 0;
        REP(i, N - 1) {
            int l = v[i].first;
            int r = v[i].second;
            RL.erase(RL.find(-l));
            RR.erase(RR.find(r));
            LL.insert(-l);
            LR.insert(r);

            int ll = *LL.begin();
            int lr = *LR.begin();
            int rl = *RL.begin();
            int rr = *RR.begin();

            int ls = max(lr + ll + 1, 0LL);
            int rs = max(rr + rl + 1, 0LL);

            res = max(res, ls + rs);
        }

        REP(i, N) {
            int l = v[i].first;
            int r = v[i].second;
            int t1 = max(r - l + 1, 0LL);
            L.erase(L.find(-l));
            R.erase(R.find(r));
            int rr = *R.begin();
            int ll = *L.begin();
            int t2 = max(rr + ll + 1, 0LL);
            res = max(res, t1 + t2);

            L.insert(-l);
            R.insert(r);
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BTwoContests solver;
    solver.solve(in, out);
    return 0;
}


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

int main() {
    string S;  cin >> S;
    int N = S.size();
    S += "0";
    vector<int> RL_idx;
    for (int i = 0; i < N; ++i) {
        if (S.substr(i, 2) == "RL") {
            RL_idx.push_back(i);
        }
    }
    RL_idx.push_back(N);
    // DUMP(RL_idx);

    vector<int> ans(N + 2);
    int now = 0;
    for (int j = 0; j < (int)RL_idx.size(); ++j) {
        int cnt_r = 0, cnt_l = 0;
        while (now < RL_idx[j]) {
            if (S[now] == 'R') ++cnt_r;
            else ++cnt_l;
            ++now;
        }
        now += 2;
        ans[RL_idx[j]] += cnt_r / 2;
        ans[RL_idx[j] + 1] += (cnt_r + 1) / 2;
        if (j > 0) {
            ans[RL_idx[j - 1] + 1] += cnt_l / 2;
            ans[RL_idx[j - 1]] += (cnt_l + 1) / 2;
        }
        ++ans[RL_idx[j]];
        ++ans[RL_idx[j] + 1];
        // DUMP(ans);
    }

    for (int i = 0; i < N; ++i) cout << ans[i] << " ";
    cout << endl;
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <locale>

using namespace std;

int main(void) {
  string str;
  getline(cin, str);
  for (int i = 0; i < str.size(); i++) {
    if(str[i] >= 'a' && str[i] <= 'z'){
      str[i] = toupper(str[i]);
      //str[i] += 'A' - 'a'; どちらでも良い
    }
    else if (str[i] >= 'A' && str[i] <= 'Z'){
      str[i] = tolower(str[i]);
      //str[i] += 'a' - 'A'; どちらでも良い
    }
    cout << str[i];
  }
  cout << endl;
}


Measured memory_bytes: 3144
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    String s=sc.next();
    int[] wb=new int[n+1];
    int[] ww=new int[n+1];
    for(int i=0;i<n;i++){
      wb[i+1]=wb[i];
      ww[i+1]=ww[i];
      (s.charAt(i)=='#'?wb:ww)[i+1]++;
    }
    int min=n;
    for(int i=0;i<=n;i++){
      min=Math.min(wb[i]-wb[0]+ww[n]-ww[i],min);
      //System.err.println((wb[i]-wb[0])+" : "+(ww[n]-ww[i]));
    }
    System.out.println(min);
  }
}

Measured memory_bytes: 41992
#include <iostream>
#include <vector>
#include <string>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graph_utility.hpp>
#include <utility>
#include <boost/foreach.hpp>
#include <cmath>

class UnionFind {
  std::vector<int> parent, height;
public:
  UnionFind(const int node_size) : parent(node_size), height(node_size, 0) {
    for (int i = 0; i < node_size; i++) {
      parent[i] = i;
    }
  }
  // O(α(N))
  int Find(const int x) {
    if (parent[x] == x) {
      return x;
    }
    else {
      // 経路圧縮
      return parent[x] = Find(parent[x]);
    }
  }
  // O(α(N))
  void Union(int x, int y) {
    x = Find(x), y = Find(y);
    if (x == y) {
      return;
    }
    // ランク
    if (height[x] < height[y]) {
      parent[x] = y;
    }
    else {
      parent[y] = x;
      if (height[x] == height[y]) {
        ++height[x];
      }
    }
  }
};

long long int N, M, ans;
long long int a[50 + 1], b[50 + 1];

int main() {
  std::cin >> N >> M;
  for (int i = 1; i <= M; i++) {
    std::cin >> a[i] >> b[i];
  }

  // i 番目の辺をはぶいて
  for (int i = 1; i <= M; i++) {
    UnionFind uf(N);
    for (int j = 1; j <= M; j++) {
      if (i == j) {
        continue;
      }
      uf.Union(a[j] - 1, b[j] - 1);
    }

    int parent = uf.Find(0);
    for (int j = 1; j < N; j++) {
      if (uf.Find(j) != parent) {
        ans++;
        goto retry;
      }
    }
retry:
    continue;
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>
#include<math.h>
int main(void){
  while(1){
      int  n,i;
      scanf("%d",&n);
      
      if(n==0)
      break;
      double a[n],avg=0,b=0;
      for(i=0;i<n;i++){
          scanf("%lf",&a[i]);
          avg+=a[i];
      }
      avg/=(double)n;
      for(i=0;i<n;i++){
          b+=(a[i]-avg)*(a[i]-avg);
      }
      
      printf("%lf\n",sqrt(b/n));
  }
}

Measured memory_bytes: 2700
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    string s;
    cin>>s;
    int ans=0;
    rep(i,0,s.length()-1){
        if(s[i]!=s[i+1])ans++;
    }
    cout<<ans<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 512
import sys
import copy

h, w = map(int, sys.stdin.readline().split())

maps = [list(sys.stdin.readline().rstrip()) for _ in range(h)]

def calcdist(maps, start, end, h, w):
    nextlist = []
    nextlist.append(start)
    count = 1
    while True:
        nexnex = []
        for i in nextlist:
            if i[0] == end[0] and i[1] == end[1]:
                return count
            if i[0] > 0 and maps[i[0] -1][i[1]] == '.':
                maps[i[0] -1][i[1]] = '#'
                nexnex.append([i[0] -1, i[1]])
            if i[0] < h-1 and maps[i[0] +1][i[1]] == '.':
                maps[i[0] +1][i[1]] = '#'
                nexnex.append([i[0] +1, i[1]])
            if i[1] > 0 and maps[i[0]][i[1]-1] == '.':
                maps[i[0]][i[1]-1] = '#'
                nexnex.append([i[0], i[1]-1])
            if i[1] < w-1 and maps[i[0]][i[1]+1] == '.':
                maps[i[0]][i[1]+1] = '#'
                nexnex.append([i[0], i[1]+1])
        nextlist = nexnex
        count += 1
        if len(nexnex) == 0:
            return -1
    return count

kabe = 0

for i in range(h):
    for j in range(w):
        if maps[i][j] == '#':
            kabe += 1

total = 0
dist = calcdist(maps,[0, 0], [h-1, w-1], h, w)
if dist == -1:
    print(-1)
else:
    print(h*w - dist - kabe)


Measured memory_bytes: 40048
#include<bits/stdc++.h>
typedef long long int   ll;
typedef long double     ld;
#define nl              '\n'
#define S               string
#define inf             INT_MAX
#define SQR(a)          (a) * (a)
#define GCD(a, b)       __gcd(a, b)
#define pi              2.0*acos(0.0)
#define LCM(a, b)       (a * b) / GCD(a, b)
#define mem(a,b)        memset(a,b,sizeof(a))
#define srtv(v)         sort(v.begin(),v.end())
#define boost		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inout           freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
using namespace std;


int main()
{
    S s;
    cin>>s;

    int sz=s.size();
    char a[sz];
    int k=0;

    for(int i=sz-1;i>=0;i--)
    {
        a[k]=s[i];
        k++;
    }

    int count=0;

    for(int i=0;i<sz;i++)
    {
        if(a[i] !=s[i])
            count++;
    }
    cout<<count/2;

    return 0;
}


Measured memory_bytes: 256
// Harry Singh**************************************************************************************************************

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 using namespace std;
#define endl '\n'
#define ll long long 
#define maxn 100010
const int MOD = 1000000007;
bool prime[20000000+3]; 

void harry_singh(){

   
   int n,f;cin>>f;
   string s=to_string(f);
   n=s.length();
   if(s[n-1]=='1' || s[n-1]=='0' ||s[n-1]=='6' ||s[n-1]=='8' )cout<<"pon\n";
   else if(s[n-1]=='2' || s[n-1]=='4' ||s[n-1]=='5' ||s[n-1]=='7' ||s[n-1]=='9' )cout<<"hon\n";
   else cout<<"bon\n";
}
 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
 
    int t=1;
    while (t--)
   harry_singh();
    return 0;
}

Measured memory_bytes: 3720
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}
long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

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

long long com(long long n,long long k){
	
}
long long getDigit(long long n){
	if(n==1)return 1;
	else return log10(n)+1;
}

class Point{
public:
	long long x;
	long long y;
};


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int h,w;
	cin>>h>>w;
	for(int i=0;i<h;i++){
		string s;
		cin>>s;
		cout<<s<<endl;
		cout<<s<<endl;
	}
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;

void main(){
	auto x = readln.chomp.to!int;
	auto a = readln.chomp.to!int;
	auto b = readln.chomp.to!int;
	((x - a) % b).writeln;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.util.stream.Collectors;


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

        int N = sc.nextInt();
        Map<Integer, Integer> map = new HashMap<>();

        for (Integer i = 1; i <= N; i++)
            map.put(i, sc.nextInt());

        Map<Integer, Integer> result = map.entrySet().stream()
                .sorted(Map.Entry.<Integer, Integer>comparingByValue()
                        .thenComparing(Map.Entry.comparingByKey()))
                .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));

        for (Map.Entry<Integer, Integer> sorted : result.entrySet()) {
            System.out.printf("%d ", sorted.getKey());
        }

    }
}




Measured memory_bytes: 114444
#include <iostream>
#include <bits/stdc++.h>
#define f first
#define s second

using namespace std;
typedef long long ll;

string str,str2;
int s1,s2;
ll dp[3005][3005];
pair<int,int> con[3005][3005];

ll solve(int idx1,int idx2){

    if(idx1 == s1 || idx2 == s2) return 0;

    if(dp[idx1][idx2] != -1) return dp[idx1][idx2];
    ll ret=0;
    if(str[idx1]==str2[idx2]){
        ret = solve(idx1+1,idx2+1) + 1;
        con[idx1][idx2] = {idx1+1 , idx2+1};
    }
    else{
        ll op1 = solve(idx1+1 ,idx2);
        ll op2 = solve(idx1, idx2+1);
        if(op1 > op2) con[idx1][idx2] = {idx1+1,idx2};
        else con[idx1][idx2] = {idx1,idx2+1};
        ret = max(op1,op2);
    }
    return dp[idx1][idx2] = ret;
}

int main()
{
    cin>>str>>str2;
    s1 =  str.size();
    s2 =  str2.size();
    memset(dp,-1,sizeof(dp));

    ll tmp = solve(0,0);
    pair<int,int> curr = {0,0};
    string sol = "";
    while(curr.f < s1 && curr.s < s2){
       if (con[curr.f][curr.s].f > curr.f && con[curr.f][curr.s].s > curr.s)
            sol+= str[curr.f];
        curr = con[curr.f][curr.s];
    }
    cout<<sol;

    return 0;
}


Measured memory_bytes: 141824
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a,b;
   cin>>a>>b;
   if(a==1&&b==1||a==1&&b==3||a==1&&b==5||a==1&&b==7||a==1&&b==8||a==1&&b==10||a==1&&b==12)
   {
       cout<<"Yes";
   }
   else if(a==3&&b==3||a==3&&b==1||a==3&&b==5||a==3&&b==7||a==3&&b==8||a==3&&b==10||a==3&&b==12)
   {
       cout<<"Yes";
   }
   else if(a==5&&b==5||a==5&&b==1||a==5&&b==3||a==5&&b==7||a==5&&b==8||a==5&&b==10||a==5&&b==12)
   {
       cout<<"Yes";
   }
   else if(a==7&&b==7||a==7&&b==1||a==7&&b==3||a==7&&b==5||a==7&&b==8||a==7&&b==10||a==7&&b==12)
   {
       cout<<"Yes";
   }
   else if(a==8&&b==8||a==8&&b==1||a==8&&b==3||a==8&&b==5||a==8&&b==7||a==8&&b==10||a==8&&b==12)
   {
       cout<<"Yes";
   }
   else if(a==10&&b==10||a==10&&b==1||a==10&&b==3||a==10&&b==5||a==10&&b==7||a==10&&b==8||a==10&&b==12)
   {
       cout<<"Yes";
   }
   else if(a==12&&b==12||a==12&&b==1||a==12&&b==3||a==12&&b==5||a==12&&b==7||a==12&&b==8||a==12&&b==10)
   {
       cout<<"Yes";
   }
   else if(a==4&&b==4||a==4&&b==6||a==4&&b==9||a==4&&b==11)
   {
       cout<<"Yes";
   }
    else if(a==6&&b==6||a==6&&b==4||a==6&&b==9||a==6&&b==11)
   {
       cout<<"Yes";
   }
    else if(a==9&&b==9||a==9&&b==4||a==9&&b==6||a==9&&b==11)
   {
       cout<<"Yes";
   }
    else if(a==11&&b==11||a==11&&b==4||a==11&&b==6||a==11&&b==9)
   {
       cout<<"Yes";
   }
   else if(a==2&&b==2)
   {
       cout<<"Yes";
   }
   else
   {
       cout<<"No";
   }


    return 0;
}


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

int main() {
    int n, m; cin >> n >> m;
    int h[n];
    for (int i = 0; i < n; i++) cin >> h[i];

    vector<int> G[n];
    for (int i = 0; i < m; i++) {
        int a, b; cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int highest = h[i];
        int flag = 1;
        for (int j = 0; j < G[i].size(); j++) {
            if (highest <= h[G[i][j]]) {
                flag = 0;
                break;
            }
        }
        if (flag) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 9156
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include<set> 
#include<math.h>
#define pai arccos(-1);
#define keta(n) cout << fixed << setprecision((n));
#define ll long long;
int main(){
  int a;
  cin>>a;
  cout<<a+a*a+a*a*a;

}


Measured memory_bytes: 3592
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner = new Scanner(System.in);
		String input = scanner.nextLine();
		String a = input.substring(0, input.length()/2);
		String rev = reverse(input);
		String b = rev.substring(0, input.length()/2);
		int cnt = 0;
		for (int i = 0; i<input.length()/2; i++) {
			if(a.charAt(i) != b.charAt(i)) cnt++;
		}
		System.out.println(cnt);
	}
	
	private static String reverse(String str) {
		StringBuffer sb = new StringBuffer(str);
		return sb.reverse().toString();
	}

}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char* argv[])
{
	long long N,A,B;
	cin>>N>>A>>B;
	vector<long long> X(N,0);
	int i;
	for (i=0;i<N;i++){
		cin>>X[i];
	}
	long long d;
	long long aw=0;
	for (i=0;i<N-1;i++){
		d=X[i+1]-X[i];
		aw+=min(d*A,B);
	}
	cout<<aw<<endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import java.math.*;
import java.io.*;


public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String args[]) {
        String s = sc.next();
        int max = 0;
        for(int i = 0; i < s.length(); i++) {
            for(int j = i; j <= s.length(); j++) {
                String sub = s.substring(i,j);
                boolean ok = true;
                for(int k = 0; k < sub.length(); k++) {
                    if(sub.charAt(k) != 'A' && sub.charAt(k) != 'C' && sub.charAt(k) != 'G' && sub.charAt(k) != 'T') ok = false;
                }
                if(ok) max = Math.max(max, sub.length());
            }
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 21972
import sys

k=int(input())

lun=[i for i in range(1,10)]
while 1>0:
    if k <=len(lun): 
        print(lun[k-1])
        sys.exit()
    else:
        k-=len(lun)
        lunw=[]
        for i in range(len(lun)):
            if lun[i]%10!=0:
                lunw.append(lun[i]*10+lun[i]%10-1)
            lunw.append(lun[i]*10+lun[i]%10)
            if lun[i]%10!=9:
                lunw.append(lun[i]*10+lun[i]%10+1)
    lun =lunw

Measured memory_bytes: 17444
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<typename T,typename U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

struct edge{
    int to,id;
    ll dist;
    edge(int to,ll dist=1,int id=1):to(to),id(id),dist(dist){};
};

template<typename Monoid,typename F>
class SegmentTree{
private:
    int sz;
    vector<Monoid> seg;
    const F op;//演算
    const Monoid e;//単位元
public:
    SegmentTree(int n,const F op,const Monoid &e):op(op),e(e){
        sz = 1;
        while(sz<=n) sz <<= 1;
        seg.assign(2*sz,e);
    }
    //代入
    void set(int k, const Monoid &x){
        seg[k+sz] = x;
    }
    //前計算(?)
    void build(){
        for(int i=sz-1;i>0;i--){
            seg[i] = op(seg[2*i],seg[2*i+1]);
        }
    }
    void update(int k,const Monoid &x){
        k += sz;
        seg[k] += x;
        while(k>>=1){
            seg[k] = op(seg[2*k],seg[2*k+1]);
        }
    }
    Monoid query(int l,int r){
        Monoid L = e,R = e;
        for(l+=sz,r+=sz;l<r;l>>=1,r>>=1){
            if(l&1) L = op(L,seg[l++]);
            if(r&1) R = op(seg[--r],R);
        }
        return op(L,R);
    }
    Monoid operator[](const int &k)const{
        return seg[k+sz];
    }
};

class EulerTourForEdge{
private:
    vec<int> down,up,dep,btm;
    vvec<edge> g;
    void dfs(int cur,int par,int d){
        dep[cur] = d;
        for(auto& e:g[cur]) if(e.to!=par){
            down[e.to] = btm.size();
            btm.push_back(e.to);
            dfs(e.to,cur,d+1);
            up[e.to] = btm.size();
            btm.push_back(e.to);
        }
    }

public:
    EulerTourForEdge(){}
    EulerTourForEdge(int N,int root,vvec<edge> g):down(N),up(N),dep(N),g(g){
        btm.clear();
        down[root] = btm.size();
        btm.push_back(root);
        dfs(root,-1,0);
        up[root] = btm.size();
        btm.push_back(root);
    }

    int child(int u,int v){return dep[u]<dep[v]? v:u;}

    int bottom(int e){return btm[e];}

    template<class T,class G>
    void update(int u,T x,G g){
        g(down[u],x);
        g(up[u],-x);//inverse
    }

    template<class F>
    //u-v path s.t. lca(u,v) = u or v
    void query(int u,int v,F f){
        if(dep[u]>dep[v]) swap(u,v);
        f(down[u]+1,down[v]);
    }
};

int main(){
    int N;
    cin >> N;
    vvec<edge> tree(N);
    for(int i=0;i<N;i++){
        int k;
        cin >> k;
        for(int j=0;j<k;j++){
            int c;
            cin >> c;
            tree[i].push_back(c);
        }
    }

    EulerTourForEdge et(N,0,tree);
    auto add = [](ll a,ll b){return a+b;};
    SegmentTree<ll,decltype(add)> seg(2*N,add,0);
    int Q;
    cin >> Q;

    auto g = [&](int i,ll x){seg.update(i,x);};
    auto f = [&](int l,int r){cout << seg.query(l,r+1) << "\n";};
    for(int i=0;i<Q;i++){
        int t;
        cin >> t;
        if(t==0){
            int v; ll w;
            cin >> v >> w;
            et.update(v,w,g);
        }else{
            int v;
            cin >> v;
            et.query(0,v,f);
        }
    }
}


Measured memory_bytes: 26164
n,m=map(int,input().split())
arr=[0]+list(map(int,input().split()))
g=[[] for _ in range(n+1)]
for _ in range(m):
  a,b=map(int,input().split())
  g[a].append(b)
  g[b].append(a)
ans=0
for v in range(1,n+1):
  for u in g[v]:
    if arr[u]>=arr[v]:
      break
  else:
    ans+=1
print(ans)

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

#define int int_fast64_t
const int mod = 998244353;  

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

  int n, s; cin >> n >> s;
  vector<int> v;
  copy_n(istream_iterator<int>(cin), n, back_inserter(v));

  vector<int> dp(s+1);
  for (int i = 0; i < n; ++i) {
    int x = v[i];
    if (x == s)
      (dp[s] += (i+1)*(n-i)) %= mod;
    else if (x < s)
      (dp[s] += dp[s-x]*(n-i)) %= mod;
    for (int k = s-1; k > x; --k)
      (dp[k] += dp[k-x]) %= mod;
    if (x < s)
      (dp[x] += i+1) %= mod;
  }
  cout << dp[s] << '\n';
}



Measured memory_bytes: 384