akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<ll, ll> PL;
using graph = vector<vector<int>>;

const double pi = 3.14159265358979323846;
const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n, k; cin >> n >> k;
	vector<ll> a(n);
	int num_m = 0, num_p = 0;
	rep(i,n){
		cin >> a.at(i);
		if(a.at(i) < 0) num_m++;
		else if(a.at(i) > 0) num_p++;
	}
	sort(a.begin(), a.end());
	ll ans = 1;
	if(k % 2 == 1){
		if(a.at(n-1) > 0){
			ans *= a.at(n-1);
			int l = 0, r = n-2;
			for(int i = 1; i < k; i+=2){
				if(a.at(l)*a.at(l+1) < a.at(r)*a.at(r-1)){
					ans *= a.at(r)*a.at(r-1)%mod;
					ans %= mod;
					r -= 2;
				}
				else{
					ans *= a.at(l)*a.at(l+1)%mod; 
					ans %= mod;
					l += 2;
				}
			}
		}
		else{
			for(int i = 0; i < k-1; i+=2){
				ans *= a.at(n-1-i)*a.at(n-2-i)%mod;
				ans %= mod;
			}
			ans *= a.at(n-k);
			ans = (ans%mod+mod)%mod;
		}
	}
	else{
		int l = 0, r = n-1;
		for(int i = 0; i < k; i+=2){
			if(a.at(l)*a.at(l+1) < a.at(r)*a.at(r-1)){
				ans *= a.at(r)*a.at(r-1)%mod;
				ans %= mod;
				r -= 2;
			}
			else{
				ans *= a.at(l)*a.at(l+1)%mod; 
				ans %= mod;
				l += 2;
			}
		}	
	}
	cout << (ans % mod + mod)%mod << endl;
} 


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

using namespace std;

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

    int A,B,C,D,flag=0;
    cin>>A>>B>>C>>D;
    while(1)
    {
        C-=B;
        if(C<=0)
        {
            flag++;
            break;
        }

        A-=D;
        if(A<=0)
            break;
    }

    if(flag==1)
        cout<<"Yes";
    else 
        cout<<"No";
   
    return 0;   
}   


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define pb push_back
#define endl "\n"
#define pii tuple<ll,ll,ll>
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
const ll N=1005;
const ll INF=LLONG_MAX;
void amfetamin()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);
}
int main()
{
amfetamin();
ll n;
cin>>n;
string sol="";
while (n>0)
{
    n--;
    sol=string(1,'a'+n%26)+sol;
    n/=26;
}
cout<<sol<<endl;

}


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

using ll = long long;

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

int main()
{
    int h, w, K;
    cin >> h >> w >> K;
    vector<string> str;

    rep(i, h) {
        string tmp;
        cin >> tmp;
        str.push_back(tmp);
    }

    int result = 100000000;

    rep(i, pow(2, h-1)) {
        int count = 0;
        vector<int> gyouCount(h, 0);
        rep(j, w) {
            vector<int> tmpGypuCount(h, 0);
            rep(k, h) {
                if (str[k][j] == '1') {
                    gyouCount[k]++;
                    tmpGypuCount[k]++;
                }
            }
            int whiteNum = 0;
            int tmpWhiteNum = 0;
            rep(k, h) {
                whiteNum += gyouCount[k];
                tmpWhiteNum += tmpGypuCount[k];
                if (whiteNum > K) {
                    if (tmpWhiteNum > K) {
                        count += 1024000;
                    } else {
                        count++;
                        rep(l, h) gyouCount[l] = tmpGypuCount[l];
                        break;
                    }
                }
                if (i >> k & 1) {
                    whiteNum = 0;
                    tmpWhiteNum = 0;
                }
            }
        }
        rep(k, h) if (i >> k & 1) count++;
        result = min(result, count);
    }
    cout << result << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int maxn=2e5+5;
const int mod=1e9+7;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    cout<<a*b<<'\n';


}


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

int main(int argc, char *argv[]){
    int N, K;
    std::cin >> N >> K;
    std::deque<long int> V;
    long int v;
    for(int i=0; i<N; ++i){
        std::cin >> v;
        V.push_back(v);
    }

    std::vector<long int> sumValue;
    std::vector<long int> subsequent;
    int left,right;
    int lSubsequent;
    long int sumSubsequent;
    int dequeIdx;
    int R = N < K ? N : K;
    for(lSubsequent=0; lSubsequent<=R; ++lSubsequent){
        for(left=N-lSubsequent; left<=N; ++left){
            right = left+lSubsequent;
            subsequent.clear();
            for(dequeIdx=left; dequeIdx<right; ++dequeIdx){
                subsequent.emplace_back(V[dequeIdx%N]);
            }
            std::sort(subsequent.begin(),subsequent.end());
            sumSubsequent = 0;
            for(dequeIdx=0; dequeIdx<lSubsequent; ++dequeIdx){
                if(dequeIdx<K-lSubsequent && subsequent[dequeIdx]<0){
                    continue;
                }
                sumSubsequent += subsequent[dequeIdx];
            }
            sumValue.emplace_back(sumSubsequent);
        }
    }

    std::cout << *std::max_element(sumValue.begin(),sumValue.end()) << std::endl;
    return 0;
}


Measured memory_bytes: 256
N, M = [int(x) for x in input().split()]
a = [int(input()) for _ in range(M)]
p = 10 ** 9 + 7

if M == 0:
    a = [-1]

fib = [1, 1] + [None] * (N - 1)
for i in range(2, N + 1):
    fib[i] = (fib[i - 1] + fib[i - 2]) % p

