akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const double pi=acos(-1);

/*
void make(vector<vector<int>> &A,int N,int M,vector<int> a)
{
  if(a.size()==N) {A.push_back(a); return;}
  if(a.size()==0)
  {
    rep(i,M)
    {
      make(A,N,M,{i+1});
    }
    return;
  }
  int l=a.at(a.size()-1);
  for(int i=l;i<=M;i++)
  {
    auto b=a;
    b.push_back(i);
    make(A,N,M,b);
  }
}
*/



int main() 
{
  int N,M,Q; cin>>N>>M>>Q;
  /*
  vector<vector<int>> A(0);
  make(A,N,M,{});
  for(auto a:A)
  {
    for(auto w:a)
    {
      cout<<w<<" ";
    }
    cout<<endl;
  }
  */
  queue<vector<int>> que;
  for(int i=1;i<=M;i++)
  {
    que.push({i});
  }
  while(que.front().size()<N)
  {
    auto vec=que.front();
    que.pop();
    auto l=vec.at(vec.size()-1);
    for(int i=l;i<=M;i++)
    {
      auto vec2=vec;
      vec2.push_back(i);
      que.push(vec2);
    }
  }  
  vector<int> a(Q);
  vector<int> b(Q);
  vector<int> c(Q);
  vector<int> d(Q);
  rep(i,Q)
  {
    cin>>a.at(i)>>b.at(i)>>c.at(i)>>d.at(i);
    a.at(i)--;
    b.at(i)--;
  }
  
  int ans=0;
  while(!que.empty())
  {
    auto hoge=que.front();
    que.pop();
    int sum=0;
    rep(i,Q)
    {
      if(hoge.at(b.at(i))-hoge.at(a.at(i))==c.at(i))
      {
        sum+=d.at(i);
      }
    }
    ans=max(sum,ans);
  }
  
  cout<<ans<<endl;
  
  return 0;
}



Measured memory_bytes: 13060
// AtCoder ABC133: B - Good Distance
// 2019.9.2 bal4u

#include <stdio.h>
#include <math.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif

