akhauriyash/Code-Regression huggingface dataset:
//#include <algorithm>
//#include <cassert>
//#include <cfloat>
//#include <cmath>
//#include <cstdio>
//#include <cstdlib>
//#include <deque>
#include <iostream>
//#include <limits>
//#include <map>
//#include <queue>
//#include <set>
//#include <stack>
//#include <string>
//#include <tuple>
//#include <unordered_map>
//#include <unordered_set>
//#include <vector>
using namespace std;

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

#define DIVUP(x, y) (((x) + ((y) - 1)) / (y))
#define DIVOFF(x, y) (((x) + ((y) / 2)) / (y))
#define REMAINDER(x, y) ((x) % (y))

char S[10+1];
int main() {
  scanf("%10s", &S);
  int len{0};
  for (; len < 10; ++len) {
    if (S[len] == '\0') break;
    S[len] &= 0xF;
  }
  int diff{1000};
  for (int i{0}; i <= len - 3; ++i) {
    int temp{0};
    for (int j{i}; j < i + 3; ++j) {
      temp = temp * 10 + S[j];
    }
    int d = 753 > temp ? 753 - temp : temp - 753;

    if (diff > d) diff = d;
  }


  printf("%d\n", diff);
  return 0;
}


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

int main() {
  string A, B, C;
  cin >> A >> B >> C;
  queue<char> QA, QB, QC;
  for (char e : A) QA.push(e);
  for (char e : B) QB.push(e);
  for (char e : C) QC.push(e);
  
  char t = 'a';
  while (1) {
    if (t == 'a') {
      if (QA.empty()) {
        cout << "A" << endl;
        break;
      }
      t = QA.front();
      QA.pop();
    }
    else if (t == 'b') {
      if (QB.empty()) {
        cout << "B" << endl;
        break;
      }
      t = QB.front();
      QB.pop();
    }
    else if (t == 'c') {
      if (QC.empty()) {
        cout << "C" << endl;
        break;
      }
      t = QC.front();
      QC.pop();
    }
  }
}

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

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

  if (A == "Sunny")
    cout << "Cloudy" << endl;
  if (A == "Cloudy")
    cout << "Rainy" << endl;
  if (A == "Rainy")
    cout << "Sunny" << endl;
}

Measured memory_bytes: 256
import numpy as np

a, b, h, m = map(int, input().split())
rad_a = 2 * np.pi / 720 * (60 * h + m)
rad_b = 2 * np.pi / 60 * m

ans = np.sqrt(a ** 2 + b ** 2 - 2 * a * b * np.cos(rad_a - rad_b))
print("{:.20f}".format(ans))

Measured memory_bytes: 27208
n,m=map(int,input().split())

num=[0]*n
for i in range(m):
  s_,c_=map(int,input().split())
  
  if s_==1 and c_==0 and n>1:
    print(-1)
    exit()
  elif num[s_-1]==0 or num[s_-1]==c_:
    num[s_-1]=c_
  else:
    print(-1)
    exit()
    
if num[0]==0 and len(num)>1:
  print(str(1)+''.join(map(str,num[1:])))
  
else:
  print(''.join(map(str,num)))

Measured memory_bytes: 9168
#include "bits/stdc++.h"
using namespace std;

// コンテスト中のみ
//#define int long long

#define ll long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define P pair<ll,ll>
int MOD = 1000000007;
const ll INF = 1LL << 60;

