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

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;

const ll MOD = 998244353;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);

#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define ull unsigned long long
#define deb(x )     cerr << #x << " = "<< x << endl;
#define endl    "\n"
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof(y))
#define all(x) (x).begin(), (x).end()
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC
#define verify(x) if(x >= MOD) x -= MOD;

inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void print_case(int tn) {cout<<"Case #"<<tn<<": ";}

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;
/*----------------------------------------------------------------------*/

const int nax = 3005;
ll n,s, arr[nax], pref[nax][nax], dp[nax][nax]; // dp[i][j] = sum of starting index of subseq ending at i with sum j

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    clock_t clk = clock();

    cin>>n>>s;
    FOR(i, 1, n + 1) cin>>arr[i];
    memset(dp, 0, sizeof(dp));
    dp[1][arr[1]] = 1; pref[1][arr[1]] = 1;
    FOR(i, 2, n + 1) {
        FOR(j, 0, s + 1) {
            if(j < arr[i]) continue;
            ll sm = pref[i - 1][j - arr[i]];
            // FOR(k, 1, i) {
            //     sm += dp[k][j - arr[i]]; sm %= MOD;
            // }
            dp[i][j] = sm;
        }
        if(arr[i] <= s) {
            dp[i][arr[i]] += i; dp[i][arr[i]] %= MOD;
        }
        FOR(j, 0, s + 1) {
            pref[i][j] = dp[i][j] + pref[i - 1][j];
            pref[i][j] %= MOD;
        }
    }
    ll res = 0;
    FOR(i, 1, n + 1) {
        res += (dp[i][s] * 1LL * (n - i + 1))%MOD;
        res %= MOD;
    }
    cout<<res;
    cerr << endl << "Time (in ms): " << double(clock() - clk) * 1000.0 / cps << endl;
    return 0;
}

Measured memory_bytes: 141312
#include <bits/stdc++.h>
using namespace std;
int n;
double x,D[4000],D_[4000],ans;
main () {
	cin>>n;
	D_[0]=1;
	for (int i=1; i<=n; i++) {
		cin>>x;
		
		for (int j=0; j<i; j++) {
	  	D[j]+=D_[j]*(1-x);
			D[j+1]+=D_[j]*(x);
		}
		
		for (int j=0; j<=i; j++) 
	  	D_[j]=D[j],D[j]=0;
	}
	
	for (int i=n/2+1; i<=n; i++)
		ans+=D_[i];
	
	printf("%.9f\n",ans);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    long long ans = 0LL;
    for (int j = 1; j <= 5; ++j) {
        for (int i = 1; i <= n - 3 + 1; ++i) {
            if ((8 * i + 9 * j + 9) % 11 == k) {
                ans++;
                if (n - 3 + 1 - i >= 11) {
                    ans += (n - 3 + 1 - i) / 11;
                }

                break;
            }
        }
    }


    cout << ans << endl;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001001001001ll;

int N;
string S;

int dp[333333][3];

int solve(vint v){
    int n=v.size();
    rep(i,n+1)rep(j,3)dp[i][j]=-INF;
    dp[0][0]=0;
    rep(i,n){
        chmax(dp[i+1][0],dp[i][0]);
        chmax(dp[i+1][0],dp[i][1]);
        chmax(dp[i+1][0],dp[i][2]+v[i]);

        chmax(dp[i+1][1],dp[i][0]+v[i]);
        if(v[i]>=2)chmax(dp[i+1][1],dp[i][1]+v[i]-1);


        chmax(dp[i+1][2],dp[i][0]);
        if(v[i]>=2)chmax(dp[i+1][2],dp[i][1]);
        if(v[i]>=2)chmax(dp[i+1][2],dp[i][2]+v[i]-1);
    }

    return dp[n][0];
}

signed main(){
    cin>>N;
    cin>>S;
    S+="00000";
    N=S.size();
    vint v;
    int cur=0;

    int ans=0;
    while(cur<N){
        int nex=cur;
        while(nex<N&&S[cur]==S[nex])nex++;
        if(S[cur]=='1'){
            v.pb(nex-cur);
        }
        else{
            if(nex-cur>1){
                ans+=solve(v);
                v.clear();
            }
        }
        cur=nex;
    }

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


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

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

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    ll ans = 0;
    for(i = 1;i <= n;++i){
        ll inf = i;
        ll sup = n-n%i;
        ll tmp = (inf + sup)*((sup-inf)/i + 1)/2;
        ans += tmp;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#define FOR(n) for(int i = 0;i < n;i++)
#define PRN(n) printf("%d\n",n)

 int main(void){
   int a, b;
   int i=scanf("%d%d",&a,&b);
   a = a * a;
   PRN(a-b);
   return 0;
}

Measured memory_bytes: 128
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int n; string a[255];
int check(int x, int y, int dx, int dy) {
	int ret = 0;
	while(0 <= x && x < n && 0 <= y && y < n) {
		if(a[y][x] == '0') return ret;
		x += dx, y += dy, ret++;
	}
	return ret;
}
int main() {
	while(~scanf("%d", &n), n) {
		for(int i = 0; i < n; i++) cin >> a[i];
		int ret = 0;
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				for(int k = -1; k <= 1; k++) {
					for(int l = -1; l <= 1; l++) {
						if(k != 0 || l != 0) {
							ret = max(ret, check(j, i, l, k));
						}
					}
				}
			}
		}
		printf("%d\n", ret);
	}
	return 0;
}

Measured memory_bytes: 3276
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <cmath>
#include <cstdint>
#include <climits>
using namespace std;

inline namespace atcoder {
    using i32 = int32_t; using u32 = uint32_t;
    using i64 = int64_t; using u64 = uint64_t;
    using f32 = float; using f64 = double;

    template <typename T, size_t Depth>
    struct vector_helper { using type = vector<typename vector_helper<T, Depth - 1>::type>; };
    template <typename T>
    struct vector_helper<T, 0> { using type = T; };
    template <typename T, size_t Depth>
    using vector_t = typename vector_helper<T, Depth>::type;

    template <typename T> using vec = vector_t<T, 1>;
    template <typename T> using vvec = vector_t<T, 2>;
    template <typename T> using vvvec = vector_t<T, 3>;
}

int main() {
    int n; cin >> n;
    vec<int> x(n);
    for (auto &e : x) cin >> e;

    int ans = INT_MAX;
    for (int i = 1; i <= 100; ++i) {
        int sum = 0;
        for (auto e : x) sum += (e - i) * (e - i);
        ans = min(ans, sum);
    }

    cout << ans << endl;
}



Measured memory_bytes: 3608
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

long long dp[30+1];

long long get_dp(int n);

int main(void) {
    for (int i = 0; i <= 30; i++) dp[i] = -1;
    while (1) {
        int n;
        cin >> n;
        if (n == 0) break;
        long long ans, tmp;
        tmp = get_dp(n);
        ans = tmp / 10;
        if (ans * 10 < tmp) ans++;
        tmp = ans / 365;
        if (tmp * 365 < ans) tmp++;
        cout << tmp << endl;
    }

    return 0;
}

long long get_dp(int n) {
    if (dp[n] != -1) return dp[n];
    else if (n == 0 || n == 1) return dp[n] = 1;
    else if (n == 2) return dp[n] = 2;
    else return dp[n] = get_dp(n-1) + get_dp(n-2) + get_dp(n-3);
}

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

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

    int a, b;
    cin >> a >> b;
    
    int ans = 0;
    REP(i, b - a){
        ans += i;
    }
    cout << ans - a << endl;

    return 0;
}