ans = 1
for j in range(M):
    if a[j] == N or (j + 1 < M and a[j] + 1 == a[j + 1]):
        ans = 0
        break

    if j == 0:
        ans = fib[a[j] - 1]
    else:
        ans *= fib[a[j] - 1 - (a[j - 1] + 1)]
        ans %= p
else:
    ans *= fib[N - a[M - 1] - 1]
    ans %= p

print(ans)


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

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

  int N = S.size();
  bool ans = true;

  for (int i = 0; i < (N-1)/2; i++) {
    if (S.at(i) != S.at(N-1-i)) ans = false;
  }

  if ((N-1)/2 % 2 == 0) {
    for (int i = 0; i < (N-1)/4; i++) {
      if (S.at(i) != S.at((N-1)/2 -1 -i)) ans = false;
      if (S.at((N+3)/2 -1 +i) != S.at(N -1 -i)) ans = false;
    }
  }
  else {
    for (int i = 0; i < (N-3)/4; i++) {
      if (S.at(i) != S.at((N-1)/2 -1 -i)) ans = false;
      if (S.at((N+3)/2 -1 +i) != S.at(N -1 -i)) ans = false;
    }
  }
  cout << (ans ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
int n;


int c;
string d;
int m;
int e;
int f;
while(cin >> n){
if(n!=0){
string a[n];
string b[n];
c=0;
while(c<n){
cin >>a[c];
cin >>b[c];
c=c+1;}


cin >> m;
c=0;

while(c<m){
cin >>d;
e=0;
f=0;
while(e<n){
if(d==a[e]){cout<<b[e]; f=1;}
e=e+1;
}
if(f==0){cout <<d;}
c=c+1;}
cout << endl;
}
}
}

Measured memory_bytes: 1196
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

int dx[]={1, 0, -1, 0};
int dy[]={0, -1, 0, 1};