int N;
string c;
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> N;
	cin >> c;
	ll cntw = 0, cntr = 0;
	rep(i, N)if (c[i] == 'R')cntr++;
	ll ans = cntr;
	rep(i, N) {
		if (c[i] == 'R') {
			cntr--; 
		}
		else cntw++;
		ans = min(ans, max(cntr, cntw));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3748
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <cmath>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    int N, M, C;
    cin >> N >> M >> C;
    int B[M];
    int A[N][M];
    for(int i = 0; i < M; i++){
        cin >> B[i];
    }

    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            cin >> A[i][j];
        }
    }
    int count = 0;
    for(int i = 0; i < N; i++){
        int result = C;
        for(int j = 0;j < M; j++){
            result += B[j]*A[i][j];
        }
        if(result > 0){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int main(){
  FAST();

  int n, time;
  cin >> n >> time;
  vii abc(n);

  int small = INT_MAX;
  REP(i, 0, n){
      int c, t;
      cin >> c >> t;
      if(t <= time){
        small = min (small, c);
      }
  }
  if(small == INT_MAX)
    cout << "TLE\n";
  else
    cout << small << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define debug(X) cout << #X << " = " << X << endl

using namespace std;

const int oo = 1e9;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	#ifdef UTP
	freopen("input.txt", "r", stdin);
	#endif
	int a, b, c, x, y; cin >> a >> b >> c >> x >> y;
	int ans = oo;
	for (int i = 0; i <= x; i++)
		ans = min(ans, i * a + 2 * (x - i) * c + max(0, y - (x - i)) * b);
	for (int i = 0; i <= y; i++)
		ans = min(ans, i * b + 2 * (y - i) * c + max(0, x - (y - i)) * a);
	cout << ans << endl;
	return 0;
}


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

int main() {
  int N,answer;
  answer=1;
  cin >> N;
  vector<int> vec(N);
  for (int i; i<N; i++){
   cin >> vec.at(i); 
  }
  sort(vec.begin(), vec.end());
  for(int i=0; i<N-1; i++){
    if(vec.at(i)<vec.at(i+1)){
      answer++;
    }
  }
cout << answer << endl;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    S, T = readline().strip().split()

    ans = []
    for s, t in zip(S, T):
        ans.append(s)
        ans.append(t)

    print(''.join(ans))

    return


if __name__ == '__main__':
    main()


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

int main() {
  int N;
  int number = 0;
  cin >> N;
  for(int i=0; i < N; i++){
    int l,r;
    cin >> l >> r;
    number += r - l + 1;
  }
  cout << number <<endl;    
}


Measured memory_bytes: 256
c = [list(map(int, input().split())) for _ in range(3)]
for x in range(101):
	for y in range(101):
		for z in range(101):
			if x - y == c[0][0] - c[1][0] == c[0][1] - c[1][1] == c[0][2] - c[1][2]:
				if y - z == c[1][0] - c[2][0] == c[1][1] - c[2][1] == c[1][2] - c[2][2]:
					if z - x == c[2][0] - c[0][0] == c[2][1] - c[0][1] == c[2][2] - c[0][2]:
						print("Yes")
						exit()
print("No")


Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N, t, x, y, pt = 0, px = 0, py = 0;
	bool ans = true;

	cin >> N;
	rep(i, N) {
		int d, T;

		cin >> t >> x >> y;

		d = abs(x - px) + abs(y - py);
		T = t - pt;

		if (d > T) ans = false;
		else if ((T - d) % 2 != 0) ans = false;

		pt = t;
		px = x;
		py = y;
	}

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

	return 0;
}


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

int main() {
  int64_t n;
  cin >> n;
  vector<string> judge = {
    "a", 
    "b", 
    "c", 
    "d", 
    "e", 
    "f", 
    "g", 
    "h", 
    "i", 
    "j", 
    "k", 
    "l", 
    "m", 
    "n", 
    "o", 
    "p", 
    "q", 
    "r", 
    "s", 
    "t", 
    "u", 
    "v", 
    "w", 
    "x", 
    "y", 
    "z", 
  };
  string ans;
  while (n > 0){
    n--;
    ans = judge.at(n%26)+ ans;
    n /= 26;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3636
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt64() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func judge(k int64, n int, a int, b int, h []int) bool {
	var sum int64 = 0
	for i := 0; i < n; i++ {
		var t int64 = int64(h[i]) - k*int64(b)
		if t > 0 {
			sum += (t + int64(a-b-1)) / int64(a-b)
			if sum > k {
				return false
			}
		}
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)
	var n, a, b int

	n = nextInt()
	a = nextInt()
	b = nextInt()

	h := make([]int, n)

	for i := 0; i < n; i++ {
		h[i] = nextInt()
	}

	var low, high int64 = 0, 1000000009

	for low < high {
		mid := (low + high) / 2
		if judge(mid, n, a, b, h) {
			high = mid
		} else {
			low = mid + 1
		}
	}

	fmt.Println(low)
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
int dp[999],a[999],l[999],r[999],m[999],N,Q,i,j,k,OK;
main(){
	cin>>N;
	for(i=0;i<N;i++)cin>>l[i]>>r[i]>>m[i];
	for(i=0;i<N;i++)
		for(j=0;j<400;j++)
			for(k=l[i];k<=r[i];k++)
				dp[j+k]=max(dp[j+k],dp[j]+m[i]);
	cin>>Q;
	for(i=0;i<Q;i++){
		cin>>a[i]; 
		OK=dp[a[i]]?OK:1;
	}
	if(OK)cout<<"-1\n";
	else for(i=0;i<Q;i++)cout<<dp[a[i]]<<endl;
}

Measured memory_bytes: 1180
def primes(n,num):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    rec = {}
    ans = len(num)
    for i in num:
        if i in rec:
            if rec[i] == 1:
                ans -= 1
                continue
            else:
                if is_prime[i]:
                    ans -= 2
                else:
                    ans -= 1
                rec[i] = 1
                continue
        if not is_prime[i]:
            ans -= 1
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
        rec[i] = 0
    return(ans)
n = int(input())
a = list(map(int,input().split()))
a.sort()
ma = max(a)
ans = primes(ma,a)
print(ans)

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

using namespace std;

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<string> s(n);
  for (size_t i = 0; i < n; i++) cin >> s[i];
  vector<char> vec_inter(s[0].begin(), s[0].end());

  for (size_t i = 0; i < n; i++) {
    vector<char> si(s[i].begin(), s[i].end()), vec;
    sort(si.begin(),si.end());
    sort(vec_inter.begin(), vec_inter.end());
    set_intersection(vec_inter.begin(), vec_inter.end(), si.begin(), si.end(), back_inserter(vec));
    vec_inter = vec;
  }
  sort(vec_inter.begin(), vec_inter.end());
  string ans;
  for (size_t i = 0; i < vec_inter.size(); i++) ans.push_back(vec_inter[i]);
  cout << ans << endl;
  return 0;
}


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

/*Range Add Min(Max) Query*/
/*区間加算、区間Min,区間Max*/

class RSUQ{
public: 
  typedef long long ll;

  //マージ可能な主データ型
  struct D{
    ll value;
    D():value(0){} /*適切な値にする!!!!!!*/
    D(ll value):value(value){}
    bool operator < (D a)const {return value < a.value;}
  };

  //遅延用の型  
  struct T{
    int type; //0 - empty   , 1 - update
    ll value;
    T():type(0),value(0){}
    T(int type,ll value):type(type),value(value){}
  };

  
  int n, n_;
  vector<D> dat;
  vector<T> td;
  D returnD = D(0); // 範囲外の時に返す値。
  
  RSUQ(){n=-1;}
  RSUQ(int n_):n_(n_){
    n=1;
    while(n < n_) n *= 2;
    td.resize(2*n-1,T());
    dat.resize(2*n-1,D());
  }
  
  inline D merge(D a,D b){return a.value + b.value;}
  
  void delay(int k,int len){
    if(td[k].type==0) return;
    ll type = td[k].type;
    ll v = td[k].value;
    td[k].type = 0;
    td[k].value = 0;
    
    len /= 2;
    {
      int l = k*2+1;
      dat[l].value = v * len;
      td[l].type = type;
      td[l].value = v;
    }
    {
      int r = k*2+2;
      dat[r].value = v * len;
      td[r].type = type;
      td[r].value = v;
    }
  }

  D write(int k, D x, int len){
    dat[k].value = x.value * len;
    td[k].type = 1;
    td[k].value = x.value;
    return dat[k];
  }

  D test(int a,int b,D x, bool flag){
    
    function<D(int,int,int)> dfs = [&](int k, int l, int r){
      if(r <= a||b <= l) return flag? dat[k]:returnD;
      if(a <= l && r <= b) return flag? write(k, x, r - l):dat[k];
      delay(k, r - l);
      D vl = dfs(k*2+1, l, (l+r)/2);
      D vr = dfs(k*2+2, (l+r)/2, r);
      return flag? (dat[k] = merge(vl, vr)):merge(vl, vr);
    };
    return dfs(0, 0, n);
  }

  //[l,r)の値をx変更　query(l,r,x)
  void update(int l,int r,ll x){
    assert(l <= r);
    assert(0 <= l && l <= n);
    assert(0 <= r && r <= n);
    test(l, r, D(x), true);
  }
  
  //[l,r)の合計値を得る　find(a,b);
  ll find(int l,int r){
    assert(l <= r);
    assert(0 <= l && l <= n);
    assert(0 <= r && r <= n);
    D res = test(l, r, D(), false);
    return res.value;
  }
};


signed main(){
  int n,q;
  cin>>n>>q;
  
  RSUQ rsuq(n);

  while(q--){
    int cmd;
    cin>>cmd;
    if(cmd == 0){
      int s,t,x;
      cin>>s>>t>>x;
      rsuq.update(s,t+1,x);
    }
    
    if(cmd == 1){
      int s,t;
      cin>>s>>t;
      cout<<rsuq.find(s,t+1)<<endl;
    }
  }
  
  return 0;
}



Measured memory_bytes: 8888
N = gets.chomp.to_i
P = gets.chomp.split.map(&:to_i)

# If increasing order, n is match with i (index)

diff = 0
0.upto(N-1).each do |i|
  n = P[i]
  if n != (i + 1)
    diff += 1
  end
end

if diff <= 2
  print "YES\n"
else
  print "NO\n"
end

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

const int INF=1001001001001001001;

int N;
int A[222222];

vint calc(){
	vint table(N);
	for(int i=1;i<N;i++){
		if(A[i-1]>=A[i]){
			int tmp=A[i];
			while(tmp<=A[i-1]){
				tmp*=4;
				table[i]--;
			}
			table[i]++;
		}
		else{
			int tmp=A[i-1];
			while(tmp<A[i]){
				tmp*=4;
				table[i]++;
			}
		}
	}


	int num=0;
	deque<pint>deq;
	deq.eb(0,0);
	auto dbl=[&](int n){
		deq.back().se++;
		int p=deq.size()-1;
		while(p&&deq[p-1].se-deq[p].se<table[deq[p].fi]){
			deq[p-1].se++;
			p--;
		}
		if(p==0){
			num+=n;
		}
		else{
			num+=deq.size()-p;
		}
	};

	auto nor=[&](){
		while(deq.size()>1&&deq.front().se-deq[1].se==table[deq[1].fi]){
			deq.pop_front();
		}
	};

	vint ret(N+1);
	for(int i=1;i<N;i++){
		while(deq.back().se<table[i]){
			dbl(i);
			nor();
		}
		deq.eb(i,0);
		nor();
		ret[i+1]=num;
	}
	return ret;
}

signed main(){
	cin>>N;
	rep(i,N)cin>>A[i];
	
	vint pre=calc();
	reverse(A,A+N);
	vint suf=calc();
	reverse(all(suf));


	int ans=INF;
	for(int i=0;i<=N;i++){
		chmin(ans,(pre[i]+suf[i])*2+i);
	}

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

Measured memory_bytes: 6500
a,b,c,d=map(int,input().split())
total=b-a+1
cdead=b//c-(a-1)//c
ddead=b//d-(a-1)//d
from fractions import gcd

def lcm(a,b):
    x= a*b // gcd(a,b)
    return x

z=lcm(c,d)
cddead=b//z-(a-1)//z
print(total-cdead-ddead+cddead)

Measured memory_bytes: 63980
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
int a[1000001];

 int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n, m;  cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	int tmp = a[0];
	for (int i = 0; i < m; i++) {
		a[i] -= tmp;
	}
	int ans = 100000000;
	for (int i = 0; i < m; i++) {
		int tmp = 0;
		if (i + 1 < m)tmp = n - a[i + 1];
		int cnt = a[i] + tmp;
		ans = min(ans, cnt);
	}
	cout << ans << '\n';







}

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



int main(){
  int a[100]={0},num,kaisu=0,j,i,t;

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


for(i=0;i<num-1;i++){

  for(j=num-1;j>i;j--){

    if(a[j]<a[j-1]){
      t=a[j];a[j]=a[j-1];a[j-1]=t;
      kaisu++;
    }

  }
 }


 for(int i=0;i<num;i++){
   cout<<a[i];
   if(i<num-1) cout<<" ";
 }
 cout << endl;
 cout<<kaisu<<endl;

 return 0;
}



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

#define int long long
#define all(v) (v).begin(), (v).end()
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

const int INF = 1e18;

int N, A, B, C;
vector<int> l;

// Aに使う竹の集合、Bに使う竹の集合、Cに使う竹の集合を渡すと、作りたい竹にするのにかかるコストを返してくれる
int calc(vector<int> a, vector<int> b, vector<int> c) {
  int aRes = abs(accumulate(all(a), 0LL) - A) + ((a.size()-1) * 10);
  int bRes = abs(accumulate(all(b), 0LL) - B) + ((b.size()-1) * 10);
  int cRes = abs(accumulate(all(c), 0LL) - C) + ((c.size()-1) * 10);

  return aRes + bRes + cRes;
}

int rec(int idx, vector<int> a, vector<int> b, vector<int> c) {
  if (idx >=  N) {
    if (a.size() == 0 or b.size() == 0 or c.size() == 0) return INF;
    return calc(a, b, c);
  }

  int ret = INF;

  // idx番目の竹をAに使う
  a.push_back(l[idx]);
  chmin(ret, rec(idx+1, a, b, c));
  a.pop_back();

  // idx番目の竹をBに使う
  b.push_back(l[idx]);
  chmin(ret, rec(idx+1, a, b, c));
  b.pop_back();

  // idx番目の竹をCに使う
  c.push_back(l[idx]);
  chmin(ret, rec(idx+1, a, b, c));
  c.pop_back();

  // idx番目の竹を使わない
  chmin(ret, rec(idx+1, a, b, c));

  return ret;
}

signed main() {
  cin >> N >> A >> B >> C;
  l.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> l[i];
  }

  vector<int> a;
  vector<int> b;
  vector<int> c;
  cout << rec(0, a, b, c) << endl;

  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String word = br.readLine();
		int cnt = 0;
		String line;
		while ((line = br.readLine()) != null) {
			if (line.equals("END_OF_TEXT"))
				break;

			for (String w : line.split(" ")) {
				if (word.equalsIgnoreCase(w))
					cnt++;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 17104
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s[0]=='A'&&s[1]=='A'&&s[2]=='A') cout<<"No";
	else if(s[0]=='B'&&s[1]=='B'&&s[2]=='B') cout<<"No";
	else cout<<"Yes";
	return 0;
}

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

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

	if(b-a <= 0) cout << "delicious" << endl;
	else if(b-a <= x) cout << "safe" << endl;
	else cout << "dangerous" << endl;

	return 0;
}

Measured memory_bytes: 256
'use strict';

waterfall([
  function(next) {
    lineReader(4, next);
  }, function(line, next) {
    var toInt = function(s) {
      return parseInt(s);
    }
    var s = line[1].split(' ').map(toInt);
    var t = line[3].split(' ').map(toInt);

    function binSearch(start, end, i) {
      // console.log(start, end)
      var arr = s;
      var t = arr[start + Math.floor((end - start) / 2)];
      if (i === t) {
        return 1;
      }
      if (start >= end) {
        return 0;
      }
      if (i < t) {
        return binSearch(start, start + Math.floor((end - start) / 2) - 1, i);
      }
      if (i > t) {
        return binSearch(start + Math.floor((end - start) / 2) + 1, end, i);
      }
    }

    next(t.reduce(function(sum, i) {
      // console.log(i, sum,'---------------')
      return sum + binSearch(0, s.length - 1, i);
    }, 0));
  }], function(result) {
    console.log(result);
    process.exit(0);
  });

function strMap(str, map) {
  var newStr = '';
  for (var i = 0; i < str.length; i++) {
    newStr += map(str.charAt(i), i);
  }
  return newStr;
}

function lineReader(limit, cb) {
  var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout,
  });
  var lines = [];
  var counter = 0;
  reader.on('line', function(line) {
    lines.push(line);
    ++counter;
    if (counter === limit) {
      reader.close();
      return cb(lines);
    }
  });
  reader.on('close', function() {});
  reader.on('error', function(err) {
    cb(err);
  });
}

function waterfall(tasks, cb) {
  var taskIndex = 0;
  function nextTask(args) {
    if (taskIndex === tasks.length)
      return cb.apply(null, args);

    var taskCallback = function() {
      var _arguments = arguments;
      nextTask(Object.keys(_arguments).reduce(function(memo, key) {
        memo.push(_arguments[key]);
        return memo;
      }, []));
    };
    args.push(taskCallback);
    var task = tasks[taskIndex++];
    task.apply(null, args);
  }
  nextTask([]);
}

Measured memory_bytes: 29764
#include <bits/stdc++.h>  
using namespace std;  
typedef long long ll; 
typedef long double ld; 
const int INF = 0x3f3f3f3f;  
const int N = 200000 + 5;
int a[N],b[N];
 
int main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
	int k,n;
	cin >> k >> n;
	int maxn = 0;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		if(maxn < a[i] - a[i-1])
			maxn = a[i] - a[i-1];
	}
	int z = k+a[1]-a[n];
	if(z > maxn)
		maxn = z;
	cout << k - maxn << endl;
    return 0;
}