int in()   // 整数の入力（負数対応）
{
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

int x[25][25];

int main()
{
	int N, D, r, rr, c, s, b, ans;
	
	N = in(), D = in();
	for (r = 0; r < N; r++) for (c = 0; c < D; c++) x[r][c] = in();
	ans = 0;
	for (r = 0; r < N; r++) for (rr = r+1; rr < N; rr++) {
		s = 0; for (c = 0; c < D; c++) s += (x[r][c]-x[rr][c])*(x[r][c]-x[rr][c]);
		b = (int)sqrt((double)s);
		if (b*b == s) ans++;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1 << 30;
ll ans = 0;

int main()
{
ll n,z,w;
cin >> n>>z>>w;
ll t[n] = {};
rep(i, n)
{
    cin >> t[i];
}
if(n==1){
    cout << abs(w-t[n-1]) << endl;
    return 0;
}


cout << max(abs(w-t[n-1]),abs(t[n-1]-t[n-2])) << endl;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int i,i0,n,m,ans;
bool is(int x)
{
    if(x==0)return 1;
    int cnt=0;
    while(x)cnt++,x/=10;
    return cnt%2;
}
int main()
{
    scanf("%d",&n);
    for(i=1;i<=n;i++)ans+=is(i);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
   int h,a,c=0;
   scanf("%d",&h);
   scanf("%d",&a);
   while(1)
   {
   h=h-a;
   c++;
   if(h<=0)
   {
    break;
   }
   }
   printf("%d",c);
   return 0;
}



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

using namespace std;

const int max_n = 111, inf = 1000111222;

int n, x, l, cur, ans = 1;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> x;
    while (n--) {
        cin >> l;
        cur += l;
        ans += (cur <= x);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    int N,K,idx;
    cin >> N >> K;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        if(a==1)idx=i;
    }

    //cout << (idx+1)/(K-1)+(N-idx)/(K-1) << endl;
    cout << ceil((double)(N-1)/(double)(K-1)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<map>
#include<cstring>

using namespace std;

typedef long long int ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = 1e9;
const ll LLINF = 1LL<<60;
int arrayMax(int a[], const int N){
    int maxv = 0;
    rep(i, N)maxv = max(a[i], maxv);
    return maxv;
}
/* -- template -- */
int dp[100000];//dp[i] : 頂点iを含む最大有効パス長
vivi G;

int dfs(int i){
    if(dp[i] != -1)return dp[i];
    for(int next : G[i]){
        dp[i] = max(dp[i], dfs(next) + 1);
    }
    if(dp[i] == -1)dp[i] = 0;
    return dp[i];
}

int main(){
    int N, M;cin >> N >> M;
    G.resize(N);
    rep(i, M){
        int x, y;
        cin >> x >> y;
        --x;--y;
        G[x].push_back(y);
    }
    rep(i, N)dp[i] = -1;//未探索
    int ans = 0;
    rep(i, N)
        ans = max(ans, dfs(i));
    cout << ans << endl;
}


Measured memory_bytes: 7424
#include <iostream>

using namespace std;

int main()
{
	unsigned long long a,b,c,x;
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> x;
	
	unsigned long long ans = 0,sum = 0;
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			for(int k=0;k<=c;k++){
				sum = i*500 + j*100 + k*50;
				if(sum == x){
					ans++;
				}
			}
		}
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
e=[[] for _ in range(n)]
for _ in range(n-1):
    xi,yi,wi=map(int, input().split())
    xi-=1;yi-=1
    e[yi].append((xi,wi))
    e[xi].append((yi,wi))

c=[0]*n
used=[0]*n

from collections import deque

q=deque()
q.append(0)
while q:
    u=q.popleft()
    for v,w in e[u]:
        if not used[v]:
            c[v]=(c[u]+w)%2
            used[v]=1
            q.append(v)
for i in c:
    print(i)

Measured memory_bytes: 72480
# -*- Coding: utf-8 -*-
import numpy as np
import sys

  
N,A,B,C,D = map(int,raw_input().split())
originalS = raw_input()
S = originalS
S = S[:A-1]+'A'+S[A:]
S = S[:B-1]+'B'+S[B:]

S = list(S)
boolean = False

if A<B:
  while S[D-1] != 'B':
    if S[B]  == '.':
      if S[B-2] == '.':
        while S[C-1] != 'A':
          if S[A] != '.':
            if S[A+1] == '.':
              S[A-1] = originalS[A-1]
              A += 1
            else:
              print 'No'
              sys.exit()
          S[A] = 'A'
          S[A-1] = originalS[A-1]
          A += 1
        boolean = True
    else:
      if S[B+1] == '.':
        S[B-1] = originalS[B-1]
        B  += 1
      else:
        print 'No'
        sys.exit()

    S[B] = 'B'
    S[B-1] = originalS[B-1]
    B += 1

  if boolean == False:
    while S[C-1] != 'A':
          if S[A] != '.':
            if S[A+1] == '.':
              S[A-1] = originalS[A-1]
              A += 1
            else:
              print 'No'
              sys.exit()
          S[A] = 'A'
          S[A-1] = originalS[A-1]
          A += 1
  print 'Yes'
  sys.exit()

else:
  while S[C-1] != 'A':
    if S[A]  == '.':
      if S[A-2] == '.':
        while S[D-1] != 'B':
          if S[B] != '.':
            if S[B+1] == '.':
              S[B-1] = originalS[B-1]
              B += 1
            else:
              print 'No'
              sys.exit()
          S[B] = 'B'
          S[B-1] = originalS[B-1]
          B += 1
        boolean = True
    else:
      if S[A+1] == '.':
        S[A-1] = originalS[A-1]
        A  += 1
      else:
        print 'No'
        sys.exit()

    S[A] = 'A'
    S[A-1] = originalS[A-1]
    A += 1

  if boolean == False:
    while S[D-1] != 'B':
      if S[B] != '.':
        if S[B+1] == '.':
          S[B-1] = originalS[B-1]
          B += 1
        else:
          print 'No'
          sys.exit()
      S[B] = 'B'
      S[B-1] = originalS[B-1]
      B += 1

  print 'Yes'
  sys.exit()


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

using namespace std;

int main()
{
  double x1, y1, x2, y2, x3, y3;
  cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
  double d1 = hypot(x1 - x2, y1 - y2);
  double d2 = hypot(x2 - x3, y2 - y3);
  double d3 = hypot(x3 - x1, y3 - y1);
  double s = (d1 + d2 + d3) * 0.5;
  double S = sqrt(s * (s - d1) * (s - d2) * (s - d3));
  double r = 2 * S / (d1 + d2 + d3);
  auto p = max(d1, max(d2, d3));
  cout << fixed << setprecision(10) << r * p / (p + 2 * r) << endl;
}


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
typedef vector<vector<int>> Graph;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

class LowLink {
public:
    const int N;
    vector<vector<int>> G;

private:
    set<int> used_v;
    vector<int> ord, low, parent;

    void dfs(int v, int &k)
    {
        used_v.insert(v);
        ord[v] = low[v] = k++;

        for (auto u : G[v]) {
            if (u == parent[v]) continue;
            if (!used_v.count(u)) {
                parent[u] = v;
                dfs(u, k);
                low[v] = min(low[v], low[u]);
            } else {
                low[v] = min(low[v], ord[u]);
            }
            if (ord[v] < low[u]) bridges.emplace_back(min(u, v), max(u, v));
        }
    }

public:
    vector<PII> bridges;
    LowLink(int _N) : N(_N), G(_N), ord(_N), low(_N), parent(_N) {}

    void compute_bridge()
    {
        int k = 0;
        bridges.clear();
        dfs(0, k);
    }

    bool is_bridge(int u, int v)
    {
        if (ord[u] > ord[v]) swap(u, v);
        return ord[u] < low[v];
    }

    void add_edge(int u, int v)
    {
        G[u].push_back(v);
        G[v].push_back(u);
    }
};
int main()
{
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;
    LowLink G(N);
    rep(i, M) {
        int A, B;
        cin >> A >> B;
        A--, B--;
        G.add_edge(A, B);
    }
    G.compute_bridge();
    cout << G.bridges.size() << endl;
}

Measured memory_bytes: 256
//话说这么简单一题我还用这么麻烦的做法是不是误导新人？
#include<stdio.h>
#include<string.h>
int a[4];
void abcd(int l,int r)//手写快排函数，详见我at2823的快排题解
{
    int i=l,j=r,t;
    int p=a[(l+r)/2];
    while(i<=j)
    {while(a[i]<p)
    {i++;}
    while(a[j]>p)
    {j--;}
    if(i<=j)
    {t=a[i]; 
    a[i]=a[j]; 
    a[j]=t;
    i++; 
    j--;}}
    if(l<j)
    abcd(l,j);
    if(i<r)
    abcd(i,r); 
    }
int main()
{
    scanf("%d%d%d",&a[1],&a[2],&a[3]);
    abcd(1,3);
    if(a[2]-a[1]==a[3]-a[2])
    printf("YES\n");//又是大写加回车，老是换大小写，首字母，全小，全大，真是的~
    else
    printf("NO\n");
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int H = sc.nextInt();
        int W = sc.nextInt();
        int N = sc.nextInt();
        int[] a = new int[N + 1];
        for(int i = 1; i <= N; i++){
            int v = sc.nextInt();
            a[i] = v;
        }

        int[][] ans = new int[H][W];
        int curr = 1;
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                ans[i][i % 2 == 0 ? j : W - 1 - j] = curr;
                a[curr] -= 1;
                if(a[curr] == 0){
                    curr += 1;
                }
            }
        }

        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                System.out.print(String.format("%d ", ans[i][j]));
            }
            System.out.println();
        }

    }
}

