akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
	int main(){
		int a,b,c;
		int i,f=0;
		scanf("%d %d",&a,&b);
		if(b<=9)
			c=b+a*10;
		else if(b<=99)
			c=b+a*100;
		else
			c=b+a*1000;
		
		for(i=0;i<400;i++){
			if(c==i*i)
				f=1;}
		
			if(f==1)
				printf("Yes");
			else 
				printf("No");
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define f(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define name "main"
#define ll long long
#define maxn 405
#define oo 100000000000000

using namespace std;

int n,a[maxn];
ll res[maxn][maxn],b[maxn];
bool xd[maxn][maxn];

ll sol(int x,int y)
{
    if(x==y)
    {
        return 0;
    }
    if(xd[x][y]!=0)
    {
        return res[x][y];
    }
    xd[x][y]=1;
    res[x][y]=oo;
    f(i,x,y-1)
    {
        res[x][y]=min(res[x][y],sol(x,i)+sol(i+1,y)+b[y]-b[x-1]);
    }
    return res[x][y];
}

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

    cin>>n;
    f(i,1,n)
    {
        cin>>a[i];
        b[i]=b[i-1]+a[i];
    }
    cout<<sol(1,n);




}


Measured memory_bytes: 5128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, a, b, c, d; cin >> n >> a >> b >> c >> d; 
  string s; cin >> s;
  int mn = min(c,d)-1;
  int mx = max(c,d)-1;
  //? ~~ A   ? ~ B   ? ~ C,D ~ C,D ~~ ?
  //0 ~~ a-1 a ~ b-1 b ~ mn  ~ mx  ~~ length()-1
  //連続した##のとき除外
  for(int i=a; i<mx; i++){
    if(s[i]=='#' && s[i+1]=='#'){
      cout << "No" << endl;
      return 0;
    }
  }
  
  if(c<d){
    cout << "Yes" << endl;
    return 0;
  }else{//(c>d)
    //連続した...ならok
    for(int i=b-2; i<mn; i++){
      if(s[i]=='.' && s[i+1]=='.' && s[i+2]=='.'){
        cout << "Yes" << endl;
        return 0;
      }
    }
    cout << "No" << endl;
    return 0;
  }  
  return 0;
}


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

// Created by White Knife on 15/04/20.
// doot diddly donger cuckerino Hahahahahah

#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#pragma GCC target("popcnt")


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

// @formatter:off
#define F               first
#define S               second
#define all(x)          (x).begin(), (x).end()
#define sz(x)           int((x).size())
#define sim             template<typename T
#define ris             return *this
#define dor             > debug & operator <<
#define eni(x)          sim > typename enable_if<sizeof dud<T>(0) x 1, debug&>::type operator<<(T i)
sim> struct rge { T b, e; };
sim> rge<T> rang(T i, T j) { return rge<T>{i, j}; }
sim> auto dud(T *x) -> decltype(cerr << *x, 0);
sim> char dud(...);
struct debug {
#ifdef LOCAL
  ~debug() { cerr << endl; }
  eni(!=) { cerr << boolalpha << i; ris; }
  eni(==) { ris << rang(all(i)); }
  sim, typename U dor(pair<U, T> d) { ris << "(" << d.first << ", " << d.second << ")"; }
  sim dor(rge<T> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
  sim dor(const T&) { ris; }
#endif
};
#define pr(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ull = unsigned long long;
using ld = long double;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vb = vector<bool>;

using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
template <typename T> using ordered_set = tree<T, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;

const ld PI = acos(-1);

template<typename T> inline T mini(T& x, T y) { return x = min(x, y); }
template<typename T> inline T maxi(T& x, T y) { return x = max(x, y); }
template <typename T> T rand(T x, T y) { return rand() % (y - x + 1) + x; }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
// @formatter:on


class ATherefore {
public:

  void solveOne(istream& cin, ostream& cout) {

  }

  void solve(std::istream& cin, std::ostream& cout) {
      int n;
      cin >> n;
      n %= 10;
    if(n == 3){
        cout << "bon";
        return;
    }
    if(n == 0 || n == 1 || n == 6 || n == 8){
        cout << "pon";
        return;
    }
    cout << "hon";
  }
};

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
	ATherefore solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
int main()
{
    long long int a,b,c=0,o,e,d=1,i,t,j,n,y,k,m,l,r=0;
    scanf("%lld%lld%lld",&k,&a,&b);

    c=a/k;
    c++;
    if((c*k>=a&&c*k<=b)||a%k==0||b%k==0){printf("OK\n");}
    else{printf("NG\n");}


}


Measured memory_bytes: 1632
#include <iostream>
#include <bits/stdc++.h>
#include <stdio.h>
#define scan(n)      scanf("%I64d",&n);
#define scan2(a,b)   scanf("%I64d%I64d",&a,&b);
#define scan3(a,b,c) scanf("%I64d%I64d%I64d",&a,&b,&c);
#define sc(n)        scanf("%c",&n);
#define sf(n)        scanf("%lf",&n);
#define ss(n)        scanf("%s",n);
#define forall(i,a,b)for(long long int i=a;i<b;i++)
#define all(a)       a.begin(), a.end()
#define pb           push_back
#define mp           make_pair
#define FAST_IO      ios_base::sync_with_stdio(false); cin.tie(NULL);
#define minimum(a)   *min_element(a.begin(),a.end())
#define maximum(a)   *max_element(a.begin(), a.end())
#define display(a)   for(auto i : a) cout<<i<<" ";
typedef long long int ll;
typedef long double ld;
const int MOD = 1e9 + 7;
using namespace std;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
vector<ll> scanVector(ll n, vector<ll> &v)
{
  ll temp;
  for(ll i = 0; i < n ; i++)
  {
     cin>>temp;
     v.pb(temp);
  }
  return v;
}

int main() {
    FAST_IO
    ll t;
    //cin>>t;
    t = 1;
    while(t--)
    {
        ll l;
        cin>>l;
        long double l1 = ((long double)l/3);
        printf("%.6Lf\n",l1*l1*l1);
    }
    return 0;
}

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

using namespace std;

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