Measured memory_bytes: 256
<?php
$stdins = '';
$flg_check = false;

$stdins = explode(' ', trim(fgets(STDIN)));

$al = substr($stdins[0], -1, 1);
$bs = substr($stdins[1], 0, 1);
$bl = substr($stdins[1], -1, 1);
$cs = substr($stdins[2], 0, 1);

if($al == $bs && $bl == $cs) $flg_check = true;

if($flg_check){
    printf('YES');
} else {
    printf('NO');
}
?>

Measured memory_bytes: 3828
import java.util.*;

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

        int R = sc.nextInt();
        int C = sc.nextInt();
        int K = sc.nextInt();

        int[][] field = new int[R + 1][C + 1];
        for(int i = 0; i < K; i++){
            field[sc.nextInt()][sc.nextInt()] = sc.nextInt();
        }

        long[][][] dp = new long[R + 1][C + 1][4];
        for(int i = 1; i < R; i++){
            for(int j = 1; j < C; j++){
                Arrays.fill(dp[i][j], Long.MIN_VALUE);
            }
        }
        dp[1][1][0] = 0;

        for(int i = 1; i <= R; i++){
            for(int j = 1; j <= C; j++){
                if(field[i][j] > 0){
                    dp[i][j][0] = Math.max(dp[i - 1][j][3], dp[i][j - 1][0]);
                    dp[i][j][1] = Math.max(dp[i][j - 1][1],
                                           Math.max(dp[i - 1][j][3], dp[i][j - 1][0]) + field[i][j]);
                    dp[i][j][2] = Math.max(dp[i][j - 1][2],
                                           Math.max(dp[i - 1][j][3], dp[i][j - 1][1]) + field[i][j]);
                    dp[i][j][3] = Math.max(dp[i][j - 1][3],
                                           Math.max(dp[i - 1][j][3], dp[i][j - 1][2]) + field[i][j]);
                }else{
                    dp[i][j][0] = Math.max(dp[i - 1][j][3], dp[i][j - 1][0]);
                    dp[i][j][1] = Math.max(dp[i - 1][j][3], dp[i][j - 1][1]);
                    dp[i][j][2] = Math.max(dp[i - 1][j][3], dp[i][j - 1][2]);
                    dp[i][j][3] = Math.max(dp[i - 1][j][3], dp[i][j - 1][3]);
                }
            }
        }


        System.out.println(dp[R][C][3]);

        /*
        for(int i = 0; i < R + 1; i++){
            for(int j = 0; j < C + 1; j++){
                System.out.print(field[i][j] + " ");
            }
            System.out.println();
        }
        System.out.println();

        for(int k = 0; k < 4; k++){
            for(int i = 0; i < R + 1; i++){
                for(int j = 0; j < C + 1; j++){
                    System.out.print(dp[i][j][k] + " ");
                }
                System.out.println();
            }
            System.out.println();
        }

         */

    }


}


