akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;
	cin>>n;
	int ct[9]={};
	for(int i=0; i<n; i++){
		int a; cin>>a;
		if(a/400>=8) ct[8]++;
		else ct[a/400]++;
	}
	int ans=0;
	for(int i=0; i<8; i++) if(ct[i]>0) ans++;
	if(ans==0) cout<<1<<" "<<n<<endl;
	else{
		cout<<ans<<" "<<ans+ct[8]<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MN = 200200;
set<ll> se;
ll w[MN],st[MN];
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n,k;
	cin >> n >> k;
	for(int i=0;i<n;i++) {
		cin >> w[i];
	}
	int rv = 0;
	for(int i=0;i<n;i++) {
		if(w[i] <= w[i-1]) {rv = 0;}
		rv++;
		st[i] = rv;
	}
	ll tot = 0;
	for(int i=0;i<k;i++) {
		se.insert(w[i]);
	}
	int ns = 0;
	if(st[k-1] >= k) {
		ns = 1;
	} else {
		tot++;
	}
	for(int i=k;i<n;i++) {
		ll ov = w[i-k];
		ll nv = w[i];
		if(st[i] >= k) {
			ns = 1;
		} else {
			if(!(*se.begin() == ov) || !(*se.rbegin() < nv)) {
				tot++;
			}
		}
		se.erase(ov);
		se.insert(nv);
	}
	cout << tot+ns << '\n';
}

Measured memory_bytes: 14848
N = int(input())
* A, = map(int, input().split())
count = 0
for i in range(N):
    minj = i
    for j in range(i+1, N):
        if A[j] < A[minj]:
            minj = j
    A[i], A[minj] = A[minj], A[i]
    if i != minj:
        count += 1
print(*A)
print(count)



Measured memory_bytes: 5612
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

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

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    string w;
    cin >> w;

    map<char, int> mp;

    for(int i = 0; i < w.size(); i++){
        mp[w[i]]++;
    }

    bool ok = true;
    for(auto i : mp){
        if(i.second == 0) continue;
        if(i.second % 2 != 0){
            ok = false;
        }
    }
    if(ok){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
//code by lynmisakura.wish to be accepted!
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(void){
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> a(m);
    vector<ll> p(n,0);
    vector<bool> ac(n,false);
    for (int i = 0; i < m; ++i)
    {
        int x;cin >> x;x--;
        string s;cin >> s;
        if(ac[x])continue;
        else{
            if(s == "AC"){
                ac[x] = true;
            }else{
                p[x]++;
            }
        }
    }

    ll A=0,P=0;
    for (int i = 0; i < n; ++i)
    {
//        cout << p[i] << endl;
        if(ac[i]){
            P += p[i];
            A++;
        }
    }
    cout << A << " " << P << endl;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
#define MOD 1000000007
#define INF 1000000000
#define mp make_pair
#define pb push_back
#define ss second
#define ff first
#define endl '\n'
#define pl cout<<endl;
void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); }
const long long INFll=1ll*INF*INF;
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define debug(x) cout << x << endl;
#define sz(a) int((a).size())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
    //unordered_map<long long, int, custom_hash>
    //gp_hash_table<long long, int, custom_hash>
};
long long genrand(long long L,long long R)
{
	return uniform_int_distribution<long long>(L, R)(rng);
}
int mul(int a, int b,int mod = MOD) {
	return int(a * 1ll * b % mod);
}
int norm(int a,int mod = MOD) {
	while(a >= mod) a -= mod;
	while(a < 0) a += mod;
	return a;
}
int powmod(int x,int y,int mod = MOD){
	int res = 1;
	while(y>0)
	{
		if(y&1)
			res = mul(res,x,mod);
		x = mul(x,x,mod);
		y=y>>1;
	}
	return res;
}
int inv(int a,int mod = MOD) {
	return powmod(a, mod - 2);
}
int main() {
	
	long long k; cin>>k;
	long double n = 100;
	int ans = 0;
	while(n<k){
		n = n * 1.01;
		n = (long long) n;
		ans++;
	}
	cout<<ans;
	return 0;
}

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()

