akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<(n);i++)
#define init(a,i) for(int k=0;k<(i);k++)(a)[k]=0
#define in(a,i) for(int k=0;k<(i);k++)cin>>(a)[k]
struct factoring
{
private:
	//素数
	vector<int>  prime;
	int find_SPF(int n){
		for(int i=0;prime[i]<=n/prime[i];i++)
			if(n%prime[i]==0)return prime[i];
		return n;
	}
public:
	vector<int> SPF;
	//前処理
	factoring(int max){
		//(素数列挙）
		bool num[max+1];
		num[0]=0;
		num[1]=0;
		for(int i=2;i<=max;i++)num[i]=1;
		//ふるい
		for(int i=2;i<=max/i;i++)
			if(num[i]==1)
				for(int j=2;i<=max/j;j++)
					num[i*j]=0;
		
		for(int i=0;i<max+1;i++)
			if(num[i]==1)prime.emplace_back(i);
		
		//SPFを求める
		SPF.emplace_back(0);
		SPF.emplace_back(1);
		for(int i=2;i<=max;i++)SPF.emplace_back(factoring::find_SPF(i));	
	}
};
int main(){
	factoring s(1000000);
	int n;
	cin >> n;
	int a[n];
	in(a,n);
	int tmp,tmp2;
	bool flag=1,num[1000001];
	init(num,1000001);
	rep(i,n){
		tmp=a[i];
		while(tmp!=1){
			tmp2=s.SPF[tmp];
			if(num[tmp2]==1)flag=0;
			num[tmp2]=1;
			while(!(tmp%tmp2))tmp/=tmp2;
		}
	}
	if(flag==1){
		cout<<"pairwise coprime";
		return 0;
	}
	
	int g;
	g=a[0];
	rep(i,n)g=gcd(g,a[i]);
	if(g==1)cout << "setwise coprime";
	else cout<<"not coprime";
	return 0;
}

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

