akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

int main(){
    int N; cin>>N;
    int A,B,C,D; cin>>A>>B>>C>>D;
    char S[200001];
    scanf("%s",S);
    int iwa=0;
    int aki=0;
    int i;

    for(i=0;i<N;i++){
        if(S[i]=='#'){
            iwa++;
            aki=0;
        }
        if(S[i]=='.'){
            iwa=0;
            aki++;
        }
        if(iwa>=2){
            if((i<A-1 && i<B-1)||(i>C-1 && i>D-1)) continue;
            else{
                printf("No");
                i=200002;
                break;
            }
        }
        if(C>D && aki>=3){//追い越す
          	if(i-1<B-1){
               continue;
            }else if(i-1<=D-1){
                printf("Yes");
                i=200002;
                break;
            }else{
                printf("No");
                i=200002;
                break;
            }
        }
    }
    if(i==N){
        if(C>D) printf("No");
        else printf("Yes");
    }
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll h,w;
int main()
{
	scanf("%lld%lld",&h,&w);
    if (h==1||w==1) printf("1\n");
    else printf("%lld\n",(h*w+1)/2);
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
    int n;
    cin>>n;
    int buka[300000];
    rep(i,n-1){
        int a;
        cin>>a;
        buka[a-1]++;
    }
    rep(i,n) cout<<buka[i]<<endl;
    return 0;
}

Measured memory_bytes: 4312
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

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


ll lcm(ll x, ll y){
  return x/gcd(x,y)*y;
}

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

	ll ans = 1;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		ans = lcm(ans,x);
	}
	cout<<ans;
}

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