Measured memory_bytes: 42116
def main():
    l, r = map(int, input().split())
    res = 1 << 30
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            res = min(res, (i * j) % 2019)
            if res == 0:
                print(res)
                return
    print(res)


if __name__ == "__main__":
    main()


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

const ll INF = 100100100;

int main()
{
    int a, b, m;
    cin >> a >> b >> m;
    vector<ll> A(a);
    vector<ll> B(b);
    rep(i, a) cin >> A[i];
    rep(i, b) cin >> B[i];
    ll mini = INF;
    rep(i, m) {
        ll x, y, c;
        cin >> x >> y >> c;
        x--;
        y--;
        mini = min(mini, A[x] + B[y] - c);
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    cout << min(mini, A[0] + B[0]) << endl;
    return 0;
}

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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template <typename T>
inline void chkmax(T &x, T y) { if (x < y) x = y; }

template <typename T>
inline void chkmin(T &x, T y) { if (x > y) x = y; }

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = x * 10 + (c ^ 48), c = nc;
  return x;
  #undef nc
}

typedef long long ll;
const int maxn = 2e6 + 10;
int n,m;
char str[maxn];

const int P = 1e9 + 7;

int Inc(int x, int y) {
  return x + y < P ? x + y : x + y - P;
}

int Dec(int x, int y) {
  return x < y ? x - y + P : x - y;
}

void Add(int &x, int y) {
  x += y;
  if (x >= P) x -= P;
}

void Sub(int &x, int y) {
  x -= y;
  if (x < 0) x += P;
}

int qp(int a, int k) {
  int res = 1;
  for (; k; k >>= 1, a = 1ll * a * a % P) {
    if (k & 1) res = 1ll * res * a % P;
  }
  return res;
}

int inv[maxn], fac[maxn], ifac[maxn];

int binom(int n, int m) {
  return n < m ? 0 : 1ll * fac[n] * ifac[m] % P * ifac[n - m] % P;
}

void init() {
  fac[0] = ifac[0] = 1;
  inv[1] = fac[1] = ifac[1] = 1;
  rep(i, 2, maxn - 1) {
    inv[i] = 1ll * (P - P / i) * inv[P % i] % P;
    fac[i] = 1ll * i * fac[i - 1] % P;
    ifac[i] = 1ll * inv[i] * ifac[i - 1] % P;
  }
}

void solve() {
  init();
  cin>>n;
  scanf("%s",str+1);
  m=strlen(str+1),n+=m;
  int ans=0;
  rep(i,m,n){
    ans=(ans+1ll*binom(n,i)*qp(25,n-i))%P;
  }
  cout<<ans<<endl;
}

int main() {
//  int T = read();
//  while (T--) solve();
  solve();
  return 0;
}

Measured memory_bytes: 28068
use proconio::*;
use std::collections::*;

