akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include <stdlib.h>
#include <math.h>
int main() {

	int x, a, b;
	scanf("%d%d%d", &x, &a, &b);
	
	if (abs(a - x) < abs(b - x))printf("A\n");
	else printf("B\n");
	return 0;
}


Measured memory_bytes: 128
/// Updated! https://www.youtube.com/watch?v=U07_n9xGIlM
#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define dbug printf("I am here\n");
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int maxn = 2e5+100;

const ll inf = 1e18;
ll dp[15][10][2][2];
int n;
vector < int > digits;

ll solve(int i , int prv , bool st , bool pos){

    if(i >= n and st == true)return 1;
    if(i >= n)return 0;
    ll &ret = dp[i][prv][st][pos];
    if(ret != -1)return ret;
    int rg = digits[i];
    if(pos == false)rg = 9;

    ret = 0;
    for(int j = 0; j<=rg; j++){
        if(st == false)
            ret += solve(i+1,j,st||j>0, pos&&j==rg);
        else if(abs(prv-j)<=1){
            ret += solve(i+1,j,st||j>0 , pos&&j==rg);
        }
    }
    return ret;
}

ll gen(ll num){
    digits.clear();
    while(num>0){
        digits.push_back(num%10);
        num/=10;
    }
    n = digits.size();
    reverse(digits.begin(),digits.end());
}

int main()
{
    fast;
    ll k; cin >> k;
    ll lo = 0 , hi = 1e12 , ans = 0;
    while(lo <= hi){
        ll mid = (lo + hi)/2;
        gen(mid);
        memset(dp,-1,sizeof dp);
        if(solve(0,10,false,true) >= k){
            ans = mid;
            hi = mid - 1;
        }
        else lo = mid + 1;
    }
    cout << ans << endl;
    return 0;
}
/*



*/


Measured memory_bytes: 256
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

ll a[MAXn],b[MAXn];

int main()
{
    IOS();
    ll n,h;
    cin>>n>>h;
    REP(i,n)cin>>a[i]>>b[i];
    ll tt=0;
    REP(i,n)tt+=b[i];
    ll t=*max_element(a,a+n),ct=0;
    if(tt<h)
    {
      ll k=h-tt;
      ct=(k-1)/t+1;
      h-=ct*t;
    }

    {
      sort(b,b+n,greater<ll>());
      REP(i,n)
      {
        h-=max(b[i],t);
        if(h<=0)
        {
          cout<<i+1+ct<<endl;
          return 0;
        }
      }

    }
}


Measured memory_bytes: 1792
#include <stdio.h>

#define MAX_N 1024
static int H, W;
static char A[MAX_N][MAX_N];
typedef struct queue {
  int i;
  int j;
  int d;
} t_queue;
static t_queue queue[MAX_N*MAX_N];
static int src;
static int dst;

void add_queue(int i, int j, int d) {
  A[i][j] = '#';
  queue[dst].i = i;
  queue[dst].j = j;
  queue[dst].d = d;
  dst++;
  //if((dst % MAX_N) == 0)
  //dst = 0;
}

int main(void) {
  scanf("%d %d", &H, &W);
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      scanf(" %c", &A[i][j]);
      if(A[i][j] == '#') {
	add_queue(i, j, 0);
      }
    }
  }

  int max_d = 0;
  while(src != dst) {
    int i = queue[src].i;
    int j = queue[src].j;
    int d = queue[src].d;
    if(max_d < d) max_d = d;
    //printf("%d-%d-%d\n", i, j, d);

    if((i != 0) && (A[i-1][j] == '.')) {
      add_queue(i-1, j, d+1);
    }
    if((j != 0) && (A[i][j-1] == '.')) {
      add_queue(i, j-1, d+1);
    }
    if((i != (H-1)) && (A[i+1][j] == '.')) {
      add_queue(i+1, j, d+1);
    }
    if((j != (W-1)) && (A[i][j+1] == '.')) {
      add_queue(i, j+1, d+1);
    }
    src++;
    //if((src % MAX_N) == 0)
    //src = 0;
  }

  printf("%d\n", max_d);
  return 0;
}


Measured memory_bytes: 13440
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto A = RD;
	auto B = RD;

	bool ans;
	if (A % 3 == 0)
		ans = true;
	else if (B % 3 == 0)
		ans = true;
	else if ((A + B) % 3 == 0)
		ans = true;

	writeln(ans ? "Possible" : "Impossible");
	stdout.flush();
	debug readln();
}

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

#define MAX_N 200000

using namespace std;

typedef long long lint;

const lint MOD = (lint)(1e9) + 7;

int n;

struct elem
{
    lint a, b;
    double c;
    int sign;
};

