akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <complex>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
_T _DEF(T,in,int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_T _DEF(T,in,){return in<T>(gcu());}
_DEF(int,in,){return in<int>(gcu());}
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
_T _SCAN(T &n){int c=gcu();return c==EOF?n=0,false:(n=in<T>(c),true);}
_SCAN(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_SCAN(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=(char)c;}}
#endif
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);} _OUT(const char *s){while(*s)pcu(*s++);} _OUT(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_OUT(string s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _OUTL(T&&... t){out(move(t)...);outl();}
struct range{
	int e,b=0,s=1; range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
	struct it { int v, s; it (int _v, int _s) : v(_v), s(_s) {} operator int()const{return v;} operator int&(){return v;} int operator*()const{return v;}
		it& operator++(){v+=s;return *this;} }; it begin() {return {b, s};} it end() {return {e, s};}};

template <typename T>
using V = vector<T>;
using P = complex<int>;
P read() {
	return {in() + 1, in() + 1};
}
#define x(o) real(o)
#define y(o) imag(o)
bool operator < (P a, P b) {
	return x(a) == x(b) ? y(a) < y(b): x(a) < x(b);
}

int main() {
	for (int n {in()}; n; n--) {
		P g {read()}, s {g + P{1, 1}};
		V<V<int>> r(y(s), V<int>(x(s), 3)), dp(y(s), V<int>(x(s)));
		for (int p {in()}; p; p--) {
			P s {read()}, e {read()};
			if (e < s)
				swap(s, e);
			P d = e - s;
			r[y(e)][x(e)] &= x(d) ? ~1 : ~2;
		}
		dp[1][0] = 1;
		for (int i: range(1, y(s)))
			for (int j: range(1, x(s)))
				dp[i][j] = (r[i][j] & 1 ? dp[i][j - 1] : 0) + (r[i][j] >> 1 & 1 ? dp[i - 1][j] : 0);
		if (dp[y(g)][x(g)])
			outl(dp[y(g)][x(g)]);
		else
			outl("Miserable Hokusai!");
	}
}


Measured memory_bytes: 2584
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  vector<ll> x(n),y(n),h(n);
  ll a;
  rep(i,n){
    cin>>x[i]>>y[i]>>h[i];
    if(h[i]>0) a=i;
  }
  ll tmp;
  rep(cy,101){
    rep(cx,101){
      bool flag=true;
      ll tmp=h[a]+abs(cx-x[a])+abs(cy-y[a]);
      rep(i,n){
        if(h[i]>0 && tmp-h[i]!=abs(cx-x[i])+abs(cy-y[i])) flag=false;
        if(h[i]==0 && tmp-abs(cx-x[i])-abs(cy-y[i])>0) flag=false;
      }
      if(flag){
        cout<<cx<<' '<<cy<<' '<<tmp<<endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
/*||>>>> Praveen Ojha <<<<>>>> 30 June 2019 <<<<>>>> 01:09:32 <<<<||*/
// #pragma GCC optimize("Ofast") //(Very Fast but Inaccurate)
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //(Small operations in many loops)
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
//Read Problems Carefully & Check for corner cases N=0,1 ?
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
const int N=2200;
int fact[N];
inline int powermod(int a,int n){
	int result=1;
	a=a%mod;
	while(n>0){
		if(n & 1)
			result=(a*result)%mod;
		a=(a*a)%mod;
		n/=2;
	}
	return result;
}
inline int modInv(int x){
	return powermod(x,mod-2);
}
inline int ncr(int n, int r){
	if(n<r)
		return 0;
	int cur=fact[n];
	cur=(cur*modInv(fact[n-r]))%mod;
	cur=(cur*modInv(fact[r]))%mod;
	return cur;
}
int32_t main(){__
	int n,k;
	cin>>n>>k;
	int red=n-k;
	fact[0]=1;
	for(int i=1;i<N;i++){
		fact[i]=(i*fact[i-1])%mod;
	}
	for(int i=1;i<=k;i++){
		cout<<ncr(red+1,i)*ncr(k-1,i-1)%mod<<"\n";
	}
return 0;
}

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

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; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using pint = pair<int, int>; 
using pll  = pair<ll, ll>;
using vint = vector<int>; 
using vll  = vector<ll>;
using vstr = vector<string>;

//　定数, 変数 *********************************************
const ll MOD=1e9+7;
const ll INF=1ll<<60;

ll N;

map<int,int> mp;
vector<pair<ll,ll>> fs;
//***********************************************************
void dp(int n)
{
    // 割る数の初期値
    int a = 2;
    // √n ≧ a ( n ≧ a * a ) の間ループ処理
    while (n >= a * a) {
        // a で割り切れたら、a は素因数
        // そして、割られる数を a で割る
        // a で割り切れなかったら、 a を 1 増加させる
        if (n % a == 0) {
            //printf("%d * ", a);
            ++mp[a];
            n /= a;
        } else {
            ++a;
        }
    }
    // 最後に残った n は素因数
    //printf("%d\n", n);
    ++mp[n];
}


// *********************************************************


void dp2(ll n){
    for(ll i=2; i*i<=n; ++i){
        int x=0;
        while(n%i == 0){
            n /= i;
            ++x;
        }
        if(x != 0){
            fs.emplace_back(i,x);
        }
    }
    if(n != 1){
        fs.emplace_back(n,1);
    }
}
// *****************************************************


int main(){
    int sum = 0;
    cin >> N;
    
    if (N==1){
        cout << 0 << endl;
        return 0;
    }




    dp2(N);
    for(auto p: fs){
        //cout << p.first << " " << p.second << endl;
        int x =p.second;
        int b=1;
        while(b<=x){
            x -= b;
            ++b;
            ++sum;
        }
    }



    cout << sum << endl;
    
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    int n = s.length();

    int a = -1, b = -1;
    for(int i=0; i<n; i++){
        if(i <= n-2 && s[i] == s[i+1]){
            a = i+1;
            b = i+2;
            break;
        }
        if(i <= n-3 && s[i] == s[i+2]){
            a = i+1;
            b = i+3;
            break;
        }
    }
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int maxn = (2000000 + 10);
typedef long long int LLI;



int main(){
   // freopen("/home/qihan/Documents/in","r",stdin);
    int s,k;
    LLI ans = 0;
    scanf("%d%d",&k,&s);
    for(int i = 0; i <= k; i++){
        int temp = s - i;
        int mins = max(0,temp - k);
        int maxs = min(k,temp);
        if(mins > maxs) continue;
        ans += (maxs - mins + 1);
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	int N;
	cin >> N;

	string S, T;
	cin >> S >> T;

	for (int i = 0; i < N; i++)
	{
		cout << S[i] << T[i];
	}

	return 0;
}

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

int main() {
	
	int n, m, l;
	std::cin >> n >> m >> l;

	std::vector< std::vector<long int> > A, B, C;

	A.resize(n);
	for (int i = 0; i < n; i++) {
		A[i].resize(m);
	}

	B.resize(m);
	for (int i = 0; i < m; i++) {
		B[i].resize(l);
	}

	C.resize(n);
	for (int i = 0; i < n; i++) {
		C[i].resize(l);
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			std::cin >> A[i][j];
		}
	}

	for (int i = 0; i < m; i++) {
		for (int j = 0; j < l; j++) {
			std::cin >> B[i][j];
		}
	}
	

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			for (int k = 0; k <m; k++) {
				C[i][j] += A[i][k] * B[k][j];
			}
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			std::cout << C[i][j];
			if (j != l - 1)
				std::cout << " ";
		}
		std::cout << std::endl;
	}

	return 0;
}

Measured memory_bytes: 3224
#include <iostream>

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

int gcd(int x, int y) {
  if (x % y == 0) {
    return y;
  } else {
    return gcd(y, x % y);
  }
}

int main() {
  int x, y;
  std::cin >> x >> y;

  std::cout << gcd(x, y) << '\n';
  return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ve vector
#define chmin(x,y) x = min(x,y)

int dfs(ve<int> &f, int i){
    if(f[i] != -1) return f[i];
    int pc = __builtin_popcount(i);
    int nex = i % pc;
    return f[i] = dfs(f,nex) + 1;
}

int main(){
    int n;
    string s;
    cin >> n >> s;
    int cnt = 0;
    rep(i,n){
        if(s[i] == '1')cnt++;
    }
    if(cnt == 0){
        rep(i,n) cout << 1 << endl;
        return 0;
    }
    if(cnt == 1){
        if(s[n-1] == '1'){
            rep(i,-1){
                cout << 2 << endl;
            }
            cout << 0 << endl;
            return 0;
        }else{
            rep(i,n-1){
                if(s[i] == '1'){
                    cout << 0 << endl;
                }else{
                    cout << 1 << endl;
                }
            }
            cout << 2 << endl;
            return 0;
        }
    }
    
    reverse(s.begin(), s.end());
    ve<ve<int>> mk(2,ve<int>(n));
    mk[0][0] = 1 % (cnt-1);
    mk[1][0] = 1 % (cnt+1);
    rep(i,n-1){
        (mk[0][i+1] = mk[0][i] * 2) %= cnt-1;
        (mk[1][i+1] = mk[1][i] * 2) %= cnt+1;
    }
    ve<int> su(2);
    rep(i,n){
        if(s[i] == '1'){
            rep(j,2){
                su[j] += mk[j][i];
            }
        su[0] %= cnt-1;
        su[1] %= cnt+1;
        }
    }
    
    ve<int> f(500010,-1);
    
    f[0] = 0;
    f[1] = 1;
    
    ve<int> ans(n);
    rep(i,n){
        int nex;
        if(s[i] == '1'){
            nex = su[0] - mk[0][i];
            while(nex<0)nex += cnt-1;
        }
        else{
            nex = su[1] + mk[1][i];
            nex %= cnt+1;
        }
        ans[i] = dfs(f,nex) + 1;
    }
    reverse(ans.begin(), ans.end());
    
    rep(i,n) cout << ans[i] << endl;
    return 0;
}


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

using namespace std;
using ll = long long;

const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 3e3 + 8;
const int logN = 20, BL = 400;
const double EPS = 3e-16;

long long dp[SM][SM];

int main(){
//	freopen("ex.in", "r", stdin);
//	freopen("ex.out", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	string s, t; cin >> s >> t;
	
	long long n = ll(s.size()), m = ll(t.size());
	for(long long i = 0; i <= n; i++){
		for(long long j = 0; j <= m; j++){
			if(i == 0 || j == 0) continue;
			if(s[i - 1] == t[j - 1]){
				dp[i][j] = dp[i - 1][j - 1] + 1;
			}
			else {
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			}
		}
	}
	
	long long i = n, j = m;
	string lcs = "";
	while(i > 0 && j > 0){
		if(s[i - 1] == t[j - 1]){
			lcs += s[i - 1];
			i--, j--;
		}
		else if(dp[i - 1][j] > dp[i][j - 1]){
			i--;
		}
		else {
			j--;
		}
	}
	
	reverse(lcs.begin(), lcs.end());
	cout << lcs;
	return 0;
}


Measured memory_bytes: 70784
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>

using namespace std;

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

long long int INF = 3e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl


ll mod = 1000000007;
ll rui(ll number1,ll number2){

    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){

    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){

    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;}
void Yes(bool condition){

    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;}

/*
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
	rfact[800000] = rui(fact[800000],mod - 2);
	for(ll i=800000; i>=1; i--){
	   rfact[i-1] = rfact[i] * i;
	   rfact[i-1] %= mod;
	}
	return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/

ll n,m,num,sum,ans,a,b,c,d,e,g,h,w,i,j,k,q,l,r;
ll x[500005],y[500005],z[1200005];
char s[500005],t[500005];
bool flag,dame;

int main(){
	cin >> n >> k;
	for(i=1;i<=n;i++){
		a = i;
		num = 0;
		while(a < k){
			a *= 2;
			num ++;
		}
		c = max(c,num);
		x[i] = num;
	}
	for(i=1;i<=n;i++){
		ans += rui(2,c - x[i]);
	}
	//p(ans);
	ps((double)(ans/(double)(n*rui(2,c))));
	return 0;
}

Measured memory_bytes: 29568
#include<iostream>
#include<string>
#include<array>
#include<utility>
#include<cmath>
#include<algorithm>

int main(){

    std::string s;
    std::cin >> s;

    std::array<long, 3> ar = {};

    for(const auto& e : s){
        ar[e - 'a']++;
    }

    size_t max = 0;
    for(size_t i = 0; i < ar.size() - 1; i++){
        for(size_t j = 1; j < ar.size(); j++){
            max = std::max<size_t>(max, std::abs(ar[i] - ar[j]));
        }
    }

    std::cout << (max < 2 ? "YES" : "NO") << std::endl;

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <set>
#include <string>
using namespace std;

int main() {
	int n; cin >> n;
	while (n--) {
		string s; cin >> s;
		set<string> train;
		for (int i = 1; i < s.size(); i++) {
			string front, end;
			front = s.substr(0, i);
			end = s.substr(i, s.size()-i);

			train.insert(front + end);
			train.insert(end + front);

			reverse(front.begin(), front.end());
			train.insert(front + end);
			train.insert(end + front);

			reverse(end.begin(), end.end());
			train.insert(front + end);
			train.insert(end + front);

			reverse(front.begin(), front.end());
			train.insert(front + end);
			train.insert(end + front);
		}
		cout << train.size() << endl;
	}
	return 0;
}

Measured memory_bytes: 996
#include <stdio.h>

int count = 0;

void merge(int *a, int left, int mid, int right){
  int i, j, k;
  int n1, n2;

  n1 = mid - left;
  n2 = right - mid;
  int L[n1+1], R[n2+1];

  for(i = 0; i < n1; i++)
    L[i] = a[left + i];
  for(i = 0; i < n2; i++)
    R[i] = a[mid + i];
  L[n1] = 1000000001;
  R[n2] = 1000000001;

  i = j = 0;
  for(k = left; k < right; k++){
    if(L[i] <= R[j]){
      a[k] = L[i];
      i++;
    } else{
      a[k] = R[j];
      j++;
    }
    count++;
  }
}

void mergeSort(int *a, int left, int right){
  if(left+1 < right){
    int mid = (left + right) / 2;
    mergeSort(a, left, mid);
    mergeSort(a, mid, right);
    merge(a, left, mid, right);
  }
}

int main(){

  int i, n, left, mid, right;

  scanf("%d", &n);
  int a[n];
  for(i = 0; i < n; i++)
    scanf("%d", &a[i]);

  mergeSort(a, 0, n);
  
  for(i = 0; i < n-1; i++)
    printf("%d ", a[i]);
  printf("%d\n", a[i]);
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 4504
N = int(input())
 
A = list(map(int,input().split()))
 
dic = {}
 
for a in A:
 
    if a not in dic:
        dic[a] = 1
    else:
        dic[a] += 1
 
B = []
for i in dic:
    B.append(dic[i])
 
B.sort()
 
B_sub = B.copy()
 
for i in range(len(B)-1):
    B_sub[i+1] += B_sub[i] 
 
aind = N + 1
nind = len(B) - 1
 
#print (B,B_sub)
 
for i in range(N):
 
    i += 1
 
    while True:
 
        while nind > 0 and B[nind] > aind - 1:
 
          nind -= 1
 
        if i > len(B):
            print (0)
            break
 
        elif ((len(B) - 1) - nind ) * (aind-1) + B_sub[nind] >= (aind - 1) * i:
            print (aind - 1)
            break
 
        aind -= 1

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    vector<int> A(3);
    cin >> A[0] >> A[1] >> A[2];
    sort(ALL(A));
    cout << A[0] +A[1]<< endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=1e5+5;
const int mod=998244353;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    double b;
    cin>>b;
    cout<<fixed<<setprecision(5)<<2*b*3.14159<<'\n';



}


Measured memory_bytes: 3784
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

a,b,c=mp()
print(min(a+b,b+c,c+a))

Measured memory_bytes: 77376
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    int h,w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    vector<vi> L(h,vi(w,0)),R(h,vi(w)),U(h,vi(w)),D(h,vi(w));
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='#') L[i][j] = 0;
            else if(j==0) L[i][j] = 1;
            else L[i][j] = L[i][j-1] + 1;
        }
    }
    rep(i,h){
        for(int j=w-1;j>=0;j--){
            if(s[i][j]=='#') R[i][j] = 0;
            else if(j==w-1) R[i][j] = 1;
            else R[i][j] = R[i][j+1] + 1;
        }
    }
    rep(j,w){
        rep(i,h){
            if(s[i][j]=='#') U[i][j] = 0;
            else if(i==0) U[i][j] = 1;
            else U[i][j] = U[i-1][j] + 1;
        }
    }
    rep(j,w){
        for(int i=h-1;i>=0;i--){
            if(s[i][j]=='#') D[i][j] = 0;
            else if(i==h-1) D[i][j] = 1;
            else D[i][j] = D[i+1][j] + 1;
        }
    }

    ll ans = 0;
    rep(i,h){
        rep(j,w) chmax(ans,R[i][j] + L[i][j] + U[i][j] + D[i][j] - 3);
    }
    cout << ans << endl;
}

Measured memory_bytes: 67200
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef pair<long long, long long> pll;
typedef pair<int, int> pi;
typedef long double ld;
typedef pair<long double, long double> pld;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;
const int MAX_N = 500000;

int cnt[MAX_N];
int C[MAX_N];
int ans = 0;

// void init(int N) { cnt = vi(N, 0); }

void add(int p) {
    // pの位置をクエリ範囲に加えるときの処理
    if(cnt[C[p]]++ == 0)
        ans++;
}

void del(int p) {
    // pの位置をクエリ範囲から除くときの処理
    if(--cnt[C[p]] == 0)
        ans--;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j, k;
    int N, Q;
    cin >> N >> Q;
    for(i = 0; i < N; i++) {
        int c;
        cin >> c;
        C[i] = c;
    }
    // init(N);

    vector<pi> LR(Q);
    for(i = 0; i < Q; i++) {
        int l, r;
        cin >> l >> r;
        l--;
        LR[i] = pi(l, r);
    }

    vi qi(Q);
    for(i = 0; i < Q; i++) {
        qi[i] = i;
    }
    int sq = sqrt(N);
    sort(qi.begin(), qi.end(), [&](int i, int j) {
        if(LR[i].first / sq != LR[j].first / sq)
            return LR[i].first < LR[j].first;
        // return LR[i].second < LR[j].second;
        return bool((LR[i].second < LR[j].second) ^ (LR[i].first / sq % 2));
    });

    int nl = 0, nr = 0;
    vi vans(Q);
    for(auto i : qi) {
        while(nl > LR[i].first)
            add(--nl);
        while(nr < LR[i].second)
            add(nr++);
        while(nl < LR[i].first)
            del(nl++);
        while(nr > LR[i].second)
            del(--nr);
        vans[i] = ans;
    }

    for(i = 0; i < Q; i++) {
        cout << vans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 15424
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll N=1e5+5;
ll n,ans,a[N];
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    cin>>n;for(ll i=1;i<=n;i++)cin>>a[i];
    for(ll i=0;i<=n;i++)ans+=abs(a[i]-a[i+1]);
    for(ll i=1;i<=n;i++)cout<<ans - abs(a[i-1] - a[i]) - abs(a[i] - a[i+1]) + abs(a[i-1] - a[i+1]) <<"\n";
}

Measured memory_bytes: 2048
#include<iostream>
#include<vector>
using namespace std;
const int MOD=1000000007;
void add(long long &a,long long b){a+=b;if(a>=MOD)a-=MOD;}

int H,W,K;
long long solve(){
    --K;
    vector<vector<long long> > dp(H+1,vector<long long>(W,0));
    dp[0][0]=1;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            for(int bit=0;bit<1<<(W-1);bit++){
                bool ok=true;
                for(int k=0;k<W-2;k++){
                    if((bit&(1<<k))&&(bit&(1<<(k+1)))) ok=false;
                }
                if(!ok)continue;
                int nj=j;
                if(bit&(1<<j))nj=j+1;
                else if(j>0&&(bit&(1<<(j-1))))nj=j-1;
                add(dp[i+1][nj],dp[i][j]);
            }
        }
    }
    return dp[H][K];
}

int main(){
    while(cin>>H>>W>>K)cout<<solve()<<endl;
}

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

using namespace std;

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

int i= 1;
while(1) {
int x= i;

if(x % 3 == 0){
cout<<" "<<i;
}
else {
while(1){
if(x % 10 == 3){
cout<<" "<<i;
break;
}
x /= 10;
if(x == 0) break;
}
}
if(++i > n) break;
}
cout<<endl;
}


Measured memory_bytes: 3088
import sys

W = str(input()).upper()

line = []

while True:
  tmp_line = str(input())
  if tmp_line == "END_OF_TEXT":
    break
  line += tmp_line.upper().split()

cnt = 0

for tmp_word in line:
  if tmp_word == W:
    cnt += 1
print(cnt)


Measured memory_bytes: 5556
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int main(){
    int n,m,l;
    cin >> n;
    if(n == 2){
	cin >> n >> m;
	if(n < m) swap(n,m);
	FOR(i,1,n+1){
	    if(n % i == 0 && m % i == 0){
		printf("%d\n",i);
	    }
	}
    }else{
	cin >> n >> m >> l;
	if(n < m) swap(n,m);
	if(n < l) swap(n,l);
	FOR(i,1,n+1){
	    if(n % i == 0 && m % i == 0 && l % i == 0){
		printf("%d\n",i);
	    }
	}

    }
    return 0;
}

Measured memory_bytes: 1144
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

bool ma(char c1, char c2) {
    if (c1 == '?' || c2 == '?') {
        return true;
    } else if (c1 == c2) {
        return true;
    } else {
        return false;
    }
}

string s[3];
bool match[3][3][6100];

void calc_match(int i, int j) {
    string a = s[i], b = s[j];
    for (int k = 0; k < a.size(); k++) {
        bool ok = true;
        for (int l = 0; ok && l < b.size() && k + l < a.size(); l++) {
            ok &= ma(a[k + l], b[l]);
        }
        match[i][j][k] = ok;
    }
}

int check(int i, int j, int k) {
    int res = INT_MAX;
    for (int x = 0; x < s[i].size(); x++) {
        if (!match[i][j][x]) continue;

        chmin(res, (int)(max({ s[i].size(), x + s[j].size() }) + s[k].size()));

        for (int y = 0; y < max(s[i].size() - x, s[j].size()); y++) {
            if (!match[j][k][y]) continue;
            if (!match[i][k][x + y]) continue;
            chmin(res, (int)max({ s[i].size(), x + s[j].size(), x + y + s[k].size() }));
        }
    }
    return res;
}

pii ps[3] = { { 0, 1 }, { 1, 2 }, { 0, 2 } };
int rest[3] = { 2, 0, 1 };

int main() {
    fastio();

    cin >> s[0] >> s[1] >> s[2];

    forn(i, 3) forn(j, 3) forn(k, 6100) match[i][j][k] = true;

    for (auto p : ps) {
        calc_match(p.fst, p.snd);
        calc_match(p.snd, p.fst);
    }

    int ans = s[0].size() + s[1].size() + s[2].size();

    forn(i, 3) {
        chmin(ans, check(ps[i].fst, ps[i].snd, rest[i]));
        chmin(ans, check(ps[i].snd, ps[i].fst, rest[i]));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

ll GCD(ll, ll);

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<ll> gcd(n-1);
    gcd[0] = GCD(a[0], a[1]);
    for(int i = 1; i < n; i++) {
        a[i] = GCD(a[i-1], a[i]);
    }
    cout<< a[n-1] << endl;
}


ll GCD(ll num1, ll num2) {
    if (num1 < num2) {
        ll temp = num1;
        num1 = num2;
        num2 = temp;
    } 

    while(true) {
        int r = num1 % num2;
        if (r == 0) {
            return num2;
        }
        if (r == 1) {
            return 1;
        }
        num1 = num2;
        num2 = r;
    }
}


Measured memory_bytes: 1792
line = gets.split(' ').map(&:to_i)
n = line[0]
q = line[1]

nline = gets.split('')
jline = []
jline[0] = 0
qline = Array.new(q)
for i in 1..n-1 do
  if nline[i] == "C" && nline[i-1] == "A"
    jline[i] = jline[i-1] + 1
  else
    jline[i] = jline[i-1]
  end
end
qline[-1] = 0
q.times do |i|
  line2 = gets.split(' ').map(&:to_i)
  l = line2[0]
  r = line2[1]
  qline[i] = jline[r-1] - jline[l-1]
end
puts qline


Measured memory_bytes: 13568
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int N = sc.nextInt();
        int K = sc.nextInt();
        String Ss = sc.next();
        char[] S = Ss.toCharArray();
        char now = S[0];
        int turn = 0;
        int point=0;
        for(int i=0;i<N;i++){
            if(S[i] != now){
                now = S[i];
                turn ++;
            }
            if(S[i] == 'R' && i+1 < N && S[i+1] == 'R'){
                point ++;
            }
            if(i > 0 && S[i] == 'L' && S[i-1] == 'L'){
                point ++;
            }
        }
        point += Math.min(K*2, turn);
        System.out.println(point);
    }
}


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

using namespace std;

int main()
{
	int w;

	while (1){
		int rs;

		scanf("%d", &w);
		if (w == -1){
			break;
		}

		if (w <= 10){
			rs = 1150;
		}
		else if (w <= 20){
			rs = 1150 + (w - 10) * 125;
		}
		else if (w <= 30){
			rs = 1150 + 1250 + (w - 20) * 140;
		}
		else if (30 < w){
			rs = 1150 + 1250 + 1400 + (w - 30) * 160;
		}

		cout << 4280 - rs << endl;
	}

	return (0);
}

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

public class Main {
	String[] word;
	int[] rank;

	public static void main(String[] args) {
		new Main().run();
	}
	
	private void run() {
		Scanner scan = new Scanner(System.in);
		while (scan.hasNext()) {
			String letter = scan.nextLine();
			word = letter.split(" ");
			//System.out.println(Arrays.toString(word));
			
			rank = new int[word.length];
			Arrays.fill(rank, 0);
			
			for (int i = 0; i < word.length; i++) {
				for (int j = 0; j < word.length; j++) {
					if (word[i].equals(word[j])) rank[i]++;
				}
			}
			
			int max = 0, mindex = -1;
			int lng = 0, lindex = -1;
			for (int i = 0; i < word.length; i++) {
				if (max < rank[i]) {
					max = rank[i];
					mindex = i;
				}
				if (lng < word[i].length()) {
					lng = word[i].length();
					lindex = i;
				}
			}
			
			System.out.println(word[mindex] + " " + word[lindex]);
		}
		
		
	}
	
	private void debug() {
		System.out.println();
	}

}

Measured memory_bytes: 17956
def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    lst = [[i, x] for i, x in enumerate(a_list)]
    lst.sort(key = lambda x: x[1])

    for i in lst:
        print(i[0] + 1, end=" ")

if __name__ == "__main__":
    main()


Measured memory_bytes: 99140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B > C + D) {
  	cout << "Left" << endl;
  } 
  else if (A + B == C + D) {
  	cout << "Balanced" << endl;
  }
  else {
  	cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
//# define int ll
using namespace std;

int b,a,ans;

int32_t main(){_
    //freopen("input","r",stdin);
    string s;
    cin >> s;
    int i = 0;
    while(i < sz(s))
    {
        b = 0;
        while(s[i] == 'S' && i < sz(s))
        {
            i++;
            a++;
        }
        if(a)
        {
            while(s[i] == 'T' && i < sz(s))
            {
                i++;
                b++;
            }
        }
        else i++;
        int x = min(a,b);
        ans += x * 2;
        if(x == b)
        {
            a -= b;
            b = 0;
        }
        else
        {
            a = b = 0;
        }
    }
    rc(sz(s) - ans);
}

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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;
map<ll, ll> mp1, mp2, mp3;
set<ll> st1, st2, st3;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n;cin>>n;

  for(int i=0;i<n;i++){
    int t;cin>>t;mp1[t]++;st1.insert(t);
  }
  for(int i=0;i<n;i++){
    int t;cin>>t;mp2[t]++;st2.insert(t);
  }
  for(int i=0;i<n;i++){
    int t;cin>>t;mp3[t]++;st3.insert(t);
  }
  ll cnt = 0;
  for (auto iter = mp3.rbegin(); iter != mp3.rend(); ++iter) {
    auto k = iter->first;
    auto v = iter->second;
    cnt += v;
    mp3[k] = cnt;
  }
  ll ans = 0;
  for(auto &kv : mp2){
    auto k = kv.first,v = kv.second;
    auto it = st3.upper_bound(k);
    if(it == st3.end()){
      mp2[k] = 0;
    }else{
      mp2[k] = v * mp3[*it];
    }
  }

  cnt = 0;
  for (auto iter = mp2.rbegin(); iter != mp2.rend(); ++iter) {
    auto k = iter->first;
    auto v = iter->second;
    cnt += v;
    mp2[k] = cnt;
  }

  for(auto &kv : mp1){
    auto k = kv.first,v = kv.second;
    auto it = st2.upper_bound(k);
    if(it == st2.end())continue;
    ans += v * mp2[*it];
  }

  cout<<ans<<endl;

  return 0;
}


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

int main() {
    int N;
    string S;

    cin >> N;
    cin >> S;

    int count=1;
    int i=0;
    int j=1;

    while(i < N-1){
        if(S.at(i) == S.at(j)){
            j++;
        }
        if(S.at(i) != S.at(j)){
            i = j;
            count++;
        }
        if(j == N-1){
            break;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 512
#include<iostream>

using namespace std;

int main(void){
	int root[101];
	bool ch=true;
	int a,f,t;
	for(a=0;a<=100;a++){
		root[a]=0;
	}
	while(~scanf("%d%d",&f,&t)){
		if(f==0 && t==0){
			if(root[1]%2==0)ch=false;
			if(root[2]%2==0)ch=false;
			for(a=3;a<=100;a++){
				if(root[a]%2==1)ch=false;
			}
			if(ch==true)cout << "OK" << endl;
			else cout << "NG" << endl;
			for(a=0;a<=100;a++){
				root[a]=0;
			}
			ch=true;
		}else{
			root[f]++;
			root[t]++;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <cmath>
#include <unordered_map>

#define MaxN 200010

using namespace std;

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

int n;
double pi = 3.14159265358;

int main() {
    scanf("%d", &n);
    printf("%.10f\n", 2 * n * pi);
    return 0;
}

Measured memory_bytes: 3836
// abc109_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int A,B;
    cin >> A >> B;

    if ((A*B) & 1){
        print("Yes");
    } else {
        print("No");
    }

    return 0;
}


Measured memory_bytes: 256
N = gets.chomp.to_i
array = gets.chomp.split.map(&:to_i)

def insertion_sort(array, n)
  puts array.join ' '
  (1..n-1).to_a.each do |i|
    v = array[i]
    j = i - 1
    while j >= 0 && array[j] > v
      array[j + 1] = array[j]
      j -= 1
    end
    array[j + 1] = v
    puts array.join ' '
  end
end

insertion_sort(array, N)

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

bool prime[1000001];
vector<int> p;

int main(){
	for(int i = 2;i <= 1000000;i++) prime[i] = true;
	for(int i = 4;i <= 1000000;i += 2) prime[i] = false;
	for(int i = 3;i <= 1000;i += 2){
		for(int j = 2 * i;j <= 1000000;j += i) prime[j] = false;
	}
	for(int i = 0;i <= 1000000;i++) if(prime[i]) p.push_back(i);
	
	int n,x;
	while(1){
		cin >> n >> x;
		if(!n) break;
		bool dp[1000001] = {true};
		for(int i = 0;i < n;i++){
			int v;
			cin >> v;
			for(int j = v;j <= x;j++){
				if(dp[j - v]) dp[j] = true;
			}
		}
		int i;
		for(i = x;i >= 0;i--){
			if(prime[i] && dp[i]) {
				cout << i << endl;
				break;
			}
		}
		if(i == -1) cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 5048
def myAnswer(H:int,W:int) -> int:
   if(H == 1 or W == 1):
      return 1
   else:
      return (H * W) // 2 + (H * W) % 2


def modelAnswer():
   tmp=1
def main():
   H, W = map(int,input().split())
   print(myAnswer(H,W))

if __name__ == '__main__':
   main()

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <string>
#include <cmath>
#include <set>
#include <cmath>
using namespace std;






void solve()
{
	string s, t;
	cin >> s >> t;
	cout << t << s;
}




int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("file.in", "r", stdin);//freopen("file.out", "w", stdout);

	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 1000001
#define M 1001
using namespace std;
typedef pair<int,int>P;
typedef pair<P,P> PP;
int h,w,n;
string mp[M],str;

int D[4][M][M];
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};

int getCost(int x,int dir,int ndir){
  while(x<n&&dir!=ndir){
    if(str[x] == 'L') dir = (dir+3)%4;
    else dir = (dir+1)%4;
    x++;
  }
  if(dir!=ndir) return -1;
  return x;
}

bool dijkstra(int sy,int sx){
  for(int i=0;i<4;i++)
    for(int j=0;j<h;j++)
      for(int k=0;k<w;k++) D[i][j][k] = 1e9;
  
  priority_queue<PP,vector<PP>,greater<PP> > Q;
  Q.push(PP(P(0,0),P(sy,sx)));
  D[0][sy][sx] = 0;

  while(!Q.empty()){
    PP t = Q.top();Q.pop();
    int cost = t.first.first;
    int dir = t.first.second;
    int y = t.second.first;
    int x = t.second.second;
    
    if(mp[y][x] =='G') return 1;    
    if(D[dir][y][x]<cost) continue;

    
    for(int i=0;i<4;i++){
      int ncost = getCost(cost,dir,i);
      if(ncost == -1 || D[i][y][x]<=ncost)continue;
      Q.push(PP(P(ncost,i),P(y,x)));
      D[i][y][x] = ncost;
    }

    int ny = y+dy[dir]; 
    int nx = x+dx[dir];
    if(nx<0||ny<0||nx>=w||ny>=h||mp[ny][nx]=='#'||D[dir][ny][nx]<=cost)continue;
    D[dir][ny][nx] = cost;
    Q.push(PP(P(cost,dir),P(ny,nx)));
    
  }  
  
  return 0;
}

int main(){

  while(1){
  cin>>h>>w>>n;
  if(!h&&!w&&!n)break;
  cin>>str;
  for(int i=0;i<h;i++)cin>>mp[i];

  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      if(mp[i][j] == 'S') cout<<(dijkstra(i,j)?"Yes":"No")<<endl;

  }
  return 0;
}

Measured memory_bytes: 21644
n = int(input())
a = sorted(map(int,input().split()))
b = [(a[i + 1] - a[i], i) for i in range(n -1)]
b.sort(key = lambda x:x[0])
if b[0][1] < n - 2:print((a[-1] + a[-2]) / b[0][0])
elif b[0][1] == n - 3:
    if b[1][1] == n - 2:print(max((a[-1] + a[-2]) / b[2][0], (a[-1] + a[-4]) / b[0][0], (a[-3] + a[-4]) / b[1][0]))
    else:print(max((a[-1] + a[-2]) / b[1][0], (a[-1] + a[-4]) / b[0][0]))
else:
    if b[1][1] == n - 3:print(max((a[-1] + a[-2]) / b[2][0], (a[-1] + a[-4]) / b[1][0], (a[-3] + a[-4]) / b[0][0]))
    else:print(max((a[-1] + a[-2]) / b[1][0], (a[-3] + a[-4]) / b[0][0]))


Measured memory_bytes: 5732
package main

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

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
        buf := make([]byte, 0, 1000000)
        for {
                l, p, e := rdr.ReadLine()
                if e != nil {
                        panic(e)
                }
                buf = append(buf, l...)
                if !p {
                        break
                }
        }
        return string(buf)
}

func strSprit(str string) []string {
        cols := strings.Split(str, " ")
        return cols
}

func parseInt(str string) int {
        n, _ := strconv.Atoi(str)
        return n
}

func intSprit(str string) []int {
        strs := strSprit(str)
        cols := make([]int, len(strs))
        for i, v := range strs {
                cols[i] = parseInt(v)
        }
        return cols
}

func bitCount(n uint) int {

        x := uint64(n)

        const m = 1<<64 - 1
        const m0 = 0x5555555555555555
        const m1 = 0x3333333333333333
        const m2 = 0x0f0f0f0f0f0f0f0f

        x = x>>1&(m0&m) + x&(m0&m)
        x = x>>2&(m1&m) + x&(m1&m)
        x = (x>>4 + x) & (m2 & m)
        x += x >> 8
        x += x >> 16
        x += x >> 32

        return int(x) & (1<<7 - 1)
}

func bitExist(n, i int) bool {
        return ((n >> uint(i)) & 1) == 1
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////

func main() {
        line := nextLine()

        spl := strSprit(line)

        N := parseInt(spl[0])
        K := parseInt(spl[1])

        n := (N + 1) / 2

        if n >= K {
                fmt.Println("YES")
        } else {
                fmt.Println("NO")
        }
}

Measured memory_bytes: 640
#include<stdio.h>
#define MAX 1000002
#define MOD 1000000007

long long fac[MAX], finv[MAX], inv[MAX];

void init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long f(int n1, int n2){
    return fac[n1+n2] * (finv[n1] * finv[n2] % MOD) % MOD;
}

int main()
{
  int x, y, a=0, b=0;
  scanf("%d %d", &x, &y);
  init();

  for(int i=0; i<=MAX; i++){
    int j = x - 2*i;
    if(y == i+2*j){
      a = i;
      b = j;
    }
  }

  if((x+y)%3 != 0){
    printf("0");
    return 0;
  }

  if(a<0 || b<0){
    printf("0");
    return 0;
  }

  if(a==0 && b==0){
    printf("0");
    return 0;
  }

  long long ans;
  ans = f(a, b);
  printf("%lld", ans);
  return 0;
}


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

int A[101][101];

int main()
{
    int n,u,k,v;
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> u >> k;
        for(int j = 0; j < k; ++j){
            cin >> v;
            A[u-1][v-1] = 1;
        }
    }
    
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            if(j != 0) cout << ' ';
            cout << A[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 1200