int main(){
    double a, b, x;
    cin >> a >> b >> x;

    double bd = a*a*b/2;
    if(x<bd){
        double t = a*b*b/(2*x);
        double p = atan(t);
        cout << (p/acos(-1)*180) << endl;
    }
    else{
        double t = 2*b/a-2*x/(a*a*a);
        double p = atan(t);
        cout << setprecision(20) << (p/acos(-1)*180) << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a,b;
	int cnt1=0,cnt2=0;
	int mi=INT_MAX;
	int t;
	for(a=1;a<n;a++){
		cnt1=0;
		cnt2=0;
		t=a;
		b=n-a;
		while(t>0){
			cnt1+=t%10;
			t/=10;
		}
		while(b>0){
			cnt2+=b%10;
			b/=10;
		}
		int he=cnt1+cnt2;
		mi=min(mi,he);
	}
	cout<<mi<<endl;
	return 0;
}

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

int main() {
	string ss[3] = {"Sunny", "Cloudy", "Rainy"};
	string input;
	cin>>input;
	for (int i=0; i<3; i++)
		if (input == ss[i]) {
			cout<<ss[(i+1)%3]<<endl;
			break;
		}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

int H=1, A[MAX+1];

void maxHeapify(int j)
{
	int largest;
	if(A[j]<A[j*2]&&(j*2<=H))
	{
		largest=j*2;
	}
	else 
		largest=j;
	if(A[largest]<A[j*2+1]&&((j*2+1)<=H))
		largest = j*2+1;
	if(largest!=j)
	{
		swap(A[largest], A[j]);
		maxHeapify(largest);
	}
}

int extractMax()
{
	int max = A[1];
	if(H<1) return -INFTY;
	A[1]=A[H--];
	maxHeapify(1);
	return max;	
}

void increaseKey(int i, int key)
{
	if(key<A[i])
		return;
	A[i]=key;
	while(i>1&&A[i/2]<A[i])
	{
		swap(A[i], A[i/2]);
		i=i/2;
	}
}

void insert(int key)
{
	H++;
	A[H]=-INFTY;
	increaseKey(H, key);
}

int main()
{
	int key, i=0, j;
	char com[10];
	while(1)
	{
		scanf("%s", com);
		if(com[0]=='e'&&com[1]=='n') break;
			
		if(com[0]=='i')
		{
			scanf("%d", &key);
			insert(key);
		}
		else if(com[0]=='e'&&com[1]=='x')
		{
			printf("%d\n", extractMax());
		}
	}
	return 0;
}


Measured memory_bytes: 6468
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;




signed main() {
    ll a, b, c, d, e, f;
    cin >>a >>b >>c >>d >>e >>f;
    if (e - a > f) {
        mes (":(");
        re0;
    }
    
    
    mes("Yay!");
    
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;
const int N = 1e6 + 10;

long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

void solve(){
   int m,k;cin >> m >>k;
   if(pow(2,m)<=k) cout << -1;
   else if(k==0){for(int i = 0;i<pow(2,m);i++) cout << i <<' '<< i <<' ';}
   else if(m==1) cout << -1;
   else {
    cout << k <<' ';
    for(int i = 0;i<pow(2,m);i++){
        if(i==k) continue;
        cout << i <<' ';
    }
    cout << k <<' ';
    for(int i = pow(2,m)-1;i>=0;i--){
        if(i==k) continue;
        cout << i <<' ';
    }
   }
}

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


Measured memory_bytes: 4116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll>PLL;
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll MOD = 1e4+7;
int main() {
    int x;
    cin >> x;
    if ( x < 100 ) {
        cout << 0 << endl;
        return 0;
    }
    int x_mod100 = x % 100;
    if ( x_mod100 <= 5 ) {
        cout << 1 << endl;
        return 0;
    }
    else if ( ( ( x_mod100 + 4 ) / 5 ) * 100 > x ) {
        cout << 0 << endl;
        return 0;
    }
    else {
        cout << 1 << endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>
#include <queue>

using namespace std;




int main()
{
	int A, B;

	cin >> A >> B;

	int ans = 0;
	if (A > 12){
		ans = B;
	}else if(A > 5){
		ans = B /2;
	}


	printf("%d",ans);


	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A,B;
  cin>>A>>B;
  int count=0;
  for(int t=A;t<=B;t++){
    string i=to_string(t);
    if(i.at(0)==i.at(4)&&i.at(1)==i.at(3)){
      count++;
      int t=stoi(i);
    }
  }
  cout<<count;
}


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

int main() {
	int n, a[100];
	cin >> n;
	for (int i = 0; i<= n-1; i++){
	  cin >> a[i];
	}
	
	for (int i = 0; i <= n-1; i++){
		int v = a[i];
		int j =  i - 1;
		while (j >= 0 && a[j] > v){
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = v;
		for (int k = 0; k <= n-1; k++){
		   cout << a[k];
		   if (k < n-1){
		   	cout << " ";
		   }else {
		   	cout << endl;
	       }
	     }
    }
	
	
	return 0;
}


Measured memory_bytes: 3096
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
    string b;
int main(){
	int qwq=0;
    cin>>b;
    for(int i=0;i<b.size();i++){
    	if(b[i]=='C')
	qwq++;
	if(qwq!=0&&b[i]=='F')
	qwq-=10000000000;
	}
	if(qwq<0)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

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

int main(){
  int N; cin >> N;
  map<int,int> m;
  long long c=0;
  for(int i=1; i<=N; i++){
    int A; cin >> A;
    if(m.count(i-A)>0) c+=m[i-A];
    A+=i;
    if(m.count(A)==0) m[A]=1;
    else m[A]++;
  }
  cout << c << endl;
}

Measured memory_bytes: 12828
#include <iostream>

using namespace std;

int main()
{
	int N, l, r;
	int ans = 0;

	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> l >> r;

		ans += (r - l) + 1;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
N = int(input())

A = []

[A.append(int(input())) for _ in range(N)]

A_sorted = sorted(A, reverse=True)
A_max1 = A_sorted[0]
A_max2 = A_sorted[1]

for a in A:
    if a == A_max1:print(A_max2)
    else:print(A_max1)

Measured memory_bytes: 14764
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll N, D;
  std::cin >> N >> D;

  ll span = 2 * D + 1;
  ll ans  = (N + span - 1) / span;
  print(ans);

  return 0;
}


Measured memory_bytes: 256
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  string s;
  cin >> s;
  int n = sz(s);
  int a[n];
  a[n - 1] = (s[n - 1] == 'W');
  int ans = 0;
  for (int i = n - 2; i >= 0; i--) {
    a[i] = a[i + 1];
    if (s[i] == 'B') {
      ans += a[i + 1];
    } else {
      a[i]++;
    }
  }
  cout << ans << "\n";
}



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

int main() {
	int N; cin >> N;
	string S, T; cin >> S >> T;
	for (int i = 0; i < 2*N; i++)
	{
		if (i % 2 == 0)cout << S[i / 2];
		else cout << T[i / 2];
	}
	cout << endl;
}


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

int main() {
  ll h,w;
  cin>>h>>w;
  if(h==1 || w==1){
    cout<<1<<endl;
    return 0;
  }
  ll ans=(h*w+1)/2;
   cout<<ans<<endl;
}

Measured memory_bytes: 256
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
----

local N = read.n()

local function get(b, e)
    -- number of integer x where:
    --  - begin with b,
    --  - end with e, and
    --  - x <= N
    local c = 0
    for i=e,N,10 do
        local x = tonumber(tostring(i):sub(1,1))
        if x == b then
            c = c + 1
        end
    end
    return c
end

local cnt = 0
-- A
-- x....y
-- B
-- y....x
for x=1,9 do
    for y=1,9 do
        local cnt_a = get(x, y)
        local cnt_b = get(y, x)
        cnt = cnt + cnt_a * cnt_b
    end
end
print(cnt)

Measured memory_bytes: 2856
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;
 
char str[100005];
ll a[100005][4];

int main(int argc, char* argv[])
{
    scanf("%s", str);
    int n=strlen(str);
    a[0][0]=1;
    int i;
    for(i=0; i<n; i++) {
        a[i+1][0]=a[i][0]*(str[i]=='?'?3:1)%MOD;
        a[i+1][1]=a[i][1]*(str[i]=='?'?3:1)%MOD;
        a[i+1][2]=a[i][2]*(str[i]=='?'?3:1)%MOD;
        a[i+1][3]=a[i][3]*(str[i]=='?'?3:1)%MOD;

        if(str[i]=='A' || str[i]=='?') {
            a[i+1][1]=(a[i+1][1]+a[i][0])%MOD;
        }
        if(str[i]=='B' || str[i]=='?') {
            a[i+1][2]=(a[i+1][2]+a[i][1])%MOD;
        }
        if(str[i]=='C' || str[i]=='?') {
            a[i+1][3]=(a[i+1][3]+a[i][2])%MOD;
        }
    }
    printf("%lld\n", a[n][3]);

    return 0;
}

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

using namespace std;

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

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

  long costs[n];
  costs[0] = 0;
  costs[1] = abs(hs[1] - hs[0]);
  for (int i = 2; i < n; i++) {
    costs[i] = min(costs[i - 1] + abs(hs[i] - hs[i - 1]), costs[i - 2] + abs(hs[i] - hs[i - 2]));
  }

  cout << costs[n - 1] << endl;
  return 0;
}



Measured memory_bytes: 1408
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nk = readln.split.to!(long[]);
    auto N = nk[0];
    auto K = nk[1];
    auto AS = readln.split.to!(long[]);
    sort!"a < b"(AS);
    auto FS = readln.split.to!(long[]);
    sort!"a > b" (FS);

    long min_r = -1, max_r = 10L^^12;
    while (min_r + 1 < max_r) {
        auto r = (min_r + max_r) / 2;
        auto k = K;
        foreach (i; 0..N) {
            auto d = r - AS[i] * FS[i];
            if (d < 0) k += (d - FS[i]+1) / FS[i];
            if (k < 0) break;
        }
        if (k >= 0) {
            max_r = r;
        } else {
            min_r = r;
        }
    }
    writeln(max_r);
}

Measured memory_bytes: 14176
var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', function (line) {
  lines.push(line);
});
process.stdin.on('end', function () {
  const number = lines[0];
  const str = lines[1];
  if (number >= 3200) {
    console.log(str);
  } else {
    console.log('red');
  }
});

Measured memory_bytes: 9548
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false)
#define ll long long

int a[300000];
int main()
{
    IO;
    int i, j, m, k, n, t, l=0, mxx,mx1,r,c,x,y;
    cin>>n;
    for(i=1; i<n; i++){
        cin>>j; a[j]++;
    }
    for(i=1; i<=n; i++) cout<<a[i]<<endl;
    return 0;

}


Measured memory_bytes: 4392
#include<bits/stdc++.h>
using namespace std;
#define MOD int(1e9+7)

int main()
{
    int n;cin>>n;
    vector<long long> a(n);
    int i;
    for(i=0;i<n;i++)cin>>a.at(i);
    long long ans=1234567890123456;
    long long pos1=0;
    long long neg1=0;
    long long ksum=0;
    long long kans=0;
    for(i=0;i<n;i++)
    {
        if(i==0)
        {
            if(a.at(i)>=1)ksum+=a.at(i);
            else
            {
                kans+=1-a.at(i);
                ksum=1;
            }
        }
        else if(i%2==0)
        {
            if(ksum+a.at(i)>=1)ksum+=a.at(i);
            else
            {
                kans+=1-(ksum+a.at(i));
                ksum=1;
            }
        }
        else
        {
            if(ksum+a.at(i)<=-1)ksum+=a.at(i);
            else
            {
                kans+=ksum+a.at(i)+1;
                ksum=-1;
            }
        }
    }
    pos1=kans;
    ksum=0;
    kans=0;
    for(i=0;i<n;i++)
    {
        if(i==0)
        {
            if(a.at(i)<=-1)ksum+=a.at(i);
            else
            {
                kans+=a.at(i)+1;
                ksum=-1;
            }
        }
        else if(i%2==0)
        {
            if(ksum+a.at(i)<=-1)ksum+=a.at(i);
            else
            {
                kans+=ksum+a.at(i)+1;
                ksum=-1;
            }
        }
        else
        {
            if(ksum+a.at(i)>=1)ksum+=a.at(i);
            else
            {
                kans+=1-(ksum+a.at(i));
                ksum=1;
            }
        }
    }
    neg1=kans;
    ans=min(pos1,neg1);
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
//	var input = input.split("\n");
	//文字列から10進数に変換するときはparseIntを使います
    var input2 = input.split(" ");
  	
  	var a = Number(input2[0])
   	var b = Number(input2[1])
  	
  	var num = Math.floor((b -1) / (a-1))
    num = num * (a -1) + 1 >= b ? num : num +1 
  	
  console.log(num)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int N;
vector<vector<P>> v;

bool check(int bit) {
  rep(i,N) {
    if (!(bit & (1 << i))) continue;

    for (P xy: v[i]) {
      int x = xy.first;
      int y = xy.second;
      if (y == 1 && !(bit & (1 << x))) return false;
      if (y == 0 && (bit & (1 << x))) return false;
    }
  }
  return true;
}

int main() {
  cin >> N;
  v.resize(N);
  rep(i,N) {
    int a;
    cin >> a;
    v[i].resize(a);
    rep(j,a) {
      cin >> v[i][j].first >> v[i][j].second;
      --v[i][j].first;
    }
  }

  int res = 0;
  rep(bit, 1<<N) {
    if (check(bit)) {
      int cnt = 0;
      rep(i,N) {
	if (bit & (1 <<i)) ++cnt;
      }
      res = max(res, cnt);
    }
  }
  cout << res << endl;
  return 0;
}


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

typedef long long ll;

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

int main(){
  int n;
  cin >> n;
  int p[n];
  rep(i,n) cin >> p[i];

  int cnt=0;
  rep(i,n-2)
    if(p[i+1]!=min({p[i],p[i+1],p[i+2]})&&p[i+1]!=max({p[i],p[i+1],p[i+2]}))
      cnt++;


  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
  char x, y;
  cin >> x >> y;

  if(x < y){
    cout << "<" << endl;
  }else if(x > y){
    cout << ">" << endl;
  }else{
    cout << "=" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	
	int a, b, o, j, i = 0;

	while(1){
		
		if(scanf("%d%d", &a, &b) == EOF){
			
			break;
			
		}
		
		j = 1;

		o = a + b;
		while(o >= 10){
		
			j++;
		
			o /= 10;
		
		}
		
		printf("%d\n", j);
		
		i++;
	
	}

    return 0;
}

Measured memory_bytes: 600
# coding: utf-8
# Your code here!

S = input().rstrip()
T = input().rstrip()

T1 = list(T)
T1.pop()
#print(T1)
S1 = list(S)
T1= list(T1)
#print(S1)
#print(T1)
#print(T1)
#print(S1)
if T1 == S1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9040
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    int N, K;
    cin >> N >> K;
    vector<bool> A(N);
    for (int i = 0; i < K; i++) {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++) {
            int a;
            cin >> a;
            A[a - 1] = true;
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (!A[i]) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3600
#include<stdio.h>
int main(void){
	int a,b,c,i;
	while(scanf("%d %d",&a,&b)!=EOF){
		c=a+b;
		for(i=1;i<=8;i++){
			if(c<10){
				break;
			}
			c=c/10;
		}
		printf("%d\n",i);
	}
	return 0;
}


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

using namespace std;

#define REP(x,y) for (int (x) = 0; (x) < (y); (x)++)

int correct_result = 0, penalty = 0;

int correct[100000] = {};
int incorrect[100000] = {};

int N = 0, M = 0;
int p[100000] = {};
string S[100000] = {};

int main() {
    cin >> N >> M;
    REP(i, M) {
        cin >> p[i] >> S[i];
    }

    REP(i, M) {
        if (S[i] == "AC") {
            if (correct[p[i]] == 0) {
                correct[p[i]] = 1;
                correct_result += 1;
                penalty += incorrect[p[i]];
            }
        } else if (S[i] == "WA") {
            if (correct[p[i]] == 0) {
                incorrect[p[i]] += 1;
            }
        }
    }

    cout << correct_result << " " << penalty << endl;

    return 0;
}

Measured memory_bytes: 6912
#!/usr/bin/ruby
h,w=gets.split.map &:to_i
m=h.times.map{gets.chomp}
h.times{|y|w.times{|x|
	if m[y][x]=='#'
		d={[y,x]=>0}
		q=[[y,x]]
		while !q.empty?
			c=q.shift
			[[-1,0],[0,-1],[1,0],[0,1]].each{|dy,dx|
				ny=c[0]+dy
				nx=c[1]+dx
				if 0<=ny&&ny<h && 0<=nx&&nx<w && m[ny][nx]=='#' && !d[[ny,nx]]
					d[[ny,nx]]=d[c]+1
					q<<[ny,nx]
				end
			}
		end
		if d.size==1
			puts :No
			exit
		end
		d.each_key{|a,b|m[a][b]='.'}
	end
}}
puts :Yes


Measured memory_bytes: 2172
#include <iostream>
#include <numeric>

using namespace std;

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

signed main() {
  int n, m;
  cin >> n >> m;
  int a[n];
  rep(i,n) cin >> a[i];
  
  int p = 1;
  rep(i,n) {
    p = lcm(p, a[i]);
    if(m < p / 2) break;
  }
  rep(i,n) if(p / 2 % a[i] != a[i] / 2) p = 2 * m + 2;
    
  cout << (m - p / 2) / p + (m >= p / 2) << endl;
  return 0;
}

Measured memory_bytes: 4384
N,K,S = map(int,input().rstrip().split(" "))
ans = []
if S != 10 ** 9:
    for i in range(K):
        ans.append(S)
    for i in range(N - K):
        ans.append(S + 1)
else:
    for i in range(K):
        ans.append(S)
    for i in range(N - K):
        ans.append(1)
print(" ".join(map(str,ans)))

Measured memory_bytes: 66592
import itertools as it
N = list(map(int, input().split()))
K = int(input())
ans = 0

for i in it.product(list(range(3)), repeat = K):
    T = N.copy()
    for k in range(K):
        T[i[k]] *= 2
    if ans <= sum(T):
        ans = sum(T)
print(ans)

Measured memory_bytes: 3060
n = int(input())
s = input()

r_cnt = s.count('R')
g_cnt = s.count('G')
b_cnt = s.count('B')

ans = r_cnt * g_cnt * b_cnt

for i in range(n):
    for d in range(n):
        j = i + d
        k = j + d
        if k >= n:
            break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            ans -= 1
print(ans)

Measured memory_bytes: 9204
#[allow(dead_code)]
fn read_line(n: usize) -> String {
    let mut ss = String::new();
    for _i in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        ss.push_str(&s);
    }
    ss
}

macro_rules! parse {
    ($s:expr => $($r:tt)*) => {
        let s = $s;
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        parse!{s => $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main()
{
    parse!{
        n: u64,
    }
    let begin = (n as f64).sqrt() as u64;
    let mut x = 0;
    let mut y = 0;
    for i in (1..begin + 1).rev() {
        if n % i == 0 {
            x = i;
            y = n / i;
            break;
        }
    }
    println!("{}", (x - 1) + (y - 1));
}

Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
long long num[200005];
using namespace std;
long long ans;
int main(){
	long long a;
	scanf("%lld" , &a);
	for(long long i = 1 ;i <= a ; i++)	scanf("%lld" , &num[i]);
	long long anext = 1;
	long long xorr = 0 , plu = 0;
	for(long long i = 1 ; i <= a; i++){
		while(xorr == plu and anext <= a){
			xorr ^= num[anext];
			plu += num[anext];
			if(xorr == plu)	anext++;
			else{
				xorr ^= num[anext];
				plu -= num[anext];
				break;
			}
			if(anext > a)	break;
		}
		ans += anext - i;
		xorr ^= num[i];
		plu -= num[i];
	}
	cout << ans;
	return 0;
} 

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int N;
    cin>>N;
    vll L(N);
    for(int i=0;i<N;i++){
        cin>>L[i];
    }
    if(N<=2){
        cout<<0<<endl;return 0;
    }
    ll ans=0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            if(L[i]==L[j])continue;
            for(int k=j+1;k<N;k++){
                if(L[i]==L[k]||L[j]==L[k])continue;
                ll small=min(L[i],min(L[j],L[k]));
                ll big=max(L[i],max(L[j],L[k]));
                ll med=L[i]+L[j]+L[k]-small-big;
                if(small+med>big)ans++;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3628
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

// UnionFind 構造体 for tree
type UnionFind struct {
	par []int
}

/*コンストラクタ*/
func newUnionFind(N int) *UnionFind {
	u := new(UnionFind)
	u.par = make([]int, N)
	for i := range u.par {
		u.par[i] = -1
	}
	return u
}
func (u UnionFind) root(x int) int {
	if u.par[x] < 0 {
		return x
	}
	u.par[x] = u.root(u.par[x])
	return u.par[x]
}
func (u UnionFind) unite(x int, y int) {
	xr := u.root(x)
	yr := u.root(y)
	if xr == yr {
		return
	}
	u.par[yr] += u.par[xr]
	u.par[xr] = yr
}
func (u UnionFind) same(x, y int) bool {
	if u.root(x) == u.root(y) {
		return true
	}
	return false
}
func (u UnionFind) size(x int) int {
	return -u.par[u.root(x)]
}

var mod int = 1000000007

type pair struct {
	fi int
	se int
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	k := iScan()
	l := iScan()
	p := make([]int, k)
	q := make([]int, k)
	r := make([]int, l)
	s := make([]int, l)
	u1 := newUnionFind(n)
	u2 := newUnionFind(n)
	for i := 0; i < k; i++ {
		p[i] = iScan()
		q[i] = iScan()
		p[i]--
		q[i]--
		u1.unite(p[i], q[i])
	}
	for i := 0; i < l; i++ {
		r[i] = iScan()
		s[i] = iScan()
		r[i]--
		s[i]--
		u2.unite(r[i], s[i])
	}
	ar := make([]int, n)
	br := make([]int, n)
	data := make(map[pair]int)
	for i := 0; i < n; i++ {
		ar[i] = u1.root(i)
		br[i] = u2.root(i)
		var es pair
		es.fi = ar[i]
		es.se = br[i]
		data[es]++
		//fmt.Println(ar[i])
		//fmt.Println(br[i])
	}
	for i := 0; i < n; i++ {
		var es pair
		es.fi = ar[i]
		es.se = br[i]
		fmt.Println(data[es])
	}
}

Measured memory_bytes: 25516
from collections import defaultdict

MOD = int(1e9+7)


def div(a, b):
    return a * pow(b, MOD-2, MOD) % MOD


def main():
    N = int(input())
    A = list(map(int, input().split()))
    front = [1] * (N+1)
    back = [1] * (N+1)
    for i in range(N):
        front[i+1] = front[i] * A[i] % MOD
    for i in range(N)[::-1]:
        back[i] = back[i+1] * A[i] % MOD
    used = defaultdict(int)
    ans = 0
    divprod = 1
    for i in range(N):
        use = defaultdict(int)
        a = A[i]
        for x in range(2, int(a**0.5 + 1)):
            while a % x == 0:
                use[x] += 1
                a //= x
            if a == 1:
                break
        if a != 1:
            use[a] += 1
        for u in use:
            divprod = divprod * (u ** min(used[u], use[u])) % MOD
            used[u] = max(use[u], used[u])
        ans = (ans + front[i] * back[i+1]) % MOD
    ans = div(ans, divprod)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 49904
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>

using namespace std;

#define ll long long

ll l[100050] = {};
ll r[100050] = {};

int main() {
	int a, p;
	cin >> a >> p;
	p += a * 3;

	cout << p / 2 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    long long X, money;
    int cnt;
    cnt = 0;
    money = 100;

    scanf("%lld", &X);
    while(money < X){
        money *= 1.01;
        cnt ++;
    }
    printf("%d\n", cnt);

    return 0;
}


Measured memory_bytes: 1736
using System;
using System.Collections.Generic;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            String s = Console.ReadLine();

            String[] sequence = s.Split();

            Array.Reverse(sequence);

            for (int i = 0; i < n; i++)
            {
                if (i == n - 1)
                {
                    Console.WriteLine(sequence[i]);
                }else
                {
                    Console.Write(sequence[i] + " ");
                }
            }
        }
    }
}


Measured memory_bytes: 15976
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int a = in.nextInt(), b = in.nextInt();

			if (a + b == 15) {
				out.println("+");
			} else if (a * b == 15) {
				out.println("*");
			} else {
				out.println("x");
			}

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 21332
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#define ll long long
#define mod 1000000007
using namespace std;
int main(){
    ll n,answer=0;
    std::cin >> n;
    ll *arr=new ll[n];
    for(ll i=0;i<n;i++){
        std::cin >> arr[i];
    }
    sort(arr,arr+n);
    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<n;j++){
            if(arr[i]==arr[j])continue;
            for(ll k=j+1;k<n;k++){
                if(arr[j]==arr[k])continue;
                if(arr[i]+arr[j]>arr[k])answer++;
            }
        }
    }
    std::cout << answer << std::endl;
    return 0;
}

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	lli n,d;
	cin>>n>>d;
	lli val=0;

	vector<lli> x(n),y(n);

	for(int i=0;i<n;i++)
		cin>>x[i]>>y[i];

	for(int i=0;i<n;i++)
	{
		if(sqrt(x[i]*x[i]+y[i]*y[i])<=d)
			val++;
	}

	cout<<val;
}

Measured memory_bytes: 6380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

template<class T>
class SegTree {
public:
    int n;
    vector<T> nodes;
    T ini;
    function<T(T,T)> fn; // 2つの子要素から親を計算する関数
    SegTree(int _n, T ini, function<T(T,T)> fn): ini(ini), fn(fn) {
        n = 1 << (int)ceil(log2(_n));
        nodes.resize(n*2-1, ini);
    }
    void update(int i, T x) {
        i += n-1;
        nodes[i] = x;
        while (i > 0) {
            i = (i-1) / 2;
            nodes[i] = fn(nodes[i*2+1], nodes[i*2+2]);
        }
    }
    T query(int l, int r) {
        return _query(l, r, 0, n, 0);
    }
    T _query(int l, int r, int tl, int tr, int k) {
        if (tr <= l || r <= tl) return ini;
        if (l <= tl && tr <= r) return nodes[k];
        return fn(
            _query(l, r, tl, (tl+tr)/2, 2*k+1),
            _query(l, r, (tl+tr)/2, tr, 2*k+2)
        );
    }
};

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

    SegTree<ll> sg(N, 0, [](ll a, ll b){ return a | b; });
    for (int i=0; i<N; ++i) {
        sg.update(i, 1LL<<(S[i]-'a'));
    }

    int ty, a, b; char c;
    for (int i=0; i<Q; ++i) {
        cin >> ty;
        if (ty == 1) {
            cin >> a >> c;
            a --;
            sg.update(a, 1LL<<(c-'a'));
        } else {
            cin >> a >> b;
            a --;
            ll bit = sg.query(a, b);
            cout << __builtin_popcountll(bit) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 9092
N,K=map(int,input().split())
A=list(map(int,input().split()))
ma=max(A)
ma=max(ma,K)
num=len(bin(ma)[2:])
B=[]
count=[0]*num
for a in A:
    b=bin(a)[2:].zfill(num)
    B.append(b)
    for i in range(num):
        if b[i]=="0":
            count[i]-=1
        else:
            count[i]+=1
s=""
for i in count:
    if i<0:
        s+="1"
    else:
        s+="0"
k=bin(K)[2:].zfill(num)
t=""
for i in range(num):
    if s[i]<k[i]:
        t+=s[i:]
        break
    else:
        t+=k[i]
t=int(t,2)
sum=0
for i in A:
    sum+=i^t
print(sum)


Measured memory_bytes: 93328
#include<iostream>

using namespace std;

long long N,A[100100],B[100010],z=0;
int main(){
  cin >> N;
  for(int i=0;i<N+1;i++){
    cin >> A[i];
  }
  for(int i=0;i<N;i++){
    cin >> B[i];
  }

  for(int i=0;i<N;i++){
    if(B[i]<=A[i]){
      z = z + B[i];
    }else{
      z = z + A[i];
      if(A[i+1]<=(B[i]-A[i])){
        z=z+A[i+1];
        A[i+1]=0;
      }else{
        z=z+(B[i]-A[i]);
        A[i+1] = A[i+1] - (B[i]-A[i]);
    }
  }
  }


  cout<<z;

  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

#define N 8
#define F -1
#define NF 1

int row[N],col[N],dpos[2 * N - 1],dneg[2 * N - 1];

int A[N][N];

void setup(){
  int i;
  for(i = 0; i < N; i++){
    row[i] = F;
    col[i] = F;
  }
  for(i = 0; i < 2 * N - 1; i++){
    dpos[i] = F;
    dneg[i] = F;
  }
  
}

void print(){
  int i,j;
  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      if(A[i][j]){
        if(row[i] != j) return;
      }
    }
  }
  
  for(i = 0; i < N; i++){
     for(j = 0; j < N; j++){
       if(row[i] == j) printf("Q");
       else printf(".");
     }
     printf("\n");
  }
  

}

void recursive(int i){
  int j;
  if(i == N){
    print();
    return;
  }
  for(j = 0; j < N; j++){
    if(col[j] == NF || dpos[i + j] == NF || dneg[i - j + N - 1] == NF) continue;
    row[i] = j;
    col[j] = dpos[i + j] = dneg[i - j + N - 1] = NF;

    recursive(i + 1);

    row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = F;
  }
  
}


int main(){
  int n,i,j,a,b;
    
  setup();
  
  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      A[i][j] = 0;
    }
  }
  
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d%d",&a,&b);
    A[a][b] = 1;
  }

  recursive(0);
 
  return 0;
}