elem v[2][MAX_N + 1];

unordered_map <double, int> ap;

map <pair<lint, lint>, int> w[2];

struct cmp
{
    bool operator() (const elem &x, const elem &y)
    {
        return x.a * y.b < x.b * y.a;
    }
};

lint p2[MAX_N + 1];
/*
int k;
elem diff[MAX_N + 1];

void getDiff()
{
    diff[++ k] = v[1];
    for(int i = 2; i <= n; i ++)
    {
        if(((v[i].a != v[i - 1].a) || (v[i].b != v[i - 1].b)) && ( ) )

    }
}*/

int main()
{
    lint ab = 0, a = 0, b = 0;
    cin >> n;
    lint na, nb;
    for(int i = 1; i <= n; i ++)
    {
        cin >> na;
        cin >> nb;

        if(nb == 0 || na == 0)
        {
            if(na == 0 && nb == 0)
                ab ++;

            else
                if(na == 0)
                    a ++;

            else
                if(nb == 0)
                    b ++;
        }

        else
        {
            lint x = __gcd(na, nb);

            na /= x;
            nb /= x;


            lint sign = ((na * nb < 0) ? 0 : 1);

            if(na < 0)
                na = -na;

            if(nb < 0)
                nb = -nb;

         //   cout << na << " " << nb << " ++\n";
            w[sign][{na, nb}] ++;

        }
    }


    p2[0] = 1;
    for(int i = 1; i <= n; i ++)
        p2[i] = p2[i - 1] * 2 % MOD;

    lint rez = 1;
    lint ant = 1;
    for(auto u : w[1])
    {
        lint a = u.first.first;
        lint b = u.first.second;
        lint c = u.second;

       // cout << " AVEM POZ " << a << " " << b << " ap " << c << "\n";

        if(w[0][{b, a}] == 0)
        {
            rez = rez * p2[c] % MOD;
        }

        else
        {
            lint n1 = c;
            lint n2 = w[0][{b, a}];

            w[0][{b, a}] = 0;

            rez = rez * (p2[n1] + p2[n2] - 1) % MOD;
        }
    }

    for(auto u : w[0])
    {
        lint a = u.first.first;
        lint b = u.first.second;
        lint c = u.second;


      //  cout << " AVEM NEG " << a << " " << b << " ap " << c << "\n";

        if(w[1][{b, a}] == 0)
        {
            rez = rez * p2[c] % MOD;
        }
    }

    rez = rez * (p2[a] + p2[b] - 1) % MOD;
    rez = rez + ab % MOD;


    rez --;
    if(rez < 0)
        rez += MOD;

    cout << rez << "\n";

    return 0;
}


Measured memory_bytes: 29956
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int r;
  while (cin >> r) {
    cout << (r * r) << endl;
  }
  return 0;
}


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

using namespace std;

#define make_unique(a) (a.erase(unique(a.begin(),a.end()),a.end()))
#define allof(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define exists(s, e) (s.find(e)!=s.end())
#define INF 0x3f3f3f3f
#define endl '\n'
#define mp make_pair
#define readln(x) (getline(cin, x))
#define watch(x) cout << (#x) << " is " << (x) << endl;

typedef pair<int, int> pii;
typedef long long ll;

ll gcd(ll a, ll b) {return b == 0 ? a : gcd(b, a % b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

const int MAXN = 1e5 + 5;

ll dp[MAXN];

void solve() {
    int n, k;
    cin >> n >> k;
    fill(dp, dp+n, 1LL*1e18);
    vector<int> h(n+1);
    for(int i=0; i<n; i++) cin >> h[i];
    dp[0] = 0;
    for(int i=0; i<n; i++) {
        for(int j=1; j<=k; j++) {
            if(i+j>=n) break;
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i]-h[i+j]));
        }
    }
//    for(int i=1; i<=5; i++) {
//        watch(dp[i]);
//    }
    cout << dp[n-1] << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    solve();
    return 0;
}



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


int main() {
  double a, b, x;
  cin >> a >> b >> x;
  
  double ans;
  if (x <= a * a * b / 2.0) {
    ans = atan(a * b * b / 2.0 / x);
  } else {
    ans = atan(2.0 * b / a - 2 * x / (a * a * a));
  }

  ans *= 180.0 / M_PI;
  printf("%.10f", ans);
  return 0;
}

Measured memory_bytes: 4100
A, B = map(int, input().split())

def gcd(a, b):
    if a > b:
        a, b = b, a
    while a != 0:
        b, a = a, b % a
    return b

X = gcd(A, B)

ans_l = []
while X % 2 == 0:
    X //= 2
    ans_l.append(2)