int main(){
    int n; cin>>n;
    string s; cin>>s;
    int rcnt=0;
    for(int i=0; i<n; i++){
        if(s[i] == 'R') rcnt++;
    }

    if(rcnt > (n - rcnt)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
	input!(n: usize);

	let mut nn = n;
	let mut fact: Vec<(usize, usize)> = Vec::new();

	fn factor_sub(n: usize, m: usize) -> (usize, usize) {
        let mut c = 0;
        let mut x = n;
        while x % m == 0 {
            c += 1;
            x /= m;
        }
        (c, x)
    }

    let (c, n) = factor_sub(n, 2);
    if c > 0 {
		fact.push((2,c));
		 //print!("({},{})", 2, c); 
	}
    let mut x = 3;
    let mut m = n;
    while x * x <= m {
        let (c, n) = factor_sub(m, x);
        if c > 0 {
			fact.push((x,c));
			//print!("({},{})", x, c);
		}
        m = n;
        x += 2;
    }
    if m > 1 {
		fact.push((m,1));
		//print!("({},{})", m, 1);
	}

	let mut z: Vec<usize> = Vec::new();
	for i in fact {
		for j in 0..(i.1) {
			z.push(i.0.pow((j+1) as u32));
		}
	}
	z.sort();
	z.dedup();

	let mut count: usize = 0;
	let mut index: usize = 0;
	loop {
		if z.len() == index {
			break;
		}
//			println!("nn={}", nn);
		if nn % z[index] != 0 {
			index += 1;
			continue;
		}
		nn /= z[index];
		if nn == 0 {
			break;
		}
		count += 1;
		index += 1;
	}
	println!("{}", count);
//	println!("{}", z.len());
//	println!("{:?}", z);
}


Measured memory_bytes: 2188
#include<stdio.h>

int main() {
	int ans, N, i, j, temp = 0;
	while(scanf("%d",&N)!=EOF) {
		if(N<105) {
			printf("0\n");
			continue;
		}
		if(N<135) {
			printf("1\n");
			continue;
		}
		if(N<165) {
			printf("2\n");
			continue;
		}
		if(N<189) {
			printf("3\n");
			continue;
		}
		if(N<195) {
			printf("4\n");
			continue;
		}
		printf("5\n");
	}
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main(int argc, char *argv[])
{
	int n, i, answer;
	cin >> n;
	vector<int> d(n);
	for (i = 0; i < n; i++)
		cin >> d[i];

	sort(d.begin(), d.end());
	answer = d[n / 2] - d[n / 2 - 1];

	cout << answer << endl;

	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}

int main()
{
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	int k=read();
	cout<<a[0]+a[1]+(a[2]<<k)<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <deque>

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

using namespace std;

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

	printf("%.10f\n", a / b);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll fun(ll a)
{
  ll ans;
  if(a%4==0)
    ans=a;
  if(a%4==1)
    ans=1;
  if(a%4==2)
    ans=a+1;
  if(a%4==3)
    ans=0;
  return ans;
}
int main()
{
  ll a,b;
  cin>>a>>b;
  if(a>0)
    a--;
  cout<<(fun(b)^fun(a));
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;


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


Measured memory_bytes: 3632
// #pragma GCC optimize(3)
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <vector>
#include <cstdio>
#include <bitset>
#include <cstring>
#include <iostream>
#include <algorithm>
#define maxn 100010
#define MOD 1000000007
#define int long long
using namespace std;
void write(int x){if(x<0){putchar('-');x=-x;}if(x>9) write(x/10);putchar(x%10+'0');}
int read(){int d=0,w=1;char c=getchar();for(;c<'0'||c>'9';c=getchar())if(c=='-')
w=-1;for(;c>='0'&&c<='9';c=getchar())d=(d<<1)+(d<<3)+c-48;return d*w;}
void wln(int x){write(x);putchar('\n');}
void wrs(int x){write(x);putchar(' ');}
// int n,x,y,a[maxn],f[maxn][maxn][2],ans;
int tree[maxn<<2][2],lazy[maxn<<2][2],n,x,y,a[maxn];
void up(int x,int y)
{
	(tree[x][y]=tree[x<<1][y]+tree[x<<1|1][y])%=MOD;
}
void hok(int x,int l,int r,int addv,int y)
{
	if(lazy[x][y]==-1) lazy[x][y]=0;
	(lazy[x][y]+=addv)%=MOD;
	tree[x][y]=(r-l+1)*addv%MOD;
}
void down(int x,int l,int r,int y)
{
	if(lazy[x][y]==-1) return;
	int m=l+r>>1;
	hok(x<<1,l,m,lazy[x][y],y);
	hok(x<<1|1,m+1,r,lazy[x][y],y);
	lazy[x][y]=-1;
}
void update(int cnt,int l,int r,int ql,int qr,int addv,int y)
{
	if(ql<=l&&r<=qr)
	{
		hok(cnt,l,r,addv,y);
		return;
	}
	down(cnt,l,r,y);
	int m=l+r>>1;
	if(ql<=m) update(cnt<<1,l,m,ql,qr,addv,y);
	if(qr>m) update(cnt<<1|1,m+1,r,ql,qr,addv,y);
	up(cnt,y);
}
int query(int cnt,int l,int r,int ql,int qr,int y)
{
	if(ql<=l&&r<=qr) return tree[cnt][y];
	down(cnt,l,r,y);
	int m=l+r>>1,ans=0;
	if(ql<=m) ans=query(cnt<<1,l,m,ql,qr,y);
	if(qr>m) (ans+=query(cnt<<1|1,m+1,r,ql,qr,y))%=MOD;
	return ans;
}
signed main()
{
	// freopen(".in","r",stdin);
	// freopen(".out","w",stdout);
	n=read();
	x=read();
	y=read();
	for(int i=1;i<=n;a[i++]=read());
	memset(lazy,255,sizeof lazy);
	update(1,0,n,0,0,1,0);
	update(1,0,n,0,0,1,1);
	// f[0][0][0]=f[0][0][1]=1;
	for(int i=1;i<=n;i++)
	{
		// if(a[i]-a[i-1]>=x||i==1) f[i][0][0]=f[i-1][0][0];
		// if(a[i]-a[i-1]>=y||i==1) f[i][0][1]=f[i-1][0][1];
		// for(int j=1;j<i-1;j++)
		// {
			// if(a[i]-a[i-1]>=x) f[i][j][0]=f[i-1][j][0];
			// if(a[i]-a[i-1]>=y) f[i][j][1]=f[i-1][j][1];
		// }
		// if(i!=1)
		// 	for(int j=0;j<i-1;j++)
		// 	{
		// 		if(a[i]-a[j]>=x||j==0) (f[i][i-1][0]+=f[i-1][j][1])%=MOD;
		// 		if(a[i]-a[j]>=y||j==0) (f[i][i-1][1]+=f[i-1][j][0])%=MOD;
		// 	}
		if(i!=1)
		{
			int tmp1=upper_bound(a+1,a+i-1,a[i]-x)-a;
			int tmp2=upper_bound(a+1,a+i-1,a[i]-y)-a;
			tmp1--;
			tmp2--;
			// wrs(i);
			// wrs(tmp1);
			// wln(tmp2);
			update(1,0,n,i-1,i-1,query(1,0,n,0,tmp1,1),0);
			update(1,0,n,i-1,i-1,query(1,0,n,0,tmp2,0),1);
		}
		if(i!=1&&a[i]-a[i-1]<x) update(1,0,n,0,i-2,0,0);
		if(i!=1&&a[i]-a[i-1]<y) update(1,0,n,0,i-2,0,1);
		// for(int j=0;j<i;j++)
		// 	for(int k=0;k<2;k++)
		// 		printf("f[%lld][%lld][%lld]=%lld\n",i,j,k,query(1,0,n,j,j,k));
	}
	// for(int i=1;i<=n;i++)
	// 	for(int j=0;j<i;j++)
	// 		for(int k=0;k<2;k++)
	// 			printf("f[%d][%d][%d]=%d\n",i,j,k,f[i][j][k]);
	// for(int i=0;i<n;i++)
	// 	(ans+=f[n][i][0]+f[n][i][1])%=MOD;
	// ans=query(1,0,n,0,n-1,0)+query(1,0,n,0,n-1,1);
	// write(ans);
	write((query(1,0,n,0,n-1,0)+query(1,0,n,0,n-1,1))%MOD);
	return 0;
}


Measured memory_bytes: 12544
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;

bool broken[100001];
ll dp[100001];

int main(){
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++){
		int x;
		cin >> x;
		broken[x] = true;
	}

	dp[0] = 1;
	if (!broken[1]) dp[1] = 1;
	for (int i = 2; i <= n; i++){
		if (!broken[i]){ 
			dp[i] += dp[i-1];
			dp[i] += dp[i-2];
			dp[i] %= MOD;
		}
	}
	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 4420
N, K, Q = map(int, input().split())
Ai = list(map(int, [input() for i in range(Q)]))

scores = [K-Q for i in range(N)]

for i in range(Q):
    scores[Ai[i] - 1] += 1
    scores = scores


for k in range(len(scores)):
    if scores[k] > 0 :
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 13384
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;

int main(void){
    int n;
    cin >> n;
    
    int a[n];
    
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    
    //int i = 0;
    int ans = 0;
    bool isEven = 1;
    while(isEven == true){
        for(int j=0; j<n; j++){
            if(a[j] % 2 != 0){
                isEven = 0;
                break;
            }
            //printf("hoge%d\n", a[j]);
            a[j] = a[j]/2;
        }
        ans++;
    }
    ans--;
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int a0 = sc.nextInt();
    int M = a0;
    int g = a0;
    for(int i = 1; i < n; i++) {
      int a = sc.nextInt();
      M = Math.max(M, a);
      g = gcd(g, a);
    }
    String ans = "IMPOSSIBLE";
    if((M >= k) && ((k % g) == 0)) ans = "POSSIBLE";
    System.out.println(ans);
  }

  public static int gcd(int a, int b) {
    if(b == 0) return a;
    return gcd(b, (a % b));
  }
}


Measured memory_bytes: 47520
#include <iostream>
using namespace std;
     
int main() {
    
    int m, f, r;
    
    while(1){
        cin >> m >> f >> r;
        
        if(m == -1 && f == -1 && r == -1) break;
        
        int p;
        p = m + f;
        
        if(m == -1 || f == -1){
            cout << "F" << endl;
        } else if(80 <= p){
             cout << "A" << endl;
        } else if(65 <= p && p < 80){
             cout << "B" << endl;
        } else if(50 <= p && p < 65){
             cout << "C" << endl;
        } else if(30 <= p && p < 50 && 50 <= r ){
             cout << "C" << endl;
        } else if(30 <= p && p < 50){
             cout << "D" << endl;
        } else if(p < 30){
             cout << "F" << endl;
        }
    }
    return 0;
}
	
	


Measured memory_bytes: 3084
#include <cstdio>
#include <vector>
#include <cstring>
#include <functional>
#include <algorithm>
#include <math.h>
#include <bitset>
#include <set>
#include <queue>
#include <assert.h>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <complex>
#include <numeric>
#include <map>
#include <time.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<int,ull> piu;
typedef pair<ull,ull> puu;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
typedef pair<pii,ll> ppl;
typedef pair<ll,pii> plp;
typedef pair<ll,pll> plP;
typedef pair<int,pii> pip;
typedef pair<pii,int> ppi;
typedef pair<pii,pii> ppp;
typedef pair<double,int> pdi;
typedef pair<int,double> pid;
typedef pair<double,pii> pdp;
typedef pair<double,double> pdd;
typedef pair<pdd,double> pd3;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i,n) for (int (i) = 0; (i) < (n); (i)++)
#define repn(i,a,n) for (int (i) = (a); (i) < (n); (i)++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define SORT(x) sort((x).begin(),(x).end())
#define SORTN(x,n) sort((x),(x)+(n))
#define ERASE(x) (x).erase(unique((x).begin(),(x).end()),(x).end())
#define COUNT(x,c) count((x).begin(),(x).end(),(c))
#define REMOVE(x,c) (x).erase(remove((x).begin(),(x).end(),(c)),(x).end())
#define REVERSE(x) reverse((x).begin(),(x).end())
#define FORIT(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))-(x).begin()
#define lb(x,a) lower_bound((x).begin(),(x).end(),(a))
#define LBN(x,a,n) lower_bound((x),(x)+(n),(a))-(x)
#define lbN(x,a,n) lower_bound((x),(x)+(n),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))-(x).begin()
#define ub(x,a) upper_bound((x).begin(),(x).end(),(a))
#define BS(x,a) binary_search((x).begin(),(x).end(),(a))
#define BS2(x,n,a) binary_search((x),(x)+(n),(a))
#define NB(x) (((x)&~((x)+((x)&-(x))))/((x)&-(x))>>1)|((x)+((x)&-(x)))
#define NP(x) next_permutation((x).begin(),(x).end())
#define MM(x,p) memset((x),(p),sizeof(x))
#define SQ(x) (x)*(x)
#define SC(c1,c2) strcmp(c1,c2)==0
#define mp make_pair
#define INF (1<<29)
#define INFL (1LL<<61)
#define fi first
#define se second
#define EPS 1e-9
#define MOD 1000000007
#define MIN(x,a) x=min(x,a)
#define MAX(x,a) x=max(x,a)
#define madd(x,a) x=(x+a)%MOD
#define msub(x,a) x=(x+MOD-a)%MOD
#define OUTPUT(x) rep(__,x.size())printf("%d%c",x[__],__+1==x.size()?'\n':' ')

int H,W,N;
int A[10000];
int m[100][100];

int main()
{
	scanf("%d%d%d",&H,&W,&N);
	rep(i,N)scanf("%d",&A[i]);
	int ptr=0;
	rep(i,H)rep(j,W)
	{
		if(A[ptr]==0)ptr++;
		A[ptr]--;
		m[i][j]=ptr+1;
	}
	rep(i,H)if(i%2==1)rep(j,W/2)swap(m[i][j],m[i][W-j-1]);
	rep(i,H)rep(j,W)printf("%d%c",m[i][j],j+1==W?'\n':' ');
}

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

public class ABC168C {
	private static void Main(string[] args) {
		var inputs = ReadDoublesAsArray();
		var a = inputs[0];
		var b = inputs[1];
		var h = inputs[2];
		var m = inputs[3];

		var angle = ((h * 60 + m) * 360 / (12 * 60)) - (m * 360 / 60);
		var answer = CalcTriangleSide(a, b, CalcRadian(angle));
		Console.WriteLine(answer);
	}

	private static double[] ReadDoublesAsArray() => Console.ReadLine().Trim().Split().Select(x => double.Parse(x)).ToArray();
	private static double CalcRadian(double angle) => angle * Math.PI / 180;
	private static double CalcTriangleSide(double a, double b, double radian) => Math.Sqrt((a * a) + (b * b) - (2 * a * b * Math.Cos(radian)));
}

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

int main() {
  int s;
    cin>>s;
  int t=s;
  int sum=1;
for(int i=1;i<=100000;i++){ 
  if(t==2||t==1||t==4){
    cout<<4<<endl;
    break;
  }
  if(t%2==0&&4<t){
    t=t/2;
    sum+=1;
  }
  else if(1<t){
    t=3*t+1;
    sum+=1;
  }
  if(t==4){
    cout<<sum+3<<endl;
  break;
  }
}
}


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

vector<pair<ll, ll> > prime_factorize(ll n) {
  vector<pair<ll, ll> > res;
  for(ll p = 2; p * p <= n; ++p) {
    if(n % p != 0) continue;
    int num = 0;
    while(n % p == 0)  ++num, n /= p;
    res.push_back(make_pair(p,num));
  }
  if (n != 1) res.push_back(make_pair(n,1));
  return res;
}

int main() {
  ll n;
  cin >> n;
  auto pf = prime_factorize(n);
  ll res = 0;
  for(auto p : pf) {
    ll e = p.second;
    ll tmp = 0,cur = 1;
    while(e >= cur) e -= cur++, ++tmp;
    res += tmp;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = INT64_MAX;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i=0;i<N;i++)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n,k;
struct edge{/*重み付き,有向*/
    int to , cost;/*toは接続先*/
    edge(ll to_ ,ll cost_ = 1){ to=to_; cost=cost_; };/*全てのcost=1 <=> 無向グラフ*/
};
bool operator<(edge e1 ,edge e2){return e1.cost < e2.cost; }
bool operator>(edge e1 ,edge e2){return e1.cost > e2.cost; }
using graph =  vector< vector<edge> >;
graph g;
bool ma[110][110];

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n>>k;
    if(k>(n-1)*(n-2)/2){
        print(-1);
    }else{
    g.resize(n);
    rep(i,n){
        if(i==0)continue;
        g[0].pb(edge(i));
        g[i].pb(edge(0));
    }
    ll tmp = (n-1)*(n-2)/2 - k;
    bool fg = true;
    ll m = (n-1);
    rep(i,n-1){
        if(!fg)break;
        repi(j,i+2,n){
            if(tmp==0)fg = false;
            if(!fg)break;
            m++;
            g[i+1].pb(j);
            g[j].pb(i+1);
            tmp--;
        }
    }
    rep(i,110)rep(j,110)ma[i][j]=false;
    print(m);
    rep(i,n){
        rep(j,g[i].size()){
            if(ma[i][g[i][j].to])continue;
            ma[i][g[i][j].to]=true;
            ma[g[i][j].to][i]=true;
            princ(i+1);print(g[i][j].to+1);
        }
    }
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>

bool flag[110];

int main() {
    int n, k;
    std::cin >> n >> k;
    for(int i = 0; i < k; i++){
        int d;
        std::cin >> d;
        for(int j = 0; j < d; j++){
            int t;
            std::cin >> t;
            flag[t] = true;
        }
    }
    int count = 0;
    for(int i = 1; i <= n; i++){
        if(!flag[i]) count++;
    }
    std::cout << count << std::endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;


int main()
{
	string s;
	cin>>s;
	int len;
	len=s.size();
	int cnt=0;long long ans=0;
	int sum1=1,sum2=0;
	while(cnt<=len-1)
	{
		if(s[cnt]==s[cnt+1])
		{
			
			if(s[cnt]=='>')
			{//cout<<sum1<<endl;
				ans+=sum1;sum1++;
				
			}
			else ans+=sum1-1,sum1++;
		}
		else
		{
			if(s[cnt]=='>')
			{
			//	cout<<"aaa"<<sum1<<endl;
				ans+=sum1;
				if(sum2>sum1)ans+=sum2-sum1;
			}
			if(s[cnt]=='<')ans+=sum1-1;
			sum2=sum1;
			sum1=1;
		}
		cnt++;
	}
	if(s[len-1]=='<')ans+=sum2;
	printf("%lld",ans);
}

Measured memory_bytes: 4288
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int seisu = scan.nextInt();
		int len = scan.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		int min = Integer.MAX_VALUE;
		int ans = 0;

		for(int i=0;i<len;i++) {
			list.add(scan.nextInt());
		}

		for(int i=0;i<=110;i++) {
			if(!list.contains(i)) {
				if(min > Math.abs(i-seisu)) {
				min = Math.abs(i-seisu);
				ans = i;
				}
			}

		}
		System.out.println(ans);
		scan.close();

	}

}


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

long long N, K;

long long subNK()
{
    long long s = N % K;
    long long tmp = N % K;
    long long res;
    while(true)
    {
        if(tmp <= K) tmp = K - tmp;
        else tmp = tmp - K;

        res  = min(s, tmp);
        if(res == s) return res;
        else s = res;
    }
}

int main()
{
   cin >> N >> K;
   cout << subNK() << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define RREP(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using llong = long long;

const int INF = 100100100;
const int MOD = 1e9 + 7;

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

    int N;
    cin >> N;

    int ans = 0;
    FOR(i, 1, N + 1) {
        string i_str = to_string(i);
        if(i_str.length() % 2 == 1) {
            ans++;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
i;char s[99];main(){for(;~scanf("%[^\n]",s);i=!puts(s))for(getchar();!strstr(s,"this")&!strstr(s,"the")&!strstr(s,"that");)for(i=0;s[i];)s[i++]=s[i]>47?s[i]-122?s[i]+1:97:s[i];}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

int main(){
    int N, D, A;
    cin >> N >> D >> A;
    pair<int, int> G[N];
    int X[N];
    for(int i=0; i<N; i++){
        cin >> G[i].first >> G[i].second;
    }
    sort(G, G + N);  // sorted in ascend order
    long ans = 0; //回数
    long dmg = 0; //ダメージ　Aをかけたもの
    queue<pair<int, int> > q; // X[i], 実際に使った爆弾の威力
    for(int i=0; i<N; i++){
        while(!q.empty() && q.front().first < G[i].first - 2 * D){
            dmg -= q.front().second;
            q.pop();
        }
        G[i].second -= dmg;
        if(G[i].second <= 0) continue;
        long atk = (G[i].second - 1) / A + 1;
        ans += atk;
        dmg += A * atk;
        
        q.push({G[i].first, A * atk});
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int N,H,W;
int X1[1000],X2[1000],Y1[1000],Y2[1000];
int fld[3002][3002],dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};

int compress(int *x1,int *x2,int w){
  vector<int>xs;

  for(int i=0;i<N;i++){
    for(int d=-1;d<=1;d++){
      int tx1=x1[i]+d,tx2=x2[i]+d;
      if(1<=tx1 && tx1<=w)xs.push_back(tx1);
      if(1<=tx2 && tx2<=w)xs.push_back(tx2);
    }
  }
  xs.push_back(0);
  xs.push_back(w);
  sort(xs.begin(),xs.end());
  xs.erase(unique(xs.begin(),xs.end()),xs.end());
  for(int i=0;i<N;i++){
    x1[i]=find(xs.begin(),xs.end(),x1[i])-xs.begin();
    x2[i]=find(xs.begin(),xs.end(),x2[i])-xs.begin();
  }
  return xs.size()-1;
}

int bfs(void){

  int ans=0;

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(fld[i][j])continue;
      ans++;
      queue<pair<int,int> >que;
      que.push(make_pair(j,i));
      while(!que.empty()){
	int nx=que.front().first,ny=que.front().second;
	que.pop();

	for(int i=0;i<4;i++){
	  int tx=nx+dx[i],ty=ny+dy[i];
	  if(tx<0 || W<tx || ty<0 || H<ty)continue;
	  if(fld[ty][tx]>0)continue;
	  que.push(make_pair(tx,ty));
	  fld[ty][tx]=1;
	}
      }
    }
  }
  return ans;
}

int main(void){

  while(cin >> W >> H,W|H){
    cin >> N;
    for(int i=0;i<N;i++)
      cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
    
    fill(fld[0],fld[3002],0);
    
    W=compress(X1,X2,W);
    H=compress(Y1,Y2,H);
    
    for(int i=0;i<N;i++){
      fld[Y1[i]][X1[i]]++;
      fld[Y1[i]][X2[i]]--;
      fld[Y2[i]][X1[i]]--;
      fld[Y2[i]][X2[i]]++;
    }
    
    for(int i=0;i<H;i++){
      for(int j=1;j<W;j++){
	fld[i][j]+=fld[i][j-1];      
      }
    }
    
    for(int i=1;i<H;i++){
      for(int j=0;j<W;j++){
	fld[i][j]+=fld[i-1][j];
      }
    }
    cout << bfs() << endl;
  }
  return 0;
}

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

int n, m;

const int INF = 1e+9;
const int MAX_V = 100;
int cost[MAX_V][MAX_V];
int mincost[MAX_V];
bool used[MAX_V];

int prim(){
	for(int i=0 ; i < n ; i++ ){
		mincost[i] = INF;
		used[i] = false;
	}
	mincost[0] = 0;
	int res = 0;
	
	while( true ){
		int v = -1;
		for(int u=0 ; u < n ; u++ ){
			if( !used[u] && (v == -1 || mincost[u] < mincost[v]) ){
				v = u;
			}
		}
		
		if(v == -1) break;
		used[v] = true;
		res += mincost[v];
		
		for(int u=0 ; u < n ; u++ ){
			mincost[u] = min( mincost[u] , cost[v][u] );
		}
	}
	return res;
}

// ツ閉カツ篠堋療アsツづーツ閉カツ篠喞ツ凝ヲツ静伉づィツづ閉ェツ環つオツづ陛板つキ
vector<string> split_string(string s, char c){
	string str;
	vector<string> vs;
	s.push_back( c );
	
	for(int i=0 ; i < s.size() ; i++ ){
		if( s[i] == c ){
			if( !str.empty() ){
				vs.push_back( str );
				str.clear();
			}
		}else{
			str.push_back( s[i] );
		}
	}
	return vs;
}

// stringツづーintツづ可陛渉環キ
int s_to_i(string s){
	int n=0;
	for(int i=0 ; i < s.size() ; i++ ){
		n *= 10;
		n += s[i] - '0';
	}
	return n;
}

int main(){
	while( cin >> n , n ){
		for(int u=0 ; u < n ; u++ ){
			for(int v=0 ; v < n ; v++ ){
				cost[u][v] = cost[v][u] = INF;
			}
		}
		
		cin >> m;
		cin.ignore();
		for(int i=0 ; i < m ; i++ ){
			string s;
			getline(cin,s);
			vector<string> vs = split_string( s , ',' );
			int u = s_to_i( vs[0] );
			int v = s_to_i( vs[1] );
			int c = (s_to_i( vs[2] ) - 100) / 100;
			cost[u][v] = cost[v][u] = c;
		}
		int ans = prim();
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    long[] monster = new long[n+1];
    long[] hero = new long[n];
    long sum = 0;
    for(int i = 0; i <= n; i++) {
      monster[i] = Long.parseLong(sc.next());
    }
    for(int i = 0; i < n; i++) {
      hero[i] = Long.parseLong(sc.next());
    }
    if(monster[0] >= hero[0]) {
      sum += hero[0];
      hero[0] = 0;
    } else {
      sum += monster[0];
      hero[0] -= monster[0];
    }
    for(int i = 1; i < n; i++) {
      if(monster[i] > hero[i-1] + hero[i]) {
        sum += hero[i-1] + hero[i];
        hero[i] = 0;
      } else if(monster[i] <= hero[i-1]) {
        sum += monster[i];
      } else {
        sum += monster[i];
        hero[i] -= monster[i] - hero[i-1];
      }
    }
    if(monster[n] > hero[n-1]) sum += hero[n-1];
    else sum += monster[n];
    System.out.println(sum);
  }
}


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

int a[1000000]={};

int main(){
	int n,ans=0;
	vector<int> v;
	for(int i = 2; i*i < 1000000; i++){
		for(int j = 0; j < 1000000; j+=i){
			if(i!=j) a[j]=1;
		}
	}
	while(cin >> n){
		for(int j = 2; j <= n; j++){
			if(a[j]==0) ans++;
		}
		cout << ans << endl;
		ans=0;
	}
}

Measured memory_bytes: 5064
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func main() {
	sc.Split(bufio.ScanWords)

	A, B := getInt(), getInt()

	n := (B - 1 + A - 2) / (A - 1)

	out(n)
}


Measured memory_bytes: 640
def sarch(i,j):
    cnt=0
    i1=[i-1,i,i+1]
    j1=[j-1,j,j+1]
    for x in range(3):
        for y in range(3):
            if S[i1[x]][j1[y]]=="#":
                cnt+=1
    return cnt

import numpy as np
H,W=map(int,input().split())
S=np.array([list(str(input())) for i in range(H)])


gyo_0=np.array(["."]*W)
retu_0=np.array([["."]]*(H+2))

S=np.vstack((gyo_0,S))
S=np.vstack((S,gyo_0))
S=np.hstack((retu_0,S))
S=np.hstack((S,retu_0))

for i in range(1,H+1):
    for j in range(1,W+1):
        if S[i][j]==".":
            S[i][j]=sarch(i,j)
        print(S[i][j],end="")
    print()

Measured memory_bytes: 26952
<?php
$s=trim(fgets(STDIN));
$t=trim(fgets(STDIN));
$ans=10000;
$len_s=strlen($s);
$len_t=strlen($t);
$i=0;
while($i<=$len_s-$len_t){
  $j=0;
  $ans_i=0;
  while($j<$len_t){
    if($s[$i+$j]!=$t[$j]){
      ++$ans_i;
    }
    ++$j;
  }
  $ans=min($ans,$ans_i);
  ++$i;
}
echo $ans;

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

int main() {
  int a,i;
  cin >> a;
  vector<int>A(a);
  for(i=0;i<a;i++){
  cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  cout << A.at(a/2)-A.at(a/2-1) << endl;
}

Measured memory_bytes: 640
N = int(input())
S = input()
answers = []

from itertools import accumulate

white_cumsum = list(accumulate([1 if s=='.' else 0 for s in S]))
black_cumsum = list(accumulate([1 if s=='#' else 0 for s in S]))

answers.append(white_cumsum[-1])
answers.append(black_cumsum[-1])

for i in range(N):
  answers.append(black_cumsum[i] + white_cumsum[-1] - white_cumsum[i])
    
answer = min(answers)
print(answer)


Measured memory_bytes: 28620
def main():
    N, A = (int(i) for i in input().split())
    X = [int(i) for i in input().split()]
    dp = [[[0 for s in range(N*A + 1)] for k in range(N + 1)]
          for j in range(N + 1)]
    dp[0][0][0] = 1
    for j in range(1, N+1):
        for k in range(0, N+1):
            for s in range(N*A + 1):
                dp[j][k][s] = dp[j-1][k][s]
                if k >= 1 and s - X[j-1] >= 0:
                    dp[j][k][s] += dp[j-1][k-1][s-X[j-1]]
    ans = 0
    for k in range(1, N+1):
        ans += dp[N][k][k*A]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 94940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

ll ans = 0;

ll dfs(ll n) {
    ll res = 0;
    if (n == 1) {
        return 1;
    }
    res += dfs(n / 2) * 2;
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll h;
    cin >> h;
    cout << (dfs(h) * 2 - 1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;


int a[100000];
signed main(){
  int n;
  scanf("%lld", &n);
  rep(i,n)scanf("%lld", &a[i]);
  sort(a, a+n);
  int sum = 0;
  rep(i,n-1)sum += a[i];
  printf("%lld\n", sum+a[n-1]/2);
  return 0;
}






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

int main(void){
    int n, m, tmp, rest;
    cin >> n >> m;
    rest = n;
    for(int i=0; i<m; i++){
        cin >> tmp;
        rest = rest - tmp;
    }
    
    if(rest < 0){cout <<  -1 << endl;}
    else{ cout << rest << endl; }
    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdio>
#define ull unsigned long long 
#define ll long long
using namespace std;

const int N = 1e5 + 5;
const ll maxx = 1e18;

ll a[N];
int main() {
	int n;
	cin >> n;
	ll ans = 1;
	int flag = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (a[i] == 0) {
			flag = 1;
		}
	}
	if (flag == 1) {
		cout << 0;
		return 0;
	}

	for (int i = 1; i <= n; i++) {
		if (1000000000000000000 / a[i] < ans) {
			cout << -1;
			return 0;
		}
		else
			ans *= a[i];
	}
	
	cout << ans;
}

//int main() {
//	ll a;
//	double b;
//	scanf("%lld%lf", &a, &b);
//	ll bz = (ll)floor(b);
//	double bd = b - bz;
//	printf("%lld", (ll)(a*bz+floor(a*bd)));
//}

//int main() {
//
//}

Measured memory_bytes: 4388
#include<iostream>

using namespace std;

int line[100][1000];

int main()
{
loop:
  for(int i = 0; i < 100; i++)
    for(int j  = 0; j < 1000; j++)
      line[i][j] = -1;
  int n, m, a;
  cin >> n >> m >> a;
  if(!n)
    return 0;
  a--;
  for(int i = 0; i < m; i++)
  {
    int h, p, q;
    cin >> h >> p >> q;
    p--; q--;
    line[p][h] = q;
    line[q][h] = p;
  }
  for(int i = 1000; i > 0; i--)
  {
    if(line[a][i] != -1)
      a = line[a][i];
  }
  cout << a + 1 << endl;
  goto loop;
}

Measured memory_bytes: 1548
x,y,z,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

ls = [0]*(len(A)*len(B))
for i in range(len(A)):
    for j in range(len(B)):
        ls[(i*len(B))+j] = A[i] + B[j]
ls.sort(reverse = True)
ls = ls[:k]
check_ls = []
for i in range(len(C)):
    for j in range(len(ls)):
        check_ls.append(C[i] + ls[j])
check_ls.sort(reverse = True)
for i in range(k):
    print(check_ls[i])

Measured memory_bytes: 132560
n=gets.to_i
result=['']
i=1

while i <= n
  x=i
  if x%3==0
    result<<i
  else
    begin
      if x%10==3
        result<<i
        break
      end
      x /= 10
    end while(x>0)
  end
  i+=1
end

puts result*' '

Measured memory_bytes: 8876
import itertools
n,m,q=map(int,input().split())
l=[]
for _ in range(q):
    l.append(list(map(int,input().split())))

a=list(itertools.combinations_with_replacement([i for i in range(m)],n))
S=0
for j in range(len(a)):
    b=a[j]
    s=0
    for k in range(q):
        if b[l[k][1]-1]-b[l[k][0]-1]==l[k][2]:
            s+=l[k][3]
    S=max(s,S)
print(S)

Measured memory_bytes: 84860
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;
 
int main() {
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  
  if ((e-a) > k) {
    std::cout << ":(" << std::endl;
  } else {
    std::cout << "Yay!" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main(){
	int n, c, d[6], t;
	char s[10];
	while(scanf("%d", &n), n != 0){
		d[0] = 1, d[1] = 2, d[2] = 3, d[3] = 4, d[4] = 5, d[5] = 6;
		t = 1;
		for(int i = 0;i < n;i++){
			scanf("%s", s);
			if(s[0] == 'N'){
				c = d[0];
				d[0] = d[1];
				d[1] = d[5];
				d[5] = d[4];
				d[4] = c;
			}
			if(s[0] == 'E'){
				c = d[0];
				d[0] = d[3];
				d[3] = d[5];
				d[5] = d[2];
				d[2] = c;
			}
			if(s[0] == 'W'){
				c = d[0];
				d[0] = d[2];
				d[2] = d[5];
				d[5] = d[3];
				d[3] = c;
			}
			if(s[0] == 'S'){
				c = d[0];
				d[0] = d[4];
				d[4] = d[5];
				d[5] = d[1];
				d[1] = c;
			}
			if(s[0] == 'R'){
				c = d[1];
				d[1] = d[2];
				d[2] = d[4];
				d[4] = d[3];
				d[3] = c;
			}
			if(s[0] == 'L'){
				c = d[1];
				d[1] = d[3];
				d[3] = d[4];
				d[4] = d[2];
				d[2] = c;
			}
			t += d[0];
		}
		printf("%d\n", t);
	}
	return 0;
}

Measured memory_bytes: 2544
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)

int digit(int n){
  int res = 0;
  while(n > 0){
    res += n%10;
    n /= 10;
  }

  return res;
}

int main(void){

  //入力
  int N;
  cin >> N;
  
  //Aが1からNまでの場合でBを考える
  int ans = INF;
  for(int A = 1; A < N; A++){//正の整数らしいから 0からで A < N
    int B = N - A;
    int sum = digit(A) + digit(B);
    ans = min(ans, sum);
  }
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
n = int(input())
w = list(map(int,input().split()))
minnum = sum(w)
for t in range(0,n-1):
  w1 = w[0:t+1]
  w2 = w[t+1:n]
  s1 = sum(w1)
  s2 = sum(w2)
  minnum = min(minnum,abs(s1-s2))
print(minnum)
  


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


int main() {
    ll n;
    cin >> n;
    string ans = "";
    while (n != 0) {
        int r = n % 2;
        if (r < 0) r += 2;
        ans.push_back((char) '0' + r);
        n = (n - r) / (-2);
    }
    reverse(ans.begin(), ans.end());
    if (ans == "") ans = "0";
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e9;

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

int main()
{
   ll a, b;
   cin >> a >> b;
   cout << lcm(a, b) << endl;
   return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Map.Entry;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>();
		String line;
		while ((line = bf.readLine()) != null) {
			String[] s = line.split(",");
			if (s.length < 2)
				break;
			Integer k = Integer.valueOf(s[0]);
			Integer v = map.get(k);
			if (v == null)
				v = Integer.valueOf(0);
			v--;
			map.put(k, v);
		}
		while ((line = bf.readLine()) != null) {
			String[] s = line.split(",");
			if (s.length < 2)
				break;
			Integer k = Integer.valueOf(s[0]);
			Integer v = map.get(k);
			if (v == null)
				continue;
			if (v < 0)
				v = -v;
			v++;
			map.put(k, v);
		}
		while (!map.isEmpty()) {
			Entry<Integer, Integer> e = map.pollFirstEntry();
			if (e.getValue() > 0)
				System.out.println(e.getKey() + " " + e.getValue());
		}
	}
}

Measured memory_bytes: 9736
#include <algorithm>
#include <iostream>

using namespace std;
using ll = long long;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

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

  transform(ALL(S),begin(S),
            [&](char c){
              return (c - 'A' + N)%26 + 'A';
            });

  cout << S << endl;
  
  return 0;
}


Measured memory_bytes: 256