  while(N > 0) {
    if (N % 10 == 9) {
      cout << "Yes" << endl;
      return 0;
    }
    N /= 10;
  }
  cout << "No" << endl;
  return 0;
}

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

#define MAX_LEN (100000)

int main(int argc, char *argv[]) {
  // read inputs
  char s[MAX_LEN + 1];
  scanf("%s", s);
  const int len = strlen(s);

  // calculate whether s[i] and s[i - 1] are different
  int xs[MAX_LEN + 1];
  xs[0] = 0;    // doesn't really matter
  xs[len] = 0;  // doesn't really matter
  for (int i = 1; i < len; i++) {
    xs[i] = (s[i] != s[i - 1]);
  }
  // for (int i = 0; i <= len; i++) {
  //   printf("%d ", xs[i]);
  // }
  // printf("\n");

  // solve binary search
  int b = 1, e = len + 1;
  while (e - b > 1) {
    int m = (b + e) / 2;
    // it is possible if or xs[(N - K + 1):(K - 1)] == 0
    int is_possible = 1;
    for (int i = len - m + 1; i <= m - 1; i++) {
      if (xs[i]) {
        is_possible = 0;
        break;
      }
    }
    if (is_possible) {
      b = m;
    } else {
      e = m;
    }
  }
  printf("%d\n", b);

  return 0;
}


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