Measured memory_bytes: 702392
n=int(input())
n_str = str(n)
ans = 0

if len(n_str) == 1:
    print(n)
elif len(n_str) == 2:
    print(9)
elif len(n_str) == 3:
    print(9+n-99)
elif len(n_str) == 4:
    print(909)
elif len(n_str) == 5:
    print(9+900+n-9999)
else:
    print(90909)


Measured memory_bytes: 3060
/* monkukui 競技プログラミング用のテンプレート  (ここから) */
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using Graph = vector<vector<int>>;
using Wgraph = vector<vector<pair<int, long long int>>>;
constexpr long long int INF = 1001001001001001LL;
constexpr long long int MOD = 1000000007LL;
constexpr double PI = 3.1415926535897932;
constexpr long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
constexpr long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = 1; i <= (n); i++)
#define DREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define SREP(i,s,t) for(int i = s; i < t; i++)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define PB push_back

/* monkukui 競技プログラミング用のテンプレート (ここまで)*/

int main(){
  
  lint n, k; cin >> n >> k;
  vector<lint> a(n);
  vector<lint> f(n);
  REP(i, n) cin >> a[i];
  REP(i, n) cin >> f[i];
  sort(ALL(a));
  sort(RALL(f));
  
  lint lb = -1;
  lint ub = 10000000000000;
  while(ub - lb > 1) {
    double mid = (ub + lb) / 2;
    
    lint cnt = 0;
    for(lint i = 0; i < n; i++) {
      lint need = mid / f[i];
      cnt += max(a[i] - need, 0LL);
    }

    if(cnt > k) lb = mid;
    else ub = mid;
  }

  cout << ub << endl;
  return 0;
}


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


int main()
{
    //freopen("test.inp","r",stdin);
    string s, s1;
    int k;
    cin>>k;
    cin.get();
    getline(cin,s);
    s1="";
    if(s.length()<=k) cout<<s;
    else
    {
        for(int i=0; i<k; i++)
        {
            s1+=s[i];
        }
        s1+="...";
        cout<<s1;
    }
    return 0;
}


Measured memory_bytes: 3588
// Problem : A - Five Variables
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb push_back
#define mk make_pair
#define fast                    \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define rep(i, a, b) for (ll i = a; i < b; i++)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define sz(x) (int)x.size()
#define mem(a, val) memset(a, val, sizeof(a))
#define deci(x) cout << fixed << setprecision(x);
#define bitcount(x) __builtin_popcountll(x)

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

const long long int mod = 1e9 + 7;
const long double EPS = 1e-12;
const int N = 1e5 + 20;

void solve() {
  ll cnt = 1;
  ll temp;
  rep(i, 0, 5) {
    cin >> temp;
    if (temp == 0) {
      cout << cnt;
      return;
    }
    cnt++;
  }
}
int main() {
  fast;
  ll t;
  t = 1;

  // cin>>t;

  while (t--) {
    solve();
  }

  return 0;
}


Measured memory_bytes: 3644
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N, A, B = get_ints

X = A + B

a = (N / X) * A
b = (N % X > A) ? A : N % X

puts a + b


Measured memory_bytes: 14544
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
-- import Data.List
-- import qualified Data.Vector.Unboxed as VU
-- import qualified Data.Vector.Unboxed.Mutable as VUM
-- import Control.Monad
-- import Control.Monad.ST
-- import Debug.Trace
trace _ = id

solve :: Int -> Int -> Int -> Int -> Int -> Int -> (Int,Int)
solve a b c d e f = (y, z)
  where
  (x, y, z) = maximum [ fromWater (100 * a * na + 100 * b * nb)
                      | nb <- [0 .. f `div` (100 * b)],
                        na <- [0 .. (f - (100*b*nb)) `div` (100*a)]]

  fromWater :: Int -> (Double, Int, Int)
  fromWater 0 = (0.0, 0, 0)
  fromWater water | trace ("fromWater " ++ show water) False = undefined
  fromWater water = maximum [ fromD nd | nd <- [0 .. sugarLim `div` d] ]
    where
    sugarLim = min ((water `div` 100) * e) (f - water)
    fromD :: Int -> (Double, Int, Int)
    fromD nd = ((fromIntegral (100 * sugar)) / (fromIntegral (water + sugar)),
                water + sugar, sugar)
      where
      nc = (sugarLim - d * nd) `div` c
      sugar = c * nc + d * nd

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> (Int,Int)
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_a,bs_b,bs_c,bs_d,bs_e,bs_f]:remLines1 = remLines0
      a = readBInt bs_a
      b = readBInt bs_b
      c = readBInt bs_c
      d = readBInt bs_d
      e = readBInt bs_e
      f = readBInt bs_f
  in solve a b c d e f

