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

#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i,a) for (auto i = rbegin(a); i != rend(a); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using namespace std;
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
ll mod = static_cast<ll>(1e9 + 7);
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }
template<class A, int N, class T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

ll x;
void solve() {
    cin >> x;

    auto res = x / 500;
    auto res2 = (x - 500 * res) / 5;
    cout << 1000 * res + 5 * res2 << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}


signed main(void) {
    int i,j;
    int n,m;
    cin >> n >> m;
    vi fac;
    for(int i = 1; i * i <= m; i++)if(m % i == 0){
        fac.push_back(i);
        if(i * i < m)fac.push_back(m/i);
    }
    int ans = 0;
    rep(i,fac.size())if(fac[i] >= n){
        ans = max(ans,m/fac[i]);
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
// C++ program to find LCM of two numbers  
#include <iostream>
#include <vector>
#include <numeric>

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPONE(i, n) for(int i = 1; i < n; i++)
#define ld long double
#define ll long long

using namespace std; 

// Driver program to test above function  
int main()  
{  
    int n; cin >> n;
    vector<ll> time;
    ll t;
    REP(i, n) {
        cin >> t;
        time.push_back(t);
    }

    ll ans = time[0];

    REPONE(i, n) {
        // ans = ((ld)ans * (ld)time[i]) / gcd((ll)ans, (ll)time[i]);
        ans = lcm(ans, time[i]);
    }

    cout << (ll)ans << endl;

    return 0;  
}  

Measured memory_bytes: 3608
import java.util.*;

class Main
{
  public static void main(String[] args)
  {
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int ans[] = new int[n];
    
    for(int i = 0; i < n; i++)
    {
      ans[i] = 0;
    }
    
    for(int i = 0; i < n-1; i++){
      ans[stdIn.nextInt()-1] ++;
    }
    
    for(int i = 0; i < n; i++){
      System.out.println(ans[i]);
    }
  }
}


Measured memory_bytes: 60488
# include <stdio.h>
int main(void){
    int a,b,c,x;
    int count = 0;
    scanf("%d %d %d",&a,&b,&c);
    for(x = a;x <= b;x++){//a??????b?????§?????????
        if(c % x == 0){//???????????§??????????????????????????????????´???°??????
            count = count + 1;

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












    return 0;
}

Measured memory_bytes: 596
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <vector>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(a) (a).begin(), (a).end()

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

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

int main()
{
  int n;
  cin >> n;
  cout << lcm(2, n) << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		int k = stdIn.nextInt();
		
		int[] p = new int[n];
		
		for(int i = 0; i < n; i++) {
			p[i] = stdIn.nextInt();
		}
		
		Arrays.parallelSort(p);
		
		long cnt = 0;
		
		for(int i = 0; i < k; i++) {
			cnt += p[i];
		}
		
		System.out.println(cnt);
		
	}

}


Measured memory_bytes: 38748
n,k = map(int,input().split())

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

dp = [float("inf") for i in range(n)]

dp[0] = 0
for idx, h in enumerate(hl):
    for i in range(1,k+1):
        if i + idx < n:
            dp[idx+i] = min(dp[idx+i], dp[idx]+ abs(hl[idx]-hl[i+idx]))


print(dp[n-1])

Measured memory_bytes: 57056
using System;

class alds16a
{
    struct lcg
    {
        public int cur;
        int a;
        int b;int c;
        public void next()
        {
            cur = (a * cur + b) % c;
        }
        public lcg(int a, int b, int c, int cur)
        {
            this.a = a;
            this.b = b;
            this.c = c;
            this.cur = cur;
        }
    }
    static void Main()
    {
        while (true)
        {
            string[] input = Console.ReadLine().Split(' ');
            if (input[0] == "0") break;
            int n = int.Parse(input[0]);
            lcg rand = new lcg(int.Parse(input[1]), int.Parse(input[2]), int.Parse(input[3]), int.Parse(input[4]));
            int c=0;
            string[] tgt = Console.ReadLine().Split(' ');
            try
            {
                for (int i = 0; i < n; i++)
                {
                    int t = int.Parse(tgt[i]);
                    if (i > 0)
                    {
                        c++;
                        rand.next();
                    }
                    while (true)
                    {
                        if (t == rand.cur) break;
                        c++;
                        if (c > 10000) throw new Exception();
                        rand.next();
                    }
                }
                Console.WriteLine(c);
            }
            catch
            {
                Console.WriteLine(-1);
            }
        }
    }
}

Measured memory_bytes: 5908
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
int main(void){
    string str;
    cin>>str;
    int i=0;
    for(int b=0;b < str.length();b++){
        i=i+int(str[b]-48);
    }
    if(i%9==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3696
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from fractions import gcd
e = enumerate

sys.setrecursionlimit(10**7)
H = int(input())

cnt = 1
phase = 1
while H>1:
    H //= 2
    cnt += phase * 2
    phase *= 2

print(cnt)


Measured memory_bytes: 5696
#include<iostream>
#include<cmath>
#include<string>
using namespace std;
const int MAX=1000001;

int main(){
    int n,m;cin>>n>>m;
    int city[51];
    for(int i=1;i<=n;i++) city[i]=0;
    for(int i=0;i<m;i++){
        int a,b;cin>>a>>b;
        city[a]++;
        city[b]++;
    }

    for(int i=1;i<=n;i++){
        cout<<city[i]<<endl;
    }
    
}    

Measured memory_bytes: 256
n = int(input())
person = [[] for _ in range(n)]

for p in range(n):
    num = int(input())
    for i in range(num):
        array = list(map(int, input().split()))
        array[0] -= 1
        person[p].append(array)



honest = 0
for i in range(2**n):
    bi_num = format(i, 'b').zfill(n)
    q = 0
    for k in bi_num:
        if k == '1':
            q += 1
    flg = False
    for man in range(n):
        if bi_num[man] == '0':
            continue
        else:
            for hito, t in person[man]:
                if t == 0:
                    if bi_num[hito] == '0':
                        continue
                    else:
                        flg = True
                        break
                elif t == 1:
                    if bi_num[hito] == '1':
                        continue
                    else:
                        flg = True
                        break
    if flg is True:
        continue
    else:
        if honest < q:
            honest = q

print(honest)



Measured memory_bytes: 3188
#include <iostream>
#include <string>
using namespace std;
int main() {
    string str; cin >> str;
    string::reverse_iterator rit = str.rbegin();
    while (rit != str.rend()) {
        cout << *rit;
        ++ rit;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1172
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <math.h>
#include <stdlib.h>
#include <algorithm>

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

template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true; } return false; }

//INT_MAX	2,147,483,647 = 2*1.0e9

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

  float ans = 0;
  for(int i = 0 ; i < N; i++){
    float x;
    string u;
    cin >> x >> u;
    if(u[0] == 'J') ans += x;
    else ans += x * 380000;
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        long[] list = new long[n];

        for (int i = 0; i < n; i++) {
            list[i] = sc.nextLong();
        }
        Arrays.sort(list);

        int ans = 0;
        int count = 1;
        long lastV = list[0];

        for (int i = 1; i < n; i++) {
            if (list[i] != lastV) {
                lastV = list[i];
                if (count % 2 == 1) {
                    ans++;
                }
                count = 0;
            }
            count++;
        }

        if (count % 2 == 1) {
            ans++;
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 52596
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << '\n';
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    int N; cin >> N;
    
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        int a; cin >> a;
        if (i & 1) {
            if (a & 1) ans++;
        }
    }

    cout << ans << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3644
#include <cstdio>
#include <algorithm>

using namespace std;

//???????????????????????¢??° write ?????????

void write( int A[], int N ){

    for( int i = 0 ; i < N ; i++ ){

        if( i > 0 ){

            printf(" ");
            
        }

        printf("%d", A[i] );

    }

    printf("\n");

}

//Bubble Sort?????????

void bubble_sort( int A[], int N ){

    int flag, j, buffer, number;

    flag = 1;
    number = 0;

    while( flag == 1 ){

        flag = 0;

        for( j = N-1 ; j > 0 ; j-- ){

            if( A[j] < A[j-1] ){

                buffer = A[j];

                A[j] = A[j-1];
            
                A[j-1] = buffer;

                flag = 1;

                number++;

            }

        }

    } 

    write( A, N );
    printf("%d\n", number );

}

int main(){

    int n;

    scanf("%d", &n );

    int A[n];

    for( int i = 0; i < n ; i++ ){

        scanf( "%d" , &A[i]  );

    }

    bubble_sort( A, n);

}

Measured memory_bytes: 2728
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second

constexpr int mod = 1000000007;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

// value
int N;
int a[100010];

void solve() {

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

	bool ans = true;

	for (int i = 0; i < 32; i++) {
		int cnt = 0;
		for (int j = 0; j < N; j++) {
			if ((a[j] >> i) & 1) cnt++;
		}
		if (cnt % 2) {
			ans = false;
			break;
		}
	}

	cout << (ans ? "Yes" : "No") << endl;

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}


Measured memory_bytes: 640
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt(),k=sc.nextInt();
    int val=1;
    for(int i=0;i<n;i++){
      if(val>k){
        val+=k;
      }else{
        val=2*val;
      }
    }
    System.out.println(val);
  }
}

Measured memory_bytes: 22608
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

const MOD: i64 = 1e9 as i64 + 7;

fn main() {
    let n = read();
    let a: Vec<usize> = readnc();
    let mut v: Vec<usize> = vec![0; n];
    for i in 0..n {
        v[a[i]] += 1;
    }
    let mut ans = 1;
    for i in 0..n/2 {
        ans *= 2;
        ans %= MOD;
    }

    for i in 0..n {
        if i % 2 == n % 2 {
            if v[i] != 0 {
                ans = 0;
            }
        } else {
            if i == 0 && v[i] == 1 {
            } else if i >= 1 && v[i] == 2{
            } else {
                ans = 0;
            }
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 6396
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
using namespace std;
#define ll long long

int main() {
  int n, k;
  cin >> n >> k;
  ll h[100000];
  for(int i=0;i<n;++i) {
    cin >> h[i];
  }

  sort(h, h+n);
  ll minSumH = 1000000000;

  for(int i=0;i<n-k+1;++i) {
    minSumH = min(minSumH, h[i+k-1] - h[i]);
  }

  cout << minSumH << endl;
  return 0;
}

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

#define int long long

signed main() {
    int h, w; cin >> h >> w;
    vector<string> a(h);
    for(int i = 0; i < h; i++) cin >> a[i];

    vector<bool> row(h, false);
    vector<bool> col(w, false);
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(a[i][j] == '#') {
                row[i] = true;
                col[j] = true;
            }
        }
    }

    for(int i = 0; i < h; i++) {
        if(row[i]) {
            for(int j = 0; j < w; j++) {
                if(col[j]) {
                    cout << a[i][j];
                }
            }
            cout << endl;
        }
    }

}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import numpy as np


def solve(A: "List[int]"):
    if A[0]+A[1]+A[2]>21:
        print('bust')
    else:
        print('win')
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [int(next(tokens)) for _ in range(3)]  # type: "List[int]"
    solve(A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 12404
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<bitset>
typedef long long ll;
#define pi 3.1415926535897931159979635

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a,ans=0;
    string b,c;
    cin>>b>>c;
    a=b.size();
    for(int i=0; i<a; i++)
    if(b[i]!=c[i]) ans++;
    cout<<ans<<"\n";
    
    

    return 0;
}

Measured memory_bytes: 3784
n,tt=map(int,input().split())
c=[0]*n
t=[0]*n
ans=1001
for i in range(n):
  c[i],t[i]=map(int,input().split())
  if (t[i]<=tt):
    ans=min(ans,c[i])
    
print(ans if (ans<1001) else "TLE")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	vector<string> a(n),b(m);
	rep(i,n) cin >> a.at(i);
	rep(i,m) cin >> b.at(i);
	bool ok = false;
	rep(i,n - m + 1){
		rep(j,n - m + 1){
			bool flg = true;
			rep(k,m){
				if(a[i + k].substr(j,m) != b[k]) flg = false;
			}
			if(flg) ok = true;
		}
	}
	if(ok) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cassert>
#include <unordered_set>
#include <set>
#include <bitset>
#include <memory.h>
#include <algorithm>
#include <cmath>
#include <iomanip>
 
using namespace std;
 
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
 
const int MOD = (int) 1e9 + 7;
 
long long fact[(int)2e6 + 5];
long long ob[(int)2e6 + 5];
 
long long bin_pow(long long a, long long b) {
    if (b == 0)
        return 1;
 
    long long ans = bin_pow(a, b / 2);
    ans = ans * ans % MOD;
    if (b % 2)
        ans = ans * a % MOD;
 
    return ans;
}
 
long long C(int n, int k) {
    // cout << n << " " << k << "\n";
    // cout << fact[n] << " " << ob[k] << " " << ob[n - k] << "\n";
 
    return fact[n] * ob[k] % MOD * ob[n - k] % MOD;
}
 
int main() {
    // freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
    fact[0] = 1;
    ob[0] = 1;
    for (int i = 1; i <= (int) 2e6; ++i) {
        (fact[i] = fact[i - 1] * i) %= MOD;
        ob[i] = bin_pow(fact[i], MOD - 2);
    }
 
    long long x, y;
    cin >> x >> y;
 
    if ((x + y) % 3 || (x + y) / 3 > x || (x + y) / 3 > y) {
        cout << "0\n";
        return 0;
    }
 
    cout << C((x + y) / 3, x - ((x + y) / 3)) << "\n";
}


Measured memory_bytes: 31488
;; F - Tree and Constraints

(defun main ()
  (let* ((n (read))
         (ab (loop repeat (1- n) collect (cons (read) (read))))
         (m (read))
         (uv (loop repeat m collect (cons (read) (read)))))
    (princ (solve n ab m uv))))

(defun make-adjacency-list (n edges)
  (let ((adj (make-array n :initial-element nil)))
    (loop for i from 0
          for edge in edges
          for a = (1- (car edge))
          for b = (1- (cdr edge))
          do (setf (aref adj a) (cons (cons b i) (aref adj a)))
             (setf (aref adj b) (cons (cons a i) (aref adj b))))
    adj))

(defun find-paths (m uv n adj)
  (labels ((dfs (u v parent)
             (if (eql u v)
                 (empty-set (1- n))
                 (loop for (a . i) in (aref adj u)
                       for p = (and (not (eql a parent))
                                    (dfs a v u))
                       when p do (set-add p i)
                                 (return p)))))
    (loop for (u . v) in uv
          collect (dfs (1- u) (1- v) nil))))

(defun coloring (n paths union sign)
  (if paths
      (+ (coloring n (cdr paths) union sign)
         (coloring n (cdr paths) (set-union union (car paths)) (- sign)))
      (* sign (ash 1 (- (1- n) (count-set-elem union))))))

(defun solve (n ab m uv)
  (let* ((adj (make-adjacency-list n ab))
         (paths (find-paths m uv n adj)))
    (coloring n paths (empty-set (1- n)) 1)))

;; set operations

(defun empty-set (n-elem)
  (make-array n-elem :element-type 'bit :initial-element 0))

(defun set-add (set elem)
  (setf (aref set elem) 1))

(defun set-union (set1 set2)
  (loop with result = (make-array (array-dimension set1 0) :element-type 'bit)
        for b1 across set1
        for b2 across set2
        for i from 0
        do (setf (aref result i) (logior b1 b2))
        finally (return result)))

(defun count-set-elem (set)
  (count 1 set))

(main)


Measured memory_bytes: 69476
#include <bits/stdc++.h>
using namespace std;
typedef string str;
typedef long double ld;

typedef long long ll;
//typelower_bounddef priority_queue<long long> pq;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
//typedef set<int>::iterator sit;
//typedef map<int,int>::iterator mit;
//typedef vector<int>::iterator vit;


#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repn(i,a,b) for(int i=(a);i<=(b);i++)
#define repin(i,a,b,x) for(int i=(a);i<(b);i+=x)
#define repnin(i,a,b,x) for(int i=(a);i<=(b);i+=x)
#define MAX(a,blower_bound) a=max(a,b)
#define MIN(a,b) a=min(a,b)

int main() {

    int n;
    cin >> n;
    ll minv=0;
    ll ans=0;
    rep(i,0,n){
        ll a;
        cin >> a;
        if(minv!= max(minv,a)){
            minv= a;
        }
        else{
            ans+= minv-a;
        }
    }
    cout << ans;
}


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

int main(){
    int H,W,K;
    cin >> H >> W >> K;
    char c[H][W];
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> c[i][j];
        }
    }
    int ans =0;
    for(int u = 0; u < (1<<(H+W)); u++){
        int w = u%(1<<W);
        int h = u/(1<<W);
        int count = 0;
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if(c[i][j] == '#' && !((1<<i)&h) && !((1<<j)&w)){
                    count++;
                }
            }
        }
        if(count == K) ans ++;
    }
    cout << ans << endl;
        
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define mid (tl+tr)/2
#define mod 1000000007
#define fain(arr) for(int i=0;i<n;i++)cin>>arr[i];
#define all(x) x.begin(),x.end()
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define bugv(n1) if(DEBUG)cout<<#n1<<" is "<<n1<<'\n';
#define buga(A) cout<<#A<<" is :"<<endl ; for(auto x:A)cout<<x<<" "; cout<<endl;
#define FILE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define endl '\n'
#define ll long long 
#define pii pair<int,int>
#define pll pair<long long ,long long >
#define pi acos(-1)
#define sz(x) ((int)x.size())
#define clr(x) memset(x, 0, sizeof(x))
#define init(x, a) memset(x, a, sizeof(x))
#define DEBUG true
using namespace std;

 


int main() {
  // FILE;
  SPEED;
  
  int n;
  cin>>n;
  
  int arr[n];
  fain(arr);
  int dp[n];
  
  dp[n-1]=0;
  dp[n-2]=abs(arr[n-1]-arr[n-2]);

  for(int i=n-3;i>=0;i--){
    int a1 = abs(arr[i]-arr[i+2])+dp[i+2];
    int a2 = abs(arr[i]-arr[i+1])+dp[i+1];
    dp[i]=min(a1,a2);
  }

  cout<<dp[0]<<endl;

}

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

int main() {
    ll x;
    cin >> x;
    int a = x / 500;
    x -= a * 500;
    int b = x / 5;
    cout << 1000 * a + 5 * b << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

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

int a[300015];

signed main() {
	int N;
	
	cin >> N;
	REP(i, 3*N) {
		cin >> a[i];
	}

	sort(a, a + 3*N);

	int ans = 0;

	for (int i = N;i < 3 * N;i+=2) {
		ans += a[i];
	}

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

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

int main()
{
    ll n,W,i,j,sum=0;
    cin>>n>>W;

    ll A[n+1][2];
    for(i=1;i<=n;i++)
    {
        cin>>A[i][0]>>A[i][1];
        sum+=A[i][1];
    }

    ll dp[sum+1],temp[sum+1];

    for(i=1;i<=sum;i++)
        dp[i]=99999999999999;
    dp[0]=0;

    for(j=1;j<=n;j++)
    {
        for(i=1;i<=sum;i++)
        {
            if(i>=A[j][1])
                temp[i]=min(dp[i],dp[i-A[j][1]]+A[j][0]);
            else
                temp[i]=dp[i];
        }

        for(i=1;i<=sum;i++)
            dp[i]=temp[i];
    }
    
    for(i=sum;i>=0;i--)
    {
        if(dp[i]<=W)
        {
            cout<<i<<"\n";
            break;
        }
    }
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC____098
{
    class Program
    {
        static void Main(string[] args)
        {
            int A, B,max;

            var word = Console.ReadLine().Split(' ');

            A = int.Parse(word[0]);
            B = int.Parse(word[1]);

            max = A + B;

            if (A - B > max)
                max = A - B;

            if (A * B > max)
                max = A * B;
            
                    
            Console.WriteLine(max);

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
from collections import deque
s = list(input())
s = deque(s)
cnt = 0
while len(s) > 1:
    left = s.popleft()
    right = s.pop()
    if left == right:continue
    if left != 'x' and right != 'x':
        print(-1)
        exit()

    if left == 'x':
        s.append(right)
    else:
        s.appendleft(left)
    cnt += 1
print(cnt)

Measured memory_bytes: 4916
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>

using namespace std;

typedef long long ll;

int k,n;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
	
	cin >> n >> k;
	
	cout << n-k+1 << '\n';
    return 0;
}


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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fill(a,v) memset(a,v,sizeof(a))
#define d1(a) cout << a << "\n"
#define d2(a,b) cout << a << " " << b << "\n"
#define d3(a,b,c) cout << a << " " << b << " " << c << "\n"
#define d4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << "\n"
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

int32_t main(){
	fast;
	int n;
	cin >> n;
	int ans = 0;
	map<int,int>m;
	
	int a[n];
	f(i,0,n){
		cin >> a[i];
		ans += m[a[i]];
		m[a[i]]++;
	}
	
	f(i,0,n){
		cout << ans - m[a[i]] + 1 << "\n";
	}
}


Measured memory_bytes: 11136
# include<bits/stdc++.h>
using namespace std ;
int main () {
int N , M , C ; cin >> N >> M >> C ;
vector <int > B ( M );
for ( int i = 0; i < M ; ++ i ) {
cin >> B [ i ];
}
vector < vector <int >> A (N , vector <int >( M ));
for ( int i = 0; i < N ; ++ i ) {
for ( int j = 0; j < M ; ++ j ) {
cin >> A [ i ][ j ];
}
}
int ans = 0;
for ( int i = 0; i < N ; ++ i ) {
int sum = 0;
for ( int j = 0; j < M ; ++ j ) {
sum+= A [ i ][ j ] * B [ j ];
}
if ( sum + C > 0) {
ans++;
}
}
cout << ans << endl ;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define int ll
#define pb push_back
#define mp make_pair
using pii = pair<int,int>;
const int N = 4005;
const int Inf = 1e17+7;
#ifndef M_PI
#define M_PI 3.1415926535
#endif
#define F first
#define S second

void io()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cerr.tie(NULL);
//		cout << setprecision(10) << fixed;
}

int n, k, pf[3][N];

string s;

signed main()
{
	io();
	cin >> n >> s;
	for (int i = 1; i <= n; ++i)
	{
		pf[0][i] = pf[0][i - 1] + (s[i - 1] == 'R');
		pf[1][i] = pf[1][i - 1] + (s[i - 1] == 'G');
		pf[2][i] = pf[2][i - 1] + (s[i - 1] == 'B');
	}
	int ans = 0;
	for (int i = 0; i < n - 2; ++i)
	{
		for (int j = i + 1; j < n - 1; ++j)
		{
			if (s[i] == s[j])
				continue;
			int d = (j - i);
			int cnt;
			if ((s[i] != 'R') && (s[j] != 'R'))
				cnt = 0;
			if ((s[i] != 'G') && (s[j] != 'G'))
				cnt = 1;
			if ((s[i] != 'B') && (s[j] != 'B'))
				cnt = 2;
			if (!(j + d >= n) && (s[i] != s[j + d]) && (s[j] != s[d + j]))
			{
				--ans;
			}
			ans += pf[cnt][n] - pf[cnt][j + 1];
		}
	}
	cout << ans;
}

Measured memory_bytes: 3700
def main():
    N, M, X, Y = map(int, input().split())
    x = list(map(int, input().split()))
    y = list(map(int, input().split()))

    for i in range(max(x)+1, min(y)+1):
        if X < i and i <= Y:
            print('No War')
            exit()

    print('War')


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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;
}

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

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

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

  vector<ll> x(N);
  rep(i, N) cin >> x[i];

  vector<ll> diff(N);
  rep(i, N) { diff[i] = abs(X - x[i]); }

  ll ans = 0;
  rep(i, N) { ans = gcd(ans, diff[i]); }

  cout << ans << endl;
}

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

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var sp = Console.ReadLine().Split(' ');
            var n = int.Parse(sp[0]);
            var k = int.Parse(sp[1]);
            sp = Console.ReadLine().Split(' ');
            var p = sp.Select(i => int.Parse(i)).OrderBy(x=>x).ToArray();

            int res = 0;
            for(int i = 0; i<k; i++)
            {
                res += p[i];
            }

            Console.WriteLine(res);

            Console.Out.Flush();
        }
    }
}


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


int main()
{
	int mod = 1e9 + 7;
	int n;
	string s;
	cin >> n;
	cin >> s;
	int a[26] = {};
	for (int i = 0; i < n; i++)
	{
		a[s[i] - 'a']++;

	}
	long long ans = 1;
	for (int i = 0; i < 26; i++)
	{
		ans *= (a[i] + 1);
		ans %= mod;
	}
	cout << ans - 1<< endl;

}

Measured memory_bytes: 512
fn main() {
    let v:Vec<u32> = read_vec();
    let n = v[0];
    let k = v[1];
    println!("{}", (1..n).fold(k,|p,_|p*(k-1)));
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main()
{
   cin.tie(0);
   cin.sync_with_stdio(0);
   string s ;
   int counter =0 ;
   cin>>s;
   for(int i =0 ; i< s.size() ; i++){
    if(s[i]== 'a' )
        counter  =counter + 1 ;
    else if(s[i]== 'b' )
        counter  =counter + 2 ;
    else if(s[i]== 'c' )
        counter  =counter + 3 ;
   }

   if(counter == 6) cout<<"Yes"<<"\n";
   else cout<< "No"<<"\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define TRACE
#ifndef TRACE
#define tcout 0 && cout
#else
#define tcout cout << "Debug: "
#endif
#define in inline
#define reg register
#define int long long
#define MAX 20030813
using namespace std;
namespace qwq{
	in int read()
	{
		int o=0;
		int w=1;
		char c=getchar();
		while(c<'0'||c>'9')
		{
			if(c=='-')w=-1;
			c=getchar();
		}
		while(c>='0'&&c<='9')
		{
			o=(o<<3)+(o<<1)+(c^48);
			c=getchar();
		}
		return o*w;
	}
	in void write(int x)
	{
    	if(x>9)write(x/10);
    	putchar(x%10+48);
	}
	in int max(int x,int y)
	{
		return x>y?x:y;
	}
	in int min(int x,int y)
	{
		return x<y?x:y;
	}
}
using namespace qwq;
class Rest
{
public:
	int id;
	string city;
	int mark;
public:
	bool operator<(const Rest&r)const
	{
		if(city==r.city)return mark>r.mark;
		else return city<r.city;
	}
	void init(int i)
	{
		cin>>city;
		mark=read();
		id=i;
	}
}r[105];
int n;
signed main()
{
	n=read();
	for(reg int i=1;i<=n;++i)r[i].init(i);
	sort(r+1,r+n+1);
	for(reg int i=1;i<=n;++i)write(r[i].id),putchar('\n');
	return 0;
}



Measured memory_bytes: 256
import std.stdio, std.algorithm;

void main(){
    foreach(char[] line; lines(stdin)){
        foreach(i; 0..26){
			foreach(ref c; line){
                if('a' <= c && c <= 'z') c = c == 'z' ? 'a' : cast(char)(c + 1);
			}
            if(line.countUntil("the") + 1 || line.countUntil("this") + 1 || line.countUntil("that") + 1){
                line.write;
                break;
            }
        }
    }
}

Measured memory_bytes: 956
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <sstream>
#include <string>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define EPS 1e-14
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) FOR(i, 0, n)
#define PI 2*acos(0.0)
#define ALL(a) (a).begin(),(a).end()
#define DEBUG(x) cout<<#x <<": "<< x << "\n"
#define DEBUG_ARR(a) REP(i, size(a)){ cout << #a << "[" << i << "]: " << a[i] << "\n"; }
const int VX[] = { 0, 1, 0, -1 };
const int VY[] = { 1, 0, -1, 0 };
const long MOD = 1000000007;

int main()
{
	//	--- I/O 高速化 ---
	cin.tie(0);
	ios::sync_with_stdio(false);
	// --- ここまで ---

	int N, l = 0, r = 0;
	string S;
	cin >> N >> S;

	REP(i, S.length())
	{
		switch (S[i])
		{
			case '(': r++; break;
			case ')':
				if (r == 0) l++;
				else r--;
		}
	}

	REP(i, l) cout << "(";
	cout << S;
	REP(i, r) cout << ")";
	cout << "\n";

	return 0;
}


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

int main() {
int n,k;
cin >>n >>k;
vector<int>a(n);
for(int i=0;i<n;i++){
  cin >> a.at(i);
}
vector<int >che(2*10e5+1,0);
for(int i=0;i<n;i++){
  che.at(a.at(i))+=1;
}
int ans =0;
for(int i=0;i<2*10e5+1;i++){
  if(che.at(i)>0)ans++;
}

sort(che.begin(),che.end());
if(ans<=k) cout << 0 << endl;
else {
  int i =0;
  int chea =0;
  while(k<ans){
    if(che.at(i)>0){
      chea+=che.at(i);
      ans--;
    }
    i++;
  }
  cout << chea << endl;
}
}





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

int main() {
  int B;
  cin >> B;
  int A = B + 1;
  int sum = 0;
  rep(i,A){
    rep(n,A){
      rep(m,A){
        sum += gcd(gcd(i,n),m);
      }
    }
  }
  cout << sum << endl;
 
}


Measured memory_bytes: 3612
import scala.io.StdIn.readInt

object Main {
  def fib(a:Int, b:Int, c:Int, n:Int):Int = {
    n match {
      case 0 => a
      case n => fib(a+b, a, b, n-1)
    }
  }

  def main(args: Array[String]) = {
    val n = readInt()
    println(fib(1, 0, 0, n))
  }
}

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

#define ft first
#define sd second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
const int  p=31,po=1,N=1e5+10, M=(ll)1e9+1 ;
const int mod = 1e9+7 ;
vl compute(string s){
        vl has(s.length());
        ll i;

        for(i=0;i<s.length();i++){
            if(i==0){
                has[i]=((s[i]-'a'+1))%mod;
            }
            else
                has[i]=(has[i-1]*p + (s[i]-'a'+1))%mod;
        }
        return has;
}
// vl ed[N],g[N],in(N),vis(N,0),cost(N,0);
vl g[N],vis(N,0),ans;
vl check;
priority_queue<ll,vl,greater<ll>> pq;


int main(){
 ios_base::sync_with_stdio(0);
  ll i;
  vl indegree(5);
  for(i=1;i<=3;i++){
      ll u,v;
      cin >> u >> v;
      indegree[u]++;
      indegree[v]++;
  }
  
  for(i=1;i<=4;i++){
      if(indegree[i]>2){
          cout << "NO";
          return 0;
      }
  }
  cout << "YES";
  return  0;
  return 0;
}

Measured memory_bytes: 3328
#include <iostream>
using namespace std;
int main(void){
    
    string S, T;
    cin >> S >> T;
    
    int cnt = 0;
    
    for(int i = 0; i < S.size(); i++){
        if(S[i] != T[i]) cnt++;
    }
    
    if(cnt > 0){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define w(t) ll t;cin>>t; while(t--)

int main()
{
  
  ll i,j,n;
  cin>>n;
  ll a[n][3],dp[n+1][3]={0};
    
  
  for(i=0;i<n;i++)
  {
    for(j=0;j<3;j++)
    {
      cin>>a[i][j];//>>b[i][j]>>c[i][j];
      //cout<<a[i][j];//<<b[i][j]<<c[i][j];
    }
  }

 for(i=0;i<3;i++)
  {
    
    dp[0][i]=a[0][i];
    //cout<<dp[0][i]<<" ";
    }
    for(i=1;i<n;i++)
    {
      
     dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
     dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
   dp[i][2]=max(dp[i-1][1],dp[i-1][0])+a[i][2];
   }
   
   cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
      
      }





  /*for(i=0;i<n;i++)
  {
    cin>>b[i];
    
    //cout<<a[i];
  }
  for(i=0;i<n;i++)
  {
    s+=a[i];
    k+=b[i];
    if(s==k && a[i]==b[i])
    z+=a[i];
    
    }
    cout<<z<<endl;
 /* for(i=0;i<5;i++)
  {
    s+=a[i]*p;
    //cout<<s;
    }
    if(s<=120)
    flag=1;
    
    if(flag==1)
      cout<<"No"<<endl;
      else
      cout<<"Yes"<<endl;*/
    
  

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

#define ll long long
#define mod 1000000007
#define pb push_back
#define UM unordered_map

int main()
{
  ll a;
  cin>>a;
  ll pro=1,c=a;
  while(c)
  {
    pro*=2;
    c/=2;
  }
  cout<<pro-1<<endl;


}


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

int dh[]={1,-1,0,0};
int dw[]={0,0,1,-1};
int h,w;

bool isrange(int i,int j){
  return 0<=i && i<h && 0<=j && j<w;
}

int main(){
  int k;
  cin>>h>>w>>k;
  vector<string> a(h);
  for(int i=0;i<h;i++) cin>>a[i];
  pair<int,int> s;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(a[i][j]=='S'){
	s.first=i;
	s.second=j;
	i=h;
	j=w;
      }
    }
  }
  queue<pair<pair<int,int>,int>> que;
  vector<vector<int>> reach(h,vector<int>(w,0));
  que.push(make_pair(s,k));
  while(!que.empty()){
    auto st=que.front();
    que.pop();
    auto p=st.first;
    int step=st.second;
    reach[p.first][p.second]=true;
    if(step==0) continue;
    for(int i=0;i<4;i++){
      int toh=p.first+dh[i];
      int tow=p.second+dw[i];
      if(isrange(toh,tow) && !reach[toh][tow] && a[toh][tow]!='#'){
	reach[toh][tow]=1;
	que.push(make_pair(make_pair(toh,tow),step-1));
      }
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(reach[i][j]) que.push(make_pair(make_pair(i,j),k));
    }
  }
  while(!que.empty()){
    auto st=que.front();
    que.pop();
    auto p=st.first;
    int score=st.second;
    if(p.first==0 || p.first==h-1 || p.second==0 || p.second==w-1){
      cout<<ceil(double(score)/k)<<endl;
      return 0;
    }
    for(int i=0;i<4;i++){
      int toh=p.first+dh[i];
      int tow=p.second+dw[i];
      if(!reach[toh][tow]){
	reach[toh][tow]=1;
	que.push(make_pair(make_pair(toh,tow),score+1));
      }
    }

  }
  return 1;
}


Measured memory_bytes: 11152
extern crate core;

use std::fmt;
use std::cmp::{Ordering, min, max};
use std::fmt::{Display, Error, Formatter, Binary, Pointer};
use std::f32::MAX;
use std::ops::{Add, Sub, Mul, Div, Neg, Index, IndexMut};
use std::collections::{BTreeMap, VecDeque, BinaryHeap, BTreeSet};
fn show<T: Display>(vec: &Vec<T>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        print!("[{}", vec[0]);
        for i in 1 .. vec.len() {
            print!(", {}", vec[i]);
        }
        println!("]");
    }
}
fn show2<T: Display>(vec: &Vec<Vec<T>>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        for l in vec {
            show(l);
        }
    }
}
macro_rules! read_line{
    () => {{
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).ok();
        line
    }};
    (delimiter: ' ') => {
        read_line!().split_whitespace().map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (delimiter: $p:expr) => {
        read_line!().split($p).map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (' ') => {
        read_line!(delimiter: ' ')
    };
    ($delimiter:expr) => {
        read_line!(delimiter: $delimiter)
    };
    (' '; $ty:ty) => {
        read_line!().split_whitespace().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
    ($delimiter:expr; $ty:ty) => {
        read_line!($delimiter).into_iter().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
}
macro_rules! read_value{
    () => {
        read_line!().trim().parse().ok().unwrap()
    }
}
macro_rules! let_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}
macro_rules! let_mut_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let mut $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}
fn primes(upper_limit: usize) -> Vec<bool> {
    let mut is_prime = vec![true; upper_limit + 1];
    is_prime[0] = false;
    is_prime[1] = false;
    let mut i = 2;
    while i * i <= upper_limit {
        if is_prime[i] {
            let mut j = i * i;
            while j <= upper_limit {
                is_prime[j] = false;
                j += i;
            }
        }
        i += 1;
    }
    is_prime
}
fn main() {
    let prime = primes(1000000);
    loop {
        let_all!(a: usize, d: usize, n: usize);
        if a == 0 && d == 0 && n == 0{
            return
        }
        let mut count = if prime[a] {1} else {0};
        let mut i = a;
        while count < n {
            i += d;
            if prime[i] {
                count += 1;
            }
        }
        println!("{}", i);
    }
}


Measured memory_bytes: 5032
#1:初期化
N = int(input())
a = []
for i in range(N):
    a.append(list(map(int,input().split())))
dp = [[0]*3 for _ in range (N+1)]
#print(dp, sep="\n")
#print(a, sep="\n")

#2:初期値(元からゼロなので記述無し)

#3:dp実行部(貰うDP)
for i in range(1,N+1):
    for j in range(3):
        for k in range(3):
            if(j == k):
                continue
            dp[i][j] = max(dp[i][j], dp[i-1][k]+a[i-1][j]) #dpは[1]からだが，aは[0]からに注意

#4:出力
dpmax = 0
for i in range(3):
    dpmax= max(dp[N][i], dpmax)
#print(*dp, sep="\n")
print(dpmax)


Measured memory_bytes: 74072
#include <bits/stdc++.h>
#define MAXN 3010
#define pii pair<int, int>
#define pb push_back
typedef long long ll;

using namespace std;

int n, m, dp[MAXN][MAXN];
int b[MAXN][MAXN];
string s, t;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    cin >> s >> t;
    n = s.size();
    m = t.size();
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(s[i - 1] == t[j - 1]){
                dp[i][j] = dp[i - 1][j - 1] + 1;
                b[i][j] = 2;
                continue;
            }
            if(dp[i - 1][j] < dp[i][j - 1]){
                dp[i][j] = dp[i][j - 1];
                b[i][j] = 1;
            } else{
                dp[i][j] = dp[i - 1][j];
                b[i][j] = 0;
            }
        }
    }
    vector<char> v;
    //cout << dp[n][m];
    int i = n, j = m;
    while(i > 0 and j > 0){
        if(b[i][j] == 2){
            v.pb(s[i - 1]);
            i--;
            j--;
        } 
        if(b[i][j] == 1) j--;
        if(b[i][j] == 0) i--;
    }
    reverse(v.begin(), v.end());
    for(auto i : v) cout << i;
}

Measured memory_bytes: 70912