f = 3
while f * f <= X:
    if X % f == 0:
        X //= f
        ans_l.append(f)
    else:
        f += 2
if X != 1:
    ans_l.append(X)

print(len(set(ans_l))+1)


Measured memory_bytes: 38640
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(a, max(b, c))
#define MIN(x, y, z) min(a, min(b, c))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll N;
  cin >> N;
  mll m;
  rep(i, N) {
    ll a;
    cin >> a;
    m[a - 1]++;
    m[a]++;
    m[a + 1]++;
  }

  ll ans = 0;
  for (auto mm : m) {
    ans = max(ans, mm.second);
  }
  ANS;
  return 0;
}

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

int main() {
    int m, d;
    cin >> m >> d;

    int count = 0;
    for (int i = 1; i <= m; i++) { // month
        for (int j = 10; j <= d; j++) { // day
            int J = j;
            int d1 = J % 10;
            J /= 10;
            int d10 = J % 10;
            if ((d1 >= 2) && (d10 >= 2) && (d1 * d10 == i)) {
                count++;
            }
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main()
{
 int i, j, x, y;
 do {
  scanf("%d%d", &x, &y);
  for(i = 0; i < x; i++) {
   for(j = 0; j < y; j++) {
    printf("#");
   }
   printf("\n");
  }
  if(x != 0 && y != 0) {
   printf("\n");
  }
 } while(x != 0 && y != 0);
 return 0;
}

Measured memory_bytes: 572
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for ( auto blockTime = make_pair(chrono::high_resolution_clock::now(), true);blockTime.second;\
debug("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false)
#define li long long int
#define ld long double
#define eb push_back
#define pb pop_back
#define INF 1e18+10
#define MINF -1e18-10
#define rep(i,a,b) for(li i=a;i<b;i++)
#define size(a) a.size()
#define rev(a) reverse(a.begin(),a.end())
#define len(a) a.length()
#define f first
#define s second
#define sort(a) sort(a.begin(),a.end())
#define vli vector<li>
#define vvli vector<vli >
#define pli pair<li,li>
#define vpli vector<pli>
#define inp(t) li t;cin>>t; while(t--)
using namespace std;
const li mod = 1e9+7;
#define MAXN 1000005 

li power(li a, li b, li mod) { a%=mod; li ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=mod) ret%=mod;if(a>=mod) a%=mod;b>>=1;}return ret;}
li powerinv(li a)
{
  return power(a,mod-2,mod);
}

li facts[200005] = {0};
li fact()
{ 
  facts[0] = 1; 
  for (li i = 1; i <= 2e5+5; i++) 
    facts[i] = (facts[i - 1] * i) % mod;
}

void solve()
{
  li a;
  cin>>a;

  cout<<a+a*a+a*a*a<<endl;
}

int main()
{
    IOS;

	solve();
    return 0;
}

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

#define lli long long int
#define pb push_back

int main()
{
  int l;
  cin >> l;
  double ans;
  double k = (double)l / 3;
  ans = k * k * k;
  printf("%.12lf\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include <cstdlib>
#include <typeinfo>
#include <math.h>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << n); bit++)
using namespace std;

template<class T>
void print(const T &value) {
    std::cout << value << std::endl;
}

void yesno(bool a) { if (a)cout << "yes" << endl; else cout << "no" << endl; }

void YesNo(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

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;
}

ll INF = 10000000;
ll mod = 1000000007;//10^9+7
int dx[8] = {-1, 0, 0, 1, -1, -1, 1, 1};
int dy[8] = {0, -1, 1, 0, -1, 1, -1, 1};
using Graph = vector<vector<int>>;//隣接リスト:G[i]にはiと隣接する頂点が入るよ。
using P = pair<int, int>;//BFSで利用。queueに入れる。
using lP = pair<ll, ll>;
using PP = pair<int, P>; //dijkstraで利用,priority_queueに入れる。
using p_queue = priority_queue<int, vector<int>, greater<int>>;//小さい順
//struct edge{int to, cost};

class UnionFindTree {

public:
    UnionFindTree(int size) : memberSize(size) {
        par.resize(size * sizeof(ll));
        rnk.resize(size * sizeof(ll));
        REP(i, size) {
            par[i] = i;
            rnk[i] = 1;
        }
    }

    int memberSize;

    vector<int> par;
    vector<int> rnk;

//n個のnodeで初期化する関数
    void init(ll n) {
        REP(i, n) {
            par[i] = i;
            rnk[i] = 1;
        }
    }

//木の根を求める。この際，親は根に更新される。
    int find(ll x) {
        if (par[x] == x) { return x; }
        else { return par[x] = find(par[x]); }
    }

//xとyが同じ集合に属するか判定
    bool same(ll x, ll y) {
        return find(x) == find(y);
    }

//xとyの属する集合を融合
    void unite(ll x, ll y) {
        x = find(x);
        y = find(y);
        if (x == y) { return; }

        if (rnk[x] < rnk[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if (rnk[x] == rnk[y]) { rnk[x]++; }
        }
    }
};


//番号ズレ注意！！
int main() {
    int N, M;
    cin >> N >> M;
    int p[N+1];
    REP_1(i, N) {
        cin >> p[i];
    }
    UnionFindTree Tree(N+1);
    REP(i, M) {
        int x, y;
        cin >> x >> y;
        Tree.unite(x, y);
    }
    int cnt=0;
    REP_1(i,N){
        if(Tree.same(p[i],i)){cnt++;}
    }
    print(cnt);
}

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

#define M1 1000000007
#define M2 1000000009
#define ll long long 
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define INF 1001001001
#define PI 3.1415926535897932384626
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define f0(i, n) for (int i = 0; i < (int)(n); ++i)
#define f1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define fc0(i,l,r) for(int i = (int)(l); i<(int)(r); ++i)
#define fc1(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i)
#define fr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii; 
 
void init()
{
  #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
      freopen("error.txt", "w", stderr);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
}
 
signed main()
{
    init();
    string s;
    cin>>s;
    if(isupper(s[0])){cout<<"A"<<endl;}
    else{cout<<"a"<<endl;}
    cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    return 0;
}

Measured memory_bytes: 3768
n,k = list(map(int,input().split() ))

noTrick=[]

for ik in range(k):

    d =int(input())
    ad = list(map(int,input().split() ))
    for id in range(d):
        for iad in ad:
            noTrick.append(iad)
#   print("aaaa:",k,id,ad)

print( n -  len(set(noTrick)))

Measured memory_bytes: 16668
#include <stdio.h>

int main() {

	int n, p, i = 0, j = 0,k,koisi;
	int N[50] = { 0 };
	int ans[10000] = {0};

	while (1) {
		scanf("%d %d", &n, &p);

		if (n == 0 && p == 0)
			break;

		koisi = p;
		
		while (1) {
			if (p == 0) {
				p = N[i];
				N[i] = 0;
			}
			else {
				p--;
				N[i]++;
				if (N[i] == koisi) {
					ans[j] = i;
					break;
				}
			}
			i++;
			if (i == n)
				i = 0;
			
		}
		for (k = 0; k < n; k++)
			N[k] = 0;
		i = 0;
		j++;
	}
	
	for (i = 0; i < j; i++)
		printf("%d\n", ans[i]);

	return 0;
}

Measured memory_bytes: 644
#include<stdio.h>

#define true 1
#define false 0

int linearSearch(int A[], int key, int n){
  int i;

  for(i = 0; i < n; i++){
    if(A[i] == key){
      return true;
    }
  }
  return false;
}

int main(){
  int S[10000], T[500];
  int i, n, q;
  int count = 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(S, T[i], n) == true){
      count++;
    }
  }

  printf("%d\n", count);

  return 0;
}



Measured memory_bytes: 2092
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define swap(type ,a ,b) {type t; t=a; a=b; b=t;}
#define forN(i,n) for(i=0;i<n;i++)
#define forR(i,s,n) for(i=s;i<n;i++)
#define ll long long
#define pb(t,d,n) {t p;int i;forN(i,n){cin>>p;d.push_back(p);}}

using namespace std;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;

typedef vector<pair<int,int>> vpii;

int main(){
    int n,m,tmpl,tmpr,res,i,j;
    vpii lr;
    cin >> n >> m;
    forN(i,m){
        cin >> tmpl >> tmpr;
        lr.push_back({tmpl,tmpr});
    }
    res = 0;
    tmpr = 0;
    tmpl = n+1;
    forN(i,m){
        tmpr = max(tmpr,lr[i].first);
        tmpl = min(tmpl,lr[i].second);
    }
    cout << ((res=tmpl-tmpr+1)<0?0:res) << endl;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int k;
  cin>>k;
  string s;
  cin>>s;
  
  for(int i=0;i<s.size();i++)
  {
    int x=s[i];
    if(x+k>90) 
    {
      s[i]=s[i]+k-26;
    }
    else s[i]+=k;
  }
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
      
int main(void) {
	long a, b, x, ans;

    scanf("%ld%ld%ld", &a, &b, &x);
    
    if (a == 0) {
    	ans = b / x + 1;
    } else {
    	ans = ( b / x ) - ( ( a - 1 ) / x );
    }
    
    printf("%ld\n", ans);
    
    return 0;
}

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

#define m(a,b) memset(a,b,sizeof(a))
#define rep(i,n) for(int i=1;i<=n;i++)
typedef long long ll;
const int MAXN=1e5+10;

int check(int x){
	int e=x%10;
	x/=10;
	int d=x%10;
	x/=10;
	int c=x%10;
	x/=10;
	int b=x%10;
	x/=10;
	int a=x%10;
	if (a==e&&b==d) return 1;
	return 0;
}	

int main(){
	int a,b,ans=0;
	scanf("%d%d",&a,&b);
	if (a>b) swap(a,b);
	for(int i=a;i<=b;i++){
		if (check(i)) ans++;
	}
	printf("%d\n",ans);
	return 0;
}

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

int main(void)
{
    int H, W;
    while(true){
        cin >> H >> W;
    if(H == 0 && W == 0){
        break;
    }
    for(int j = 0; j < W; j++){
        cout << '#';
    }
    cout << endl;
     for(int i = 1; i < H-1; i++){
        cout << '#';
         for(int j = 1; j < W-1; j++){
        cout << '.';
    }
    cout << '#' << endl;
  }
   for(int j = 0; j < W; j++){
        cout << '#';
    }
    cout << endl << endl;
    }
}


Measured memory_bytes: 3076
#include <iostream>
#include <string>
#include <set>

int n;

std::string s;
std::set<std::string> set;

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

    for (int i = 0; i < n; ++i)
    {
        std::cin >> s;
        set.insert(s);
    }

    std::cout << set.size() << std::endl;

    return 0;
}

Measured memory_bytes: 19204
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
    int N;
    scanf("%d", &N);
    int h[N];
    for (int n = 0; n < N; n++) {
        scanf("%d", &h[n]);
    }
    int count = 0, fin = 0;
    while (fin == 0) {
        fin = 1;
        int pun = -1;
        int isFirstZ = 1, counted = 0, isLastZ = 0;
        for (int i = 0; i < N; i++) {
            if (h[i] != 0) {
                h[i]--;
                fin = 0;
                if (isFirstZ == 1) {
                    isFirstZ = 0;
                }
                counted = 0;
                isLastZ = 0;
            } else {
                isLastZ = 1;
                if (isFirstZ == 0 && counted == 0) {
                    count++;
                    counted = 1;
                }
            }
        }
        if (isLastZ == 0) {
            count++;
        }
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl '\n'
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void  solve(){
 	int a,p;
 	cin>>a>>p;
 	cout<<((a*3+p)>>1)<<endl;
}
int32_t main(){
  IOS;
  solve();
  //debug();
 #ifdef LOCAL_DEFINE
 cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
 #endif	
}


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

int sum_max(int a, int b, int k){
  if(a >= k) return k;
  if(b >= k - a) return a;
  return a + (k - a - b) * -1;
}

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  
  cout << sum_max(A, B, K) << endl;
}

Measured memory_bytes: 3592
import itertools


num_sticks = int(input())

sticks = list(map(int, input().split()))

stick_combinations = list(itertools.combinations(sticks, 3))

counter = 0

for a, b, c in stick_combinations:
    if a == b or b == c or c == a:
        continue

    if abs(b - c) < a < (b + c):
        counter += 1

print(counter)


Measured memory_bytes: 20536
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int get_xor(int n)
{
	int rem = n % 4;
	if (rem == 0)  return n;
	else if (rem == 1)  return 1;
	else if (rem == 2)  return n + 1;
	else if (rem == 3)  return 0;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	//one thing to observe in this question is XOR repeated after %4
	//one more very important property n^
	int a, b;
	cin >> a >> b;
	int ans = get_xor(b)^get_xor(a - 1);
	cout << ans << en;

	return 0;
}



Measured memory_bytes: 3672
#include <iostream>

using namespace std;
int main()
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    
    if(x-r >= 0 && y-r >= 0 && y+r <= h && x+r <= w)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


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

using namespace std;


int main(){
	long long int N, X;
	cin >> N >> X;
	vector<long long int >S(N);
	for( size_t i = 0; i < N; i++ ){
		cin >> S[i];
	}
	sort(S.rbegin(), S.rend());
	long long int minv = S[N - 1];
	auto now = map<long long int, long long int>();
	now[X] = 1;
	for( long long int i = 0; i < N; i++ ){
		auto s = S[i];
		auto prev = now;
		now= map<long long int, long long int>();



		for( auto x : prev ){
			now[x.first] += x.second*(N-i-1);
			now[x.first] %= 1000000007LL;
			now[x.first%s] += x.second;
			now[x.first%s] %= 1000000007LL;
		}
	}
	long long int sum = 0;
	for( auto s : now ){
		if( s.first < minv ){
			sum += s.first*s.second;
			sum %= 1000000007LL;
		}
	}
	cout << sum << endl;
}


Measured memory_bytes: 1664
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N, H, W;
    cin >> N >> H >> W;

    cout << (N - H + 1) * (N - W + 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<functional>


#define ll long long int

using namespace std;

int main() {
  int n;
  int a[100];
  int b[100];

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

  int max = a[0];

  for (int i = 0; i < n; i++) {
    cin >> b[i];
    max += b[i];
  }

  int current = max;
  for(int i = 0; i < n - 1; i++) {
    int tmp = current - b[i] + a[i+1];
    if (tmp > max) {
      max = tmp;
    }
    current = tmp;

  }

  cout << max << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int partition(vector<int> & a, vector<char> & b, int p, int r )
{
	int x = a[r];
	int i = p - 1;
	for (int j = p; j < r; j++ ){
		if (a[j] <= x ){
			i++;
			swap (a[i], a[j] );
			swap (b[i], b[j] );
		} // end dif
	} // end for
	swap (a[i+1], a[r] );
	swap (b[i+1], b[r] );

	return i+1;
}

void quick_sort (vector<int> &a, vector<char> &b, int p, int r )
{
	if (p < r ){
		int q = partition (a, b, p, r );
		quick_sort (a, b, p, q-1 );
		quick_sort (a, b, q+1, r );
	} // end if
}

int main()
{
	ios_base::sync_with_stdio(0);
	int n; cin >> n;
	vector<int> a(n, 0 );
	vector<char> b(n, 0 );

	set<int> suit; suit.clear();

	rep (i, n ){
		cin >> b[i] >> a[i];
		suit.insert (a[i] );
	} // end rep

	map<int,int> cnt; cnt.clear();
	set<int>::iterator it = suit.begin();
	int m = 0;
	for (; it != suit.end(); it++ ){
		int num = (*it);
		cnt[num] = m++;
	} // end for		

	vector<string> str(m, "" );
	rep (i, n ) str[cnt[a[i]]] += b[i];

	quick_sort (a, b, 0, n-1 );

	bool is_stable = true;
	rep (i, n ){
		string s = str[cnt[a[i]]];
		if ( s[0] == b[i] ){
			str[cnt[a[i]]] = s.substr(1);
		}else{
			is_stable = false;
			break;
		} // end if
	} // end rep		

	cout << (is_stable ? "Stable" : "Not stable" ) << endl;
	rep (i, n ) cout << b[i] << ' ' << a[i] << endl;

	return 0;
}

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

using namespace std;
int main(void){
    for(;;){
	int n,m,count=0,ans=0;
	int a,flag=0;
	int p=0;
	int b[10000]={0};
	cin >> n;
	cin >> m;
	if(n==0)break;
	for(int i=0;i<n;i++)cin >>b[i];
	for(int i=0;i<m;i++){
        cin >> a;
        p+=a;
        p+=b[p];
        count++;
        if(flag==0&&p>=n-1)ans=count,flag=1;
    }
    cout << ans <<endl;


    }
	return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<double, ll> P;

const ll MOD = ll(1e9 + 7);
const ll INF = LLONG_MAX;
const ll MAX_N = ll(1e3) + 5;
const double EPS = 1e-8;
const double PI = 3.14159265359;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)

int main() {
    int a,b;
    cin >> a >> b;
    if(a>8||b>8)cout << ":(" << endl;
    else cout << "Yay!" << endl;
    return 0;
}


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

int main(){
  string a;
  cin >> a;
  if(a=="A"||a=="B"||a=="C"||a=="D"||a=="E"||a=="F"||a=="G"||a=="H"||a=="I"||a=="J"||a=="K"||a=="L"||a=="M"||a=="N"||a=="O"||a=="P"||a=="Q"||a=="R"||a=="S"||a=="T"||a=="U"||a=="V"||a=="W"||a=="X"||a=="Y"||a=="Z"){
    cout << "A"<<endl;
  }else cout << "a" <<endl;
}

Measured memory_bytes: 3564
import java.util.*;

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

      int n = Integer.parseInt(sc.next());
      int m = Integer.parseInt(sc.next());

      long ans = 0;

      PriorityQueue<Integer> q = new PriorityQueue<>(Collections.reverseOrder());

      long[] a = new long[n];
      for(int i=0;i<n;i++){
        q.add(sc.nextInt());
      }

      for(int i=1;i<=m;i++){
        int aaa = q.poll()/2;
        q.add(aaa);
      }

      int lng = q.size();

      for(int i=0;i<lng;i++){
        ans += q.poll();
      }


      System.out.println(ans);


    }
}


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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int64_t a,int64_t b){return a/gcd(a, b)*b;}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//	for(auto x : v) cout << x << " "; cout << "\n";     // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//	bitset<ビット数> s(tmp);
//	// (ビット列sに対する処理)
// }

int main()
{
	int cost = 0, n, temp, mean_p_int;
	double mean_p = 0;

	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		mean_p += a[i];
	}
	mean_p /= n;
	mean_p_int = (int)round(mean_p);
	for (int i = 0; i < n; i++)
		cost += pow(abs(a[i] - mean_p_int), 2);
	cout << cost << endl;
}


Measured memory_bytes: 3620
N=int(input())
s=' '
num_AB=0
num_A=0
num_B=0
num_A_and_B=0
for i in range(0,N):
    s=str(input())
    if(s[0]=='B' and s[-1]=='A'):
        num_A_and_B+=1
    elif(s[0]=='B'):
        num_B+=1
    elif(s[-1]=='A'):
        num_A+=1
    for j in range(0,len(s)-1):
        if(s[j]=='A' and s[j+1]=='B'):
            num_AB+=1;

ans=num_AB
if(num_A_and_B>0):
    ans+=(num_A_and_B-1)
if(num_A_and_B>0 and num_A>0):
    num_A-=1
    ans+=1
if(num_A_and_B>0 and num_B>0):
    num_B-=1
    ans+=1
ans=ans+min(num_A,num_B)
print(ans)

Measured memory_bytes: 3188
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, s, n)    for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...)  type __VA_ARGS__; read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x): x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