Measured memory_bytes: 1024
from math import factorial as f
def cmb(n,r):
    if n<r:return 0
    else:return f(n)//f(r)//f(n-r)

n,a,b=map(int,input().split())
v=sorted(map(int,input().split()),reverse=True)
m=sum(v[:a])/a
print(m)
i=j=a-1
while 1:
    if i==0:break
    elif v[i-1]!=v[a-1]:break
    else:i-=1
while 1:
    if j==n-1:break
    elif v[j+1]!=v[a-1]:break
    else:j+=1
ans=0
if i==0:
    for r in range(a,b+1):ans+=cmb(j+1,r)
else:
    ans+=cmb(j-i+1,a-i)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int f[30],c[100],b[100];
int main()
{
	string s,t;
	cin>>s;t=s;
	int a=s.size();
	for (int i=0;i<s.size();i++) c[i]=b[i]=s[i]-'a';
	if (s.size()<26){
		for (int i=0;i<s.size();i++) f[s[i]-'a']=1;
		for (int i=0;i<26;i++) if (f[i]==0){
			s+=char('a'+i);
			break;
		}
		cout<<s<<endl;
	}
	else if (s=="zyxwvutsrqponmlkjihgfedcba")
		cout<<-1<<endl;
	else{
		next_permutation(b,b+s.size());
		for (int i=0;i<s.size();i++)
			if (b[i]!=c[i]){
				for (int j=0;j<=i;j++)
					cout<<char('a'+b[j]);
				return 0;
			}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll n;
  cin >> n;
  if(n%2==0){
    print(n);
  }
  else{
    print(2 * n);
  }
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

t = [True] * (10 ** 6 + 1)
d = {}
for a in A:
    d.setdefault(a, 0)
    d[a] += 1

A = sorted(set(A))
for a in A:
    if d[a] > 1:
        t[a] = False
    for i in range(a + a, 10 ** 6 + 1, a):
        t[i] = False
print(sum(1 for a in A if t[a]))


Measured memory_bytes: 52036
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;

ll n,k;
const int maxn=2e5+5;
ll x[maxn][2];
ll fast_pow(ll a, ll b){
	ll ret = 1;
	for(;b;b>>=1){
		if(b&1) ret = ret * a % mod;
		a = a * a % mod;
	}
	return ret;
}

int main(){
	cin >> n >> k;
	ll mns=1;
	x[0][0]=1;
	x[0][1]=1;
	for (int i=1;i<=n-1;i++){
		mns *= (n+1-i);
		mns %= mod;
		mns *= fast_pow(i,mod-2);
		mns %= mod;	
		x[i][0]=mns;
	}
	mns = 1;
	for (int i=1;i<=n-1;i++){
		mns *= (n-i);
		mns %= mod;
		mns *= fast_pow(i,mod-2);
		mns %= mod;	
		x[i][1]=mns;
	}
	ll s=0;
	for (int i=0;i<=min(n-1,k);i++){
		s += x[i][0]*x[i][1];	
		s %= mod;
	}
	while (s<0) s+=mod;
	cout << s;
	return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
using namespace std;
typedef long long ll;
int num[105]={0},idx[105];
int main(){
  int n;
  cin>>n;
  for(int i=1;i<=n;i++) {
    cin>>num[i];
    idx[i]=i;
  }
  vector<int> ans;
  for(int i=0;i<n;i++){
    bool f=false;
    for(int j=n;j>=1;j--){
      if(idx[j]==num[j]){
        f=true;
        ans.push_back(num[j]);
        idx[j]=0;
        for(int k=j+1;k<=n;k++) idx[k]--;
        break;
      }
    }
    if(!f){
      cout<<-1<<endl;
      return 0;
    }
  }
  for(int i=ans.size()-1;i>0;i--) cout<<ans[i]<<" ";
  cout<<ans[0]<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define vii vector<int>
#define vcc vector<char>
#define pll pair<long long, long long>
#define mem memset
#define sof sizeof
#define PB push_back
#define MP make_pair
#define TS to_string
#define F first
#define S second
#define endl '\n'
using namespace std;
long long binsearch(long long ar[],long long l,long long h,long long value){
    while(l<=h){
        long long mid=l+(h-l)/2;
        if(ar[mid]==value||ar[mid]<value&&ar[mid+1]>value){
            return mid;
        }
        else if(ar[mid]<value) l=mid+1;
        else h=mid-1;
    }
    return h;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long a,b,c,d,e,f,i,j,k,m,n,o,x,y;
    cin>>a>>b>>k;
    long long aa[a+1], ab[b+1];
    long long mx=0,s=k;
    aa[0]=0,ab[0]=0;
    for(i=1;i<=a;i++) cin>>aa[i];
    for(i=1;i<=b;i++) cin>>ab[i];
    for(i=1;i<=a;i++) aa[i]+=aa[i-1];
    for(i=1;i<=b;i++) ab[i]+=ab[i-1];
    long long srt=binsearch(aa,0,a,k);
    for(i=srt;i>=0;i--){
        s=k-aa[i];
        j=binsearch(ab,0,b,s);
        mx=max(mx,(i+j));
    }
    cout<<mx<<"\n";   
}

Measured memory_bytes: 6752
#include <iostream>
#include <stack>

using namespace std;

int main()
{
	int a;
	stack<int> car;

	while (cin >> a){

		if (a != 0){
			car.push(a);
		}
		if (a == 0){
			cout << car.top() << endl;
			car.pop();
		}
	}

	return 0;
}

Measured memory_bytes: 1200
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  ll n, k, ans = 1;
  scanf("%lld%lld", &n, &k);
  for (int i = 0; i < n; i++)
  {
    ans = MIN(ans * 2, ans + k);
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<=n;i++)
#define rep2(i,k,n) for(int i=k;i>=n;i--)
using namespace std;
const int N=1e5+7;
typedef long long ll;
int n,a[N],b[N],ans=0;
int main(){
	scanf("%d",&n);
	rep(i,1,n)scanf("%d",&a[i]),b[i]=a[i];sort(b+1,b+n+1);
	rep(i,1,n)a[i]=lower_bound(b+1,b+n+1,a[i])-b;
	rep(i,1,n)if((i&1) && !(a[i]&1))ans++;
	printf("%d\n",ans);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
int n,m;
 
//vector<pair<int,long long> > adj[2503];
vector<pair<long long,pair<int,int> > > edges;
long long dis[2503];
long long disn[2503];
long long par[2503];
 
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int p;
	cin>>n>>m>>p;
	for(int i=0;i<m;i++){
		int x,y,z;
		cin>>x>>y>>z;
		//adj[x].push_back({y,z});
		edges.push_back({p-z,{x,y}});
	}
	
	for(int i=2;i<=n;i++) dis[i] = 1e18;
	dis[1] = 0;
	
	
	for(int i=0;i<n-1;i++){
		for(auto x : edges){
			if(x.second.second == n){
				if(dis[x.second.first] + x.first < disn[x.second.first]){
					disn[x.second.first] = dis[x.second.first] + x.first;
				}
			}
			if(dis[x.second.first] + x.first < dis[x.second.second]){
				dis[x.second.second] = dis[x.second.first] + x.first;
			}
		}
	}
	long long ans = -dis[n];
	
	for(int i=0;i<n;i++){
		for(auto x : edges){
			if(x.second.second == n){
				if(dis[x.second.first] + x.first < disn[x.second.first]){
					//disn[x.second.first] = dis[x.second.first] + x.first;
					cout<<-1;
					return 0;
				}
			}
			if(dis[x.second.first] + x.first < dis[x.second.second]){
				dis[x.second.second] = dis[x.second.first] + x.first;
			}
		}
	}
	
	if(-dis[n] > ans){
		cout<<-1;
		return 0;
	}
	cout<<max(ans,0ll)<<endl;;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
using namespace std;
int main()
{
    int n;
    cin >> n;
    double ans;
    if (n % 2 == 0)
    {
        ans = 1.0 / 2;
        cout << setprecision(6) << ans << endl;
    }
    else if (n % 2 != 0)
    {
        ans = (n + 1) / 2.0 / n;
        cout << setprecision(6) << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n = int(input().rstrip())

current_max = 0
current = []
table = {}

for i in range(n):
    s = input().rstrip()
    table[s] = table[s] + 1 if table.get(s) is not None else 0
    if table[s] > current_max:
        current = [s]
        current_max = table[s]
    elif table[s] == current_max:
        current.append(s)
    else:
        continue

current.sort()

for word in current:
    print(word)


Measured memory_bytes: 33420
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

bool palin(string s){
  string temp = s;
  reverse(all(temp));
  return s == temp;
}

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  string s;
  cin >> s;
  int n = s.size();
  bool f = true;
  if(!palin(s)){
    f  = false;
  }
  s = " "+s;
  string s1 = s.substr(1,(n-1)/2);
  string s2 = s.substr((n+3)/2);
  if(!palin(s1) || !palin(s2) ){
    f = false;
  }
  if(f){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

return 0;
}
///....


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define MXN 200005
int f[105];
void KMP(char *c){
    f[0]=-1;
    int j = -1;
    for(int i = 1;c[i]!=0;i++){
        while(j!=-1&&c[i]!=c[j+1])j=f[j];
        if(c[i]==c[j+1])j++;
        f[i]=j;
    }
}
int main(){
    int n;
    scanf("%d",&n);
    char s[105],t[105];
    scanf("%s %s",s,t);
    KMP(t);
    int j=-1;
    for(int i = 0 ; s[i] != 0 ; i++){
        while(j!=-1&&s[i]!=t[j+1])j=f[j];
        if(s[i]==t[j+1])j++;
    }
    printf("%d\n",2*n-j-1);
}
/*

b[i]*K!/(i)!*(K-i)!
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
 
const ll N = 105;
const ll INF = 2e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-7;
const double PI = acos(-1.0);

pll bags[N];
ll n, m, ans;
ll memo[100005];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    cin >> n >> m;
    for(int i = 0; i < n; i++)
        cin >> bags[i].first >> bags[i].second;
 
    for(int i = 0; i < 100005; i++)
        memo[i] = INF;

    memo[0] = 0;
    for(int i = 0; i < n; i++)
        for(int j = 100000; j >= 0; j--)
            if(bags[i].second <= j)
                memo[j] = min(memo[j], memo[j - bags[i].second] + bags[i].first);
    
    for(int i = 0; i < 100005; i++)
        if(memo[i] <= m)
            ans = i;

    cout << ans << endl;
}

Measured memory_bytes: 1024
/*
 *  Created by Andrei Arhire 23/07/2020
 *  Copyright © 2020 Andrei Arhire. All rights reserved.
 */
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lll long long
#define llf __float128
#define lld long double
using namespace std;
const int N = 5e5 + 10  ,oo = 1e9 + 10, MOD = 1e9 + 7 ;
const long double pi = 2*acos(0.0);

int read() {
    int x = 0, f = 1; char ch;
    while(! isdigit(ch = getchar())) (ch == '-') && (f = -f);
    for(x = ch^48; isdigit(ch = getchar()); x = (x << 3) + (x << 1) + (ch ^ 48));
    return x * f;
}
int n, m, len, a[N], bel[N], cnt[N];
lll res, ans[N];
struct node {int l, r, id;} q[N];
//bool cmp(node x, node y) {return bel[x.l] == bel[y.l] ? bel[x.l] < bel[y.l] : x.r < y.r;}
bool cmp(node x, node y) {return (bel[x.l] == bel[y.l]) ? (bel[x.l] % 2 == 1 ? x.r < y.r : x.r > y.r) : x.l < y.l;}
signed main () {
    int x , y , i , temp ;
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0) ;
    n = read(); m = read(); len = sqrt(n);
    for(int i = 1; i <= n; ++ i) a[i] = read(), bel[i] = (i - 1) / len + 1;
    for(int i = 1; i <= m; ++ i) q[i].l = read(), q[i].r = read(), q[i].id = i;
    int l = 1, r = 0; sort(q + 1, q + m + 1, cmp);
    for(int i = 1; i <= m; ++ i) {
        while(l > q[i].l)    {
            x = -- l ;
            cnt[a[x]] ++; if ( cnt[a[x]] == 1 ) ++ res ;
        }
        while(r < q[i].r)   {
            x = ++ r ;
            cnt[a[x]] ++; if ( cnt[a[x]] == 1 ) ++ res ;
        }
        while(l < q[i].l) {
            x = l ++ ;
            cnt[a[x]] --; if ( cnt[a[x]] == 0 ) -- res ;
        }
        while(r > q[i].r) {
            x = r -- ;
            cnt[a[x]] --; if ( cnt[a[x]] == 0 ) -- res ;
        }
        ans[q[i].id] = res;
    }
    for(int i = 1; i <= m; ++ i) printf("%lld\n", ans[i]);

    return 0 ;
}

Measured memory_bytes: 19372
N = int( input())
S = list( input())

intger2 = 0
c = []

for i in range(N):
  intger1 = 0
  str1 = list(set(S[i + 1:]))
  str2 = list(set(S[:i + 1]))
  l = len(str2)
  
  for j in range(l):
    if( str2[j] in str1):
      intger1 += 1
      
    else:
      continue
  
  if( intger2 <= intger1):
    intger2 = intger1
    c.append(intger2)
    
  else:
    continue

print(max(c))

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

using namespace std;
int x[10];
int main(){
for(int i=0;i<10;i++){
cin>>x[i];
}
sort(x,x+10);
cout<<x[9]<<endl;
cout<<x[8]<<endl;
cout<<x[7]<<endl;
return 0;
}

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

unsigned long long n;

void solve();

int main() {
  cin >> n;

  solve();
  return 0;
}

void solve() {
  for(int i = 1; i <= 3500; ++i)
    for(int j = 1; j <= 3500; ++j) {
      unsigned long long x = n * i * j,
                         y = 4 * i * j - n * j - n * i, z;
      if(y == 0) continue;
      z = x / y;
      if(x % y == 0 && z >= 1 && z <= 3500) {
        cout << i << " " << j << " " << z << endl;
        return;
      }
    }
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int N,X;
  cin>>N>>X;
  int temp;
  int min=10000;
  for(int i=0;i<N;i++){
    cin>>temp;
    min=(min<temp)?min:temp;
    X-=temp;
  }
  cout<<N+(X/min);
  return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
   return os<<"{"<<p.fs<<","<<p.sc<<"}";
}
template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
   os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}
template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}



signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll x,g,l;cin>>x;
  g=gcd(x,360ll);
  l=x*360/g;
  cout<<l/x<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 3652
a, b, c, d = map(int, input().split())

for i in range(10000):
    if i % 2 == 0:
        c -= b
        if c <= 0:
            t_win = 1
            #print('Yes')
            break
    else:
        a -= d
        if a <= 0:
            t_win = 0
            #print('No')
            break
    
    #print(a, c)
    #if t_win == 0 or t_win == 1:
    #    break

if t_win == 1:
    print('Yes')
else:
    print('No')

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    map<char, int> mp;
    rep(i, n) {
        ++mp[s[i]];
    }
    ll ans = 1;
    for ( auto tmp_mp : mp ) {
        ans = ( ans * ( (ll)tmp_mp.second + 1LL ) % mod ) % mod;
    }
    cout << ans - 1LL << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef int int_t;

int_t A[200010], B[200010];

int main() {
    int_t n, k; scanf("%d%d", &n, &k);
    for(int_t i=1;i<=n;i++) scanf("%d", &A[i]);
    for(int_t i=1;i<=k;i++) {
        memset(B, 0, sizeof B);
        for(int_t j=1;j<=n;j++) B[max(1, j - A[j])] ++, B[min(n, j + A[j]) + 1] --;
        for(int_t j=1;j<=n;j++) A[j] = A[j-1] + B[j];
        bool ok = true;
        for(int_t j=1;j<=n;j++) if(A[j] < n) ok = false;
        if(ok) break;
    }
    for(int_t i=1;i<=n;i++) cout << A[i] << " ";
}

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

using ll =long long;

//最大公約数
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);
}
//文字列→数列
//string S;int A=atoi(S.c_str());
//数列→文字列
//int A;string S=to_string(A);
//
//
//
int main(){
int N;cin>>N;
  vector<int> v(N);
  int sum=0;
  for(int i=0;i<N;i++){
    cin>>v[i];
    sum+=v[i];
  }
  sort(v.begin(),v.end());
  sum-=v[N-1];
  if(v[N-1]<sum){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}


Measured memory_bytes: 256
n = gets.to_i
array=gets.chomp.split(" ").map(&:to_i)
sorted = array.sort

ret = 0

(0..(n-1)).each do |i|
    t = sorted[i]
    t_index = array.index(t)
    count = 0
    while t_index > i do
        count+=1
        s = sorted[t_index]
        s_index = array.index(s)
        ret+=s
        array[t_index], array[s_index] = array[s_index], array[t_index]
        t_index = s_index
    end
    ret += [t*count, t*2+sorted[0]*(count+2)].min
end

puts ret


Measured memory_bytes: 8888
n,m,c=map(int, input().split())
b=list(map(int,input().split()))
a=[[int(i) for i in input().split()] for n in range(n)]
cnt=0
for i in a:
    tmp=0
    for x,j in enumerate(i):
        tmp+=j*b[x]
    tmp+=c
    if tmp>0:
        cnt+=1
print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define lowbit(x) ((x)&(-(x)))

const int maxn=2e5+10;

int n,a[maxn][3],b[maxn];
bool R0,R1,S0,S1;

struct BIT{
	bool v[maxn];

	void add(int x)
	{
		for (;x<=n;x+=lowbit(x)) v[x]^=1;
	}

	bool query(int x)
	{
		bool Sum=0;
		for (;x;x-=lowbit(x))
			Sum^=v[x];
		return Sum;
	}
}B0,B1;

int main()
{
#ifdef h10
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
#endif
	int i;
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d",&a[i][0]);
	for (i=1;i<=n;i++) scanf("%d",&a[i][1]);
	for (i=1;i<=n;i++) scanf("%d",&a[i][2]);

	for (i=1;i<=n;i++)
		if (a[i][0]+1==a[i][1]&&a[i][1]==a[i][2]-1)
		{
			if (((a[i][2]/3)&1)!=(i&1)) {puts("No"); return 0;}
			b[i]=a[i][2]/3;
		}
		else if (a[i][0]-1==a[i][1]&&a[i][1]==a[i][2]+1)
		{
			if (((a[i][0]/3)&1)!=(i&1)) {puts("No"); return 0;}
			b[i]=a[i][0]/3;
			i&1?R1^=1:R0^=1;
		}
		else {puts("No"); return 0;}

	for (i=n;i>=1;i--)
		if (i&1) S1^=B1.query(b[i]),B1.add(b[i]);
		else S0^=B0.query(b[i]),B0.add(b[i]);

	puts(S0==R1&&S1==R0?"Yes":"No");
}


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

#define int long long

signed main() {
	ios::sync_with_stdio(0); cin.tie(0);
		
	int n, d; cin >> n >> d;
	int ans = 0;
	while (n--) {
		int x, y; cin >> x >> y;
		if (x*x + y*y > d*d) {

		} else ans++;
	}
	cout << ans;

	return 0;
}


Measured memory_bytes: 3652
def test():
    n = int(input())
    a = list(map(int,input().split()))
    ans = 0
    for i in a:
        if i % 2 == 0:
            while i%2 == 0:
                i /= 2
                ans += 1
    print(ans)


if __name__ == "__main__":
    test()


Measured memory_bytes: 4148
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		int[] A = new int[n];
		
		for (int i = 0; i < n; i ++) {
			A[i]  = scanner.nextInt();
		}
		
		int q = scanner.nextInt();

		for (int i = 0; i < q; i ++) {
			System.out.println(resolve(A, 0, 0, scanner.nextInt()) ? "yes": "no");
		}
		
		scanner.close();
	}
	
	public static boolean resolve(int[] A, int i, int sum, int m) {
		if(sum == m) return true;
		if(i >= A.length) return false;
		return resolve(A, i + 1, sum, m) || resolve(A, i + 1, sum + A[i], m);
	}
} 



Measured memory_bytes: 26800
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  s[3] = '8';
  cout << s << endl;
  return 0;
}


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