int main(){
  int N,M;cin >> N >> M;
    int Array[M]={};

    for(int i=0;i<N;i++){
        int K;cin >> K;
        for(int j=0;j<K;j++){
            int A;cin >> A;
            ++Array[--A];
        }
    }
    int count=0;
    for(int i=0;i<M;i++){
        if(Array[i]==N)count++;
    }
    cout << count << endl;
   return 0;
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N;
    ll ulim = sqrt(N)+1;
    map<ll, int> mp;
    vector<ll> prime(ulim+1, 0);
    for(ll i = 2; i <= ulim; i++){
        while(N%i == 0){
            N/=i;
            prime[i]++;
        }
        mp[i] = prime[i];
    }
    if(N > 1) mp[N] = 1;
    int ans = 0;
    vector<int> work(100, 1);
    for(int i = 2; i < 100; i++) work[i] = work[i-1] + i;
    for(auto op: mp){
        int val = op.second;
        int cnt = 0;
        int idx = 1;
        while(val >= work[idx]){
            idx++;
            cnt++;
        }
        ans += cnt;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 73396
//How much you wanna risk?
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")

const long long maxn = 1e6 + 5;
vector<long long> v, b, srt;
vector<pair<long long, long long> > part;
long long fen[maxn];
long long optimm = 0;
long long n;

void add(long long idx, long long val){
    for(; idx < maxn ; idx += idx & (-idx))//**
        fen[idx] += val;
}

long long get(long long idx){
    long long sum = 0;
    for(; idx; idx -= idx & (-idx) )
        sum += fen[idx];
    return sum;
}
/*
10
5 9 5 9 8 9 3 5 4 3
*/
long long inv_count(){
    memset(fen, 0, sizeof fen);
    long long inv = 0;
    for(auto c : part){
        inv += get(c.second);
        add(c.second, 1);
    }
    return inv;
}

long long get_inv(){
    part.clear();
    part.push_back({0, -1});
    for(long long i = 0; i < v.size(); i++)
        part.push_back({part[i].first + v[i],- i - 2});
    sort(part.begin(), part.end());
    for(long long i = 0; i < part.size(); i++){
        part[i] = {part[i].first, -part[i].second};
    }
    return inv_count();
}
bool check(long long a){
    v.clear();
    for(auto c: b){
        if(c < a)
            v.push_back(1);
        else
            v.push_back(-1);
    }
    long long tmp = get_inv();
    //cout << tmp << endl;
    return (tmp <= optimm);
}
void input(){
    cin >> n;
    optimm = (n + 1) * n / 4;
    for(long long i = 0; i < n; i++){
        long long t;
        cin >> t;
        b.push_back(t);
        srt.push_back(t);
    }
}
long long bns(){
    long long st = 0, en = n;
    sort(srt.begin(), srt.end());
    while(en - st > 1){
        long long mid = (st + en)>>1;
        //cout << srt[mid] << ' ';
        if(check(srt[mid]))
            st = mid;
        else
            en = mid;
    }
    return srt[st];
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    input();
    cout << bns();

}


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

// bool judge(int m, int n, int z) {
//     if(n==1) return m==z;
//     if(m<z) return false;
//     if(m%z!=0) return false;
//     else {
//         int zz= z;
//         while (m>zz) {
//             if(judge(m-zz, n-1,z)) return true;
//             zz+=z;
//         }
//     }
//     return false;
// }

int main(int argc, char const *argv[])
{
    int n, m; cin >> n >> m;
    int z = m/n;

    while(z>0) {
        // if(judge(m, n, z)) break;
        if(m%z==0 && m/z>=n) break;
        z-=1;
    }
    
    cout << z << endl;
    return 0;
}


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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int A[5];
    int tempo = 0;
    int contador = 0;
    cin >> A[0] >> A[1] >> A[2] >> A[3] >> A[4];

    for(int i = 0 ; i < 5 ; i++)
    {
        for (int j = i ; j < 5 ; j++)
        {
            int guarda;
            guarda = A[i];
            if(A[i] > A[j])
            {
                A[i] = A[j];
                A[j] = guarda;
            }
        }
    }
    for(int i = 0 ; i < 10 ; i++)
    {
        for(int j = 0 ; j<5 ; j++)
        {
            if( (A[j]+i) % 10 == 0)
            {
                if(contador == 4) break;
                A[j] = A[j] + i;
                contador ++;
            }
        }
    }
    for(int i = 0 ; i < 5 ; i++)
    {
        tempo += A[i];
    }
    cout << tempo << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
	string s;
	int n, x;
	while (cin >> s, s != "-") {
		cin >> n;
		for (int i = 0; i < n; i++) {
			cin >> x;
			s = s.substr(x) + s.substr(0, x);
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 1216
#include <stdio.h>
int main(void) {
int a, b, c, w;
scanf("%d", &a);
scanf("%d", &b);
scanf("%d", &c);
if( a > b ) {
w = a;
a = b;
b = w;
}
if( b > c ) {
w = b;
b = c;
c = w;
}
if( a > b ) {
w = a;
a = b;
b = w;
}
printf("%d %d %d\n", a, b, c);
return 0;
}

Measured memory_bytes: 1024
use proconio::{fastout, input};

use std::collections::HashMap;

fn pow(mut x: i64, mut n: i64, p: i64) -> i64 {
    let mut r = 1;
    while n > 0 {
        if n & 1 == 1 {
            r = r * x % p;
        }
        x = x * x % p;
        n >>= 1;
    }
    r
}

#[fastout]
fn main() {
    const M: i64 = 998244353;
    input! {
        a: i64, b: i64, c: i64, d: i64,
    }
    let mut h = vec![vec![None; d as usize + 1]; c as usize + 1];
    fn f(c: i64, d: i64, a: i64, b: i64, h: &mut Vec<Vec<Option<i64>>>) -> i64 {
        if let Some(v) = h[c as usize][d as usize] {
            return v;
        }
        let v = if c == a && d == b {
            1
        } else if c == a {
            f(c, d - 1, a, b, h) * c
        } else if d == b {
            f(c - 1, d, a, b, h) * d
        } else {
            f(c, d - 1, a, b, h) * c + f(c - 1, d, a, b, h) * d
                - f(c - 1, d - 1, a, b, h) * ((c - 1) * (d - 1))
        } % M;
        let v = (v + M) % M;
        h[c as usize][d as usize] = Some(v);
        v
    }
    let ans = f(c, d, a, b, &mut h);
    println!("{}", ans);
}


Measured memory_bytes: 143452
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    int d;
    cin >> d;
    const int n = 26;
    vector<int> c(n,0);
    rep(i,n)cin >> c[i];
    vector<vector<int>> s(365,vector<int>(n,0));
    rep(i,d)rep(j,n)cin >> s[i][j];
    vector<int> recent(n,0);

    rep(i,d)cout << i%26 + 1 << endl;
    return 0;
}


Measured memory_bytes: 3696
#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>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
const int MAX_C = 100010;
void MultipleGift() {
	ll x, y;
	cin >> x >> y;
	ll count = 1;
	ll b = x;
	while (b * 2 <= y)
	{
		count++;
		b *= 2;
	}
	cout << count << endl;

}
int main() {
	MultipleGift();
	return 0;
}

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

int main()
{
	int t;
	cin>>t;
	
	while(t--)
	{
		int n;
		cin>>n;
		
		int l[n],r[n],k[n];
		
		map<int,vector<int> > mp,mp1;
		
		long long ans=0;
		
		for(int i=0;i<n;i++)
		{
			cin>>k[i]>>l[i]>>r[i];	
			ans+=min(r[i],l[i]);

			if(l[i]>=r[i])
				mp[k[i]].push_back(i);
			else
				mp1[n-k[i]].push_back(i);
		}

		multiset<int> inserted;
		
		for(int j=1;j<=n;j++)
		{
			for(auto ele:mp[j])
			{
				inserted.insert(l[ele]-r[ele]);
				ans+=l[ele]-r[ele];
			}
			
			while(inserted.size()>j)
			{
				ans-=*inserted.begin();
				inserted.erase(inserted.begin());
			}
		}
		
		inserted.clear();
		
		for(int j=1;j<=n;j++)
		{
			for(auto ele:mp1[j])
			{
				inserted.insert(r[ele]-l[ele]);
				ans+=r[ele]-l[ele];
			}
			
			while(inserted.size()>j)
			{
				ans-=*inserted.begin();
				inserted.erase(inserted.begin());
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 46624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<"@"<<__LINE__<<": "<<x<<endl
using ll = long long;
using vi = vector<int>;
using pii = pair<int,int>;

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
	ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
	return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
	ull ans = 1;
	for (; e; b = mod_mul(b, b, mod), e /= 2)
		if (e & 1) ans = mod_mul(ans, b, mod);
	return ans;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll h, w, t;
    cin >> h >> w >> t;
    ll dh = __gcd(h,t), dw = __gcd(w,t);
    ll newh = h/dh, neww = w/dw;
    debug(dh);
    debug(dw);
    debug(newh);
    debug(neww);
    ll mod = 1e9+7;
    ll x = (mod_pow(2,newh,mod)+mod_pow(2,neww,mod)+mod-1)%mod;
    ll y = (mod_pow(2,__gcd(newh,neww),mod)+mod-2)%mod;
    x=(x+y)%mod;
    ll ans = mod_pow(x,dh*dw,mod);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
double dp[3002][3002];
int main(){
    memset(dp,0,sizeof(dp));
    int n;
    cin>>n;
    double a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<=i+1;j++){
            if(j==0)
                dp[i+1][j]=dp[i][j]*(1-a[i]);
            else{
                dp[i+1][j]=dp[i][j]*(1-a[i])+dp[i][j-1]*a[i];
            }
        }
    }
    double ans=0;
    for(int i=(n+1)/2;i<=n;i++){
        ans+=dp[n][i];
    }
    cout<<fixed<<setprecision(10)<<ans<<endl;
    return 0;
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for(auto& i : v) cin >> i;

    int cnt = 0;

    REP(i, n){
        if(v[i] != i + 1) cnt++;
    }

    cout << (cnt <= 2 ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int a;
    int b;
    cin >> a >> b;
    if(a < b){
        cout << "a < b" << endl;
    }
    else if(a > b){
        cout << "a > b" << endl;
    }
    else if(a == b){
        cout << "a == b" << endl;
    }
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int n,ans[maxn];
char ch[maxn];
bool check()
{
	if (!ans[n])
	{
		if (ch[n]=='o'&&ans[n-1]!=ans[1]) return 0;
		if (ch[n]=='x'&&ans[n-1]==ans[1]) return 0;
	}
	else
	{
		if (ch[n]=='x'&&ans[n-1]!=ans[1]) return 0;
		if (ch[n]=='o'&&ans[n-1]==ans[1]) return 0;
	}
	if (!ans[1])
	{
		if (ch[1]=='o'&&ans[n]!=ans[2]) return 0;
		if (ch[1]=='x'&&ans[n]==ans[2]) return 0;
	}
	else
	{
		if (ch[1]=='x'&&ans[n]!=ans[2]) return 0;
		if (ch[1]=='o'&&ans[n]==ans[2]) return 0;
	}
	return 1;
}
int main()
{
	scanf("%d%s",&n,ch+1);
	for (int S=0;S<4;S++)
	{
		ans[1]=S&1;
		ans[2]=(S>>1)&1;
		for (int i=3;i<=n;i++)
		    if (!ans[i-1])
		    {
		    	if (ch[i-1]=='o') ans[i]=ans[i-2];
		    	else ans[i]=ans[i-2]^1;
			}
			else
			{
				if (ch[i-1]=='x') ans[i]=ans[i-2];
		    	else ans[i]=ans[i-2]^1;
			}
		if (check())
		{
			for (int i=1;i<=n;i++)
			    if (!ans[i]) printf("S");
			    else printf("W");
			return 0;
		}
	}
	cout<<"-1";
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 1000000007;
void files(){
 freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);

}
void fast(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

}

int main(){
 fast();
 int n;
 cin>>n;
 ll ans=0;
 for(int i=1; i<=n; i++){
    if(n%i==0){
        ans=ans+(n/i)-1;
    }
    else{
        ans=ans+(n/i);
    }
 }
 cout<<ans;

    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
int test = 0;

struct seg_tree
{
    ll n;
    vector<ll>vec;

    seg_tree(ll nn):n(nn)
    {
        vec.resize(4*n+10,0);
        
    }

    void update(ll val,ll index,ll l,ll r,ll i)
    {
        
        if(l==r)
        {
            if(l==index) vec[i] = val;
            return;
        }

        ll mid = (l+r)/2;
        if(mid < index)
            update(val,index,mid+1,r,2*i+2);
        else
            update(val,index,l,mid,2*i+1);

        vec[i] = max(vec[2*i+1],vec[2*i+2]);
    }

    ll query(int i,int l,int r,int tar1,int tar2)
    {
        
        

        if(l>r) return 0;
        

        if(r < tar1 || l>tar2) return 0;

        if(l>=tar1 && r<=tar2) 
            {
                if(test) cout<<l<<" "<<r<<" "<<tar1<<" "<<tar2<<endl;
                return vec[i];
            }

        ll mid = (l+r)/2;

        return max(query(2*i+1,l,mid,tar1,tar2),query(2*i+2,mid+1,r,tar1,tar2));
    }
};
int main()
{
    int n;
    cin>>n;
    ll height[n];
    ll beauty[n];

    for(ll i=0;i<n;i++) cin>>height[i];
    for(ll j=0;j<n;j++) cin>>beauty[j];

    seg_tree seg(n+1);
    ll ans = 0;

    for(ll i=0;i<n;i++)
    {
        ll p = seg.query(0,0,n,0,height[i]);
        ans = max(ans,beauty[i]+p);
        seg.update(p+beauty[i],height[i],0,n,0);
        if(test) cout<<i<<"   "<<height[i]<<"   "<<p<<endl;
    }

    cout<<ans<<endl;
}



Measured memory_bytes: 9600
using System;
using System.Collections.Generic;
using System.Linq;

class D
{
	static void Main()
	{
		Console.ReadLine();
		var s = Console.ReadLine();
		var d = new int[10].Select(_ => new List<int>()).ToArray();
		for (int i = 0; i < s.Length; i++) d[s[i] - '0'].Add(i);

		var q = from i1 in d.Where(g => g.Any()).Select(g => g[0])
			from i2 in d.Select(g => Find(g, i1 + 1)).Where(x => x > 0)
			select d.Where(g => g.Any()).Count(g => g.Last() > i2);
		Console.WriteLine(q.Sum());
	}

	static int Find(List<int> l, int v)
	{
		var i = l.BinarySearch(v);
		if (i < 0) i = ~i;
		return i < l.Count ? l[i] : 0;
	}
}


Measured memory_bytes: 13920
#include <bits//stdc++.h>
using namespace std;
int main(void){
    long long a,b,c,i,j,ans,frag,s,t;
    cin>>a>>b;
    s=a;
    t=b;
    ans=0;
    while(1){
        c=s%t;
        if(c==0)
        break;
        s=t;
        t=c;
    }
    for(i=0;i<t;i++){
        if((i+1)*(i+1)>t){
            s=i+1;
            break;
        }
        
    }
    for(i=1;i<s;i++){
        if(t%(i+1)==0){
            ans++;
        while(1){
            t=t/(i+1);
            if(t%(i+1))
            break;
        }
        }
    }
    if(t!=1)
    ans++;
    ans++;
    cout<<ans<<endl;
}


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

int main()
{
	//コンテスト	

	int W[10], K[10];
	for (int i = 0; i < 10; i++) {
		cin >> W[i];
	}
	for (int i = 0; i < 10; i++) {
		cin >> K[i];
	}
	sort(W, W + 10);
	reverse(W, W + 10);
	sort(K, K + 10);
	reverse(K, K + 10);
	cout << W[0] + W[1] + W[2] << " " << K[0] + K[1] + K[2] << endl;

	//ポイントカード
	/*
	int N, M;
	cin >> N >> M;
	int a;
	int A[5000];
	int b = 0;
	int x = 0;
	for (int i = 0; i <  M; i++) {
		cin >> a;
		if (a < N) {
			A[x]=a;
			x++;
		}
		else
		{
			b++;
		} 
		cin >> a;
	}
	int sum = 0;
	if (b < M - 1) {
		sort(A, A+x);
		reverse(A, A+x);
		for (int i = 0; i < M - 1 - b; i++) {
			sum += N - A[i];
		}
	}
	cout << sum << endl;
	*/

	//合計時間
	/*
	int sum=0, n;
	for (int i = 0; i < 4; i++) {
	cin >> n;
	sum += n;
	}
	cout << sum / 60 << endl;
	cout << sum % 60 << endl;
	//平均点
	/*
	int P[5];
	int sum=0;
	for (int i = 0; i < 5; i++) {
	cin >> P[i];
	if (P[i] < 40) P[i] = 40;
	sum += P[i];
	}
	cout << sum / 5 << endl;
	*/
	//投票
	/*
	int N, M;
	cin >> N >> M;
	int A[1000], vote[1000];
	for (int i = 0; i < N; i++) {
	cin >> A[i];
	vote[i] = 0;
	}
	int b;
	for (int i = 0; i < M; i++) {
	cin >> b;
	for (int j = 0; j < N; j++) {
	if (A[j] <= b) {
	vote[j]++;
	break;
	}
	}
	}
	int temps = 0, ans;
	for (int i = 0; i < N; i++) {
	if (vote[i] > temps) {
	temps = vote[i];
	ans = i;
	}
	}
	cout << ans + 1 << endl;
	*/

	//2.すごろく	
	/*
	int n;
	cin >> n;
	int A, _A = 1;
	int k = 0;
	int A_count[100];
	A_count[0] = 1;
	for (int i = 0; i < n; i++)
	{
	cin >> A;
	if (A == 1)
	{
	if (A == _A)
	{
	A_count[k]++;
	}
	else
	{
	k++;
	A_count[k] = 2;
	}
	}
	_A = A;
	}
	sort(A_count, A_count + k + 1);
	cout << A_count[k] << endl;
	*/

	//タイムカード
	/*
	int t[2][3];
	int x[3][3];
	for (int n=0; n < 3; n++)
	{
	for (int i=0; i < 2; i++)
	for (int k=0; k < 3; k++)
	cin >> t[i][k];

	for (int m = 2; m >= 0; m--)
	{
	x[n][m] = t[1][m] - t[0][m];
	if (t[0][m] > t[1][m])
	{
	x[n][m] += 60;
	t[1][m - 1]--;
	}
	}
	}
	for (int n= 0; n < 3; n++)
	{
	cout << x[n][0] << ' ' << x[n][1] <<' '<< x[n][2] << endl;
	}
	*/



	return 0;
}


Measured memory_bytes: 3076
using System;

namespace AOJ.Volume2
{
    public class TimeToStudy
    {
        public static int Main()
        {
            while (true)
            {
                int goal = int.Parse(Console.ReadLine());
                if (goal == 0) { break; }

                int n = int.Parse(Console.ReadLine());
                int summary = 0;
                for(int i = 0; i < n; i++)
                {
                    var input = Console.ReadLine().Split(' ');
                    int start = int.Parse(input[0]);
                    int end = int.Parse(input[1]);
                    summary += end - start;
                }

                Console.WriteLine(goal - summary <= 0 ? "OK" : (goal - summary).ToString());
            }
            return 0;
        }
    }
}

Measured memory_bytes: 9200
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;
    int arr[n];
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    sort(arr, arr+n);
    
    int l, r;
    long long min = 1145141919810;
    for (int i = 0; i < n-1; i++) {
        long long s = arr[i];
        //float fmid = arr[n-1] / 2.0;
        long long mid = arr[n-1] / 2;
        if (arr[n-1] % 2 == 0) {
            if (abs(mid - s) <= min) {
                l = arr[n-1];
                r = arr[i];
                min = abs(mid - s);
            }
        }
        else {
            if (abs(mid - s) <= min && s < mid) {
                l = arr[n-1];
                r = arr[i];
                min = abs(mid - s);
            }
            else if (abs(mid - s + 1) <= min && s > mid) {
                l = arr[n-1];
                r = arr[i];
                min = abs(mid - s + 1);
            }
        }
    }
    cout << l << " " << r << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int dist[200][200];
int check(vector<int> used,int r,int now,int cost,vector<int>& rr){
    int mn=99999999;
    bool f=false;
    for(int i=0;i<r;i++){
        if(used[i]==0){
            f=true;
            vector<int> u(r);
            for(int j=0;j<r;j++){
                u[j]=used[j];
            }
            u[i]=1;
            mn=min(check(u,r,rr[i],cost+dist[now][rr[i]],rr),mn);
        }
    }
    if(!f) return cost;
    return mn;
}

int main(){
    const int inf=99999999;
    int i,j,k,a,b,t;
    int n,m,r;
    cin>>n>>m>>r;
    vector<int> rr(r);
    int mn=99999999;
    for(i=0;i<r;i++){
        cin>>rr[i];
        rr[i]--;
    }
    for(i=0;i<200;i++){
        for(j=0;j<200;j++){
            dist[i][j]=inf;
            if(i==j) dist[i][j]=0;
        }
    }
    for(i=0;i<m;i++){
        cin>>a>>b>>t;
        dist[a-1][b-1]=t;
        dist[b-1][a-1]=t;
    }

    for(k=0;k<n;k++){
        for(i=0;i<n;i++){
            for(j=0;j<n;j++){
                if(dist[i][j]>dist[i][k]+dist[k][j]) dist[i][j]=dist[i][k]+dist[k][j];
            }
        }
    }
    
    for(i=0;i<r;i++){
        vector<int> v(r,0);
        v[i]=1;
        mn=min(mn,check(v,r,rr[i],0,rr));
    }
    cout<<mn<<endl;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

bool check(int a, int b, int c) {
  return (a < (b + c)) && (b < (c + a)) && (c < (a + b));
}

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  REP(i, n) cin >> l[i];
  sort(ALL(l));
  int ans = 0;
  for (int i = n - 1; i >= 0; --i) {
    for (int j = i - 1; j >= 0; --j) {
      int ok = j, ng = -1;
      while (1 < abs(ok - ng)) {
        int mid = (ok + ng) / 2;
        (check(l[i], l[j], l[mid]) ? ok : ng) = mid;
      }
      ans += j - ok;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
int cnt[26];
int main()
{
    int n;
    string s;
    cin >> n >> s;
    for (int i = 0; i < n; ++i)
        cnt[s[i] - 'a']++;
    long long ans = 1;
    for (int i = 0; i < 26; ++i)
        ans = ans * (cnt[i] + 1) % M;
    cout << (ans+M-1)%M << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dp[1<<16][16];//dp[i][j]=すでに訪れた頂点の集合をi現在jにいる状態から残りのすべての頂点をめぐって頂点０に帰るようなパスの重みの総和の最小値
int d[16][16];
const int INF=100000000;

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

	int n,m;cin>>n>>m;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++)d[i][j]=INF;
	}
	for(int i=0;i<m;i++){
		int a,b,c;cin>>a>>b>>c;
		d[a][b]=c;
	}


	for(int i=0;i<(1<<n);i++){
		fill(dp[i],dp[i]+n,INF);
	}
	dp[(1<<n)-1][0]=0;

	for(int S=(1<<n)-2;S>=0;S--){
		for(int v=0;v<n;v++){
			for(int u=0;u<n;u++){
				if(!(S>>u&1)){
					dp[S][v]=min(dp[S][v],dp[S|1<<u][u]+d[v][u]);
				}
			}
		}
	}
	if(dp[0][0]>=INF)cout<<-1<<endl;
	else cout<<dp[0][0]<<endl;
	
}



Measured memory_bytes: 5136
using System;
using System.Collections.Generic;
using System.Linq;
namespace B_Balance
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var n = int.Parse (input[0]);
            var x = int.Parse (input[1]);
            var d = new List<int> {0};
            var l = new List<int> ();
            input = Console.ReadLine ().Split (' ');
            for (var i = 0; i < n; i++)
            {
                l.Add (int.Parse (input[i]));
            }
            for (var i = 1; i <= n; i++)
            {
                d.Add (d[i - 1] + l[i - 1]);
            }
            var quary = d.Where (z => z <= x)
                .ToList ();
            Console.WriteLine (quary.Count);
        }
    }
}

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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    string s; cin >> s;
    int res = 0;
    int l = (int)s.size();
    REP(i, l/2){
        if (s[i] != s[l-i-1]) res++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())

parent=[i for i in range(n)]
rank=[0 for i in range(n)]

def find(a):
  if parent[a]==a:
    return a
  else:
    return find(parent[a])

def union(a,b):
  ar=find(a)
  br=find(b)
  if ar==br:
    return
  if rank[a]>rank[b]:
    parent[br]=ar
  else:
    parent[ar]=br
    if rank[a]==rank[b]:
      rank[a]+=1
      
def same(a,b):
  ar=find(a)
  br=find(b)
  return ar==br

q=[None]*m

for i in range(m):
  x,y,z=map(int,input().split())
  q[i]=[x-1,y-1]

for i in range(len(q)):
  union(q[i][0],q[i][1])
  
roots=[0]*len(parent)
for i in range(len(parent)):
  roots[i]=find(i)

print(len(set(roots)))


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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int N,X;
    cin >> N >> X;
    vector<int> m(N);
    int sum = 0;
    for (int i = 0; i < N; i++){
        cin >> m[i];
        sum += m[i];
    }
    X -= sum;
    int minm = *min_element(all(m));
    cout << N + X/minm << endl;




    return 0;
}


Measured memory_bytes: 888
#include<stdio.h>
#include<string.h>
#define Q 150
#define L 1001

int c[L][L];

int LCS(char *x,char *y){
  int m,n,i,j;

  m=strlen(x+1);
  n=strlen(y+1);

  for(i=1;i<=m;i++) c[i][0]=0;

  for(j=0;j<=n;j++) c[0][j]=0;

  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(x[i]==y[j]) c[i][j] = c[i-1][j-1] + 1;
      else if(c[i-1][j]>=c[i][j-1]) c[i][j] = c[i-1][j];
      else c[i][j]=c[i][j-1];
    }
  }
  
/*
  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      printf("c[%d][%d]=%d <%c,%c>\t",i,j,c[i][j],x[i],y[j]);
    }
    printf("\n");
    }
*/

  return c[m][n];
}

int main(){

  int i,j,k,n;
  char x[L],y[L];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",x);
    scanf("%s",y);
    printf("%d\n",LCS(x-1,y-1));
  }

  return 0;
}




Measured memory_bytes: 5640
main :: IO ()
main = do
  [a, b, c, x, y] <- map read . words <$> getLine
  print . minimum $ if x > y
                    then [a*x + b*y, 2*c*y + (x-y)*a, 2*c*x]
                    else [a*x + b*y, 2*c*x + (y-x)*b, 2*c*y]

Measured memory_bytes: 508
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
#define rreps(i, n) for(int i=((int)(n)); i>0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define reps2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9e18
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll SearchChar(ll &cnt, char str[], vector<int> idarr_1, vector<int> idarr_2, vector<int> idarr_3, int n, char third) {
  for (const int i1 : idarr_1) {
    for (auto itr2 = lower_bound(all(idarr_2), i1 + 1); itr2 != idarr_2.end(); itr2++) {
      auto itr3 = lower_bound(all(idarr_3), *itr2 + 1);
      if (itr3 != idarr_3.end()){
        cnt += idarr_3.size() - distance(idarr_3.begin(), itr3);
        int ng3 = *itr2 - i1;
        if (*itr2 + ng3 <= n - 1 && str[*itr2 + ng3] == third) {
            cnt--;
        }
      }
    }
  }
  return cnt;
}

int main(){
    int n;
    char str[4000+2];
    vector<int> r_id;
    vector<int> g_id;
    vector<int> b_id;
    cin >> n;
    cin >> str;
    rep(i, n){
        switch (str[i])
        {
        case 'R':
            r_id.push_back(i);
            break;
        case 'G':
            g_id.push_back(i);
            break;
        case 'B':
            b_id.push_back(i);
            break;
        default:
            break;
        }
    }
    ll cnt = 0;
    SearchChar(cnt, str, r_id, g_id, b_id, n, 'B');
    SearchChar(cnt, str, r_id, b_id, g_id, n, 'G');
    SearchChar(cnt, str, g_id, r_id, b_id, n, 'B');
    SearchChar(cnt, str, g_id, b_id, r_id, n, 'R');
    SearchChar(cnt, str, b_id, g_id, r_id, n, 'R');
    SearchChar(cnt, str, b_id, r_id, g_id, n, 'G');

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

Measured memory_bytes: 3672
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar_unlocked(); while(c==' '||c=='\n') c=getchar_unlocked(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar_unlocked(); } *s='\0'; return len; }

char s[11];
int main(void){
	int n=nextint();
	int a=0, b=0, c=0, d=0;
	for(int i=0; i<n; i++){
		int l=nextstr(s);
		a+=(s[0]=='B');
		b+=(s[l-1]=='A');
		d+=(s[0]=='B'&&s[l-1]=='A');
		for(int j=0; j<l-1; j++){
			if(s[j]=='A' && s[j+1]=='B') c++;
		}
	}
	int ans=c;
	if(a>b){
		ans+=b;
	}else if(a<b){
		ans+=a;
	}else{
		if(a>0){
			ans+=a-(a==d);
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n; cin >> n;
  vector<ll> a(n+1);
  for(ll& i: a) cin >> i;
  ll S = 0;
  for(int i = n; i >= 0; i--){
    S += a[i];
  }

  ll t = 0, p = 1;

  for(int i = 0; i <= n; i++){
    t += p;
    if(p < a[i]){
      cout << -1 << endl;
      return 0;
    }
    S -= a[i];
    p = min((p - a[i]) * 2, S);
  }

  cout << t << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


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

int main(){
    string s, ans = "";
    cin >> s;
    int w;
    cin >> w;
    for (int i = 0; i < s.size(); i += w){
        ans += s[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
x, y = [int(i) for i in input().split()]

A = (1, 3, 5, 7, 8, 10, 12)
B = (4, 6, 9, 11)

if x in A and y in A:
    print("Yes")
elif x in B and y in B:
    print("Yes")
else:
    print("No")  

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<tuple>
using namespace std;
tuple<int,int,char,long long,string>a[1<<17];
main()
{
    int n;cin>>n;
    for(int i=0;i<n;i++)
    {
        int A,b;char c;long long d;string e;
        cin>>A>>b>>c>>d>>e;
        a[i]=make_tuple(A,b,c,d,e);
    }
    sort(a,a+n);
    for(int i=0;i<n;i++)
    {
        cout<<get<0>(a[i])<<" "<<get<1>(a[i])<<" "<<get<2>(a[i])<<" "<<get<3>(a[i])<<" "<<get<4>(a[i])<<endl;
    }
}



Measured memory_bytes: 13412
#include<cstdio>

int main() {
	char s[27];
	bool appear[26];
	for(int i=0;i<26;i++) appear[i] = false;
	scanf("%26s", s);
	for(int i=0;s[i]!='\0';i++) appear[s[i]-'a'] = true;
	char c = '\0';
	for(int i=0;i<26;i++) if(!appear[i]) {
		c = 'a' + i;
		break;
	}
	if(c != '\0') {
		printf("%s%c\n", s, c);
	} else { // strlen(s) == 26
		int i;
		for(i=25;i>=0;i--) {
			char m = 0x7f;
			for(int j=i+1;j<26;j++) if(s[i] < s[j] && s[j] < m) m = s[j];
			if(m != 0x7f) {
				s[i] = m;
				s[i+1] = '\0';
				break;
			}
		}
		if(i < 0) printf("-1\n");
		else printf("%s\n", s);
	}
	return 0;
}


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

#define ll long long
#define ln "\n"
#define fastio ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define mod 1e9 + 7
#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;

int main()
{
    fastio;

    int t;
    cin >> t;

    cout << (!t) << ln;

}


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

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

int main() {
    int h,n;
    cin >> h >> n;
    int A = 0;
    rep(i,n){
        int a; cin >> a;
        A += a;
    }
    if(A >= h) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int n, k, i, j, p;
double q=0;
int main(){
    scanf("%d %d", &n, &k);
    for(i=1; i<=n; i++){
        for(j=0; ; j++){
            if(k<=(i<<j)){
                p=j;
                break;
            }
        }
        q+=(double)(1./(n*(2<<(p-1))));
    }
    printf("%.12f", q);
}

Measured memory_bytes: 128
#include <stdio.h>

#define M 500010
int heap[M];
int heapsize;

int parent(int);
int left(int);
int right(int);
void maxheap(int);
void bmaxheap(void);

int main(int argc,char *argv[]){
  int i,n;
  scanf("%d",&n);
  heapsize=n;
  for(i=1;i<=n;i++){
    scanf("%d",&heap[i]);
  }
 
  bmaxheap();
 
  for(i=1;i<=n;i++){
    printf(" %d",heap[i]);
  }
  printf("\n");
  return 0;
}

int parent(int i){
  return i/2;
}
 
int left(int i){
  return 2*i;
}

 
int right(int i){
  return 2*i+1;
}

void maxheap(int i){
  int l,r,largest,tmp;
  l=left(i);
  r=right(i);
  if(l<=heapsize && heap[l]>heap[i]) largest=l;
  else largest=i;
 
  if(r<=heapsize && heap[r]>heap[largest])  largest=r;
   
  if(largest!=i){
    tmp=heap[i];
    heap[i]=heap[largest];
    heap[largest]=tmp;
    maxheap(largest);
  }
}
 
void bmaxheap(void){
  int i;
  for(i=heapsize/2;i>0;i--){
    maxheap(i);
  }
}



Measured memory_bytes: 3688
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

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

    std::vector<int> A(N);
    for (int i = 0; i < N; i++) {
        std::cin >> A[i];
    }

    std::vector<int> diff(N);
    for (int i = 0; i < N - 1; i++) {
        diff[i] = A[i+1] - A[i];
    }
    diff[N-1] = (K + A[0]) - A[N-1];

    std::sort(diff.begin(), diff.end(), std::greater<int>());

    int ans = std::accumulate(diff.begin() + 1, diff.end(), 0);
    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 4760
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] p = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }
        int key = 0;
        int value = 0;
        for (int i = 0; i < n; i++) {
            if (p[i] == i + 1) {
                continue;
            }
            if (key == 0) {
                key = i + 1;
                value = p[i];
                continue;
            }
            if (key != p[i] || value != i + 1) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }

}



Measured memory_bytes: 21716
#include <cstdio>
#include <deque>
#include <iostream>
using namespace std;

int n;

signed main(void)
{
    cin >> n;
    int a;
    deque <int> b;
   for(int i=0; i<n; ++i)
    {
        cin >> a;
        int it= lower_bound(b.begin(),b.end(),a)-b.begin();
        if(!it) b.push_front(a);
        else b[it-1]=a;
    }
    cout << b.size() << "\n";
 
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif
int read_int(){int c,r;while((c=getchar())<48);r=c-48;while((c=getchar())>47)r=r*10+c-48;return r;}
void write_int(int x){int b[10],*p=b;do*p++=48+x%10,x/=10;while(x);do putchar(*--p);while(p>b);}

struct AdditiveGroup {
  using T = int;
  static T op(const T& lhs, const T& rhs) { return lhs + rhs; }
  static constexpr T e() { return 0; }
  static T inv(const T& val) { return -val; }
};

template<class AbelianGroup> struct UnionFind {
  using T = typename AbelianGroup::T;

  V<> dat;
  V<T> pot;

  UnionFind(int n) : dat(n, -1), pot(n, AbelianGroup::e()) {}

  T sub(const T& lhs, const T& rhs) { return AbelianGroup::op(lhs, AbelianGroup::inv(rhs)); }

  T diff(int u, int v) {
    assert(same(u, v));
    return sub(pot[v], pot[u]);
  }

  int find(int v) {
    if (dat[v] < 0) return v;
    else {
      int r = find(dat[v]);
      pot[v] = AbelianGroup::op(pot[v], pot[dat[v]]);
      return dat[v] = r;
    }
  }

  bool same(int u, int v) { return find(u) == find(v); }

  int size(int v) { return -dat[find(v)]; }

  void unite(int u, int v, T d) {
    assert(!same(u, v));
    d = sub(d, sub(pot[v], pot[u]));
    if (dat[u] >= 0) u = dat[u];
    if (dat[v] >= 0) v = dat[v];
    if (-dat[u] < -dat[v]) {
      dat[v] += dat[u];
      dat[u] = v;
      pot[u] = AbelianGroup::inv(d);
    } else {
      dat[u] += dat[v];
      dat[v] = u;
      pot[v] = d;
    }
  }
};

int main() {
  while (true) {
    int n = read_int(), m = read_int();
    if (!n) break;
    UnionFind<AdditiveGroup> uf(n);
    for (int i = 0; i < m; ++i) {
      char c = getchar();
      if (c == '!') {
        int u = read_int(), v = read_int(), d = read_int(); --u, --v;
        if (!uf.same(u, v)) uf.unite(u, v, d);
      } else {
        int u = read_int(), v = read_int(); --u, --v;
        if (uf.same(u, v)) {
          printf("%d\n", uf.diff(u, v));
        } else printf("UNKNOWN\n");
      }
    }
  }
}


Measured memory_bytes: 3596
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
 
class Program
{
    static void Main()
    {
        int[][] groups = new int[3][];
        groups[0] = new int[]{1, 3, 5, 7, 8, 10, 12};
        groups[1] = new int[]{4, 6, 9, 11};
        groups[2] = new int[]{2};
        string[] inputs = Console.ReadLine().Split(' ');
        int x = int.Parse(inputs[0]);
        int y = int.Parse(inputs[1]);
        bool isSameGroup = false;
        for (int i = 0; i < groups.Length; i++)
        {
            if (groups[i].Contains(x) && groups[i].Contains(y))
            {
                isSameGroup = true;
                break;
            }
        }
        Console.WriteLine(isSameGroup ? "Yes" : "No");
    }
}


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

int main(){
    int H, W, h, w;
    scanf("%d%d", &H, &W);
    scanf("%d%d", &h, &w);
    printf("%d\n", max(0, H * W - (h * W + w * H - h * w)));

    return 0;
}


Measured memory_bytes: 256