fn run() {
    input! {
        n: usize,
        a: [f64; n],
    }
    let mut map = BTreeMap::new();
    for a in a {
        let mut a = (a * 1_000_000_000f64).round() as u64;
        let mut cnt = (0, 0);
        while a % 2 == 0 {
            a /= 2;
            cnt.0 += 1;
        }
        while a % 5 == 0 {
            a /= 5;
            cnt.1 += 1;
        }
        *map.entry(cnt).or_insert(0) += 1;
    }
    let a = map.into_iter().collect::<Vec<_>>();
    let mut ans = 0u64;
    let v = 18;
    for (i, &(x, p)) in a.iter().enumerate() {
        if 2 * x.0 >= v && 2 * x.1 >= v {
            ans += p * (p - 1) / 2;
        }
        for &(y, q) in a.iter().take(i) {
            if x.0 + y.0 >= v && x.1 + y.1 >= v {
                ans += p * q;
            }
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 6480
#include <iostream>
#include <string>
#include <sstream>

int main() {
    std::string s, ans;
    std::stringstream ss;
    while (std::cin >> s) {
        if (s == "-") break;
        else {
            int m;
            std::cin >> m;
            for (int i=0;i<m;++i) {
                int h;
                std::cin >> h;
                ans = s.substr(h) + s.substr(0, h);
                s = ans;
            }
            ss << ans << std::endl;
        }
    }
    std::cout << ss.str();
    return 0;
}


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

int main() {

    int n, imos[100003] = {0};

    imos[0] = 1;
    cin >> n;
    for(int i = 0; i < n; i++) {
        int a, b; cin >> a >> b;
        imos[a]++, imos[b + 1]--;
    }

    for(int i = 1; i < 100003; i++) {
        imos[i] += imos[i - 1];
    }

    int maxi = 0;
    for(int i = 0; i <= n + 1; i++) {
        if(imos[i] >= i) maxi = max(maxi, i);
    }
    cout << maxi - 1 << endl;
}



Measured memory_bytes: 3488
#include<iostream>
#include<string>
using namespace std;
int main(){
    string s;
    cin>>s;
    int n[100000],f=0,f2=0;
    for(int i=0;i<s.length();i++){
        n[i]=1;
    }
    for(int i=0;i<s.length();i++){
        if(s[i]=='R'&&s[i+1]=='R'){
            f++;
            n[i+1]+=n[i];
            n[i]=0;
        }
        else if(s[i]=='R'&&s[i+1]=='L'){
            n[i+1]+=(f+1)/2;
            n[i]-=(f+1)/2;
            f=0;
        }
        if(s[s.length()-1-i]=='L'&&s[s.length()-i-2]=='L'){
            f2++;
            n[s.length()-i-2]+=n[s.length()-1-i];
            n[s.length()-1-i]=0;
        }
        else if(s[s.length()-i-1]=='L'&&s[s.length()-i-2]=='R'){
            n[s.length()-i-2]+=(f2+1)/2;
            n[s.length()-1-i]-=(f2+1)/2;
            f2=0;
        }
    }
    for(int i=0;i<s.length();i++){
        cout<<n[i];
        if(i<s.length()-1){
            cout<<" ";
        }
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N, K;
  string S;
  cin >> N >> S >> K;
  rep(i, N)
  {
    if(S[i] != S[K - 1])
      S[i] = '*';
  }
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  while(cin>>n>>m,n+m!=0){
    int ans=0;
    for (int i = 1; i <= n; ++i)
    {
      for (int j = i+1; j <= n; ++j)
      {
        for (int k = j+1; k <= n; ++k)
        {
          if(i+j+k==m) ++ans;
        }
      }
    }
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 1; i <= (n); ++i)
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using P = pair<int, int>;


// ------------------------

ll COM(ll n, ll k){
    ll res = 1;
    for (ll i = 0; i < k; ++i){
        res *= (n-i);
        res /= (i+1);
    }
    return res;
}

void solve() {
    ll A_count[200100];
    ll A_comb[200100];
    ll N; cin >> N;
    vector<ll> A_vec(N);
    ll max_A = 0;
    for (ll i = 0; i < N; ++i){
        ll A;
        cin >> A;
        A_vec[i] = A;
        ++A_count[A];
        if(max_A < A){
            max_A = A;
        }
    }
    rep(i, max_A){
        A_comb[i] =  COM(A_count[i], 2);
    }

    ll all_accum = 0;
    rep(i, max_A){
        all_accum += A_comb[i];
    }

    for (ll i = 0; i < N; ++i){
        cout << all_accum - A_comb[A_vec[i]] + COM(A_count[A_vec[i]]-1, 2) << endl;
    }
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 6272
N = int(input())
l = []
for i in range(N):
    l.append(input())
AC = l.count('AC')
WA = l.count('WA')
TLE = l.count('TLE')
RE = l.count('RE')
print("AC x {}".format(AC))
print("WA x {}".format(WA))
print("TLE x {}".format(TLE))
print("RE x {}".format(RE))

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

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

  vector<int> p(N);

  for (int i = 0; i < N; i++)
  {
    cin >> p.at(i);
  }

  int sum = 0;
  sort(p.begin(), p.end());
  for (int i = 0; i < N - 1; i++)
  {
    sum += p.at(i);
  }
  
  sum += p.at(N - 1) / 2;
  cout << sum << endl;
}



Measured memory_bytes: 3600
import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.buffer.read


from collections import Counter


N = int(input())
S = [input() for _ in range(N)]
count = Counter(S)

i = ['AC', 'WA', 'TLE', 'RE']
for j in i:
    print(j, 'x', count[j])

Measured memory_bytes: 16536
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;
//using System.Numerics;
 
class Program
{
    static void Main()
    {
        SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    Random rnd = new Random();
    Stopwatch sw = new Stopwatch();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";
    readonly string ALFA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 
    int N;
    void solve()
    {
        N = cin.nextint;
        var T = new long[N];
        var x = cin.nextlong;
        for (int i = 1; i < N; i++)
        {
            var y = cin.nextlong;
            long d = gcd(x, y);
            x = y / d * x;
            //WriteLine(x);
        }
        WriteLine(x);
        
    }
 
    long gcd(long x, long y)
    {
        if (x > y)
        {
            long t = x;
            x = y;
            y = t;
        }
        while (y > 0)
        {
            long r = x % y;
            x = y;
            y = r;
        }
        return x;
    }
}
 
class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr ll INF=1e18;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

template<typename T,typename Compare>
auto make_priority_queue(const Compare& comp)
{
	return priority_queue<T,vector<T>,Compare>(comp);
}

int main()
{
	for(int n;cin>>n&&n;){
		vector<vector<tuple<int,int>>> g(n);
		rep(_,n-1){
			int u,v,w; cin>>u>>v>>w; u--,v--;
			g[u].emplace_back(v,w);
			g[v].emplace_back(u,w);
		}
		int q,k; cin>>q>>k; k--;

		vector<ll> ds(n,INF);
		auto pq=make_priority_queue<tuple<int,ll>>([](auto a,auto b){
			return get<1>(a)>get<1>(b);
		});
		pq.emplace(k,0);

		while(pq.size()){
			int u; ll w; tie(u,w)=pq.top(); pq.pop();
			if(ds[u]!=INF) continue;
			ds[u]=w;
			for(auto e:g[u])
				pq.emplace(get<0>(e),w+get<1>(e));
		}

		rep(_,q){
			int u,v; cin>>u>>v; u--,v--;
			cout<<ds[u]+ds[v]<<endl;
		}
	}
}


Measured memory_bytes: 10096
from math import sqrt
q = int(input())

primes = {i for i in range(2,10**5 + 1)}
for i in range(2,int(sqrt(10**5+1)) + 1):
    if i in primes:
        mul = 2
        while i*mul <= 10**5:
            primes.discard(i*mul)
            mul += 1

ret = [0]*(1 + 10**5)
for i in range(3,1 + 10**5):
    if i&1:
        if i in primes and (i+1)/2 in primes:
            ret[i] = ret[i-1] + 1
        else:
            ret[i] = ret[i-1]
    else:
        ret[i] = ret[i-1]

for i in range(q):
    l, r = (int(i) for i in input().split())
    print(ret[r] - ret[l-1])

Measured memory_bytes: 62308
#include<iostream>
using namespace std;
int main(){
  
  int Q,c,a,n,counter,counter2;
  
  cin >>Q;
  
  for(int i=0 ; i < Q ; i++){
    
    cin >>c>>a>>n;
    counter=0;
    
    while(1){
     
      counter2=0; 
      
      if( c >= 1 && a >= 1 && n >=1){
	counter++;
	counter2++;
	c--;
	a--;
	n--;
      }else if(c >= 2 && a >= 1){
	counter++;
	counter2++;
	c-=2;
	a--;
      }else if(c >= 3){
	counter++;
	counter2++;
	c-=3;
      }
      
      if(counter2 == 0)break;
    
    }
    
    cout <<counter<<endl;
    
  }  

  return 0;
}

Measured memory_bytes: 1160
def d():
    N, W = map(int, input().split())
    wv = [list(map(int, input().split())) for _ in range(N)]
    dp = [[0] * (W + 1) for _ in range(N + 1)]
    for i in range(N):
        for j in range(W + 1):
            if j - wv[i][0] >= 0:
                dp[i + 1][j] = max(dp[i + 1][j],
                                   dp[i][j - wv[i][0]] + wv[i][1])
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
    return dp[-1][-1]


if __name__ == '__main__':
    ans = d()
    print(ans)

Measured memory_bytes: 118896
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

bool ok(const vs64& a, int idx)
{
    s64 w = a[idx];
    int n = a.size();
    int l = 0, r = 0;
    while (true)
    {
        s64 sum = 0;
        while (r < n && a[r] <= 2 * w)
        {
            if (idx != r) sum += a[r];
            ++r;
        }
        if (l == r) return false;
        if (r == n) break;
        l = r;
        w += sum;
    }
    return true;
}

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

    int n;
    cin >> n;

    vs64 a(n);
    rep (i, n) cin >> a[i];
    sort(a.begin(), a.end());

    int l = -1, r = n - 1;
    while (l + 1 < r)
    {
        int m = (l + r) / 2;
        if (ok(a, m)) r = m;
        else l = m;
    }

    cout << n - r << "\n";
    return 0;
}



Measured memory_bytes: 3968
//subset sum problem

#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
typedef long long int ll;
typedef unsigned long long int ull;
#define fi first
#define se second
#define pb push_back
ll mod1=pow(10,9)+7;
int mod2=998244353;
ll inf=1e9;
ll maxxy=1e6+9;
typedef long double ld;
const double PI =  3.141592653589793238;

ll power(ll x, ll y, ll pp)
{
    ll res = 1;
    x = x % pp;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % pp;
        y = y>>1;
        x = (x*x) % pp;
    }
    return res;
}

ll modInverse(ll n, ll pp)
{
    return power(n, pp-2, pp);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    string t;
    cin>>s>>t;
    ll n=s.size();
    ll m=t.size();
    ll dp[n+1][m+1];
    for (int i = 0; i <=n ; ++i) {
        for (int j = 0; j <=m ; ++j) {
            if(i==0 || j==0){
                dp[i][j]=0;
            }
            else if(s[i-1]==t[j-1]){
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    char lcs[dp[n][m]];
    ll index=dp[n][m];
    if(index==0){
        cout<<" "<<"\n";
        return 0;
    }
    ll i=n,j=m;
    while(i>0 && j>0){
        if(s[i-1]==t[j-1]){
            lcs[index-1]=s[i-1];
            i--;j--;index--;
        }
        else if(dp[i-1][j]>dp[i][j-1]) {
            i--;
        }
        else
            j--;
    }
    for(auto u:lcs)
        cout<<u;
    return 0;
}


Measured memory_bytes: 73996
import java.util.Scanner;
public class Main {
public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

int a = sc.nextInt();
int b = sc.nextInt();
int area = a*b;
int length = 2*a+2*b;
System.out.println(area + " " + length);
}
}


Measured memory_bytes: 25904
//============================================================================
// Author       : Sun YaoFeng
//============================================================================

//#pragma 	comment(linker, "/STACK:100240000,100240000")
//#include	<cstdio>
//#include	<cstdlib>
//#include	<cstring>
//#include	<algorithm>

#include	<bits/stdc++.h>

using	namespace	std;

#define DB		double
#define	lf		else if
#define I64		long long
#define	Rd()	(rand()<<15|rand())
#define For(i,a,b)	for(int i=a,lim=b;i<=lim;i++)
#define Rep(i,a,b)	for(int i=a,lim=b;i>=lim;i--)

#define	fi	first
#define se	second
#define MK	make_pair
#define PA	pair<int, int>

//#define	min(a,b)	((a)<(b)?(a):(b))
//#define	max(a,b)	((a)<(b)?(b):(a))

#define	CH	(ch=getchar())
int		IN()	{
		int x= 0, f= 0, ch;
		for	(; CH < '0' || ch > '9';)	f= (ch == '-');
		for	(; ch >= '0' && ch <= '9'; CH)	x= x*10 + ch -'0';
		return	f? -x : x;
}

#define n	500005

int		N, L[n], R[n], Next[n];

char	s[n];

void	Get(int *L){
		for (int i= 2, j= 0; i <= N; i++){
			for (; j && s[j+1] != s[i]; j= Next[j]);
			if	(s[j+1] == s[i])	j++;
			Next[i]= j;
		}
		
		For(i, 1, N)	L[i]= (! Next[i] || i % (i - Next[i]) != 0);
}

int		main(int argc, char* argv[]){
		scanf("%s", s+1);
		N= strlen(s+1);
		
		Get(L);
		reverse(s+1, s+N+1);
		Get(R);
		
		if	(L[N])	printf("%d\n%d\n", 1, 1);
		lf	(Next[N] == N-1)	printf("%d\n%d\n", N, 1);
		else	{
			int	Ans= 0;
			For(i, 1, N-1)	Ans+= L[i] && R[N-i];
			printf("%d\n%d\n", 2, Ans);
		}
		
		return	0;
}

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

int main(){
    int n, i;
    cin >> n;
    long int l[n+1];
    for(i=0; i<=n; i++){
        if(i == 0){
            l[i] = 2;
        }else if(i == 1){
            l[i] = 1;
        }else{
            l[i] = l[i-1] + l[i-2];
        }
    }
    cout << l[n];
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define oo 666666666
#define ll long long
#define ld long double

ll DP[100005];
ll w[100005];
ll v[100005];

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,W;
    cin>>n>>W;
    for(int i=1; i<=n; i++)
        cin>>w[i]>>v[i];

    for(int i=1; i<=100001; i++)
        DP[i]=LLONG_MAX/10;

    for(int i=1; i<=n; i++)
        for(int j=100001-v[i]; j>=0; j--)
        DP[j+v[i]]=min(DP[j+v[i]], DP[j] + w[i]);

    ll ats = 0;
    for(int i=1; i<=100001; i++)
        if(DP[i] <= W)ats=i;

    cout<<ats;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279

#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ld INF = 1e9+123;
#define VEC(type,A,N) vector<type> A(N+10)
#define VECi(type,A,N,i) vector<type> A(N+10,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N+10,vector<type>(M+10))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N+10,vector<type>(M+10,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    ll N,K;
    cin>>N>>K;
    cout<<min((N%K),K-(N%K));
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


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

int main() {
	int i;
	cin >> i;
	i %= 10;
	switch (i) {
		case 0:
		case 1:
		case 6:
		case 8:
			cout << "pon";
			break;
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
			cout << "hon";
			break;
		case 3:
			cout << "bon";
			break;
	}
	return 0;
}

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

char tmp[105];
int w[205][205];
int vs[205];

int N;

int dfs(int x){
    if(x == N) return 1;
    if(vs[x]) return 0;
    vs[x] = 1;
    for(int i=0; i<=N; i++){
        if(!w[x][i]) continue;
        int k = dfs(i);
        if(k){
            w[x][i]--;
            w[i][x]++;
            return 1;
        }
    }
    return 0;
}

int main(){
    int H, W;
    scanf("%d%d", &H, &W);
    N = H+W+1;
    int s_x=-1, s_y=-1, t_x=-1, t_y=-1;
    for(int i=1; i<=H; i++){
        scanf("%s", &tmp[1]);
        for(int j=1; j<=W; j++){
            if(tmp[j] == 'o'){
                w[i][H+j]++;
                w[H+j][i]++;
            } else if(tmp[j] == 'S'){
                w[0][i] += 1e9;
                w[0][H+j] += 1e9;
                s_x = i, s_y = j;
            } else if(tmp[j] == 'T'){
                w[H+j][N] += 1e9;
                w[i][N] += 1e9;
                t_x = i, t_y = j;
            }
        }
    }
    if(s_x == t_x || s_y == t_y){
        printf("-1");
        return 0;
    }
    int res = 0;
    while(1){
        for(int i=0; i<=N; i++) vs[i] = 0;
        int found = dfs(0);
        res += found;
        if(!found) break;
    }
    printf("%d", res);
    return 0;
}


Measured memory_bytes: 384
n = int(input())
def make_divisors(n):
    divisors = []
    # 試し割りで、かつ積でnを作るときの相方も同時に追加してる
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
ans = 0
for i in range(1,n+1,2):
    if len(make_divisors(i)) == 8:
        ans += 1
print(ans)
        
    

Measured memory_bytes: 9376
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        MultipleOf2019 solver = new MultipleOf2019();
        solver.solve(1, in, out);
        out.close();
    }

    static class MultipleOf2019 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            char[] chars = in.next().toCharArray();
            long[] count = new long[2019];
            count[0] = 1;

            int base = 1;
            int pre = 0;
            for (int i = chars.length - 1; i >= 0; i--) {
                int a = Character.getNumericValue(chars[i]);
                int current = (a * base + pre) % 2019;
                count[current]++;
                pre = current;
                base = (base * 10) % 2019;
            }
            long ans = 0;
            for (long c : count) {
                ans += (c * (c - 1) / 2);
            }
            out.append(String.valueOf(ans));
        }

    }
}



Measured memory_bytes: 40840
H, W = map(int, input().split())
S = [input() for _ in range(H)]
A = []
for i in range(H):
    A.append([0]*(W))
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            A[i][j] = '#'
            if i-1 >= 0 and j-1 >= 0 and A[i-1][j-1] != '#' : A[i-1][j-1] +=1 
            if i-1 >= 0 and A[i-1][j] != '#' : A[i-1][j] +=1 
            if i-1 >= 0 and j+1 < W and A[i-1][j+1] != '#' : A[i-1][j+1] +=1 
            if j-1 >= 0 and A[i][j-1] != '#' : A[i][j-1] +=1 
            if j+1 < W and A[i][j+1] != '#' : A[i][j+1] +=1 
            if i+1 < H and j-1 >= 0 and A[i+1][j-1] != '#': A[i+1][j-1] +=1 
            if i+1 < H and A[i+1][j] != '#': A[i+1][j] +=1 
            if i+1 < H and j+1 < W and A[i+1][j+1] != '#' : A[i+1][j+1] +=1 
for i in range(H):
    line = []
    for j in range(W):
        line.append(str(A[i][j]))
    print(''.join(line))

Measured memory_bytes: 3188
s = input()
p = s[2:-1]
if s[0] == 'A':
	if ('C' in p) and (p.count('C') == 1):
		s = s.replace('C', '')
		s = s.lstrip('A')
		if s.islower():
			print('AC')
			exit()
print('WA')


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a%3==0||b%3==0||(a+b)%3==0)cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
    return 0;
}



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

#define maxn 100010
#define INF 1e15
#define ff first
#define ss second
#define endl '\n'
typedef long long ll;

int n;
int v[111], p[111];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); 
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> v[i];
  for (int i = 0; i < n; ++i) cin >> p[i];
  int mx = INT_MIN;
  for (int mask = 0; mask < (1 << 20); ++mask) {
    int sumv = 0, sumc = 0;
    for (int i = 0; i < 20; ++i) {
      if (mask & (1 << i)) sumv += v[i], sumc += p[i];
    }
    mx = max(sumv - sumc, mx);
  }
  cout << mx << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;