int main() {
	int nums[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
	
	int n, m;
	cin >> n >> m;
	
	vector<int> a(m);
	for (int i = 0; i < m; i++) cin >> a[i];
	
	vector<int> dp(n + 1, -1);
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		if (dp[i] == -1) continue;
        for (int j = 0; j < m; j++) {
			if (i + nums[a[j]] <= n) dp[i + nums[a[j]]] = max(dp[i + nums[a[j]]], dp[i] + 1);
		}
	}

	string res = "";
	sort(a.begin(), a.end(), greater<int>());
	while (n > 0){
        for (int i = 0; i < m; i++) {
			if (n - nums[a[i]] >= 0) {
				if (dp[n] == dp[n - nums[a[i]]] + 1) {
					res += '0' + a[i];
					n -= nums[a[i]];
					break;
				}
			}
		}
	}
	
	cout << res << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  String a = sc.next();
  String b = sc.next();
  if(a.length() > b.length()){
    for(int i = 0;i < a.length()-1;i++){
      System.out.print(a.charAt(i));
      System.out.print(b.charAt(i));
    }
    System.out.println(a.charAt(a.length()-1));
  }
  else{
    for(int i = 0;i < a.length();i++){
      System.out.print(a.charAt(i));
      System.out.print(b.charAt(i));
    }
  }
}}