Measured memory_bytes: 2108
#include <iostream>

using namespace std;

int main()
{
    int n, x;
    int prev = 0, curr;
    int count = 0;
    cin >> n >> x;
    int l[n + 1];
    for (int i = 1; i <= n; i++)
    {
        cin >> l[i];
    }

    for (int i = 1; curr <= x; i++) {
        curr = prev + l[i];
        prev = curr;
        count++;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#define N 10000
#define INT(X) \
  ( *( (const int *)(X) ) )
#define MAX(A,B) \
  ( (A) > (B) ? (A) : (B) )

int compare (
  const void  * a,
  const void  * b
  )
{
  return ( INT( a ) - INT( b ) );
}

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    int ev[ N * 2 ];
    int nanikaka = 0;
    int res = 0;
    int n;

    scanf ( " %d", &n );
    if ( !( n ) ) break ;

    for ( i = 0; i < n * 2; ++i )
    {
      int h, m, s;

      scanf ( " %d:%d:%d", &h, &m, &s );
      ev[ i ] = ( ( h * 3600 + m * 60 + s ) << 1 ) + !( i % 2 );
    }

    qsort ( ev, n * 2, sizeof ( int ), compare );

    for ( i = 0; i < n * 2; ++i )
    {
      nanikaka += 2 * ( ev[ i ] & 1 ) - 1;
      res = MAX( res, nanikaka );
    }

    printf ( "%d\n", res );
  }

  return ( 0 );
}

Measured memory_bytes: 0