using ll = long long ;
ll rec(ll x){
    if(x == 1) return 1;
    return 2 * rec(x / 2) + 1;
}
 
int main(){
    ll h;
    scanf("%lld", &h);
    printf("%lld\n", rec(h));
}

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

typedef long long LL;
typedef unsigned long long ULL;

#define debug printf("fuck %d\n", __LINE__);

inline LL read() {
	LL res = 0, bo = 1; char ch = getchar();
	while(ch < '0' || ch > '9') { if (ch == '-') bo = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9') { res = (res << 1) + (res << 3) + ch - '0'; ch = getchar(); }
	return bo * res;
}

template<typename T> void read(T &x) { x = read(); }
template<typename T, typename ...Argv> void read(T &a, Argv &...argv) { read(a); read(argv...); }

const int N = 6e5 + 10, p = 998244353;
int fac[N], inv[N];

int ksm(int x, int y) {
	int res = 1; 
	for (; y; y >>= 1, x = 1LL * x * x % p) if (y & 1) res = 1LL * res * x % p;
	return res;
}

void init(int n) {
	fac[0] = 1;
	for (int i = 1; i <= n; ++ i) fac[i] = 1LL * fac[i - 1] * i % p;
	inv[n] = ksm(fac[n], p - 2);
	for (int i = n - 1; ~i; -- i) inv[i] = 1LL * inv[i + 1] * (i + 1) % p;
}

int C(int n, int m) { return m > n || m < 0 || n < 0 ? 0 : 1LL * fac[n] * inv[m] % p * inv[n - m] % p; }

int main() {
	int n = read(), k = read(); init(N - 1);
	if (n > k) { puts("0"); return 0; }
	int ans = 0;
	for (int r = 0; r <= k; ++ r) {
		int b = k - r;
		if (r < b) continue;
		if (r == b) -- b;
		(ans += (C(r + b, r) - C(r + b, r * 2 - n + 1) + p) % p) %= p;
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin>>s;
  forv(i,s){
    forn(j,i){
      if(s[j]=='C' && s[i]=='F'){
	cout<<"Yes"<<endl;
	return 0;
      }
    }
  }
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 764
/*input
oder atc
*/

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

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 100001
#define M 1000000007
#define ll long long
#define vll vector<long long>
#define vi vector<int>
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<long long,long long> >
#define pb push_back
#define pf pop_front
#define mp make_pair
#define F first
#define S second


ll power(ll a,ll m,ll mod){
	ll ans=1;
	while(m){
		if(m%2){
			ans*=a;
			ans%=(mod);
		}
		a=(a*a)%(mod);
		m>>=1;
	}
	return ans;
}


void init(long long* a,long long n,long long val){
	for(long long i=0;i<n;i++)
		a[i]=val;
}



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);	
	ll i,j;
	//cin>>t;
	string s,t;
	cin>>s>>t;
	cout<<t<<s<<endl;
	return 0;
}




Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int n;
	float x[11];
	string u[11];
	cin >> n;
	float sumj, sumb;
	sumj = 0; sumb = 0;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
		cin >> u[i];
		if (u[i] == "JPY") {
			sumj += x[i];
		}
		else {
			sumb += x[i];
		}
	}
	float bsum;
	bsum = sumj + 380000 * sumb;
  cout << bsum;
	return 0;
}

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

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