Measured memory_bytes: 21844
h, w = map(int, input().split())
A = [list(str(input())) for i in range(h)]

n = h*w

def Find(x, par):
    if par[x] < 0:
        return x
    else:
        par[x] = Find(par[x], par)
        return par[x]

def Unite(x, y, par, rank):
    x = Find(x, par)
    y = Find(y, par)

    if x != y:
        if rank[x] < rank[y]:
            par[y] += par[x]
            par[x] = y
        else:
            par[x] += par[y]
            par[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1

def Same(x, y, par):
    return Find(x, par) == Find(y, par)

def Size(x, par):
    return -par[Find(x, par)]

par = [-1]*n
rank = [0]*n

for i in range(h):
    for j in range(w):
        idx1 = i*w+j
        idx2 = i*w+(w-1-j)
        idx3 = (h-1-i)*w+j
        Unite(idx1, idx2, par, rank)
        Unite(idx1, idx3, par, rank)
X = [0]*26
for i in range(h):
    for j in range(w):
        k = ord(A[i][j])-ord('a')
        X[k] += 1
temp = []
for i in range(26):
    if X[i] > 0:
        temp.append(X[i])
S = []
for i in range(h*w):
    if par[i] < 0:
        S.append(-par[i])

#print(temp)
#print(S)
S.sort(reverse=True)
import heapq
temp = [-1*t for t in temp]
heapq.heapify(temp)
for s in S:
    if temp:
        t = heapq.heappop(temp)*(-1)
        if t >= s:
            heapq.heappush(temp, (-1)*(t-s))
        else:
            print('No')
            exit()
    else:
        print('No')
        exit()
else:
    print('Yes')


Measured memory_bytes: 75952