akhauriyash/Code-Regression huggingface dataset:
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int a, p;

int main(){
    cin >> a >> p;
    cout << (a*3 + p)/2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

int main(){
    int N;
    cin >> N;
    int P[N];
    rep(i, N){
        cin >> P[i];
    }
    int m = P[0];
    int ans = 1;
    REP(i, 1, N) {
        if (P[i] <= m) {
            m = P[i];
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
//1616
#define MAX_SIZE (1000)
int main (void){
  using namespace std;
  while (1){
    int n, m, ans = 0;
    int a[MAX_SIZE];
    cin >> n >> m;
    if (n == 0 && m == 0) break;
    for (int i = 0;i < n; i++)
      cin >> a[i];
    for (int i = 0; i < n-1; i++){
      for (int j = i+1; j < n; j++){
        if (a[i]+a[j] <= m) ans = max(ans, a[i]+a[j]);
      }
    }
    if (ans == 0){
      cout << "NONE" << endl;
      continue;
    }
    cout << ans << endl;
  }
  return 0;
}


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
// #define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int n; cin >> n;
    modint res = 0;
    res += modint(10)^n;
    res -= (modint(9)^n)*modint(2);
    res += modint(8)^n;
    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7736
/*بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم*/

#include <bits/stdc++.h>
using namespace std;

inline int Abs (int x)
{
    if (x<0) return -x;
    else return x;
}
int main ()
{
    int i,n,mx=-1,x,idx;
    bool flag=true;

    scanf ("%d",&n);
    for (i=1;i<=n;i++) {
        scanf ("%d",&x);
        int y=Abs(x);
        if (y>mx) {
            mx=y;
            idx=i;
            if (x<0) flag=false;
            else flag=true;
        }
    }
    printf ("%d\n",2*n-2);
    for (i=1;i<=n;i++) if (i!=idx) printf ("%d %d\n",idx,i);
    if (flag) for (i=1;i<n;i++) printf ("%d %d\n",i,i+1);
    else for (i=n;i>1;i--) printf ("%d %d\n",i,i-1);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Mod 1000000007
#define Val(x) (((long long)x ) % Mod)
#define maxn 1005
using namespace std;
int cnt[maxn];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for(int i=2;i<=n;i++) {
		int tem = i;
		for(int j=2;j*j<=tem;j++)
			while(tem % j == 0) {
				cnt[j]++;
				tem /= j;
			}
		if(tem != 1)	cnt[tem]++;
	}
	int ans = 1;
	for(int i=2;i<=n;i++)
		ans = Val(ans * (cnt[i] + 1));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String args[]){
  Scanner sc=new Scanner(System.in);
  int a[]=new int[5];
  for(int i=0;i<5;i++)
  {
    a[i]=sc.nextInt();
  }
    for(int i=0;i<5;i++)
    {
    if(a[i]==0)
    {
      System.out.println(i+1);
    }
    }
        
  }
}


Measured memory_bytes: 35560
#include <iostream>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <cstring>

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))

#define INF (int)1e9+7

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

using namespace std;

int main(){
    string s,t;

    cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    cout << (s < t ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define double long double
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define all(a) a.begin(),a.end()
#define sort(a) sort(all(a))
#define rsort(a) sort(all(a),greater<>())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T> inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<int,int> P;
const long long MOD=1000000007;
clock_t time_ini = clock();
double time_diff(){
  ll time_tmp = clock();
  const double time = static_cast<double>(time_tmp - time_ini) / CLOCKS_PER_SEC * 1000.0;
  return time;
}
#define saiaku if(time_diff() > 1990)
vector <ll> dp;


void solve(std::string S){
  string ans;
  if (S=="Sunny"){
    ans = "Cloudy";
  } else if(S=="Cloudy"){
    ans = "Rainy";
  } else if(S=="Rainy"){
    ans = "Sunny";
  }
  std::cout << ans << std::endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

int ctoi(const char c) {
	return c - '0';
}
int keta(int a) {
	return to_string(a).size();
}

signed main(){
	int a;
	cin >> a;
	if (a % 2 == 0)cout << a / 2 << endl;
	else cout << (a / 2) + 1 << endl;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        --A[i];
    }
    int logK = 1;
    while((1LL << logK) < K) ++logK;
    vector<vector<int>> doubling(logK, vector<int>(N));
    for (int i = 0; i < N; ++i) doubling[0][i] = A[i];
    
    for (int i = 0; i < logK - 1; ++i) {
        for (int j = 0; j < N; ++j) {
            doubling[i + 1][j] = doubling[i][doubling[i][j]];
        }
    }
    int now = 0;
    for (int k = 0; K > 0; ++k) {
        if (K & 1) now = doubling[k][now];
        K = K >> 1;
    }
    cout << now +  1 << endl;
    return 0;
}

Measured memory_bytes: 51844
//#include <bits/stdc++.h>
#include <iostream>
#include<math.h>

using namespace std;



bool is_prime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

bool is_nitakazu(int n) {
	if (is_prime(n)==true && is_prime((n + 1) / 2)==true) {
		return true;
	}
	else
	{
		return false;
	}
}


int main() {

	int n;
	int memo[100001];
	memo[1] = 0;
	memo[3] = 1;
	cin >> n;
	
	for (int i= 5; i < 100001; i+=2)
	{
		int temp;
		if (is_nitakazu(i) == true) {
			temp = 1;
		}
		else {
			temp = 0;
		}
		memo[i] =memo[i-2]+ temp;
	}

	int l, r;
	for (int i = 0; i < n; i++)
	{
		
		cin >> l >> r;
		if (l == 1) {
			l += 2;
		}
		cout << memo[r] - memo[l-2] << endl;
	}

	return 0;
}



Measured memory_bytes: 1024
let rec read list = function
    0 -> list
  | i ->
     let n = read_int () in read (n::list) (i-1)
;;

let get_sum3 list =
  let sorted = List.sort compare list |> List.rev in
  let rec f sum l = function
      3 -> sum
    | i -> f (sum + (List.hd l)) (List.tl l) (i+1)
  in f 0 sorted 0
;;

let () =
  let w = read [] 10 |> get_sum3 and
      k = read [] 10 |> get_sum3 in
  Printf.printf "%d %d\n" w k
;;

Measured memory_bytes: 2272
#include<bits/stdc++.h>
using namespace std;
int a[55];
int main(){
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a,a+n);
	double sum=a[0];
	for(int i=1;i<n;i++){
		sum=(sum+a[i])/2;
	}
	cout << sum << endl;
}

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


int main(){
  long long a,b,c,k;
  cin >>a >>b>>c>>k;
  if(abs(a-b)>1000000000000000000){
    cout << "Unfair";
    return 0;
  }
  if(k%2==0){
    cout << a-b;
  }
  else{
    cout << b-a;
  }
}


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


using namespace std;

int main(){
    int N;
    scanf("%d", &N);
    int retarray[N]; //zero-initialization
    int scan;
    for (int i = 0; i < N; i++)
    {
        retarray[i] = 0;
    }
    for (int i = 0; i < N - 1; i++)
    {
        scanf("%d", &scan);
        retarray[scan - 1] += 1;
    }
    for (int i = 0; i < N; i++)
    {
        printf("%d\n", retarray[i]);
    }

    return 0;
}

Measured memory_bytes: 4604
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	ll N, K;
	cin >> N >> K;
	ll ans = 0;
	for (ll i = 1; i <= N; i++) {
		ll p = N / i;
		ll r = N - p*i;
		ans += max(0LL, i - K) * p;
		ans += max(r - K + 1, 0LL);
	}
	if (K == 0)ans -= N;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int count(int n){
  int i,j,k,l;
  int count=0;
  for(i=0;i<10;i++){
	for(j=0;j<10;j++){
	  for(k=0;k<10;k++){
		for(l=0;l<10;l++){
		  if(n==i+j+k+l){
			count++;
		  }
		}
	  }
	}
  }
  return count;

}

int main(){
  int num;
  char tmp[8];
  while(fgets(tmp, 8, stdin)!=NULL){
	num = atoi(tmp);
	printf("%d\n", count(num));
  }
  return 0;
}

Measured memory_bytes: 528
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll n;
    cin >> n;
    vector<string> s(n);
    loop(i, n) cin >> s[i];
    sort(all(s));
    ll ans = 1;
    loop(i, n - 1) if (s[i] != s[i + 1]) ans++;
    putout(ans);
    return 0;
}


Measured memory_bytes: 9528
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1 + 10;

int main() {
	ll a, b;
	cin >> a >> b;
	b /= 2;
	ll ans = min(a, b);
	a -= ans;
	b -= ans;
	ans += b / 2;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=505;

int a, b, c;

int32_t main()
{
	IOS;
	cin>>a>>b>>c;
	int k;
	cin>>k;
	if(k%2)
		cout<<b-a;
	else
		cout<<a-b;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	int MOD = 1000000007;

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();

		long ans = 1;
		for(int i=2; i*i<=m; i++) {
			if(m%i==0) {
				int cnt=0;
				while(m%i==0) {
					cnt++;
					m /= i;
				}
				ans *= combi(cnt+(n-1), (n-1));
				ans %= MOD;
			}
		}
		if(m > 1) {
			ans *= combi(1+(n-1),(n-1));
			ans %= MOD;
		}
		System.out.println(ans);
		sc.close();
	}

	private long combi(int n, int k) {
		long res = fact(n);
		res *= inv(fact(k));
		res %= MOD;
		res *= inv(fact(n-k));
		res %= MOD;
		return res;
	}

	private long inv(long x) {
		return modpow(x, MOD-2);
	}

	private long fact(long n) {
		long res = 1;
		for(int i=1; i<=n; i++) {
			res *= i;
			res %= MOD;
		}
		return res;
	}

	private long modpow(long a, int p) {
		if(p==0) return 1;
		if(p%2==0) {
			long h = modpow(a, p/2);
			return h*h%MOD;
		}else {
			long h = modpow(a, p-1);
			h *= a;
			h %= MOD;
			return h;
		}
	}
}




Measured memory_bytes: 23508
#include <stdio.h>

int main(void)
{
    int H = 1, W = 1, i, j;
    while(H && W)
    {
        scanf("%d %d", &H, &W);
        if (H == 0 && W == 0)
        {
            break;
        }
        for (i = 0; i < H; i++)
        {
            for (j = 0; j < W; j++)
            {
	            if ((i % 2 == 0 && j % 2 == 0) || (i % 2 == 1 && j % 2 == 1))
                {
                    printf("#");
                }
                else
                {
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2052
n, m = map(int,input().split())
l = list(map(int,input().split()))

def gcd(x, y):
    return x if y == 0 else gcd(y, x % y)
def lcm(x, y):
    return (x * y) // gcd(x, y)

ans = 1
tf = True

for i in l:
    i //= 2
    ans = lcm(ans, i)
    if (ans // i) % 2 == 0 or ans > m:
        print(0)
        tf = False
        break

if tf == True:
    print(m // ans - m // (ans * 2))

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


// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef complex<int> ci;
typedef complex<double> cd;
typedef complex<long double> cld;

// macros
#define rep(i, a, b) for(int i=a; i<b; i++)
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define tr(c, it) for(auto it=(c).begin(); it!=c.end(); it++)
#define pb push_back
#define mp make_pair
#define bitcount __builtin_popcount
#define ispresent(c, x) ((c).find(x) != (c).end())
#define watch(x) cout<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// template functions
template <typename T>
inline void printV(vector<T>& a) { rep(i, 0, sz(a)) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printV(vector<T>& a, int n) { rep(i, 0, n) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printVV(vector<vector<T>>& a)
{
	rep(i, 0, sz(a)) {
		printV(a[i]);
	}
	cout<<"\n";
}

template <typename T>
inline void clearVV(vector<vector<T>>& a)
{
	for(auto& x:a) {
		x.clear();
	}
	a.clear();
}
template <typename T>
inline void assignVV(vector<vector<T>> &a, T val)
{
	for(int i=0; i<sz(a); i++) {
		for(int j=0; j<sz(a[i]); j++) {
			a[i][j]=val;
		}
	}
}


// constants
const long double eps = 1e-9;
const int inf = 5e8;
const int modn = 1e9+7;
const int MAX = 4e3;

int n;
ll a[MAX];
ll psum[MAX];
ll dp[MAX][MAX][2];

ll solve(int i, int j, int p)
{
	if(i==j) return a[i];
	ll &memo=dp[i][j][p];
	if(memo!=-1) return memo;
	
	ll ans1=a[i]+psum[j]-psum[i]-solve(i+1, j, 1-p);
	ll ans2=a[j]+psum[j-1]-psum[i-1]-solve(i, j-1, 1-p);
	return memo=max(ans1, ans2);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
    memset(dp, -1, sizeof(dp));
	cin>>n;
	for(int i=1; i<=n; i++) {
		cin>>a[i];
		psum[i]=psum[i-1]+a[i];
	}
	
	ll x=solve(1, n, 0);
	ll y=psum[n]-x;
	cout<<x-y<<"\n";
    return 0;
}



Measured memory_bytes: 250496
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final List<Integer> list = IntStream.range(0, scanner.nextInt())
                .mapToObj(i -> scanner.nextInt())
                .sorted(Comparator.reverseOrder())
                .collect(Collectors.toList());

        for (int i = 0; i < list.size() - 1; i++) {
            if (list.get(i).equals(list.get(i + 1))) {
                final long longer = list.get(i);
                for (int j = i + 2; j < list.size() - 1; j++) {
                    if (list.get(j).equals(list.get(j + 1))) {
                        final long shorter = list.get(j);
                        System.out.println(longer * shorter);
                        return;
                    }
                }
            }
        }

        System.out.println(0);
    }
}


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

double big( double, double );
int absolute( int );

int main( void ){
    int num = 0;
    int* x = 0;
    int* y = 0;
    double ans_1 = 0.0;
    double ans_2 = 0.0;
    double ans_3 = 0.0;
    double ans_infi = 0.0;
	int i;
    
    scanf( "%d", &num );
    
    x = ( int* )malloc( sizeof( int ) * num );
    y = ( int* )malloc( sizeof( int ) * num );
    
    for( i = 0; i < num; i++ ){
        scanf( "%d", &x[i] );
    }
    for( i = 0; i < num; i++ ){
        scanf( "%d", &y[i] );
    }
    for( i = 0; i < num; i++ ){
        ans_1 += absolute( x[i] - y[i] );
        ans_2 += absolute( x[i] - y[i] ) * absolute( x[i] - y[i] );
        ans_3 += absolute( x[i] - y[i] ) * absolute( x[i] - y[i] ) * absolute( x[i] - y[i] );
        ans_infi = (double)(big( ans_infi, absolute( x[i] - y[i] )));
    }
    
	ans_2 = sqrt( ans_2 );
	ans_3 = cbrt( ans_3 );
    printf( "%lf %lf %lf %lf", ans_1, ans_2, ans_3, ans_infi );
    
    return 0;
}

double big( double a, double b ){ 
    if( a < b ){
        a = b;
    }
    else {
    }
    
    return a;
}

int absolute( int a ){
    if( a < 0 ){
        a *= -1;
    }
    
    return a;
}


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

int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  vector<int> b(n);
  b.at(0)=a.at(0);
  for(int i=0;i<n-1;i++){
    b.at(i+1)=a.at(b.at(i)-1);
  }
  bool z=false;
  int count=0;
  for(int i=0;i<n;i++){
    if(b.at(i)==2){
      z=true;
      count+=i+1;
      break;
    }
  }
  if(z){
    cout<<count;
  }
  else{
   cout<<-1; 
  }
}

Measured memory_bytes: 1024
/*input
8 6
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int main()
{
	IOS;
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	bool flag=(abs(a-c)<=d);
	flag|=(abs(a-b)<=d&&abs(b-c)<=d);
	if(flag) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
s = [["" for _ in range(h)] for _ in range(w)]
for i in range(h):
    S = input()
    for j in range(w):
        s[j][i] = S[j]
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

def bfs(x, y):
    if s[x][y] == ".":
        return True
    flag = False
    for i in range(4):
        nx = x + dx[i]
        ny = y + dy[i]
        if 0 <= nx and nx < w and 0 <= ny and ny < h:
            if s[nx][ny] == "#":
                flag = True
    return flag

ans = True
for i in range(h):
    for j in range(w):
        if bfs(j, i) == False:
            ans = False

if ans:
    print("Yes")
else:
    print("No")


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

int MOD = 1e9+7;

int main(){
  int N;
  vector<int64_t> A(300010);
  vector<int64_t> one(65, 0); //one[i]: i+1ビット目が1のものの数

  cin >> N;
  for(int i=0; i<N; i++){
    cin >> A[i]; int d = 0;
    while(A[i] > 0){
      one[d] += A[i] & 1;
      A[i] /= 2; d++;
    }
  }

  int64_t ans = 0;
  for(int i=0; i<65; i++){
    int64_t cur = one[i]*(N-one[i]) % MOD;
    for(int j=0; j<i; j++) cur = cur * 2 % MOD;
    ans = (ans + cur) % MOD;
  }

  cout << ans << endl;
}

Measured memory_bytes: 2560
public class Main {

  private static void solve() {
    int a = ni();
    int b = ni();
    int c = ni();
    System.out.println(Math.min(c, b / a));


  }

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

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

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

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

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

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

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

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

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

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

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

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



Measured memory_bytes: 21332
n,p = map(int,input().split())
a = list(map(lambda x:int(x)%2,input().split()))
cnt0 = a.count(0)
cnt1 = n-cnt0
if cnt0==n and p==0:
    print(2**n)
elif cnt0==n and p==1:
    print(0)
else:
    print(2**(n-1))

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

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

  int sum=abs(a[0]);
  for(int i=1; i<n; ++i)sum+=abs(a[i]-a[i-1]);
  sum+=abs(a[n-1]);

  for(int i=0; i<n; ++i){
    if(i==0)cout<<sum-abs(a[0])-abs(a[0]-a[1])+abs(a[1])<<endl;
    else if(i==n-1)cout<<sum-abs(a[n-1])-abs(a[n-1]-a[n-2])+abs(a[n-2])<<endl;
    else{
      cout<<sum-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i+1]-a[i-1])<<endl;
    }
  }
}


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

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;

constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main() {
    int N,T; cin>>N>>T;
    int t[N]; REP(i,N) cin>>t[i];
    i64 ans = 0;
    REP(i,N-1) ans += min(t[i+1]-t[i],T);
    ans+=T;
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
	while(1){
	int n,cnt=0,cntz=0;
	cin>>n;
	if(n==0) return 0;
	for(int i=0;i<n;i++){
		int num;
		cin>>num;
		if(num<2) cnt++;
		if(num==0) cntz++;
	}
	if(cnt==n) cout<<"NA"<<endl;
	else cout<<n+1-cntz<<endl;
	}
	return 0;
}

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

int main()
{
    string s;
    cin>>s;
    set<char>st;
    pair<set<char>::iterator,bool> ptr; 
    int count =0;
    ptr=st.insert(s[0]); 
    if (ptr.second)
        count++;
    ptr=st.insert(s[1]); 
    if (ptr.second)
        count++;
    ptr=st.insert(s[2]); 
    if (ptr.second)
        count++;
    ptr=st.insert(s[3]); 
    if (ptr.second)
        count++;
    
    if(count==2)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
    
    
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    int N, K, R, S, P;
    string T;
    cin >> N >> K >> R >> S >> P >> T;

    map<char, int> mp;
    mp['r'] = P;
    mp['s'] = R;
    mp['p'] = S;

    ll ans = 0;
    rep(i, K) {
        char c = ' ';
        for (int j = i; j < N; j += K) {
            if (T[j] == c) {
                c = ' ';
            } else {
                c = T[j];
                ans += mp[T[j]];
            }
        }
    }

    cout << ans << endl;
}

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

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;

  int N, K;
  cin >> N >> K;

  vi h(N);
  REP(i, N) cin >> h[i];

  sort(h.begin(), h.end());

  int ans = h[N - 1];

  REP(i, N - K + 1) { ans = min(ans, h[i + K - 1] - h[i]); }

  cout << ans << endl;

  return 0;
}


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

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

int main(){
    int N, X, T;
    cin >> N >> X >> T;
    int ans = 0;
    for(int i = 0; i < N; i += X){
        ans += T;
    }
    cout << ans << endl;
    return 0;
}

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


int main(void){
  int N, W;
  cin >> N >> W;

  const int MOD = (1e9) + 7;
  
  vector<int> w(N + 1);
  w[0] = 1e9;
  for(int i = 1; i <= N; i++){ cin >> w[i]; }
  sort(w.begin(), w.end());
  reverse(w.begin(), w.end());
  
  vector<vector<long long int> > dp(N + 1, vector<long long int>(W + 2, 0));
  dp[0][0] = 1;
  for(int i = 1; i <= N; i++){
    for(int j = 0; j <= W + 1; j++){
      // dp[i][j]: i???????????§?????¢?????????????????£?????????j??\??????????????????????????????????????°
      // = i-1???????????§?????¢?????????????????£?????????j??\??????????????????????????????????????° * 2
      // + i-1???????????§?????¢?????????????????£?????????[j - w[i], j)???????????????????????????????????°
      // = i-1???????????§?????¢?????????????????£?????????j??\??????????????????????????????????????° * 2
      // + (i-1???????????§?????¢?????????????????£?????????j - w[i]??\??????????????????????????????????????° - j??\??????????????????????????????????????°)
      // = i-1???????????§?????¢?????????????????£?????????j??\??????????????????????????????????????°
      // + (i-1???????????§?????¢?????????????????£?????????j - w[i]??\??????????????????????????????????????°
      int r = max(j - w[i], 0);
      dp[i][j] = (dp[i - 1][j] + dp[i - 1][r]) % MOD;
    }
  }
  
  // j????????????(j, i]???????????????(i, N]????¢??????§????????????????????°
  long long int sum = 0, ans = 0;
  for(int i = N; i >= 0; i--){
    long long int total = W - sum;
    if(sum > W){ break; }
    if(sum + w[i] > W){
      ++ans;
      ans %= MOD;
    }
    for(int j = 1; j < i; j++){
      int low = max(total - w[j] - w[i] + 1, 0LL);
      int up = max(total - w[j] + 1, 0LL);
      ans += dp[j - 1][low] - dp[j - 1][up] + MOD;
      ans %= MOD;
    }

    // ?¢??????§?????????????????????
    sum += w[i];
  }

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

Measured memory_bytes: 18508
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
A.sort()
if N%2 == 0:
    A1 = A[0:N//2]
    A2 = A[N//2:]
    ans = (2 * sum(A2) - A2[0])-(2 * sum(A1) - A1[-1])
else:
    A1 = A[0:N//2]
    A2 = A[N//2 + 1:]
    ans = (2 * sum(A2) - A2[0])-(2 * sum(A1) - A1[-1])
    add = max(A[N//2] - A1[-1], A2[0] - A[N//2])
    ans += add
print(ans)

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

int main() {
    string s;
    cin >> s;
    int len = (int)s.size();
    if (len < 4) cout << "No" << endl;
    else {
        string t;
        for (int i = 0; i < 4; i++) {
            t += s.at(i);
        }
        if (t == "YAKI") cout << "Yes" << endl;
        else cout << "No" << endl; 
    }
}   

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner((os.Stdin))

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

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

func main() {
	//sc.Split(bufio.ScanWords)
	S, T := nextLine(), nextLine()

	fmt.Printf("%s\n", ABC076C(S, T))
}

// ABC076C ...
func ABC076C(S, T string) string {
	S = strings.ReplaceAll(S, "?", ".")
  	for i := len(S) - len(T); i >= 0; i-- {
		tmpS := S[i : i+len(T)]
		matched, _ := regexp.Match(tmpS, []byte(T))
		if matched {
			li := strings.LastIndex(S, tmpS)
			return strings.ReplaceAll(S[:li]+T+S[li+len(T):], ".", "a")
		}
	}
  	return "UNRESTORABLE"
}


Measured memory_bytes: 1968
a,b = map(int,input().split())
if a==1 and b==1:
  print("Draw")
  exit()
if a==1:
  print("Alice")
  exit()
if b==1:
  print("Bob")
  exit()
  
if a>b:
  print("Alice")
elif a==b:
  print("Draw")
else:
  print("Bob")
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >>s;
  int ans =0;
  for(int i=0;i<s.size();i++){
    if(s.at(i) =='1'){
      ans++;
    }
  }
  cout <<ans<<endl;

  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)

struct FenwickTree {
    vector<ll> bit;
    ll n;

    FenwickTree() {}
    FenwickTree(ll n) {
        this->n = n;
        bit.assign(n, 0);
    }

    ll sum(ll r) {
        ll ret = 0;
        for (; r >= 0; r = (r & (r + 1)) - 1)
            ret += bit[r];
        return ret;
    }

    ll sum(ll l, ll r) {
        return sum(r) - sum(l - 1);
    }

    void add(ll idx, ll delta) {
        for (; idx < n; idx = idx | (idx + 1))
            bit[idx] += delta;
    }
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m,y,z;
    cin>>n;
    FenwickTree tree[26];
    for(int i=0;i<26;i++){
        tree[i] = FenwickTree(n);
    }
    string s;
    cin>>s;
    for(int i=0;i<n;i++){
        x = s[i] - 'a';
        tree[x].add(i,1);
    }
    cin>>t;
    while(t--){
        cin>>x;
        if(x==1){
            char ch;
            cin>>y>>ch;
            y--;
            z = ch - 'a';
            x = s[y] - 'a';
            s[y] = ch;
            tree[x].add(y,-1);
            tree[z].add(y,1);
        }
        else{
            cin>>y>>z;
            y--;z--;
            ll ans = 0;
            for(int i=0;i<26;i++){
                ans+=(tree[i].sum(y,z)>0);
            }
            cout<<ans<<endl;
        }
    }
    


    return 0;
}

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

#include <iostream>
#include <fstream>

#include <iostream>
#include <deque>

using namespace std;

class TaskC {
public:
	void solve(std::istream& in, std::ostream& out) {
		string s;
		in >> s;
		int ans = 0;
		deque<char> d(s.begin(), s.end());
		while (d.size() >= 2) {
			if (d.front() == d.back()) {
				d.pop_back();
				d.pop_front();

				continue;
			}
			if (d.front() == 'x') {
				d.pop_front();
				++ans;
				continue;
			}
			if (d.back() == 'x') {
				d.pop_back();
				++ans;
				continue;
			}
			out << -1;
			return;
		}
		out << ans << "\n";
	}
};


int main() {
	std::ios_base::sync_with_stdio(false);
	TaskC solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	in.tie(0);
	out << std::fixed;
	out.precision(20);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main() {
    int A, B, C;
    cin >> A >> B >> C;

    if ((A + B) >= C) {
        //解毒が多い場合
        cout << (B + C) <<endl;
    }
    else {
        //解毒が足りない
        cout << (B + ((A + B) + 1)) << endl;
    }
    
}

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

using namespace std;

int main(){
  int in;
  cin >> in;
  int s1, s2, s3;
  s1 = in / 100;
  s2 = (in / 10) % 10;
  s3 = in % 10;
  cout << s1 + s2 + s3 << endl;
  return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  if (n == m) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3616
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
using namespace std;


int main() {
	
	int a, b;
	char op;


	for (;;) {
		cin >> a >> op >> b;

		if (op == '?')break;

		if (op == '+')printf("%d", a + b);
		if (op == '-')printf("%d", a - b);
		if (op == '*')printf("%d", a * b);
		if (op == '/')printf("%d", a / b);
		printf("\n");


	}
	


	//system("pause");
	return 0;
}


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

namespace _0135
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			for (int i = 0; i < n; i++)
			{
				int[] x = Console.ReadLine().Split(':').Select(int.Parse).ToArray();
				int minute = x[0] * 60 + x[1];
				double a = (minute * 0.5) % 360; double b = (minute * 6) % 360;
				double min = Math.Min(a, b); double max = Math.Max(a, b);
				double d = Math.Min(max - min, min + 360 - max);
				if (d < 30) Console.WriteLine("alert");
				else if (d < 90) Console.WriteLine("warning");
				else Console.WriteLine("safe");
			}
		}
	}
}


Measured memory_bytes: 8460
#include<stdio.h>

int main() {
    int n, i, j;
    int A[255];

    scanf("%d",&n);
    for(i=1;i<=n;i++) scanf("%d",&A[i]);

    for(i=1;i<=n;i++) {
        printf("node %d: key = %d, ", i, A[i]);
        if(i != 1) printf("parent key = %d, ", A[i/2]);
        if(i*2 <= n) printf("left key = %d, ", A[i*2]);
        if(i*2+1 <= n) printf("right key = %d, ", A[i*2+1]);
        printf("\n");
    }
    return 0;
}

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

bool is_msprime[300001];

void sieve() {
  for(int i=0;i<300001;i++) {
    is_msprime[i] = false;
  }

  for(int i=1;i<300001;i++) {
    if(i % 7 == 1 || i % 7 == 6) {
      is_msprime[i] = true;
    }
  }

  for(int i=2;i<300001;i++) {
    if(is_msprime[i]) {
      for(int j=2*i;j<300001;j+=i) {
        is_msprime[j] = false;
      }
    }
  }
}

void solve(int n) {
  cout << n << ":";
  for(int i=2;i<300001;i++) {
    if(is_msprime[i]) {
      if(n % i == 0) {
        cout << " " << i;
      }
    }
  }
  cout << endl;
}

int main() {
  sieve();
  int s;
  while(cin >> s) {
    if(s==1) break;
     solve(s);
  }
}

Measured memory_bytes: 1160
import sys
from pprint import pprint

def solve(a, b):
    a_str = str(a) * b
    b_str = str(b) * a
    print(a_str if a_str <= b_str else b_str)

if __name__ == '__main__':
    a, b = map(int, sys.stdin.readline().strip().split(" "))
    solve(a, b)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using ll = long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define ALL(x) x.begin(),x.end()

#define INF (ll)1e9 //10^9:∞
#define LLINF (ll)1e12
#define MOD (ll)(1e9+7) //10^9+7:合同式の法
#define PI 3.141592653589
#define PB push_back
#define F first
#define S second
#define __MAGIC__ ios::sync_with_stdio(false);cin.tie(nullptr);

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)
#define endl "\n"

using namespace std;
/*..................DEFINE GLOBAL VARIABLES...................*/


/*.....................DEFINE FUNCTIONS ......................*/



/*.........................kemkemG0...........................*/
signed main() {
	__MAGIC__


	ll N, P;
	cin >> N >> P;

	ll even = 0, odd = 0;

	REP(i, N) {
		int a;
		cin >> a;
		if (a % 2 == 1)odd++;
		else even++;
	}

	ll ans = 0;



	if (P == 0) {
		if(odd==0) ans=pow(2, even);
		else ans = (pow(2, even) ) * (pow(2, odd) - pow(2, odd - 1)); //偶数を好きなだけ、+奇数を偶数個だけ:=偶数×偶数
	}

	else {

		if (odd == 0)ans = 0;//奇数がないときは無理

		else ans = (pow(2, even)  ) * pow(2, odd - 1);//偶数を好きなだけ+奇数を奇数個だけ:=偶数×奇数

	}

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 4120
#include<iostream>
#include<vector>
#include<algorithm>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(){
    int n, t;
    cin >> n;
    vector<int> d;
    REP(i,n){
        cin >> t;
        d.push_back(t);
    }
    sort(d.begin(), d.end());
    int num[n];
    REP(i,n){
        if(i == 0) num[i] = 1;
        else{
            num[i] = num[i-1];
            if(d[i] != d[i-1] ) num[i]++;
        }
    }
    cout << num[n-1] << endl;
    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		long prime = 1000000007L;
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		long[][] dp = new long[n+1][10];
		dp[0][0] = 1;
		for(int i=0;i<n;i++) {
			dp[i+1][0] = (dp[i][0]*2 + dp[i][2]*2 + dp[i][4]*2 + dp[i][5]*2+ dp[i][7] + dp[i][8] + dp[i][9])%prime; //その他
			dp[i+1][1] = (dp[i][0] + dp[i][1] + dp[i][4] + dp[i][5] + dp[i][6] + dp[i][9])%prime; //A
			dp[i+1][2] = (dp[i][0] + dp[i][2] + dp[i][7] + dp[i][8] + dp[i][9])%prime; //G
			dp[i+1][3] = (dp[i][1] + dp[i][6])%prime; //AG
			dp[i+1][4] = (dp[i][1])%prime; //AC
			dp[i+1][5] = (dp[i][1] + dp[i][6])%prime; //AT
			dp[i+1][6] = (dp[i][2] + dp[i][3] + dp[i][7] + dp[i][8])%prime; //GA
			dp[i+1][7] = (dp[i][3])%prime; //AGG
			dp[i+1][8] = (dp[i][5])%prime; //ATG
			dp[i+1][9] = (dp[i][3])%prime; //AGT
		}
		long ans = 0;
		for(int i=0;i<10;i++) {
			ans += dp[n][i];
		}
		System.out.println(ans%prime);
		in.close();
	}

}


Measured memory_bytes: 23764