int main(){
    int n, ans=0; cin >> n;
    vector<int> a(n), l(n+1), r(n+1);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++){
        if(i) l[i+1] = gcd(l[i], a[i-1]);
        r[n-1-i] = gcd(r[n-i], a[n-1-i]);
    }
    for(int i = 0; i < n; i++) ans = max(ans, gcd(l[i+1], r[i+1]));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main(){
  int64_t N, A, B;
  cin >> N >> A >> B;
  int64_t ans=N/(A+B);
  ans*=A;
  if(N%(A+B)<=A){
    ans+=N%(A+B);
  }
  else ans+=A;
  cout << ans << endl;
  return 0;
}

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

using ll = long long;

constexpr int INF = 1e9;

vector<int> bfs(vector<vector<int>> const& g, int s) {
    int const n = g.size();
    vector<int> d(n, INF);
    d[s] = 0;
    queue<int> que;
    que.push(s);
    while(!que.empty()) {
        int v = que.front();
        que.pop();
        for(auto to : g[v]) {
            if(d[to] != INF) {
                continue;
            }
            d[to] = d[v] + 1;
            que.push(to);
        }
    }
    return d;
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<vector<int>> g(N);
    for(int i = 0; i < N - 1; ++i) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vector<vector<int>> vs(N);
    vector<int> sz(N);
    for(int i = 0; i < N; ++i) {
        auto d = bfs(g, i);
        for(int j = 0; j < N; ++j) {
            if(d[j] > K) {
                vs[i].push_back(j);
                sz[i]++;
            }
        }
    }

    int res = 0;
    while(true) {
        auto it = max_element(sz.begin(), sz.end());
        if(*it == 0) {
            break;
        }
        int v = it - sz.begin();
        sz[v] = 0;
        for(auto w : vs[v]) {
            sz[w]--;
        }
        vs[v].clear();
        res++;
    }
    cout << res << endl;
}


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