ll gcd2(int a, int b) {
    if (a == 0) {
        return b;
    }
    if (b == 0) {
        return a;
    }
    if (a < b) gcd2(b, a);
    ll r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

int gcd3(int a, int b, int c) {
    return gcd2(gcd2(a, b), c);
}

int main() {

    ll N;
    cin >> N;

    ll ans = 0;
    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= N; ++j) {
            for (int k = 1; k <= N; ++k) {
                ans += gcd3(i, j, k);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
inline void read (int &x) {
	char ch = getchar(); int f = 0; x = 0;
	while (!isdigit(ch)) { if (ch == '-') f = 1; ch = getchar(); }
	while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar(); if (f) x = -x;
}
signed main() {
	int a, b, c, d;
	read (a), read (b), read (c), read (d);
	//a health b strengh
	if ((c / b) + (c % b != 0) <= (a / d) + (a % d != 0)) puts ("Yes");
	else puts ("No");
	return 0;
}

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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

bool comp(int a, int b){
    return (a<b);
}

int main(){
    int n; string s;
    int count = 0;
    cin >> n >> s;
    REP(i, 0, n){
        if(s[i]=='A'){
            if(s[i+1]=='B'){
                if(s[i+2]=='C') count++;
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N,K;
    cin >> N >> K;
    bool* tric = new bool[N];
    int d;
    int temp;
    for(int i=1; i<=K; ++i){
        cin >> d;
        for(int j=1; j<=d; ++j){
            cin >> temp;
            tric[temp -1]=true;
        }
    }
    int ans=0;
    for(int i=0; i<N; ++i){
        if(!tric[i]) ++ans; 
    }
    cout << ans <<endl;
    delete tric;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  int n;
  cin>>n;
ll x[n];
ll dp[n];
  for(int i=0;i<n;i++)
    cin>>x[i];
  dp[0]=0;
  dp[1]=dp[0]+abs(x[0]-x[1]);
  for(int i=2;i<n;i++)
  {
      dp[i]=min(dp[i-1]+abs(x[i]-x[i-1]),dp[i-2]+abs(x[i]-x[i-2]));
  }
  cout<<dp[n-1]<<endl;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
ll val[int(1e5+5)][3], DP[int(1e5+5)][3];

int main(){
  cin >> N;
  ll ans = 0;
  for (int i = 1; i <= N; i++){
    for (int j = 0; j < 3; j++){
      cin >> val[i][j];
      for (int k = 0; k < 3; k++){
        if (j == k) continue;
        DP[i][j] = max(DP[i][j], DP[i-1][k] + val[i][j]);
      }
      ans = max(ans, DP[i][j]);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8260
#include<stdio.h>
int main(void)
{
	int a, b;
	int wa, sa, kake;

	scanf("%d %d", &a, &b);
	wa = a + b;
	sa = a - b;
	kake = a * b;
	if (wa > sa) {
		if (wa > kake) {
			printf("%d", wa);
		}
		else {
			printf("%d", kake);
		}
	}
	else {
		if (sa > kake) {
			printf("%d", sa);
		}
		else {
			printf("%d", kake);
		}
	}
	return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS

#include <vector>
#include <deque>
#include <list>
#include <forward_list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <tuple>
#include <functional>
#include <limits>
#include <utility>
#include <string>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

// Print each element of a container.
template <typename Container>
void print(const Container& container)
{
    stringstream sstream;

    string delim("");
	for (const auto& element : container)
	{
		sstream << delim << element;
        delim = " ";
	}

    cout << sstream.str() << endl;
}

template <typename Container>
int bubbleSort(Container& container)
{
    int count(0);

    for(auto it(begin(container)); it != end(container); ++it)
    {
        for(auto jt(prev(end(container))); jt != it; --jt)
        {
            if(*jt < *prev(jt))
            {
                iter_swap(jt, prev(jt));
                ++count;
            }
        }
    }

    return count;
}

int main()
{
    vector<int> v;

    int n;
    cin >> n;

    for(size_t i(0); i < n; ++i)
    {
        int x;
        cin >> x;

        v.push_back(x);
    }

    int count(bubbleSort(v));

    print(v);

    cout << count << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;

#define newline cout<<"\n"
#define deb(x) cout<<#x<<" "<<x<<endl;

template<typename... T>
void read(T&... args){
    ((cin>>args), ...);
}

template<typename... T>
void write(T... args){
    ((cout<<args<<" "), ...);
}

void printarr(vector<int> &v){
    for(int x: v){
        cout<<x<<" ";
    }
    newline;
}

const int MOD = 1e9+7;
const int nax = 1e7+7;

ll getbtwn(ll a, ll b, ll x){
	ll upper = b/x;
	ll lower = (a-1)/x;
	ll ans = upper-lower;
	return ans;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    
    ll a,b,c,d; read(a,b,c,d);

    ll first = getbtwn(a,b,c);
	ll second = getbtwn(a,b,d);
	ll both = getbtwn(a,b,(c*d)/__gcd(c,d));

	ll tot = first + second - both;

	ll ans = (b-a+1)-tot;

	cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3696
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
using namespace std;

int main()
{
	int N, L, A1=0,A2,A3,A4,A5,f=0;
	vector<int> A;
	cin >> N >> L;

	for (int i = 1; i < N+1; i++)
	{
		if (i == 1 && L + i - 1 < 0) { f = 1; }
		if (i == N && L + i - 1 > 0 && f==1) { f = 2; }
		A.push_back(L+i-1);
		A1 = A1 + L + i - 1;
	}
	
	A2 = A1 - A[0];
	A3 = A1 - A[N-1];
	A4 = abs(A1 - A2);
	A5 = abs(A1 - A3);
	if (f == 2)
	{
		cout << A1 << endl;
	}
	else if (A4 <= A5)
	{
		cout << A2 << endl;
	}
	else
	{
		cout << A3 << endl;
	}
}

Measured memory_bytes: 256
# 解答例
# スタック

x=input()
n=len(x)
stack=[]

for i in range(n):
    if x[i]==('S'):
        stack.append(x[i])
    else:
        if stack and stack[-1]==('S'):
            stack.pop()
        else:
            stack.append(x[i])
print(len(stack))

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

int main()
{
    int A,P;
    cin >> A >> P;
    cout << (3*A+P)/2;
}


Measured memory_bytes: 3628
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, k = map(int, input().split())
p = [0] + list(map(int, input().split()))
c = [0] + list(map(int, input().split()))

from collections import deque

def bfs(queue, cycle_index, cycle_num):
    cycle = []
    score = 0
    while queue:
        current = queue.popleft()
        cycle_index[current] = cycle_num
        cycle.append(current)
        score += c[current]

        if p[current] not in cycle_index:
            queue.append(p[current])
    return cycle, score

cycle_index = {}
cycle_num = 0
cycles = []
for i in range(1, n + 1):
    if i in cycle_index:
        continue
    queue = deque([i])
    cycle, score = bfs(queue, cycle_index, cycle_num)
    cycles.append((cycle, score))
    cycle_num += 1

ans = None
for i in range(1, n + 1):
    cycle, score = cycles[cycle_index[i]]
    tmp_ans = 0

    cum = [0]
    current = i
    for j in range(1, len(cycle)):
        current = p[current]
        cum.append(cum[-1] + c[current])

    if score > 0:
        q = (k // len(cycle))
        r = k % len(cycle)
        # 一周しない方がいいケースがある
        # FYI: https://atcoder.jp/contests/abc175/submissions/15968040
        if r == 0:
            tmp_ans = max((score * q), (score * (q - 1)) + max(cum[1:]))
        else:
            tmp_ans = (score * q) + max(cum[1:r+1])
    else:
        r = min(k, len(cycle))
        tmp_ans = max(cum[1:r+1])

    if ans is None:
        ans = tmp_ans
    else:
        ans = max(ans, tmp_ans)
print(ans)


Measured memory_bytes: 83848
using System;

namespace aizu
{
    class OnlineJudge
    {
        static void Main()
        {
            int value;
            while((value = int.Parse(Console.ReadLine())) != 0) {
                int count = 0;
                while(value != 1) {
                    if((value & 1) == 1) {
                        value = value + (value << 1) + 1;
                    }
                    else {
                        value >>= 1;
                    }
                    ++count;
                }
                Console.WriteLine(count);
            }
        }
    }
}

Measured memory_bytes: 5600
def Calc(a,b,m):
    prod=0
    for i in range(m):
        prod=prod+a[i]*b[i]
    return prod


n,m=map(int,input().split(" "))

A=[[] for j in range(n)]
b=[0 for i in range(m)]

for i in range(n):
    A[i]=list(map(int,input().split(" ")))
for i in range(m):
    b[i]=int(input())

for i in range(n):
    print(Calc(A[i],b,m))


Measured memory_bytes: 6024
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>
using namespace std;

int main(void){
    // Your code here!
    int w, a, b;
    
    cin >> w >> a >> b;
    if(a < b)
        cout << max(b - (a + w), 0) << endl;
    else
        cout << max(a - (b + w), 0) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int , int> P;
typedef pair<ll, ll> PL;
const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}
 
int n,a,b;

int main(){
    cin >> n;
    if(n == 1){
        cout << "Hello World\n";
    }
    else{
        cin >> a >> b;
        cout << a + b << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
int main()
{
   char a[100][110],b[100][110];
   int n,m,s[112],t[112];
   scanf("%d",&n);
   int i,j=0,p=0;
   for(i=0;i<n;i++)
   {
       scanf("%s",a[i]);
   }
   scanf("%d",&m);
   for(i=0;i<n;i++)
   {
       if(a[i][0]!='0')
       {
           s[p]=1;t[p]=i;
       for(j=i+1;j<n;j++)
   {
       if(strcmp(a[i],a[j])==0)
       {
           s[p]++;a[j][0]='0';
       }
   }
   p++;
       }

   }

   for(i=0;i<m;i++)
   {
       scanf("%s",b[i]);
       for(j=0;j<p;j++)
       {
           if(strcmp(b[i],a[t[j]])==0)
           {
               s[j]--;
               break;
           }
       }
   }
   int max=0;
   for(i=0;i<p;i++)
   {
       if(s[max]<s[i])
       {
           max=i;
       }
   }
   if(s[max]>=0)
     printf("%d\n",s[max]);
   else
    printf("0\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define M 100001
using namespace std;
int main() {
  int N, A;
  vector<int> B(M), C(3);
  for (cin >> N; N; B[A]++, N--) {
    cin >> A;
  }
  for (int i = 0; i < M; i++) {
    if (B[i] && !(B[i]%2)) {
      C[2]++;
    } else if (B[i]) {
      C[1]++;
    }
  }
  if (C[2]%2) {
    cout << C[2]+C[1]-1;
  } else {
    cout << C[1]+C[2];
  }
}

Measured memory_bytes: 640
function Main(input){
  const splitted = input.split('\n');
  const N = parseInt(splitted[0]);
  const h = splitted[1].split(' ').map(elem => parseInt(elem));

  var total = 0;
  for(var i=1;i<=100;i++){
    var nowCounting = false;
    for(var j=0;j<N;j++){
      if(nowCounting){
        if(h[j] < i){
          nowCounting = false;
        }
      }else{
        if(h[j] >= i){
          nowCounting = true;
          total++;
        }
      }
    }
  }
  console.log(total);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(void) {

	char S[100],T[100];
	int i=0,n=0;

	scanf("%d", &n);


	scanf("%s %s", S, T);

	for(i=0;i<n;i++){
		printf("%c%c", S[i], T[i]);
	}

	return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> P(N),Q(N);
    rep(i,N) cin >> P[i];
    rep(i,N) cin >> Q[i];
    rep(i,N) A[i] = i+1;
    
    int p=0,q=0;
    int count=1;
    bool flag = true;
    do {
        flag = true;
        rep(i,N) if(A[i] != P[i]) flag = false;
        if(flag) p = count;
        flag = true;
        rep(i,N) if(A[i] != Q[i]) flag = false;
        if(flag) q = count;
        count++;
    } while (std::next_permutation(A.begin(), A.end()));
    cout << abs(q - p) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int N,M,G[10][10],s,t,dp[300][10],a=0;

int main()
{
	scanf("%d%d",&N,&M);
	for(int i=0;i<M;i++)
	{
		scanf("%d%d",&s,&t);
		s--;t--;
		G[s][t]=G[t][s]=1;
	}
	dp[1][0]=1;
	for(int i=1;i<(1<<N);i++)
	{
		for(int p=0;p<N;p++)
		{
			if((i>>p&1))
			{
				for(int t=0;t<N;t++)
				{
					if(!(i>>t&1)&&G[p][t]==1)
					{
						dp[i|(1<<t)][t]+=dp[i][p];
					}
				}
			}
		}
	}
	for(int i=0;i<N;i++)a+=dp[(1<<N)-1][i];
	printf("%d\n",a);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1e15
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int, int> P;
double a, b, c, d, PI = acos(-1), ans1, ans2, ans3, t;
signed main() {
	cin >> a >> b >> c;
	d = sqrt(a*a + b * b - 2 * a*b*cos((double)c / 180 * PI));
	ans2 = a + b + d;
	t = ans2 / 2;
	ans1 = sqrt(t*(t - a)*(t - b)*(t - d));
	ans3 = ans1 * 2 / a;
	printf("%.12lf\n%.12lf\n%.12lf\n", ans1, ans2, ans3);
	return 0;
}



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

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

  int n, k;
  cin >> n >> k;
  vi h(n);
  rep(i, n)cin >> h[i];

  sort(h.begin(), h.end());
  ll ans=0;
  rep(i, n-k)ans+=h[i];

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3976
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
char s[101];
bool vis[101],flag[101];
int main(){
	int n,t,ans=0;
	scanf("%d%s",&n,s);
	for(int i=0;s[i];i++){
		vis[s[i]-'a']=true;
		t=0;
		memset(flag,0,sizeof(flag));
		for(int j=i+1;s[j];j++)
			if (vis[s[j]-'a'])flag[s[j]-'a']=true;
		for(int j=0;j<26;j++)t+=flag[j];
		ans=max(ans,t);
	}
	printf("%d",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N_QUERY = 0;
bool ask(ll x) {
  static int num = 0;
  #define gc() getchar()
  static char tmp;
  N_QUERY ++;
  if (N_QUERY > 64) {
    cout << 1 / 0 << endl;
    assert(0);
  }
  printf("? %lld\n",x);
  fflush(stdout);
  for (tmp = gc() ; tmp != 'Y' && tmp != 'N' ; tmp = gc());
  return tmp == 'Y';
}
ll num[15],cur,cnt,tmp;
int main() {
  for (int i = 0 ; i < 9 ; ++ i) {
    int l = 0, r = 9, mid, ans;
    if (i == 0) l = 1;
    while (l <= r) {
      mid = (l + r) >> 1;
      if (ask((cur * 10ll + mid + 1) * 1000000000ll - 1))
        r = mid - 1, ans = mid;
      else l = mid + 1;
    }
    cur = cur * 10ll + ans;
    num[++cnt] = ans;
  }
  if (cur > 100000000);
  else ++ cnt;
  ll p,nz;
  int key;
  for (p = cnt ; p >= 1 && num[p] == 0 ; -- p);
  for (int i = 1 ; i <= p ; ++ i)
    tmp = tmp * 10ll + num[i];
  p ++;
  for (; p <= cnt ; ++ p) {
    nz = 1;
    for (int i = 1 ; i < p - 1 ; ++ i) 
      nz = nz * 10ll;
    if (tmp == nz) {
      nz = nz * 10ll - 1;
      key = ask(nz) ^ 1;
    } else {
      nz = nz * 10ll;
      key = ask(nz);
    }
    if (!key) break;
    tmp = tmp * 10ll;
  }
  printf("! %lld\n",tmp);
  fflush(stdout);
  // cerr << N_QUERY << endl;
  return 0;
}

Measured memory_bytes: 684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define lson (id << 1)
#define rson (id << 1 | 1)
#define lowb(x) (x & (-x))
#define mod 1000000007
#define inf 0x3f3f3f3f
#define maxm 
#define maxn 

int main()
{
	long long x, y;
	
	scanf("%lld%lld", &x, &y);
	int cc = 0;
	while (x <= y) {
		cc++;
		long long tmp = x;
		x <<= 1;
		if (x < tmp) break;
	}
	printf("%d\n", cc);
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

template <class T>
void cout_vec2(const vector<vector<T>> &vec){
  rep(i,vec.size()){
    rep(j,vec[i].size()){
      cout<<vec[i][j]<<' ';
    }
    cout<<endl;
  }
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    vector<ll> a(n),b(n);
    rep(i,n) cin>>a[i]>>b[i];
    ll ans=0;
    for(int i=31;i>=0;i--){
      ll mask=0;
      ll cnt=0;
      if(!(k & (1<<i))) continue;
      for(int j=31;j>=i+1;j--){
        if((k & (1<<j))) mask+=(1ll<<j);
      }
      for(int j=i-1;j>=0;j--) mask+=(1ll<<j);
      rep(j,n){
        if((a[j] & mask)==a[j]) cnt+=b[j];
      }
      ans=max(ans,cnt);
    }
    ll mask=k,cnt=0;
    rep(j,n){
      if((a[j] & mask)==a[j]) cnt+=b[j];
    }
    ans=max(ans,cnt);
    cout<<ans<<endl;
}

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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}

long long dist[100005], val[100005], c1[100005], c2[100005], c3[100005], c4[100005];

vector<long long> wt[4];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    // case 1: clockwise
    // case 2: counterclockwise
    // case 3: cw, then ccw
    // case 4: ccw, then cw

    int n;
    long long c, best = 0;
    cin >> n >> c;

    for(int i = 0; i < n; ++i)
        cin >> dist[i] >> val[i];

    long long cleft = 0, cright = 0;

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

        cright += val[i];
        cleft += val[n - i - 1];

        c1[i + 1] = max(c1[i], cright - dist[i]);
        c2[i + 1] = max(c2[i], cright - dist[i] * 2); // cost of coming back
        c3[n - i - 1] = max(c3[n - i], cleft - (c - dist[n - i - 1]));
        c4[n - i - 1] = max(c4[n - i], cleft - (c - dist[n - i - 1]) * 2);


    }

    for(int i = 0; i <= n; ++i)
        best = max(best, max(c1[i] + c4[i], c2[i] + c3[i]));

    cout << best << "\n";

    return 0;

}


Measured memory_bytes: 4992
abc = gets.chomp.split
a = abc[0].to_i
b = abc[1].to_i
c = abc[2].to_i
k = gets.to_i

power_count = 0
k.times do
    if c > b && b > a
        break
    elsif c > b
        b *= 2
    else
        c *= 2
    end
    power_count += 1
    if power_count == k && c > b && b > a
        power_count -= 1
        break
    elsif c > b && b > a
        break
    end
end

puts power_count < k ? "Yes" : "No"


Measured memory_bytes: 14344
#include <bits/stdc++.h>
using namespace std;
#define eb push_back
#define mp make_pair
#define hello cout<<"hello"<<"\n"
#define forr(i,a,b) for(int i=a;i<b;i++)
#define it(s)	for(auto itr:s)
#define dvg(s) 	for(auto itr:s)	cout<<itr<<" ";cout<<endl;
#define dbg(s)	cout<<#s<<"= "<<s<<endl;
typedef long long int lli;
typedef unsigned long long int ulli;
const int INF=INT_MAX;
const ulli MOD=1e9+7;


	

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    std::cout.precision(30);
	
	
	int n,k;
	cin>>n>>k;
	vector<lli> v(n,0);
	forr(i,0,n)	cin>>v[i];
	vector<lli> dp(n,INF);
	dp[0]=0;
	forr(i,1,n)
	{
		for(int j=max(0,i-k);j<i;j++)
		{
			dp[i]=min(dp[i],dp[j]+abs(v[i]-v[j]));
		}
	}
	
	
	cout<<dp[n-1]<<"\n";	
	return 0;
	
}













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

#define req(i,r,k) for(int i=k;i<r;i++)
#define rep(i,r) req(i,r,0)
const int INF = 10000;

int dp[1000000];
int odddp[1000000];

const long  int h = 180,nmax=1000000;

int main() {

    int n,a,a2;

    vector<int> t;
    vector<int> oddt;

    req(i,200,1){
        t.push_back(i * (i+1) * (i+2) / 6);
        if(t[i-1]%2 == 1){
            oddt.push_back(t[i-1]);
        }
        if(t[i-1] > 1000000) {
            t.erase(t.end() - 1);
            break;
        }
    }

    rep(i,nmax){
        dp[i] = INF;
        odddp[i] = INF;
    }

    /*rep(i,20){
        rep(j,41){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }*/

/*
    rep(i,oddh){
        odddp[i][0] = 0;
    }
*/

    /*rep(i,oddh){
        cout << t[i*2] << endl;
    }*/

    dp[0] = 0;
    odddp[0] = 0;


    rep(i,h){
        rep(j,nmax){
            if(j >= t[i]){
                dp[j] = min(dp[j],dp[j-t[i]] + 1);
            }
            else{
                dp[j] = dp[j];
            }
        }
    }

    int oddh;

    oddh = oddt.size();

    rep(i,oddh){
        rep(j,nmax){
            if(j >= oddt[i]){
                odddp[j] = min(odddp[j],odddp[j-oddt[i]] + 1);
            }
            else{
                odddp[j] = odddp[j];
            }
        }
    }

    while(1){

        cin >> n;
        if(n==0) break;


        printf("%d %d\n",dp[n],odddp[n]);

        /*if(dp[h-1][n] == INF){
            rep(i,h){
                rep(j,namx){
                    if(j >= t[i]){
                        dp[i+1][j] = min(dp[i][j],dp[i][j-t[i]] + 1);
                    }
                    else{
                        dp[i+1][j] = dp[i][j];
                    }
                }
            }
        }

        cout << dp[h-1][n] << ' ';
         */
/*
        if(odddp[oddh-1][n] == INF){
            rep(i,oddh){
                rep(j,w){
                    if(j >= t[i]){
                        dp[i+1][j] = min(dp[i][j],dp[i][j-t[i]] + 1);
                    }
                    else{
                        dp[i+1][j] = dp[i][j];
                    }
                }
            }
        }

        cout << odddp[h-1][n] << endl;
*/
    }




    return 0;
}

Measured memory_bytes: 10864
#include <stdio.h>
#include <iostream>
using namespace std;

int main(void){
  int tmp;
  int ary[3];
  cin >> ary[0] >> ary[1] >> ary[2];
  if(ary[0] > ary[1]){
    tmp    = ary[1];
    ary[1] = ary[0];
    ary[0] = tmp;
  }
  if(ary[1] > ary[2]){
    tmp    = ary[2];
    ary[2] = ary[1];
    ary[1] = tmp;
  }
  if(ary[0] > ary[1]){
    tmp    = ary[1];
    ary[1] = ary[0];
    ary[0] = tmp;
  }
  printf("%d %d %d\n", ary[0], ary[1], ary[2]);
  return 0;
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

void format(deque<ll> &v) {
    size_t n = v.size();
    if (n == 0) {
        v.emplace_back(0);
    }
}

void accum(deque<ll> &v) {
    size_t n = v.size();
    for (auto &&i: boost::irange(1U, (unsigned int) v.size())) {
        v.at(i) = v.at(i) + v.at(i - 1);
    }
}


int main() {
    ll N, W;
    cin >> N >> W;

    vector<deque<ll>> wvs(4, deque<ll>{});
    ll w0, _;
    cin >> w0 >> _;
    wvs.at(0).emplace_back(_);
    for (auto &&i: boost::irange(1LL, N)) {
        ll w, v;
        cin >> w >> v;
        wvs.at(w-w0).emplace_back(v);
    }
    for (auto &&i: boost::irange(0U, 4U)){
        format(wvs.at(i));
        sort(wvs.at(i).begin(), wvs.at(i).end(), greater<>());
        accum(wvs.at(i));
        wvs.at(i).emplace_front(0);
    }

    ll M{0};
    for (auto &&i0: boost::irange(0LL, (ll) wvs.at(0).size())) {
        for (auto &&i1: boost::irange(0LL, (ll) wvs.at(1).size())) {
            for (auto &&i2: boost::irange(0LL, (ll) wvs.at(2).size())) {
                for (auto &&i3: boost::irange(0LL, (ll)wvs.at(3).size())){
                    if (i0 * (w0) + i1 * (w0 + 1) + i2 * (w0 + 2) + i3 * (w0 + 3) > W)continue;
                    M = max(M, wvs.at(0).at(i0) + wvs.at(1).at(i1) + wvs.at(2).at(i2) + wvs.at(3).at(i3));
                }
            }
        }
    }
    cout << M;
    return 0;
}

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

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)

using namespace std;
using ll = long long;

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n,k;
  cin >> n>>k;
  int a[n];
  rep(i,n) cin>>a[i];
  int dp[n];
  for(int i=0;i<n;i++)
    dp[i]=INT_MAX;
  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
  for(int i=2;i<n;i++)
  {
    for(int j=1;j<=k and i-j>=0;j++)
    {
     dp[i]=min(dp[i],dp[i-j]+abs(a[i-j]-a[i]));
    }
    
  }
  cout<<dp[n-1]<<endl;
  return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] arags) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt();
		long[] list = new long[n];
		for(int i = 0; i < n; i++) {
			list[i] = sc.nextLong();
		}
		Map<Integer, Integer> map = new HashMap<>();
		for(; m > 0; m--) {
			int x = sc.nextInt()-1, y = sc.nextInt()-1;
			if(list[x] >= list[y]) {
				map.put(y, 1);
			}
			if(list[x] <= list[y]) {
				map.put(x, 1);
			}
		}
		System.out.println(n-map.size());
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 58528
#include <cstdio>

using namespace std;

int main()
{
 int n;
 int a[20], v[20];
 scanf("%d", &n);

 for (int i = 0; i < n; i++) scanf("%d %d", a + i, v + i);

 int ai = 9999, vi = -1;

 for (int i = 0; i < n; i++){
  if (v[i] > vi){
    vi = v[i];
    ai = a[i];
  }
  else if (v[i] == vi){
    if (ai > a[i]) ai = a[i];
  }
 }
 return (!printf("%d %d\n", ai, vi));
}

Measured memory_bytes: 1028
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

#define lc c[x][0]
#define rc c[x][1]

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-8;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 1e6+10;
const int MAXM = (int) 3e6+10;

///--------------------START-------------------------
int N;
LL ans=0;

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

void work(){
    scanf("%d",&N);
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            for(int k=1;k<=N;k++){
                int g1=gcd(i,j);
                int g=gcd(g1,k);
                ans+=g;
            }
        }
    }
    printf("%lld\n",ans);
}

///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}






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

namespace my {
template <typename T>
void input_vec(vector<T> &a, ll n) {
  if (!a.empty()) {
    cout << "wrong argument in input_vec" << endl;
    exit(1);
  }
  for (ll i = 0; i < n; i++) {
    T tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
}
template <typename T>
void input_set(set<T> &a, ll n) {
  if (!a.empty()) {
    cout << "wrong argument in input_set" << endl;
    exit(1);
  }
  for (ll i = 0; i < n; i++) {
    T tmp;
    cin >> tmp;
    a.insert(tmp);
  }
}

char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }

ll gcd(ll a, ll b) {  // O( log(a) )
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
ll lcm(ll a, ll b) { return a * (b / my::gcd(a, b)); }  // O( log(a) )

bool isPrime(ll n) {  // O( sqrt(n) )
  bool flag = true;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      flag = false;
      break;
    }
  }
  return flag;
}

vector<pair<ll, ll>> primeFac(ll n) {  // O( sqrt(n) )
  vector<pair<ll, ll>> ret;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll exp = 0;
    while (n % i == 0) {
      n /= i;
      exp++;
    }
    ret.push_back(make_pair(i, exp));
  }
  if (n != 1) ret.push_back(make_pair(n, 1));
  return ret;
}
}  // namespace my
////////////////////////////////////////////////

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

  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    ll shokou = i;
    ll makkou = (n / i) * i;
    ll kousa = i;
    ll kousuu = (makkou - shokou) / kousa + 1;
    ans += (kousuu * (shokou + makkou)) / 2;
    // cout << ans << endl;
  }

  cout << ans << endl;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int a,b,c;

signed main() {
    cin >> a >> b >> c;
    if (a == b && a == c) cout << "Yes" << endl;
    else cout << "No" << endl;
}




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

int main(){
	int n; cin>>n;
	vector<int> a(n+2,0),b(n+2,0);
	for(int i=1;i<=n;i++) {
		cin >> a[i];
		b[i]=b[i-1]+abs(a[i]-a[i-1]);
	}
	b[n+1]=b[n]+abs(a[n]);
	for(int i=1;i<=n;i++){
		cout << b[n+1]
		-(abs(a[i+1]-a[i])+abs(a[i]-a[i-1]))
		+abs(a[i+1]-a[i-1]) << endl;
	}
}


Measured memory_bytes: 2048
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
from collections import deque
def resolve():
    n,m,p=map(int,input().split())
    E=[[] for _ in range(n)]
    R=[[] for _ in range(n)]
    edges=[]
    for _ in range(m):
        a,b,c=map(int,input().split())
        a-=1; b-=1
        E[a].append(b)
        R[b].append(a)
        edges.append((a,b,p-c))

    state=[0]*n
    state[0]=1
    state[n-1]=2

    Q=deque([0])
    while(Q):
        v=Q.popleft()
        for nv in E[v]:
            if(state[nv]&1): continue
            state[nv]+=1
            Q.append(nv)

    Q=deque([n-1])
    while(Q):
        v=Q.popleft()
        for nv in R[v]:
            if(state[nv]&2): continue
            state[nv]+=2
            Q.append(nv)

    dist=[INF]*n
    dist[0]=0
    for k in range(n):
        for a,b,w in edges:
            if(state[a]!=3 or state[b]!=3): continue
            if(dist[b]>dist[a]+w):
                dist[b]=dist[a]+w
                if(k==n-1):
                    print(-1)
                    return
    print(max(-dist[-1],0))
resolve()

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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n;
	cin >> n;
	int mnFraction = INF;
	int sum = 0;
	vector<int> s(n);
	FOR(i,0,n){
		cin >> s[i];
		sum += s[i];
		if(s[i] % 10 != 0)mnFraction = min(mnFraction, s[i]);
	}
	if(sum % 10 != 0){
		ANS(sum);
	}else if(mnFraction == INF){
		ANS(0);
	}else{
		ANS(sum - mnFraction);
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(true){
            String s=sc.next();
            if(s.equals("-"))
                break;
        	int len=s.length();
        	int m=sc.nextInt();
        	for(int i=0;i<m;i++){
                String[] S=s.split("");
                String s1="",s2="";
            	int n=sc.nextInt();
                for(int j=0;j<n;j++){
                    s1+=S[j];
                }
                for(int j=n;j<len;j++){
                    s2+=S[j];
                }
            	s=s2+s1;
        	}
        	System.out.println(s);
        }
        sc.close();
    }
}
    


Measured memory_bytes: 46520
#include <string>
#include <iostream>
using namespace std;
int main(){
	string s;
	cin >> s;
	int n = s.size();
	int p = (n + 1) / 2;
	int i = 0,j = 0;
	int x = 0;
	while((i + j) < n){
		if(s[i] != s[n - j - 1]){
			if(s[i] == 'x'){
				j--;
				x++;
			}else if(s[n - j - 1] == 'x'){
				i--;
				x++;
			}else{
				cout << "-1" << endl;
				return 0;
			}
		}
		i++;
		j++;
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	int a, b, c;
	int count = 0;
	cin >> a >> b >> c;
	for (int i = a; i <= b; i++) {
		if (c%i == 0) { ++count; }
	}
	cout << count << endl;
}


Measured memory_bytes: 3108
S = input()
N = len(S)

#print(S)
#print(S[:int((N-1)/2+1)])
a = S[:int((N-1)/2)]
b = S[:int((N-1)/2):-1]
c = S[int((N+1)/2):]
d = S[int((N+1)/2):]
dd = d[::-1]
# print(a)
# print(b)
# print(c)
# print(dd)
if S == S[::-1] and a == b and c == dd:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
f :: Integer -> Integer
f x | x == 1 = 1
    | (x`mod`3) == 0 = f (x - 1)
    | (x`mod`5) == 0 = f (x - 1)
    | otherwise = x + f (x - 1)

main = do
    n <- readLn :: IO Integer
    print $ f n



Measured memory_bytes: 24172
N = int(input())
cnt = 0
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
for i in range(N+1):
	length = 0
	if(i%2==1):
		divi = make_divisors(i)
		length = len(divi)
	if(length == 8):
		cnt+=1
print(cnt)

Measured memory_bytes: 3064
/////16:35~
/////B:

#include<iostream>

using namespace std;
int main(){
    while(true){
        int T,D,L;
        cin>>T>>D>>L;
        if(T==0)return 0;
        int count = 0;
        int ans = 0;
        for(int i = 0;i<T;i++){
            int x;
            cin>>x;
            if(i==T-1)break;
            if(x>=L)count = D;
            if(count>0)ans++;
            count--;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3056
s = input()
n = len(s)
sum = 0
for b in range(1 << (n-1)):
    t = 0
    for i in range(n-1):
        if b & (1 << i):
            sum += int(''.join(s[t:i+1]))
            t = i+1
    sum += int(''.join(s[t:]))
print(sum)


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

using namespace std;
typedef long long ll;
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
const ll INF=-100000000000000000;

//a,b x
int main(){
	ll N; cin>>N;
	vector<ll> A(3*N+1);
	rep1(i,3*N) cin>>A[i];
	//1,2,3,4,......,3N-2,3N-1,3N
	// 1,2,3,....,3N-3,3N-2,3N-1
	
	priority_queue<ll,vector<ll>,greater<ll>> MAX;
	vector<ll> MAXsum(2*N+1,0);
	ll tmp=0;
	for(int i=1;i<=N;i++){
		MAX.push(A[i]);
		tmp+=A[i];
	}
	MAXsum[N]=tmp;
	for(int i=N+1;i<=2*N;i++){
		if(A[i]>MAX.top()){
			MAXsum[i]=MAXsum[i-1]+(A[i]-MAX.top());
			MAX.pop();
			MAX.push(A[i]);
		}
		else MAXsum[i]=MAXsum[i-1];
	}

	priority_queue<ll> MIN;
	vector<ll> MINsum(2*N+1,0);
	tmp=0;
	for(int i=3*N;i>=2*N+1;i--){
		MIN.push(A[i]);
		tmp+=A[i];
	}
	MINsum[2*N]=tmp;
	for(int i=2*N;i>=N+1;i--){
		if(A[i]<MIN.top()){
			MINsum[i-1]=MINsum[i]-(MIN.top()-A[i]);
			MIN.pop();
			MIN.push(A[i]);
		}
		else MINsum[i-1]=MINsum[i]; 
	}

	ll ans=INF;
	for(int i=N;i<=2*N;i++){
		ans=max(ans,MAXsum[i]-MINsum[i]);
	}
	cout<<ans;
}

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

#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define vll vector<ll>
#define pll pair<ll , ll>
#define vpll vector<pair<ll, ll> >
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define N 100001
#define HOLE 1000000007

ll fn(ll x,ll rn[])
{
    if(rn[x]==x) return x;
    else return rn[x]=fn(rn[x],rn);
}

void un(ll x,ll y,ll rn[],ll sz[])
{
    x=fn(x,rn);
    y=fn(y,rn);
    if(x==y) return;
    if(sz[x]<sz[y]) swap(x,y);
    sz[x]+=sz[y];
    rn[y]=x;
    return;
}

ll power(ll x,ll y)
{
    ll res = 1; // Initialize result

    while (y > 0) {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res * x)%HOLE;

        // n must be even now
        y = y >> 1; // y = y/2
        x = (x * x)%HOLE; // Change x to x^2
    }
    return res;
}

vector <ll> adjl[N];
ll marked[N]={0};
vector <ll> order;

void dfs (ll x){

    if(marked[x])
        return;
    marked[x]=1;

    REP(i,0,adjl[x].size()){

    }

    return;
}

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

    ll q=1;
    //cin>>q;
    while(q--){

        ll k,n;
        cin>>k>>n;

        ll a[n+1];

        int flag=0;

        REP(i,0,n){
            cin>>a[i];
        }

        a[n]=a[0]+k;

        ll maxd=0;

        REP(i,0,n){
            maxd=max(maxd,(a[i+1]-a[i]));
        }

        cout<<k-maxd<<endl;

    }

return 0;
}


Measured memory_bytes: 4224
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int ans = 0;
        int count = 0;
        for (int i = 0; i < s.length(); i++) {
            if(s.charAt(i) == 'I') {
                count++;
            } else {
                count--;
            }
            ans = Math.max(ans, count);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35804
s = int(input())
a = [s]
count = 1

for i in range(10**6+1):
    count += 1
    if a[i] % 2 == 0:
        if a[i]/2 in a:
            break
        a.append(a[i]/2)
    else:
        if 3*a[i] + 1 in a:
            break
        a.append(3*a[i] + 1)

print(count)


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

namespace ConsoleApp22
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var line = Console.ReadLine().Split(' ').Select(int.Parse).Take(n).ToArray();

            var ans = 0;
            for (int i = 1; i < line.Count() - 1; i++)
            {

                var list = new List<int> { line[i - 1], line[i], line[i + 1] };
                list.Sort();

                if(list[1] == line[i])
                {
                    ans++;
                }

            }

            Console.WriteLine(ans);
        }

    }


}


Measured memory_bytes: 13396
#include <stdio.h>
#include <algorithm>

using namespace std;

const int maxn = 510;
int k , n;
int a[maxn][maxn];
void work () {
	int i , j;
	scanf ( "%d" , &k );
	n = 2 * ((k+3)/4);
	if ( k == 1 ) {
		printf ( "1\n1\n" );
		return ;
	}
	for ( i = 1 ; i <= n ; i++ ) {
		for ( j = 1 ; j <= n ; j++ ) {
			a[i][j] = (i+j-2) % n + ((i-1)%2) * n;
			if ( a[i][j] >= k ) a[i][j] -= n;
		}
	}
	printf ( "%d\n" , n );
	for ( i = 1 ; i <= n ; i++ ) {
		for ( j = 1 ; j <= n ; j++ ) {
			printf ( "%d%c" , a[i][j] + 1 , j==n?'\n':' ' );
		}
	}
}
int main () {
	work ();
	return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<map>
#include<array>
#include<cstring>
#include<numeric>
#include<string>
#include<set>
#include<cstdio>
#include<cmath>
#include<unordered_map>
#include<bitset>
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int> x;
    while(n--){
        int tmp;
        cin>>tmp;
        x.push_back(tmp);
    }
    int res = 1;
    for(int i=0; i<x.size()-1; i++){
        if(x[i]>x[i+1]) res++;
        else x[i+1] = x[i];
    }
    cout<<res<<"\n";
    return 0;
}


Measured memory_bytes: 4248
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    private static Scanner scan;

    private static void start() {
        scan = new Scanner(java.lang.System.in);
    }

    private static void finish() {
    }


    public static void main(String[] args) {
        start();

        int a = scan.nextInt();
        int b = scan.nextInt();
        if (a * b % 2 == 0) {
            System.out.println("Even");
        } else {
            System.out.println("Odd");
        }

        finish();
    }
}


Measured memory_bytes: 21844
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(H: int, N: int, A: "List[int]"):
    if H <= sum(A):
        print(YES)
    else:
        print(NO)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(H, N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 13996
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
ans = 0

D = defaultdict(int)
for x in A:
    D[x] += 1
A.sort(reverse=True)

for x in A:
    for i in range(1, 31):
        if D[x] > 0:
            if 2**i-x in D.keys() and D[2**i-x] > 0:
                if 2**(i-1) != x:
                    ans += 1
                    D[x] -= 1
                    D[2**i-x] -= 1
for i in range(31):
    ans += D[2**i]//2
print(ans)

Measured memory_bytes: 130460