outAnswer :: (Int,Int) -> IO ()
outAnswer (x,y) = putStrLn (show x ++ " " ++ show y)

main :: IO ()
main = outAnswer . tmain =<< B.getContents


Measured memory_bytes: 892
#include<bits/stdc++.h>
#define int long long
using namespace std;
using P=pair<int,int>;
const int INF=1000000000000;
signed main(){
  int N,M;
  cin>>N>>M;
  vector<vector<P>> A(N);
  while(M--){
    int a,b,c;
    cin>>a>>b>>c;
    A[a-1].push_back({b-1,c});
    A[b-1].push_back({a-1,-c});
  }
  vector<int> B(N,INF);
  for(int i=0;i<N;i++){
    if(B[i]!=INF)continue;
    queue<int> Q;
    Q.push(i);
    B[i]=0;
    int mx=0,mn=0;
    while(!Q.empty()){
      int I=Q.front();
      Q.pop();
      mx=max(mx,B[I]);
      mn=min(mn,B[I]);
      for(P p:A[I]){
        if(B[p.first]==INF){
          B[p.first]=B[I]+p.second;
          Q.push(p.first);
        }else if(B[p.first]!=B[I]+p.second){
          puts("No");
          return 0;
        }
      }
    }
    if(mx-mn>1000000000){
      puts("No");
      return 0;
    }
  }
  puts("Yes");
}

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

#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define out(x) cout << x << endl;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int main(){
    ll w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << w*h/2.0 << " ";
    if(y == (double)h / 2.0 && x == (double)w / 2.0){//( y == (double)h/(double)w * (double)x || y == h -(double)h/(double)w * (double)x){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

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

using namespace std;

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

	string week[7] = { "SUN", "MON","TUE","WED","THU","FRI","SAT" };

	for (int i = 0; i < 7; i++) {
		if (week[i] == S) {
			cout << 7 - i  << endl;
		}
	}



}






Measured memory_bytes: 3580
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
int n; string s[SZ],t;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>s[i];
	cin>>t;
	int l=1,r=1;
	for(int i=1;i<=n;i++)
	{
		bool L=0,R=0;
		string x=s[i];
		for(int j=0;j<x.size();j++)
			if(s[i][j]=='?') x[j]='z';
		if(x>=t) R=1;
		for(int j=0;j<x.size();j++)
			if(s[i][j]=='?') x[j]='a';
		if(x<=t) L=1;
		if(L&&R) ++r;
		else if(L) ++l,++r;
	}
	for(int i=l;i<=r;i++) cout<<i<<" \n"[i==r];
}


Measured memory_bytes: 6144
#include <cstdio>
#include <vector>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n; n--;
    int m = 0, p = 1, i = 1;
    vector<pair<int, int> > e[21];
    while (n > 0) {
        if (n % 2 == 0) {
            e[i].push_back(make_pair(20, n*p));
            n--;
            m++;
        } else {
            e[i].push_back(make_pair(i+1, 0));
            e[i].push_back(make_pair(i+1, p));
            n /= 2; p *= 2; i++; m += 2;
        }
    }
    while (i < 20) { e[i].push_back(make_pair(i+1, 0)); i++; m++; }
    printf("20 %d\n", m);
    for (int i = 1; i <= 20; i++)
        for (auto q : e[i]) printf("%d %d %d\n", i, q.first, q.second);
}


Measured memory_bytes: 256
import java.io.{BufferedReader, InputStreamReader}
import java.util.Arrays.binarySearch
import java.util

object Main extends App {
  val in = new BufferedReader(new InputStreamReader(System.in))
  val n = in.readLine.toInt
  val a, b, c = in.readLine.split(" ").map(_.toLong)

  util.Arrays.sort(a)
  util.Arrays.sort(b)
  util.Arrays.sort(c)
  
  val ans = {
      var posA = 0
      var posC = 0

      def findA(tar:Long):Int = {
        // val pa = binarySearch(a, posA, n, tar - 1)
        // posA = if(pa > -1) pa else ~pa
        while(posA < n && a(posA) < tar) posA += 1
        posA
      }
      def findC(tar:Long):Int = {
        // val pc = binarySearch(c, posC, n, tar - 1)
        // posC = if(pc > -1) pc else ~pc
        while(posC < n && c(posC) <= tar) posC += 1
        posC
      }

      b./:(0L)((acc,e) => {
        val ac = findA(e)
        val cc = n - findC(e)

        acc +  ac.toLong * cc.toLong
      })
    }