using namespace std;

typedef long long ll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)

int n;
ll k;
ll a[252521];

ll sortl[252521], sortr[252521];
ll tmp[252521];

ll solve(int l,int r){
  if(r-l==1){
    sortl[l] = a[l];
    sortr[l] = a[l];
    return (ll)(a[l]>=0);
  }
  int mid = (l+r)/2;
  // divide
  ll ret = solve(l,mid) + solve(mid,r);
  // merge
  int lena = mid-l;
  int lenb = r-mid;
  // conquer
  int tailr = r-1;
  FOR(i,l,mid){
    while(tailr >= mid){
      if(sortl[tailr] + sortr[i] >= 0)tailr--;
      else break;
    }
    ret += (r-1) - tailr;
  }
  // merge sort
  {
    // left
    ll sum = 0;
    FOR(i,l,mid)sum += a[i];
    int headl = l, headr = mid;
    REP(i,r-l){
      if(headl<mid && (headr>=r || sortl[headl] < sum+sortl[headr])){
        tmp[i] = sortl[headl++];
      }else{
        tmp[i] = sum+sortl[headr++];
      }
    }
    REP(i,r-l){
      sortl[l+i] = tmp[i];
    }
  }
  {
    // right
    ll sum = 0;
    FOR(i,mid,r)sum += a[i];
    int headl = l, headr = mid;
    REP(i,r-l){
      if(headl<mid && (headr>=r || sum+sortr[headl] < sortr[headr])){
        tmp[i] = sum+sortr[headl++];
      }else{
        tmp[i] = sortr[headr++];
      }
    }
    REP(i,r-l){
      sortr[l+i] = tmp[i];
    }
  }
  return ret;
}