int main() {
    int a, b, c;  cin >> a >> b >> c;
    int ans = max({a, b, c}) - min({a, b, c});
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main(){
	int a,b;cin>>a>>b;
	puts(a*b%2?"Yes":"No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define Mod 998244353
#define Maxn 200010

long long n, m, k, fac[Maxn], inv[Maxn];

long long Pow(long long y, long long x)
{
    long long tmp=1;
    for (; x; x>>=1)
    {
        if (x & 1) tmp = (tmp * y) % Mod;
        y = (y * y) % Mod;
    }
    return tmp;
}

long long C(long long x, long long y){
    if (x<y) return 0;
    if (x<Mod && y<Mod) return fac[x] * inv[y] % Mod * inv[x - y] % Mod;
    return C(x / Mod, y / Mod) * C(x % Mod, y % Mod) % Mod;
}

int main()
{
	scanf("%lld%lld%lld", &n, &m, &k);
	fac[0]=1; for(int i=1; i<=n && i<Mod; i++) fac[i]=fac[i-1]*i%Mod;
    inv[1]=1; for(int i=2; i<=n && i<Mod; i++) inv[i]=(Mod-Mod/i)*inv[Mod%i]%Mod;
    inv[0]=1; for(int i=1; i<=n && i<Mod; i++) inv[i]=inv[i]*inv[i-1]%Mod;
    
	long long Res = 0ll;
	for (long long k0=0; k0<=k; k0++)
		Res = (Res + ((C(n - 1, k0) * m) % Mod * Pow(m - 1, n - 1 - k0)) % Mod) % Mod;
	
	printf("%lld\n", Res);
}

Measured memory_bytes: 6844
#ifdef _DEBUG
#include ".vscode/debug_print.hpp"
#else
#define debug(...)
#endif
#include <bits/stdc++.h>

using ll = long long;
using ld = long double;
using namespace std;
constexpr int INF32       = 1050000000;
constexpr long long INF64 = 4000000000000000000;
constexpr int MOD7        = 1000000007;
constexpr int MOD53       = 998244353;
constexpr long double PI  = 3.14159265358979323846;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
void scan() {}
template <class H, class... T> void scan(H &&head, T &&... args) {
    std::cin >> head;
    scan(std::forward<T>(args)...);
}
template <class T> void scan(std::vector<T> &v) {
    for (auto &&i : v) {
        scan(i);
    }
}

void vprint() { std::cout << '\n'; }
template <class H, class... T> void vprint(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << '\n';
    vprint(std::forward<T>(args)...);
}
template <class T> void vprint(std::vector<T> &v) {
    for (auto &&i : v) {
        std::cout << i << '\n';
    }
}

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

    int N;
    scan(N);
    ll ans = 0;
    for (size_t i = 0; i <= N; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            ans += i;
        }
    }
    print(ans);

    return 0;
}

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

struct _dice {
    int num[7];
    void roll(char x);
};

void _dice::roll(char o){
    int tmp;
    if (o == 'W'){
        tmp = num[4];
        num[4] = num[1];
        num[1] = num[3];
        num[3] = num[6];
        num[6] = tmp;
    }
    if (o == 'N'){
        tmp = num[1];
        num[1] = num[2];
        num[2] = num[6];
        num[6] = num[5];
        num[5] = tmp;
    }
}

bool check(_dice dice1, _dice dice2){
    int flag = 0;
    for (int i=1; i<7; i++)
        if (dice1.num[i] == dice2.num[i])
            flag++;
    if (flag == 6)
        return true;
    else
        return false;
}

int main(){
    int n;
    cin >> n;
    _dice dice[n];
    for (int i=0; i<n; i++)
        for (int j=1; j<7; j++) cin >> dice[i].num[j];
        
    for (int first=0; first<n-1; first++){
        for (int second=first+1; second<n; second++){
           for (int i=0; i<6; i++){
                for (int j=0; j<4; j++){
                    dice[second].roll('N');
                    if (check(dice[first], dice[second])){
                        cout << "No" << endl;
                        return 0;
                    }
                }
                dice[second].roll('W');
                dice[second].roll('W');
                if (i == 1) dice[second].roll('W');
                if (i == 3){
                    dice[second].roll('N');
                    dice[second].roll('W');
                }
            } 
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3124
package main
import (
  "container/list"
  "fmt"
  "os"
)
func main() {
  var n,k,r,m,t int
  var s string
  var a []int
  fmt.Scan(&n,&k)
  fmt.Scan(&s)
  a = make([]int,n)
  r = 1
  if s[0:1] == "0" { r = -1 }
  a[0] = r
  p2n := list.New()
  n2p := list.New()
  for i:=1;i<n;i++ {
    if s[i:i+1] == s[i-1:i] {
      a[i] = a[i-1] + r
    } else {
      if r > 0 {
        p2n.PushBack(i-1)
      } else {
        n2p.PushBack(i-1)
      }
      r = -r
      a[i] = r
    }
  }
  if a[n-1] > 0 {
    p2n.PushBack(n-1)
  } else {
    n2p.PushBack(n-1)
  }
  if p2n.Len() == 0 || n2p.Len() == 0 {
    fmt.Println(abs(a[n-1]))
    os.Exit(0)
  }
  used_p2n := list.New()
  used_n2p := list.New()
  t = 0
  var fneg = false
  if a[0] < 0 {
    j,_ := n2p.Remove(n2p.Front()).(int)
    t -= a[j]
    k--
    used_n2p.PushBack(j)
    fneg = true
  }
  j,_ := p2n.Remove(p2n.Front()).(int)
  t += a[j]
  used_p2n.PushBack(j)
  for c:=0;c<k;c++ {
    if n2p.Len() == 0 { break }
    y,_ := n2p.Remove(n2p.Front()).(int)
    t -= a[y]
    used_n2p.PushBack(y)
    if p2n.Len() == 0 { break }
    x,_ := p2n.Remove(p2n.Front()).(int)
    t += a[x]
    used_p2n.PushBack(x)
  }
  m = t
  for {
    if n2p.Len() == 0 { break }
    y,_ := n2p.Remove(n2p.Front()).(int)
    t -= a[y]
    used_n2p.PushBack(y)
    q,_ := used_n2p.Remove(used_n2p.Front()).(int)
    t += a[q]
    if !fneg {
      p,_ := used_p2n.Remove(used_p2n.Front()).(int)
      t -= a[p]
    }
    fneg = false
    if m < t { m = t }
    if p2n.Len() == 0 { break }
    x,_ := p2n.Remove(p2n.Front()).(int)
    t += a[x]
    used_p2n.PushBack(x)
    if m < t { m = t }
  }
  fmt.Println(m)
}
func abs(n int) int {
  if n < 0 { return -n }
  return n
}

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

using namespace std;

int main() {
  int H, W;
  for (;;) {
    cin >> H >> W;
    if (!H && !W)
      break;

    for (int i = 0; i < H; ++i) {
      const bool is_boundary = i == 0 || i == H - 1;                                                                                                                      
      for (int j = 0; j < W; ++j) {
        if (!is_boundary && j > 0 && j < W - 1)                                                                                                                           
          printf(".");
        else
          printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 3008
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int num;
  cin >> num;
  int third, second, first;
  third = num / 100;
  
  num = num - 100*third;
  second = num / 10;
    
  num = num - 10*second;
  first = num / 1;
  
  cout << first+second+third << endl;
}

Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q, p, kake;
U_MAP mp;

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

  cin >> s;
  kake = 1;
  n = Size(s);
  p = 2019;
  rrrep(i, n - 1, 0) {
    tmp += (s[i] - '0') * kake;
    kake *= 10;
    kake %= p;
    tmp %= p;
    if (tmp != 0) {
      ans += mp[tmp];
      mp[tmp]++;
    } else {
      mp[tmp]++;
      ans += mp[tmp];
    }
    // cout << tmp << "\n";
  }
  Cout(ans);
  return 0;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int cnt = 0;
    string ans;
    while (true) {
        if (cnt % 2 == 0) {
            c -= b;
            if (c <= 0) {
                ans = "Yes";
                break;
            }
        }
        else {
            a -= d;
            if (a <= 0) {
                ans = "No";
                break;
            }
        }
        cnt++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
while True:
    H,W = map(int,input().split())
    if H == W == 0:
        exit()
    for i in range(H):
        bol = (-1)**i
        for _ in range(W):
            if bol == 1:
                print("#", end = "")
                bol *= -1
            else:
                print(".", end = "")
                bol *= -1
        print()
    print()


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

int main(void) {

	std::string S;
	std::cin >> S;

	int v = 0;
	for (int i = 0; i < (int)S.size(); i++) {
		if (S[i] == '+') {
			++v;
		} else {
			--v;
		}
	}

	std::cout << v << std::endl;
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
int map[20][20];
int starty,startx;
int dx[4]={ 0,1,0,-1};
int dy[4]={-1,0,1, 0};
int min;
int w,h;
void dfs(int i,int y,int x){
    if(i==11) return;
    /*printf("i:%d y:%d x:%d\n",i,y,x);
    printf("i:%d\n",i);
    rep(a,h) {
        rep(b,w){
            if(a==y&&b==x) printf("@ ");
            else printf("%d ",map[a][b]);
        }puts("");
    }puts("");*/
    for(int d=0;d<4;d++){
        int tmpy=y+dy[d],tmpx=x+dx[d];
        if(tmpy<0||tmpy>=h||tmpx<0||tmpx>=w) continue;
        else if(map[tmpy][tmpx]==1) continue;
        else{
            int ny=y,nx=x;
            while(1){
                ny+=dy[d]; nx+=dx[d];
                if(ny<0||ny>=h||nx<0||nx>=w) break;
                else if(map[ny][nx]==3){
                    if(min>i) min=i;
                    return;
                }
                else if(map[ny][nx]!=1) continue;
                else{
                    map[ny][nx]=0;
                    dfs(i+1,ny-dy[d],nx-dx[d]);
                    map[ny][nx]=1;
                    break;
                }
            }
        }
    }
}
int main(void){
    while(1){
        scanf("%d%d",&w,&h);
        if(w+h==0) break;
        rep(i,h) rep(j,w){
            scanf("%d",&map[i][j]);
            if(map[i][j]==2) starty=i,startx=j;
        }
        //printf("%d %d\n",starty,startx);
        min=10000;
        dfs(1,starty,startx);
        if(min==10000) printf("-1\n");
        else printf("%d\n",min);
    }
}



Measured memory_bytes: 1920
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

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

const ll INF = 1e17;
const ll MOD = 1e9+7;

int main() {
    // input, ready, resolve
    int N;
    cin >> N;
    vector<int> AList;
    AList.resize(N);

    for (int i=0; i<N; i++) {
        int a;
        cin >> a;
        if (a % 2 == 0) {
            if (a % 3 != 0 && a % 5 != 0) {
                cout << "DENIED" << endl;
                return 0;
            }
        } 
    }
    cout << "APPROVED" << endl;

    return 0;
}

Measured memory_bytes: 256
/*
 * atcoder/abc119/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

const ll INF = 100000000000000000;
int N;
int A, B, C, L[8];

/*
 * index-nまでのLをみた時に長さがa, b, cである状態のコスト
 */
ll rec(int n = 0, int a = 0, int b = 0, int c = 0) {
  if (n==N) {
    if (a == 0 or b == 0 or c == 0) return INF; // Lから選んでいない場合は考えない
    return abs(A-a) + abs(B-b) + abs(C-c); // すべて合成し終わった時に残りを+-魔法で埋める
  }
  ll min_ = rec(n+1, a, b, c);
  chmin(min_, rec(n+1, a + L[n], b, c) + (a ? 10 : 0)); // 最初の1本以外はコスト10
  chmin(min_, rec(n+1, a, b + L[n], c) + (b ? 10 : 0));
  chmin(min_, rec(n+1, a, b, c + L[n]) + (c ? 10 : 0));
  return min_;
}

void solve() {
  cin >> N >> A >> B >> C;
  loop(n,0,N) cin >> L[n];
  cout << rec() << endl;
}
int main() {
  // cout.precision(15);
  // cout << fixed << double

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cctype>
using namespace std;
int main(){
    int i=0;
    char ch[1201],c;
    while(true){
        //cin>>ch[i];
        scanf("%c",&ch[i]);
        if(ch[i]=='\n'){
          break;
        }

        else if(islower(ch[i])){
            c=toupper(ch[i]);
            cout<<c;
        }
        else if(isupper(ch[i])){
            c=tolower(ch[i]);
            cout<<c;
        }
        else{
            cout<<ch[i];
        }
        
        i++;
        
        }
    cout<<endl;
    return 0;
}

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

ll n;
int M[101010][3]={};
ll dp[101010][3]={};
ll cnt=LLONG_MAX;




int main(){
   double a,b,x;
   long double pi=3.14159265;
   cin>>a>>b>>x;
   
   if(((x/a)/b)*2>=a){
      double h=x/(a*a);
      //printf("%12f",atan((b-h)*2/a)/pi*180);
      cout<< std::setprecision(10)<<(long double)atan((b-h)*2/a)/M_PI*180;
   }else{
      double h=x/(a*b);
      cout<<std::setprecision(10)<<atan(b/(h*2))/M_PI*180;
   }
   cout<<endl;
   
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vvi vector<vector<int>> 
#define vi vector<int> 
#define vpii vector<pair<int,int>> 
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define ffor(i,n) for(int i = 0; i < n; ++i)
const int inf = 1e18;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int N,W;
    cin >> N >> W;
    vi wt(N),val(N);
    ffor(i,N) cin >> wt[i] >> val[i];
    const int nax = accumulate(all(val),0LL);
    vi dp1(nax + 1,inf),dp2(nax + 1,inf);
    
    dp1[0] = dp2[0] = 0;
    for(int i = 1; i <= N; ++i)
    {
        for(int j = 1;j <= nax; ++j)
        {
            // not taking item
            dp2[j] = dp1[j];
            // taking item
            if(j - val[i - 1] >= 0)
            {
                dp2[j] = min(dp2[j],dp1[j - val[i - 1]] + wt[i - 1]);
            }
        }
        dp1 = dp2;
    }

    int ans = 0;

    ffor(i,nax + 1)
    {
        if(dp2[i] <= W)
        {
            ans = i;
        }
    }

    cout << ans;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> d(N, 0);
  
  for (int i = 0; i < N; i++) {
	cin >> d[i];
  }
  sort(d.begin(), d.end());
  reverse(d.begin(), d.end());
  
  int tmp = d[0];
  int count  = 1;
  for (int i = 1; i < N; i++) {
    if (d[i] < tmp) {
      count++;
      tmp = d[i];
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
N, C = map(int, raw_input().split())

D = []
c = []

for a in range(C):
    D.append(map(int, raw_input().split()))

for a in range(N):
    c.append(map(int, raw_input().split()))

cc = [[] for j in range(3)]

for i in range(N):
    for j in range(N):
        cc[(i + j) % 3].append(c[i][j])

c0 = [-1]
c1 = [-1]
c2 = [-1]

for i in range(1, C + 1):
    v = 0
    for j in cc[0]:
        v += D[j - 1][i - 1]
    c0.append(v)

for i in range(1, C + 1):
    v = 0
    for j in cc[1]:
        v += D[j - 1][i - 1]
    c1.append(v)

for i in range(1, C + 1):
    v = 0
    for j in cc[2]:
        v += D[j - 1][i - 1]
    c2.append(v)

res = pow(10, 100)

for i in range(1, C + 1):
    for j in range(1, C + 1):
        if i == j: 
            continue
        for z in range(1, C + 1):
            if i == z or j == z: 
                continue

            if res > c0[i] + c1[j] + c2[z]:
                res = c0[i] + c1[j] + c2[z]

print res


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


using namespace std;

using ll = long long;


void prime_factorize(ll N, vector<pair<ll, ll>> &res) {
    for (ll i = 2; i * i <= N; i++) {
        if (N % i != 0)
            continue;
        ll e = 0;
        while (N % i == 0) {
            e++;
            N /= i;
        }
        res.push_back(make_pair(i, e));
    }
    if (N != 1)
        res.push_back(make_pair(N, 1));
}


ll seq_sum(ll N) {
    return N * (1 + N) / 2;
}


int main(void) {
    vector<ll> seq_sum_values;
    ll n = 1;
    ll sum_now = seq_sum(n++);
    seq_sum_values.push_back(sum_now);
    while (sum_now < (ll)1e12) {
        sum_now = seq_sum(n++);
        seq_sum_values.push_back(sum_now);
    }

    ll N;
    cin >> N;
    ll ans = 0;
    vector<pair<ll, ll>> res;
    prime_factorize(N, res);
    for (auto r : res) {
        ll p = r.first;
        ll e = r.second;
        auto it = upper_bound(seq_sum_values.begin(), seq_sum_values.end(), e);
        ans += distance(seq_sum_values.begin(), it);
    }
    cout << ans << endl;
}


Measured memory_bytes: 19588
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define N 40

vector<int> a, b, c;

void postOrder(vector<int>::iterator a1, vector<int>::iterator a2, vector<int>::iterator b1, vector<int>::iterator b2)
{
    //printf("%d %d %d %d\n", *a1, *(a2 - 1), *b1, *(b2 - 1));
    vector<int>::iterator itr;
    c.push_back(*a1);
    //printf("%d\n", *a1);
    itr = find(b1, b2, *a1); //itrator of root on inorder tree walk
    int d = itr - b1;
    if (a1 + d + 1 < a2 && itr + 1 < b2)
        postOrder(a1 + d + 1, a2, itr + 1, b2);
    if (a1 + 1 < a1 + d + 1 && b1 < itr)
        postOrder(a1 + 1, a1 + d + 1, b1, itr);
}

int main()
{
    int n, x;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> x;
        a.push_back(x);
    }
    for (int i = 0; i < n; i++)
    {
        cin >> x;
        b.push_back(x);
    }

    postOrder(a.begin(), a.end(), b.begin(), b.end());

    for (int i = 0; i < c.size(); i++)
    {
        if (i != 0)
            cout << " ";
        cout << c[c.size() - 1 - i];
    }
    cout << "\n";

    return 0;
}


Measured memory_bytes: 3140
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
using namespace std;
#define PI 3.14159265358979
typedef unsigned long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#include<set>
//---------------------------------------------
 
int main(void)
{

 int a,b,c;
 cin>>a>>b>>c;

 cout<<c<<" "<<a<<" "<<b<<endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
ll white[ohara],black[ohara];
    
//-------------------------↓↓↓↓↓↓------------------------
    
//------ 自分を天才だと信じる ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n>>s;
    rep(i,n){
        if(s[i]=='#')cnt++;
    }
    ans=min(cnt,n-cnt);
    rep(i,n){
        if(s[i]=='.')white[i]=1;
        else black[i]=1;
    }
    rrep(i,1,n)white[i]+=white[i-1];
    rrrep(i,n-1,0)black[i]+=black[i+1];
    rep(i,n-1){
        //iまでwhite
        cnt=i+1-white[i];
        cnt+=n-i-1-black[i+1];
        ans=min(ans,cnt);
    }
    Cout(ans);
    return 0;
}

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

template<typename T> using V = vector< T >;
using Vi = V<int>;

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


    int max_move = 0;
    int cnt = 0;
    for(int i=0; i<n-1; i++){
        if(h[i]>=h[i+1]){
            cnt++;
        }else{
            cnt=0;
        }
        max_move = max(max_move,cnt);
    }

    cout<<max_move<<endl;

    return 0;
}

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

int main(){
    int R;
    cin >> R;
    if(R<1200){
        cout << "ABC" << endl;
    }else{
        if(R<2800){
            cout << "ARC" << endl;
        }else{
            cout << "AGC" << endl;
        }
    }
    return 0;
}

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

int main() {
  int a,b,c,d,l,r;
  cin >> a >> b >> c >> d;
  l = a + b;
  r = c + d;
  if (l > r) {
    cout << "Left" << endl;
  } else if (l < r) {
    cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }
}

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

const int kMaxN = 1e5 + 5;
int n;
vector<int> G[kMaxN];

int DFS(int x, int p) {
  int res = 0, f = 0;
  for (int nxt : G[x]) {
    if (nxt == p)
      continue;
    int res_nxt = DFS(nxt, x);
    if (res_nxt == 0 && f)
      ++res;
    if (res_nxt == 0 && !f) 
      f = 1;
    res += res_nxt;
  }
  return res;
}

int main() {
  scanf("%d", &n);
  for (int i = 1, x, y; i < n; ++i) {
    scanf("%d%d", &x, &y);
    G[x].push_back(y);
    G[y].push_back(x);
  }
  int rt = -1;
  for (int i = 0; i < n; ++i) {
    if (G[i].size() >= 3) {
      rt = i;
      break;
    }
  }
  if (rt == -1)
    return puts("1"), 0;
  printf("%d\n", DFS(rt, -1));
  return 0;
}

Measured memory_bytes: 9984
import sys
from collections import Counter

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))

    c = Counter(A)
    if 0 in c and len(c) == 1:
        return 'Yes'

    if 0 in c and len(c) == 2:
        v0 = c[0]
        for k, v in c.items():
            if k != 0 and v == 2 * v0:
                return 'Yes'

    if len(c) == 3:
        keys = []
        for k in c.keys():
            keys.append(k)

        if keys[0] ^ keys[1] != keys[2]:
            return 'No'

        vals = set()
        for v in c.values():
            vals.add(v)

        if len(vals) == 1:
            return 'Yes'

    return 'No'


if __name__ == '__main__':
    print(main())


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

// ====================================================================
template <unsigned int MOD>
struct ModInt {
    using uint = unsigned int;
    using ull = unsigned long long;
    using M = ModInt;

    uint v;

    ModInt(int64_t _v = 0) { set_norm(_v % MOD + MOD); }
    M& set_norm(uint _v) {
        v = (_v < MOD) ? _v : _v - MOD;
        return *this;
    }

    explicit operator bool() const { return v != 0; }
    M operator+(const M& a) const { return M().set_norm(v + a.v); }
    M operator-(const M& a) const { return M().set_norm(v + MOD - a.v); }
    M operator*(const M& a) const { return M().set_norm(ull(v) * a.v % MOD); }
    M operator/(const M& a) const { return *this * a.inv(); }
    M& operator+=(const M& a) { return *this = *this + a; }
    M& operator-=(const M& a) { return *this = *this - a; }
    M& operator*=(const M& a) { return *this = *this * a; }
    M& operator/=(const M& a) { return *this = *this / a; }
    M operator-() const { return M() - *this; }
    M& operator++(int) { return *this = *this + 1; }
    M& operator--(int) { return *this = *this - 1; }

    M pow(int64_t n) const {
        if (n < 0) return inv().pow(-n);
        M x = *this, res = 1;
        while (n) {
            if (n & 1) res *= x;
            x *= x;
            n >>= 1;
        }
        return res;
    }

    M inv() const {
        int64_t a = v, b = MOD, p = 1, q = 0, t;
        while (b != 0) {
            t = a / b;
            std::swap(a -= t * b, b);
            std::swap(p -= t * q, q);
        }
        return M(p);
    }

    bool operator==(const M& a) const { return v == a.v; }
    bool operator!=(const M& a) const { return v != a.v; }
    friend std::ostream& operator<<(std::ostream& os, const M& a) { return os << a.v; }
    friend std::istream& operator>>(std::istream& in, M& a) { int64_t v_; in >> v_; a = (v_); return in; }
    static uint get_mod() { return MOD; }
};
using Mint = ModInt<998244353>;
// ====================================================================

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

    int n, k;
    std::cin >> n >> k;

    std::vector<std::pair<int, int>> a(k);

    for (auto &[l, r] : a) {
        std::cin >> l >> r;
        ++r;
    }

    std::vector<Mint> dp(n);
    dp[0] = 1;
    dp[1] = -1;

    for (int i = 0; i < n; i++) {
        if (i > 0) dp[i] += dp[i - 1];
        for (const auto &[l, r] : a) {
            if (i + l < n) dp[i + l] += dp[i];
            if (i + r < n) dp[i + r] -= dp[i];
        }
    }
    std::cout << dp[n - 1];

    return 0;
}

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

using namespace std;

#define int         long long
#define ld          double
#define vi          vector <int>
#define vp          vector <pair<int,int>>
#define vvi         vector <vector <int>>
#define pb          push_back
#define mp          make_pair
#define pi          pair<int,int>
#define all(a)      a.begin(),a.end()
#define sz(a)       a.size()
#define sl(a)       a.length()
#define ff          first
#define ss          second
#define minel(a)	*min_element(all(a))
#define maxel(a)	*max_element(all(a))
#define Mod         1000000007
#define deb(x)      cout << x << endl;
#define o(x)        for(auto a:x)cout << a <<" ";cout << endl;
#define o2(x)       for(auto a:x)cout << a.ff << " " << a.ss;cout << endl; 

int inf = 1e18;
vi dp,vis;
vvi g;
void dfs(int node)
{
    vis[node] = 1;

    for(int i=0;i<sz(g[node]);i++)
    {
        int x = g[node][i];
        if(vis[x] != 1)
            dfs(x);
        dp[node] = max(dp[node],dp[x]+1);
    }
}

signed main() {

    int n,m;
    cin >> n >> m;
    g.resize(n);
    for(int i=0;i<m;i++)
    {
        int u,v;
        cin >> u >> v;
        u--;v--;

        g[u].pb(v);
    }

    dp.resize(n,0);
    vis.resize(n,0);
    for(int i=0;i<n;i++)
    {
        if(vis[i]!= 1)dfs(i);
    }

    int ans = 0;
    for(int i =0;i<n;i++)
    {
        ans = max(ans,dp[i]);
    }
    cout << ans << endl;

    
}

//utility function

int power(int a,int b,int m)
{
    int ans = 1;
    while(b > 0)
    {
        if(b&1){ans *= a;ans %= m;}
        a *= a;
        a %= m;
        b >>= 1;
    }
    return ans;
}



Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
#include <vector>
#include <algorithm>
using ll = long long;

// tgtよりも低い要素の個数
ll bs_lowers(ll tgt, const vector<ll> &list){

    ll left = 0, right = list.size(), mid;
    while (left<right){
        mid = (left+right)/2;
        if (list[mid]<tgt) left = mid+1;
        if (list[mid]>=tgt) right = mid;
    }
    return (left+right)/2;
}

// tgtよりも高い要素の個数
ll bs_uppers(ll tgt, const vector<ll> &list){

    ll left = 0, right = list.size(), mid;
    while (left<right){
        mid = (left+right)/2;
        if (list[mid]>tgt) left = mid+1;
        if (list[mid]<=tgt) right = mid;
    }
    return (left+right)/2;
}


int main(){

    // O(N)
    ll N; cin>>N;
    vector<ll> A(N), B(N), C(N);
    for (ll n=0; n<N; n++) cin>>A[n];
    for (ll n=0; n<N; n++) cin>>B[n];
    for (ll n=0; n<N; n++) cin>>C[n];

    // O(NlogN)
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    reverse(C.begin(), C.end());

    // O(N) * O(logN)
    ll ans = 0;
    for (ll n=0; n<N; n++){

        ll A_lowers = bs_lowers(B[n], A);
        ll C_uppers = bs_uppers(B[n], C);

        ans += A_lowers*C_uppers;

    }
    cout << ans << endl;

}

Measured memory_bytes: 5640
/*g++ main.cpp -o main.out*/
/*./main.out*/

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

#define LL long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

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

int main()
{
    string s;
    cin>>s;
    if(s[0]==s[1]&&s[1]==s[2])cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}


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

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

    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n-i; j++){
            if(i*10000+j*5000+(n-i-j)*1000 == y){
                cout << i << ' ' << j << ' ' << (n-i-j) << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;

    return 0;
}


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

int main() {
    string S, T;
    cin >> S;
    cin >> T;

    int correct = 0;

    for (int count = 0; count < 3; count++){
        if (S[count] == T[count]){
            correct++;
        }
    }
    cout << correct << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, l, r) for (int i = l; i <= (int)(r); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define all(v) v.begin(), v.end()
#define MOD (int) (1e9+7)
#define INF (int) 1e9
#define LLINF (ll) 1e18

int main(){
    int h, w, k;
    cin >> h >> w >> k;

    string s[h];
    rep(i, h) cin >> s[i];

    int ans = 0;
    rep(hi, 1<<h){

        bool hb[h];
        int hh = hi;
        rep(i, h){
            if(hh%2==1) hb[i]=true;
            else hb[i]=false;
            hh >>= 1;
        }

        rep(wi, 1<<w){
            bool wb[h];
            int ww = wi;
            rep(i, w){
                if(ww%2==1) wb[i]=true;
                else wb[i]=false;
                ww >>= 1;
            }

            int cnt=0;
            rep(hhi, h){
                rep(wwi, w){
                    if(hb[hhi] && wb[wwi]){
                        if(s[hhi][wwi]=='#') cnt++;
                    }
                }
            }
            if(cnt==k) ans++;

        }
    }

    cout << ans << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 3576
#include <stdio.h>

int main(void) {

    long int X;
    long int en500;
    long int en5;
    long int result = 0;

    // input
    scanf("%ld", &X);

    en500 = X / 500; // 500円の枚数
    en5 = (X - (en500 * 500)) / 5;  // 5円の枚数

    result = en500 * 1000 + en5 * 5;

    // output
    // printf("%ld, %ld\n", en500, en5);
    printf("%ld\n", result);

    return 0;
}

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

int main() {
    int n;
    cin>>n;
    int ma = 0;
    int mb = 0;
    int mc = 0;
    while(n > 0){
        int a,b,c;
        cin>>a>>b>>c;
        int x = a + max(mb, mc);
        int y = b + max(ma, mc);
        int z = c + max(ma, mb);
        ma = x;
        mb = y;
        mc = z;
        n--;
    }
    cout<<max(ma, max(mb, mc));
	return 0;
}


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

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  if(A==B && A !=C) {
    cout << "Yes" << endl;
  }
  else if (B==C && C != A) {
    cout << "Yes" << endl;
  }
  else if (C==A && C != B) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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


 const int MAX = 1001;
const int MOD = 1000000007;



signed main(){
    int m,d;
    cin>>m>>d;
    int ans=0;
    for(int i=1;i<=m;i++){
        for(int j=1;j<=d;j++){
            if((j%100)/10>=2&&j%10>=2){
                 if(i==((j%100)/10)*(j%10))ans++;
            }
           
        }
    }
    cout<<ans;
    

   return 0;
}

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

vector<int64_t>  l(87, -1);

int64_t lucas(int i){
  
  if(i == 0){
    l.at(0) = 2;
    return l.at(0);
  }
  if(i == 1){
    l.at(1) = 1;
    return l.at(1);
  }
  if(l.at(i) != -1){
    return l.at(i);
  }
  
  l.at(i) = lucas(i - 1) + lucas(i - 2);
  return l.at(i);
}
 
int main() {
  int n;
  cin >> n;
  cout << lucas(n) << endl;
}

Measured memory_bytes: 3632
N, M = map(int,input().split())
k = [None] * M
s = [None] * M
for i in range(M):
  k[i], *s[i] = map(int, input().split())

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

ans = 0
for i in range(2**N):
  tmp = 0
  for j in range(M):
    count = 0
    for l in range(k[j]):
      if (i >> (s[j][l]-1)) & 1:
        count += 1
    if count % 2 == p[j]:
      tmp += 1
  if tmp == M:
    ans += 1
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int field[15][15] = {0};
  for(;;){
    int x,y,s;
    if(scanf("%d,%d,%d",&x,&y,&s) == EOF) break;
    field[x+2][y+2]++;
    field[x+1][y+2]++;
    field[x+2][y+1]++;
    field[x+3][y+2]++;
    field[x+2][y+3]++;
    if(s>1){
      field[x+1][y+1]++;
      field[x+3][y+3]++;
      field[x+1][y+3]++;
      field[x+3][y+1]++;
    }
    if(s>2){
      field[x][y+2]++;
      field[x+2][y]++;
      field[x+4][y+2]++;
      field[x+2][y+4]++;
    }
  }
  int ans[2] = {0};
  for(int i=2; i<12; i++){
    for(int j=2; j<12;j++){
      if(field[i][j] == 0) ans[0]++;
      if(ans[1]<field[i][j]) ans[1] = field[i][j];
    }
  }
  cout <<ans[0]<<endl<<ans[1]<<endl;
  return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main(void){
    int r; cin >> r;
  	if(r < 1200){
    	cout << "ABC" << endl;
      	return 0;
    }
  	else if(r < 2800){
    	cout << "ARC" << endl;
      	return 0;
    }
  	else{
    	cout << "AGC" << endl;
      	return 0;
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define ll long long
#define ld long double
#define fi first
#define se second
#define INF 1000000000+10
const ll mod = 1000000000+7;
const int N = 3000+50;

ld dp[N][N];
string s[N];
ld p[N];
main()
{ 
	SPEED;
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	for(int i =1; i<=n;i++)cin >> p[i];
	ld ans = 0;
	for(int i = 0 ; i<=n; i++)
	{
		for(int j = 0; j<=n; j++)
		{
			if(i==0&&j==0){
				dp[i][j] = 1;
				continue;
			}
			if(i+j>n)continue;
			if(i>0)dp[i][j] += p[i+j]*dp[i-1][j];
			if(j>0)dp[i][j] += (1-p[i+j])*dp[i][j-1];
			if(i+j==n)if(i>j)ans += dp[i][j];
		}
	}

	cout << fixed << setprecision(10) << ans <<endl;
}

Measured memory_bytes: 143616
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
const long double PI = (acos(-1));
 
int main() {
  ld a,b,x;
  cin >> a >> b >> x;
  
  ld V = a * a * b;
  ld theta;
  if (x <= V / 2.0) theta = PI / 2 - atan(2*x/(a*b*b)); 
  else theta = atan(2*(V - x)/(a*a*a));
  
  theta = theta * 180 / PI;
  
  cout << fixed << setprecision(10) << theta << endl;  
}

Measured memory_bytes: 256
module ABC069

	! <module>s to import
	use, intrinsic :: iso_fortran_env


	! require all variables to be explicitly declared
	implicit none


	! accessibility of <subroutine>s and <function>s in this <module>
	public :: ABC069_B


	! constants for this <module>
	integer( kind=INT32 ), parameter, private :: len_TargetWord_max = 100


	! contained <subroutine>s and <function>s are below
	contains


	subroutine ABC069_B

		! variables for this <subroutine>
		character( len=len_TargetWord_max, kind=1 ) :: word_input

		integer( kind=INT16 ) :: len_word

		! STEP.01
		! read out the target word
		read( unit=INPUT_UNIT, fmt='(A)' ) word_input

		! STEP.02
		! get the length of the target word
		len_word = len_trim( word_input )

		! STEP.03
		! output the result
		write( unit=OUTPUT_UNIT, fmt='(A1,I0,A1)', advance='yes' ) word_input(1:1), len_word-2, word_input(len_word:len_word)

		! STEP.END
		return

	end subroutine ABC069_B

end module ABC069


program main

	! <module>s to import
	use, non_intrinsic :: ABC069

	! require all variables to be explicitly declared
	implicit none

	call ABC069_B

end program main


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>n;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int n;
  int count = 0;
  int ans = 0;
  cin >> n;
  rep(i, 0, n) {
    count = 0;
    rep(j, 0, i+1) {
      if( (i+1) % 2 == 0) break;
      if( (i+1) % (j+1) == 0) count++;
    }
    if (count == 8) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
a, b = map(int, input().split())
c = []
for i in range(b):
    d, e = map(int, input().split())
    c.append([i, d, e, 0])
c = sorted(c, key=lambda x: x[2], reverse=False)
d = [0] * a
for i in range(b):
    d[c[i][1]-1] += 1
    c[i][3] = d[c[i][1]-1]
c.sort()
for i in range(b):
    print(("000000" + str(c[i][1]))[-6:] + ("000000" + str(c[i][3]))[-6:])


Measured memory_bytes: 29972
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <queue>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>

using namespace std;

const int max_n = 444, inf = 1011111111;

int n, m, f1[max_n][max_n], f2[max_n];
vector<int> bad[max_n];

void er(int x, int y) {
    if (f1[x][y] == 1) {
        f1[x][y] = 0;
        f1[y][x] = 0;
        bad[x].push_back(y);
        bad[y].push_back(x);
    }
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; ++i) {
        f2[i] = 1;
        for (int j = i + 1; j <= n; ++j) {
            f1[i][j] = 1;
            f1[j][i] = 1;
        }
    }
    while (m--) {
        int x, y;
        scanf("%d%d", &x, &y);
        int a = f2[x];
        int b = f2[y];
        int c = f1[x][y] & a & b;
        if (!a) {
            f2[y] = 0;
        }
        if (!b) {
            f2[x] = 0;
        }
        if (!c) {
            f2[x] = 0;
            f2[y] = 0;
        }
        int szx = bad[x].size();
        int szy = bad[y].size();
        for (int i = 0; i < szx; ++i) {
            int a = bad[x][i];
            er(a, y);
        }
        for (int i = 0; i < szy; ++i) {
            int a = bad[y][i];
            er(a, x);
        }
        er(x, y);
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = i + 1; j <= n; ++j) {
            if (f2[i] && f2[j] && f1[i][j]) {
                ++ans;
                //cout << i << " " << j << endl;
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1920
#include <cstdio>
#include <cmath>
#include <iostream>
using namespace std;

int main() {
  double r;
  cin >> r;

  const double a =  M_PI * r * r;
  const double l = 2 * M_PI * r;
  printf("%f %f\n", a, l);
  return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
unordered_map<int, int> mp;
bool vis[111111];
int main() {
    int n,m;cin>>n>>m;
    for(int i=1;i<=n;i++) {
        int h;cin>>h;
        mp[i]=h;
    }
    for(int i=1;i<=m;i++) {
        int a, b; cin>>a>>b;
        int h1=mp[a];
        int h2=mp[b];
        if(h1==h2) vis[a]=vis[b]=true;
        else if (h1>h2) vis[b]=true;
        else vis[a]=true;
    }
    int cnt=0;
    for(int i=1;i<111111;i++) {
        cnt+=vis[i];
    }
    cout<<n-cnt<<endl;
}

Measured memory_bytes: 7400
k = 10**5
c = [0] * k
n = int(input())
A = [int(_) for _ in input().split()]
B = [0] * (n+1)
# print(B)

def CountingSort(A, B, k):
    for i in range(k):
        c[i] = 0

    for j in range(0, n):
        c[A[j]] += 1
        # print(A[j])
        # print(c)

    for i in range(1, k):
        c[i] = c[i] + c[i-1]

    # print(c)

    for j in range(n-1, -1, -1):
        # print(j)
        # print(A[j])
        # print(c[A[j]])
        B[c[A[j]]] = A[j]
        c[A[j]] -= 1

CountingSort(A, B, k)
print(" ".join(map(str, B[1:])))



Measured memory_bytes: 251652
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n,d[50];
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>d[i];
    int ans=0;
    for(int i=1;i<n;i++)
        for(int j=0;j<i;j++)
            ans+=d[i]*d[j];
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
using namespace std;
 
int main() {
    string s;
    cin >> s;
    if (s.size() == 1){
        if (s[0] == '?'){
          cout << "D" << endl;
          return 0;
        }
    }
    rep(i, 0, s.size()-1){
        if((s[i] == '?' && s[i+1]== '?')){
            s[i] = 'D';
        }
    }
    rep(i, 0, s.size()-1){
        if (s[i] == 'P'  && s[i+1]== '?'){
            s[i+1] = 'D';
        }else if (s[i] == 'D'  && s[i+1]== '?'){
             s[i+1] = 'D';
        }else if (s[i] == '?'){
             s[i] = 'D';
        }
    }
    cout << s << endl;
    
    return 0;
}


Measured memory_bytes: 3748
#include<stdio.h>

#define MAX 250

int main(){

  int id,key,i,A[MAX];

  scanf("%d",&id);

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

  for(i = 1; i <= id; i++){
    printf("node %d: key = %d, ",i,A[i]);

    if(i != 1) printf("parent key = %d, ",A[i/2]);

    if(2*i <= id) printf("left key = %d, ",A[2*i]);
    else {
      printf("\n");
      continue;
    }
    if(2*i+1 <= id) printf("right key = %d, \n",A[2*i+1]);
    else printf("\n");
  }
  return 0;
}

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

typedef long long ll;
ll MOD = 1000000007;

int main()
{
    string s;
    cin >> s;
    for (int i = 1; i <= 3; i++) {
        if (s[i-1] == s[i]) {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

const ll mod = 1e9 + 7;
const int N = 1e5 + 10, M = 1e2 + 30;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const double eps = 1e-8;

#define pi aaos(-1)
#define mk make_pair

char s[N];

bool check(int l, int r)
{
    while(l <= r)
    {
        if(s[l] != s[r])
        {
            return 0;
        }
        l++;
        r--;
    }
    return 1;
}

int main()
{
    scanf("%s", s + 1);
    int len = strlen(s + 1);
    if(check(1, len) && check(1, (len - 1) / 2) && check((len + 3) / 2, len))
    {
        puts("Yes");
    }
    else
    {
        puts("No");
    }
    
    return 0;
}

Measured memory_bytes: 256