int H, W;
vector<vector<int>> mat;

int memo[105][105][5];
int dp(int y, int x, int flipped) {
    if (y == H-1 && x == W-1) {
        return 0;
    }
    auto &ret = memo[y][x][flipped];
    if (~ret) return ret;

    ret = INF;
    rep(i, 0, 2) {
        const int nx = x + i;
        const int ny = y + (1 - i);
        if (nx >= W || ny >= H) continue;
        if (mat[ny][nx]) {
            chmin(ret, dp(ny, nx, 1) + (1 - flipped));
        } else {
            chmin(ret, dp(ny, nx, 0));
        }
    }

    return ret;
}

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

    read(H, W);
    mat = makeV(0, H, W);

    rep(i, 0, H) {
        var(string, s);
        rep(j, 0, W) mat[i][j] = (s[j] == '#');
    }

    memset(memo, -1, sizeof(memo));

    if (mat[0][0]) {
        print(dp(0, 0, 1) + 1);
    } else {
        print(dp(0, 0, 0));
    }

    return 0;
}


Measured memory_bytes: 512
from __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
#from functools import lru_cache   #use @lru_cache(None)
if os.path.exists('in.txt'): sys.stdin=open('in.txt','r')
if os.path.exists('out.txt'): sys.stdout=open('out.txt', 'w')
#
def input(): return sys.stdin.readline()
def mapi(arg=0): return map(int if arg==0 else str,input().split())
#------------------------------------------------------------------