int main(){
  scanf("%d%lld",&n,&k);
  REP(i,n)scanf("%lld",a+i);
  REP(i,n)a[i] -= k;
  ll ans = solve(0,n);
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 7296
a,b = map(int,input().split())
hachi = []
ju = []
kane = -1

for i in range(1250):
    if (i*8)//100 == a:
        hachi.append(i)
    if i//10 == b:
        ju.append(i)

for j in range(1250):
    if (1250-j in hachi)and(1250-j in ju):
        kane = 1250-j

print(kane)

Measured memory_bytes: 8980
#include <iostream>
using namespace std;
int main(){
  int x, y, tmp;
  for(; ; ){
    cin >> x >> y;
    if(x == 0 && y == 0){
      return 0;
    }
    if(x > y){
      tmp = x;
      x = y;
      y = tmp;
    }
    cout << x << " " << y << endl;
  }
  return 0;
}



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

using namespace std;
typedef long long ll;
const int N = 101 , W=1e5+1;
ll dp[N][W];
ll v[N] , w[N];
ll  n , cap;
int main()
{
    cin>> n >> cap ;
    memset(dp , 0 , sizeof dp);
    for(int i = 1 ; i <=n ; i++)
    {
        cin >> w[i] >> v[i];
    }
    for(int i = 1 ; i <=n ;i++ )
    {
        for(int weight=0 ; weight <=cap ;weight++)
        {
            dp[i][weight]=dp[i-1][weight];
            if(w[i]<=weight)
            {
                dp[i][weight]=max(dp[i][weight] , dp[i-1][weight-w[i]]+v[i]);
            }
        }
    }
    cout << dp[n][cap] << "\n";
    return 0;
}


Measured memory_bytes: 82544