  println(ans)
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

const int INF=123456;

int main()
{
    int p,q;
    while(cin >>p >>q,p)
    {
        vector<int> pr(p,0),pc(p,0),ps(p,0);
        vector<int> indent(p);
        rep(i,p)
        {
            string s;
            cin >>s;

            int now=0;
            while(now<s.size() && s[now]=='.') ++now;
            indent[i]=now;

            rep(j,s.size())
            {
                if(s[j]=='(') ++pr[i];
                else if(s[j]==')') --pr[i];
                else if(s[j]=='{') ++pc[i];
                else if(s[j]=='}') --pc[i];
                else if(s[j]=='[') ++ps[i];
                else if(s[j]==']') --ps[i];
            }
        }

        vector<int> qr(q,0),qc(q,0),qs(q,0);
        rep(i,q)
        {
            string s;
            cin >>s;

            rep(j,s.size())
            {
                if(s[j]=='(') ++qr[i];
                else if(s[j]==')') --qr[i];
                else if(s[j]=='{') ++qc[i];
                else if(s[j]=='}') --qc[i];
                else if(s[j]=='[') ++qs[i];
                else if(s[j]==']') --qs[i];
            }
        }

        vector<int> ans(q,INF);
        rep(x,20)rep(y,20)rep(z,20)
        {
            int R=x+1, C=y+1, S=z+1;

            bool valid=true;
            int PR=0,PC=0,PS=0;
            rep(i,p)
            {
                int ex_indent=PR*R+PC*C+PS*S;
                if(ex_indent!=indent[i])
                {
                    valid=false;
                    break;
                }

                PR+=pr[i];
                PC+=pc[i];
                PS+=ps[i];
            }

            if(!valid) continue;

            int QR=0,QC=0,QS=0;
            rep(i,q)
            {
                int qq=QR*R+QC*C+QS*S;
                if(ans[i]==INF) ans[i]=qq;
                else if(ans[i]!=-1)
                {
                    if(ans[i]!=qq) ans[i]=-1;
                }

                QR+=qr[i];
                QC+=qc[i];
                QS+=qs[i];
            }
        }

        rep(i,q)
        {
            if(i) printf(" ");
            printf("%d", ans[i]);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
#include<string>
#include<cmath>

using namespace std;

#define ll long long int
#define ld long double
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define deb(x) cout<< #x << '=' << x <<endl
#define MOD 1000000007
const int N = 1e5 + 5;
vector<vector<pair<int,int>>> adj;
int vis[N];
int col[N];
void dfs(int v , int skip){
    vis[v] = 1;
    int c = 1;
    for(int i = 0; i<sz(adj[v]); i++){
        if(vis[adj[v][i].fi]){
            continue;
        }
        if(c == skip){
            c++;
        }
        col[adj[v][i].se] = c;
        dfs(adj[v][i].fi,c);
        c++;
    }
}
int main() {    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;
    for(int i = 0; i<n; i++){
        vector<pair<int,int>> v;
        adj.pb(v);
    }
    for(int i = 0; i<n-1; i++){
        int u,v;
        cin>>u>>v;
        u--;
        v--;
        adj[u].pb({v,i});
        adj[v].pb({u,i});
    }
    int ans = 0;
    for(int i = 0; i<n; i++){
        ans = max(ans , sz(adj[i]));
    }
    cout<<ans<<"\n";
    dfs(0,-1);
    for(int i = 0; i<n-1; i++){
        cout<<col[i]<<"\n";
    }

}

Measured memory_bytes: 11404
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;
typedef pair<int,int> P;

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

int main()
{

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

    double K[40];
    int A[40][40];
    int LIKE[40][40]={0};

    REP(i,N){
    	cin >> K[i];
    	REP(j,K[i]){
    		cin >> A[i][j];
    		LIKE[i][A[i][j]-1]=1;
    	}
    }


    int ans = 0;
    REP(i,M){
    	bool flag = true;
    	REP(j,N){
    		if(LIKE[j][i]==0){
    			flag = false;
    			break;
    		}
    	}
    	if(flag) ans ++;
    }


    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;
using ll = long long;

int main() {
    int k;
    vector<int> v(5);
    int sum = 0;
    for (int i = 0; i < (int)(5); i++){
        cin >> v[i];
        sum += v[i];
    }

    cout << 15 - sum << endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>

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

    int k = 1;
    for ( ; ; ++k)
        if (k * (k+1) >= 2*N)
            break;
    int rem = k * (k + 1) / 2 - N;
    for (int i = 1; i <= k; ++i)
        if (rem != i)
            printf("%d\n", i);

    return 0;
}


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

int main() {
  string s;
  cin >> s;
  int c = 0;
  if (s[0] == '1') c++;
  if (s[1] == '1') c++;
  if (s[2] == '1') c++;
  cout << c << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <limits>
#include <map>
#include <cmath>
#include <set>

using namespace std;

int main()
{
    int a, b, x;
    cin >> x >> a >> b;
    if (b - a  <= 0)
        cout << "delicious" << endl;
    else if (b-a >= x+1)
        cout << "dangerous" << endl;
    else
        cout << "safe" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
	int l;
	char s[32],r[32];
	scanf("%s",s);
	l=strlen(s);
	for(int i=0;i<l;i++){
		r[l-i-1]=s[i];
	}
	for(int i=0;i<l;i++){
		printf("%c",r[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 2624
#include<stdio.h>
#define MAX 10000
#define NOT_FOUND -1
int linearSearch(int );
int n,s[MAX];
int main(){
  int i,q,t[MAX],res=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&t[i]);
  }
  
  for(i=0;i<q;i++){
    if(linearSearch(t[i]) == 1)
      res++;
  }
  printf("%d\n",res);
  return 0;
}
int linearSearch(int a){
  int count =0;
  s[n] = a;
  while(a!=s[count]){
    count++;
    if(count==n)return NOT_FOUND;
  }
	      return 1;
}

Measured memory_bytes: 644
n,d,a = gets.split.map(&:to_i)
monsters = n.times.map{ gets.split.map(&:to_i) } 

monsters.map!{ |xh| xh[1] = (xh[1]+a-1)/a; xh }.sort_by!{ |xh| xh[0] }

deq = []
acc_damage = 0
ans = 0
monsters.each do |xh|
  
  while deq.size > 0 && deq[0][0] < xh[0] do
    acc_damage -= deq[0][1]
    deq.shift
  end
  
  need = xh[1] - acc_damage
  need = 0 if need < 0
  
  if need > 0
    acc_damage += need
    ans += need
    deq.push( [xh[0] + d*2, need] )
  end
end

puts ans

Measured memory_bytes: 22520
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

ll mergecount(vector<int> &a) {
    ll count = 0;
    int n = a.size();
    if (n > 1) {
        vector<int> b(a.begin(), a.begin() + n/2);
        vector<int> c(a.begin() + n/2, a.end());
        count += mergecount(b);
        count += mergecount(c);
        for (int i = 0, j = 0, k = 0; i < n; ++i)
        if (k == c.size())       a[i] = b[j++];
        else if (j == b.size())  a[i] = c[k++];
        else if (b[j] <= c[k])   a[i] = b[j++];
        else                   { a[i] = c[k++]; count += n/2 - j; }
    }
    return count;
}

int main() {
    int n;
    cin >> n;
    vector<int> b(n), w(n);
    char c[n*2];
    int a[n*2];
    rep(i,n*2){
        cin >> c[i] >> a[i];
        a[i]--;
        if(c[i] == 'B'){
            b[a[i]] = i;
        }else{
            w[a[i]] = i;
        }
    }

    int black[n][n+1];
    rep(i,n){
        int pos = b[i];
        int cnt = 0;
        rep(j,n){
            if(w[j] < pos) cnt++;
        }
        black[i][0] = cnt;
        rep(j,n){
            if(w[j] < pos) cnt--;
            else cnt++;
            black[i][j+1] = cnt;
        }
    }

    int dp[n][n+1];
    rep(i,n)rep(j,n+1)dp[i][j] = 1001001001;

    rep(i,n){
        if(i == 0){
            rep(j,n+1) dp[i][j] = black[i][j];
        }else{
            int mi = 1001001001;
            rep(j,n+1){
                mi = min(mi, dp[i-1][j]);
                dp[i][j] = mi + black[i][j];
            }
        }
    }

    int tmp = 1001001001;
    rep(j,n+1) tmp = min(tmp, dp[n-1][j]);

    int ans = mergecount(b) + mergecount(w) + tmp;

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




Measured memory_bytes: 34928
#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<complex>
using namespace std;
typedef long long int llint;
int main(){
	int a, b, c;
	cin >> a >> b;
	if (a > b){
		cout << a - b << endl;
	}
	else{
		cout << 0 << endl;
	}
	return 0;
}


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

const ll INF =  1e18L + 5;

int main(){
	ll n,W;
	cin>>n>>W;
	ll weight[n],val[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>weight[i]>>val[i];
	}

	ll val_sum = 0;
	for (int i = 0; i < n; ++i)
	{
		val_sum += val[i];
	}

	vector<ll> dp(val_sum+1,INF);
	dp[0] = 0;
	for (int i = 0; i < n; ++i)
	{
		for(ll j=val_sum;j>=val[i];j--){
			dp[j] = min(dp[j],dp[j-val[i]]+ weight[i]);
		}
	}

	ll answer = 0;
	for (ll i = 0; i <= val_sum; ++i)
	{
		if (dp[i]<=W)
		{
			answer = max(answer,i);
		}
	}

	cout<<answer<<endl;
	return 0;
}

Measured memory_bytes: 3976
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

int main() {
  string S;
  cin >> S;
  int cnt=0;
  for(int i=0; i<S.size()-1; ++i){
    if(S[i] != S[i+1]) ++cnt;
  }
  if(cnt == S.size()-1) cout << "Good" << endl;
  else cout << "Bad" << endl;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
h = list(map(int,input().split()))
dp = [10**15+1 for i in range(N)]
dp[0] = 0
for i in range(N):
    for j in range(1,K+1):
        if i+j<N:
            dp[i+j] = min(dp[i+j],dp[i]+abs(h[i]-h[i+j]))
        
print(dp[-1])

Measured memory_bytes: 56544
#include <bits/stdc++.h>
using namespace std;;
typedef long long ll;
int main()
{
    int n;
    cin>>n;
    int ac=0,wa=0,tle=0,re=0;
    while(n--)
    {
        string s;
        cin>>s;
        if(s=="AC")
            ac++;
        else if(s=="WA")
            wa++;
        else if(s=="TLE")
            tle++;
        else
            re++;
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;
    return 0;
}


Measured memory_bytes: 3564
s = input()

def r(s):
    l = len(s)
    if(l%2 == 1):
        return r(s[:-1])
    elif(s[:int(l/2)] == s[int(l/2):]):
        return len(s)
    else:
        return r(s[:-1])
print(r(s[:-1]))

Measured memory_bytes: 3060
// --------------
// Tejas Pandey  |
// 22 - 08 - 20  |
// Atcoder BC 176|
// --------------

#include <bits/stdc++.h>
using namespace std;
     
#define mod 1000000007
#define vi vector<int>
typedef long long int ll;
       
int main (void){
  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int h,w,m;
  cin >> h >> w >> m;
  int cnt[w + 1];
  memset(cnt,0,sizeof(cnt));
  vector<pair<int,int>> bmbs(m);
  for(int i = 0;i < m;i++) cin >> bmbs[i].first >> bmbs[i].second,cnt[bmbs[i].second]++;
  sort(bmbs.begin(),bmbs.end());
  set<pair<int,int>> st;
  int cp[w + 1];
  for(int i = 1;i <= w;i++) st.insert({cnt[i],i}),cp[i] = cnt[i];
  int ans = 0;
  for(int i = 0;i < m;i++){
	  int j = i;
	  set<int> upd;
	  int now = 0;
	  while(j < m && bmbs[i].first == bmbs[j].first) cnt[bmbs[j].second]--,upd.insert(bmbs[j].second),j++,now++;
	  i = j - 1;
	  for(auto it:upd){
		st.erase({cp[it],it});
		st.insert({cnt[it],it});
	  } 
	  auto itr = st.rbegin();
	  ans = max(ans,now + (*itr).first);
	  for(auto it:upd){
		st.erase({cnt[it],it});
		st.insert({cp[it],it});
		cnt[it] = cp[it];
	  } 
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 35908
#include <iostream>
#include <cmath>
#include <vector>
#include <unordered_map>

using namespace std;

#define fi first
#define se second

int N;
int hx, hy, mx, my;
typedef pair<double, double> P;
P cs[21];

#define SQ(x) ((x)*(x))
inline double dist(P a, P b) {
  return sqrt(SQ(a.fi-b.fi) + SQ(a.se-b.se));
}

unordered_map<int, double> umap;

double G[22][22];
bool dfs(int S, int now, double cost) {
  
  if(S == (1<<N)-1) {
    return true;
  }
  
  umap[S] = cost;
  
  for(int i=0; i<N; i++) {
    if(S >> i & 1) continue;
    if(G[i][N+1] <= cost+G[now][i]) return false;
  }
  
  for(int i=0; i<N; i++) {
    if(S >> i & 1) continue;
    if(umap.count(S|(1<<i)) && umap[S|(1<<i)] <= cost+G[now][i]) continue;
    if(dfs(S|(1<<i), i, cost+G[now][i])) return true;
  }
  
  return false;
}

bool solve() {
  
  umap.clear();
  
  for(int i=0; i<N; i++) {
    for(int j=i+1; j<N; j++) {
      G[i][j] = G[j][i] = dist(cs[i], cs[j]);
    }
    G[N][i] = G[i][N] = dist(P(hx, hy), cs[i]);
    G[N+1][i] = G[i][N+1] = dist(P(mx, my), cs[i]);
  }
  
  for(int i=0; i<N; i++) {
    if(G[N+1][i] <= G[N][i]) continue;
    if(dfs(1<<i, i, G[N][i])) return true;
  }
  
  return false;
}

int main() {
  while(1) {
    cin >> N >> hx >> hy >> mx >> my;
    if(!N) break;
    for(int i=0; i<N; i++) {
      cin >> cs[i].fi >> cs[i].se;
    }
    cout << (solve() ? "YES" : "NO") << endl;
  }
  
  return 0;
}

Measured memory_bytes: 15296
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define ull unsigned long long

int main(){
    int x,y;
    scanf("%d%d",&x,&y);
    if ((y-2*x)<0||(4*x-y)<0) {
        printf("No");
        return 0;
    }
    if ((y-2*x)%2==0&&(4*x-y)%2==0) {
        printf("Yes");
    }else printf("No");
    return 0;
}


Measured memory_bytes: 1736
K=int(input())
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

Sum1=0
for i in range(1,K+1):
    for j in range(1,i+1):
        Ans=0
        Ans=gcd(i,j)
        for k in range(1,j+1):
            if i==j==k:
                Sum1+=gcd(Ans,k)
            elif i!=j!=k:
                Sum1+=6*gcd(Ans,k)
            else:
                Sum1+=3*gcd(Ans,k)

print(Sum1)

Measured memory_bytes: 9212
using System;
using System.Linq;

namespace ConsoleApp1
{

    class Program
    {

        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var n = input[0];
            var m = input[1];

            var h = new long[n];
            var goodview = new bool[n];

            var input1 = Console.ReadLine().Split().Select(long.Parse).ToArray();

            for (int i = 0; i < n; i++)
            {
                h[i] = input1[i];
                goodview[i] = true;
            }

            for (int i = 0; i < m; i++)
            {
                var input2 = Console.ReadLine().Split().Select(int.Parse).ToArray();
                var a = input2[0] - 1;
                var b = input2[1] - 1;
                if (h[a] <= h[b])
                    goodview[a] = false;
                if (h[b] <= h[a])
                    goodview[b] = false;
            }

            int res = 0;
            for (int i = 0; i < n; i++)
                if (goodview[i]) res++;

            Console.WriteLine(res);
        }

    }
}



Measured memory_bytes: 55260
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        if (S.equals("AAA") || S.equals("BBB")) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
vector<string> ans;
ll n;
void dfs(string &a){
    if(a.size()==n){
        ans.pb(a);return;
    }
    char x=*a.rbegin();
    set<char> st;
    rep(i,a.size()){
        st.ins(a[i]);
    }
    rep(i,st.size()+1){
        char y='a'+i;
        string k=a+y;
        dfs(k);
    }
}
int main(){
    cin >> n;
    string k="a";
    dfs(k);
    sort(all(ans));
    for(auto p:ans)cout << p <<endl;
}

Measured memory_bytes: 7456
import java.util.Scanner;


class Main{

    private static int max(int a,int b){
        if(a > b){
            return a;
        }else{
            return b;
        }
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int A = sc.nextInt();
        int B = sc.nextInt();

        int a = A+B;
        int b = A-B;
        int c = A*B;

        int ans = (max(max(a,b),c));

        System.out.println(ans);
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	int n;cin>>n;
	string s[n];
	int a=0,b=0,c=0,cnt=0;
	rep(i,n){
		cin>>s[i];
		if(s[i][0]=='B'&&s[i][s[i].size()-1]=='A') c++;
		else if(s[i][s[i].size()-1]=='A') a++;
		else if(s[i][0]=='B') b++;
		for(int j=0;j<s[i].size()-1;j++){
			if(s[i][j]=='A'&&s[i][j+1]=='B') cnt++;
		}
	}
	//cout<<a<<" "<<b<<" "<<c<<"\n";
	if(a+b==0&&c>0) cnt+=c-1;
	else cnt+=c+min(a,b);

	cout<<cnt<<"\n";
}

Measured memory_bytes: 768
s = input()
ans = "Yes"
for i in range(len(s)):
  if i % 2 != 0:
    if s[i] not in ["L","U","D"]:
      print("No")
      exit()
  else:
    if s[i] not in ["R","U","D"]:
      print("No")
      exit()
print("Yes")


Measured memory_bytes: 2940
// Problem : D - Axis-Parallel Rectangle
// Contest : AtCoder - AtCoder Beginner Contest 075
// URL : https://atcoder.jp/contests/abc075/tasks/abc075_d
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}
//bool collinear(int x)
void solve()
{
	int n,kt;cin>>n>>kt;
	vi x,y;
	int ans=4e18;
	vp v;
	for(int i=0;i<n;i++)
	{
		int xt,yt;cin>>xt>>yt;
		v.pb({xt,yt});
		x.pb(xt);
		y.pb(yt);
	}
	sort(all(x));
	sort(all(y));
	for(int i=0;i<n;i++)
	{
		for(int j=i;j<n;j++)
		{
			for(int k=0;k<n;k++)
			{
				for(int l=k;l<n;l++)
				{
					int cnt=0;
					for(int m=0;m<n;m++)
					if(v[m].f>=x[i] and v[m].f<=x[j] and v[m].se>=y[k] and v[m].se<=y[l])
					cnt++;
					if(cnt>=kt)
					ans=min2(ans,(x[j]-x[i])*(y[l]-y[k]));
				}
			}
		}
	}
	cout<<ans;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
using namespace std;

int main() {
  long long a,b,k; //高橋　青木　回数
  cin>>a>>b>>k;
  if(a>k){
    cout<<a-k<<" "<<b<<endl;
  }
  else if (a+b>k){
    cout<<0<<" "<<a+b-k<<endl;
  }
  else{
    cout<<"0 0"<<endl;
  }
}



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

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



Measured memory_bytes: 3632
import itertools
N = int(input())
L = input().split()
L = [int(i) for i in L]
count = 0
if(len(L) > 2):
  for comb in itertools.combinations(L, 3):
    comb = list(comb)
    if(len(set(comb))==3):
      if(comb[0]+comb[1] > comb[2]):
        if(comb[1]+comb[2] > comb[0]):
          	if(comb[2]+comb[0] > comb[1]):
          		count += 1
print(count)
  

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

using namespace std;

int main(){
    bool a = 1;
    int n;
    string s;
    cin>>n;
    cin>>s;
    if(n%2==1){
        cout<<"No"<<endl;
    }else{
    n = n/2;
    for(int i = 0; i < n; i++){
        if(s[i] != s[i + n]){
            a = 0;
            break;
        }
    }
    if(a == 1){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}
}

Measured memory_bytes: 256