n,m = mapi()
gr = defaultdict(list)
sz = [1]*(n+1)
par = {i:i for i in range(n+1)}
def find(a):
    if par[a]==a:return a
    par[a] = find(par[a])
    return par[a]
def union(a,b):
    a = find(a)
    b = find(b)
    if a==b:return
    if sz[a]>sz[b]:a,b = b,a
    sz[b]+=sz[a]
    par[a] = b

for i in range(m):
    x,y = mapi()
    union(x,y)
    # gr[x].append(y)
    # gr[y].append(x)
res = 0
for i in range(1,n+1):
    res = max(res,sz[i])
print(res)


Measured memory_bytes: 32052
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>

typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep_r(i,s,n)for(ll i = n;i>s;i--)
#define rep_re(i,s,n)for(ll i = n;i>=s;i--)
using namespace std;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_N = 100001;

ll match[10] = { 2,5,5,4,5,6,3,7,6 };
string dp[100001];
string INF_S = "-";
ll A[10];

string chmax(string s, string t) {
	if (s == INF_S)return t;
	else if (s.size() < t.size()) return t;
	else if (s.size() > t.size()) return s;
	else if (s.size() == t.size()) {
		return ((s < t) ? t : s);
	}
}

int main() {
	ll n, m; cin >> n >> m;
	rep(i, 0, m) cin >> A[i];
	rep(i, 0, 100001)dp[i] = INF_S;

	dp[0] = "";

	repe(i, 0, n) {
		if (dp[i] == INF_S)continue;

		rep(j, 0, m) {
			dp[i + match[A[j] - 1]] =
				chmax(dp[i + match[A[j] - 1]], dp[i] + (char)('0' + A[j]));
		}
	}
	cout << dp[n] << endl;

	return 0;
}

Measured memory_bytes: 44416
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d %d", &a , &b);
  	if(a>12)
    {
      printf("%d",b);
      return 0;
    }
  	if(a>=6)
    {
      printf("%d",b/2);
      return 0;
    }
  	b=0;
    printf("%d",b);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {
  int n, m, x;
  cin >> n >> m >> x;
  vector<vector<int>> v(n, vector<int>(m+1));
  rep(i, n){
    rep(j, m+1){
      cin >> v[i][j];
    }
  }

  int ans = INT_MAX;
  for(int i=0; i<(1<<n); i++){
    bool flag = true;
    vector<int> tmp(m, 0);
    int sum = 0;
    rep(j, n){
      if(i>>j & 1){
        sum += v[j][0];
        repd(k, 1, m+1){
          tmp[k-1] += v[j][k];
          // cout << v[j][k];
        }
      }
    }
    rep(k, m){
      if(tmp[k] < x){
        flag = false;
        break;
      }
    }
    if(flag){
      ans = min(ans, sum);
    }
  }
  if(ans == INT_MAX){
    cout << -1 << endl;
    return 0;
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long int LLI;
using namespace std;
const int inf = 0x3f3f3f3f;

int x;
bool check(int k) {
    if ((LLI) k * (LLI) (k+1) / 2 >= x) return 1;
    return 0;
}

int main() { 
    while (cin >> x) {
        int lo = 0, hi = inf, mi;
        while (lo < hi) {
            mi = (lo+hi)>>1;
            if (check(mi)) hi = mi;
            else lo = mi+1;
        }
        cout << lo << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
S = input()
i = len(S)
def isOK(string):
    for c in string:
        if c not in ["A","G","T","C"]:
            return(False)
    return(True)
while i > 0:
    d = len(S) - i
    for j in range(d+1):
        string = S[j:j+i]
        if isOK(string): 
            print(i)
            exit()
    i -= 1
print(i)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;

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

   ll a[n];
   for(ll i=0;i<n;i++)
   	cin>>a[i];

  vector<ll> dp(n,inf);
   dp[0]=0;
   dp[1]=abs(a[1]-a[0]);

   for(ll i=2;i<n;i++)
   		for(ll j=i-1;j>-1 and i-j<=k ;j--)
   			dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));

     cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1792
#include<cstdio>
using namespace std;
char s[12];
int main(void){
	register int i;
	scanf("%s",s);
	if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I'){
		puts("Yes");
		return 0;
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 128
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	S := make([]int, n)
	for i := 0; i < n; i++ {
		S[i] = nextInt()
	}
	q := nextInt()
	count := 0
	for j := 0; j < q; j++ {
		if binarySearch(nextInt(), S) {
			count++
		}
	}
	fmt.Println(count)
}

func binarySearch(key int, arr []int) bool {
	left, right := 0, len(arr)-1
	for left <= right {
		mid := (left + right) / 2
		if key == arr[mid] {
			return true
		} else if key < arr[mid] {
			right = mid - 1
		} else {
			left = mid + 1
		}
	}
	return false
}



Measured memory_bytes: 2680
import java.util.*

var n = -1
val bit = Array(26) {Array(500002) {0}}

// 1-indexed
fun sum(alpha:Int, i: Int): Int{
    var res = 0
    var j = i
    while (j > 0) {
        res += bit[alpha][j];
        j -= j and (-j)
    }
    return res
}

fun sum(alpha: Int, i: Int, j: Int): Int {
    return sum(alpha, j) - sum(alpha, i - 1)
}

fun add(alpha: Int, i: Int, value: Int){
    var j = i
    while(j <= n){
        bit[alpha][j] += value
        j += j and (-j)
    }
}

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    n = sc.nextInt()
    val s = sc.next().toCharArray()
    s.forEachIndexed { index, c -> add(c - 'a', index + 1, 1) }
    val q = sc.nextInt()
    repeat(q) {
        val op = sc.nextInt()
        if (op == 1) {
            val i = sc.nextInt()
            val from = s[i - 1] - 'a'
            val to = sc.next()[0] - 'a'
            s[i - 1] = 'a' + to
            add(from, i, -1)
            add(to, i, 1)
        } else {
            val l = sc.nextInt()
            val r = sc.nextInt()
            println((0 until 26).map { if(sum(it, l, r) > 0) 1 else 0 }.sum())
        }
    }
}

Measured memory_bytes: 146192