akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
using namespace std;
const int N=2e5+5,inf=1e9;
int n,a[N],ans; map<int,int> mp;
int main(){
	scanf("%d",&n);
	rep (i,1,n){
		scanf("%d",&a[i]); mp[a[i]]++;
	}
	sort(a+1,a+1+n,greater<int>());
	rep (i,1,n){
		if (!mp[a[i]]) continue;
		int j;
		for (j=1;j<=inf;j*=2) if (j>a[i]) break;
		mp[a[i]]--;
		if (mp.count(j-a[i])&&mp[j-a[i]]) mp[j-a[i]]--,ans++; else mp[a[i]]++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 10368
#include<iostream>
#include<numeric>
#include<set>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define yn(i) ((i)?"Yes":"No")
#define chmin(a,b) (a>(b)?a=(b),1:0)
#define abs(n) max((n),-(n))
#define dist(a,b) max((a)-(b),(b)-(a))
#define chmax(a,b) (a<(b)?a=(b),1:0)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define MOD 1000000000
#define rep(i,n) for(int i=0;i<(n);i++)

#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}




string key="keyence";

void add(char m,string s,set<string> st){
  int n=s.size();
  rep(i,n){
    if(s[i]!=m) continue;
    string t;
    repa(j,i,n){
      t.push_back(s[j]);
      st.insert(t);
    }
  }
}

int main(){
  int n,x; cin >>n >>x;
  int d=0,cnt=0;
  rep(i,n){
    if(d<=x) cnt++;
    int l; cin >>l;
    d=d+l;
  }
  if(d<=x) cnt++;
  print(cnt);
}





Measured memory_bytes: 3584
(a,k),o,(u,),r=$<.map{|y|y.split.map &:to_i}

z = [0]
a.times do |i|
  z[i+1] = z[i] + o[i] > k ? [z[i], 2 * k - (z[i] + o[i])].max : z[i] + o[i]
end

p = []
s = 0

(a-1).downto 0 do |i|
  p[i] = k - s > z[i]
  s += o[i] if o[i] / 2 <= s
end

r.each do |q|
  puts p[q-1] ? "YES" : "NO"
end


Measured memory_bytes: 51272
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 1e18;


int main() {
	int n; cin >> n;
	vector<int> a(n);
	rep(i, 0, n) cin >> a[i];
	vector<int> b; b = a;
	sort(b.begin(), b.end());
	int l = b[n / 2 - 1], r = b[n / 2];
	rep(i,0, n) {
		if (r > a[i]) cout << r << endl;
		else cout << l << endl;
	}
	return 0;
}

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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define repi(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mt make_tuple
#define mp make_pair
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using P = pair<ll, ll>;
using ld = long double;  using vld = vector<ld>; 

int main(void) {
	string s; cin >>s;
	ll ans=0;
	rep(i,3){
		if(s[i]=='1') ans++;
	}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef vector<string> vi;
typedef vector< vi > vvi;
typedef pair<int, int> pii;  // pair<int, int> に pii という別名を付ける
typedef long long ll;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	int N = S.size();
	int count = 0;
  int limit = (N-1) / 2;
	//for (int i = 0; i < N; i++) {
    //cout << S.at(i);
  //}
 // cout << N << endl;
  //cout << limit << endl;
  bool ans = true;
  //条件１
  for (int i = 0; i < limit; i++){
		if(S.at(i) != S.at(N-i-1)){
    //  cout << "i: " << i << endl;
			ans = false;
		}
	}
  //条件２
  for (int i = 0; i < ceil(limit/2); i++)  {
    if(S.at((N+3)/2 - 1) != S.at(N - 1)){
      ans = false;
    }
  }

	if (ans){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

typedef long long ll;

int main(void){
  ll a,b,c;
  scanf("%lld",&a);
  scanf("%lld",&b);
  scanf("%lld",&c);
  if(4*a*b <(c-a-b)*(c-a-b) && c-a-b > 0){
    printf("Yes");
  }else{
    printf("No");
  }
  
  return 0;
}
  
  

Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<stack>
#include<queue>
#include<vector>
#include<climits>
#include<algorithm>
using namespace std;

typedef long long int ll;

int main() {
    string s;
    cin >> s;
    int len = s.length();
    if (s[len - 1] != 's') {
        s += 's';
    } else {
        s += "es";
    }

    cout << s << endl;
}


Measured memory_bytes: 3628
#include<iostream>

using namespace std;

int main(void){
  int n,p_max,p_max_index;
  p_max = 0;
  int p[10]={0,0,0,0,0,0,0,0,0,0};
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> p[i];
    if(p_max < p[i]){
      p_max = p[i];
      p_max_index = i;
    }
  }
  p[p_max_index] /= 2;
  //cout << p_max_index << endl;
  int sum=0;
  for(int i=0; i<10; i++){
    sum += p[i];
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
N,M = map(int,input().split())
A=list(map(int,input().split()))
cards = defaultdict(int)
for a in A:
    cards[a]+=1
for i in range(M):
    b,c = map(int, input().split())
    cards[c] += b
d = [[k, cards[k]] for k in cards.keys()]
d.sort(key = lambda x:x[0], reverse=True)
ans = 0
i = 0
j = 0
while i < N:
    card,num = d[j]
    if i + num >= N:
        ans += (N-i)*card
        i = N
    else:
        ans += num*card
        i += num
    j += 1
print(ans)


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

int main(){
    int n,x;
    cin >> n >> x;
    vector<int>m(n);
    int sum=0;
    for(int i=0;i<n;i++){
        cin >> m[i];
        sum+=m[i];
    }
    sort(m.begin(),m.end());
    x -= sum;
    int count = x/m[0];
    cout << n + count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<int,int> pi;
typedef pair<int,pi> pii;
typedef vector<pi> vpi;
typedef set<int> si;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define f first
#define s second
ll INF = 1e15;
ll MOD = 1e9;
#define lb lower_bound
#define ub upper_bound
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(),x.end()

int N,M,Q,a,b,d;
vector<pi> V;


int main(){
  // freopen("input.txt","r",stdin);
  cin>>N>>M>>Q;
  for (int i=0;i<Q;++i){
    cin>>a>>b;
    d = (a-b);
    if (d < 0)continue;
    V.pb(mp(a, -d));
  }
  d = 0;a= N+1;
  sort(ALL(V));
  for (auto i : V){
    if (-i.s > d){
      a = min(a, i.f);
      // cout<<i.f<<' '<<i.s<<'\n';
    }
    d = max(d, -i.s+1);
    // cout<<"Change to " << i.f+1<<'\n';
  }
  cout<<a-1;
}


Measured memory_bytes: 2420
N, M = [int(_) for _ in input().split()]
XY = [[int(_) for _ in input().split()] for i in range(M)]

ps = [False] * (N + 1)
cs = [1] * (N + 1)

ps[1] = True

for x, y in XY:
    cs[x] -= 1
    cs[y] += 1
    if ps[x]:
        ps[y] = True
    if cs[x] == 0:
        ps[x] = False

result = sum(ps)

print(result)


Measured memory_bytes: 22692
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;
using ll = long long;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for( int i=0; i<N; i++ ) cin >> A.at(i);
  
  priority_queue<int> pq;
  for( int i=0; i<N; i++ ) pq.push( A.at(i) );
  int max = pq.top();
  pq.pop();
  int second_max = pq.top();
  
  for( int i=0; i<N; i++ ){
    if( A.at(i) == max ){
      cout << second_max << endl;
    }else{
      cout << max << endl;
    }
  }
  return 0;
}


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

#define FILE
#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

double r;
int main()
{
    ios_base::sync_with_stdio(false);

    double p = acos(-1);
    cin >> r;
    cout << fixed << setprecision(15) << 2 * p * r << "\n";
}



Measured memory_bytes: 3784
#include <cstdio>
#include <cctype>
#include <utility>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	for (int n = in(), k = in(); k; k--) {
		auto s = [=](int x) {return min(x - 1, n - x);};
		int a = in();
		outl(min(s(a), s(in())) % 3 + 1);
	}
}


Measured memory_bytes: 2612
#include<stdio.h>
#define M 100
int main(){
	int i,N,S[M],rent;

	//入力
	scanf("%d",&N);


	//処理
	if(N==1){printf("1\n");return 0;}
	if(N==0){printf("0\n");return 0;}
	for(i=0;;i++){
		rent = N % (-2);
		N = N/(-2);
		if(rent==-1){
			rent = 1;
			N++;
		}
		S[i]=rent;
		if((N==1)||(N==0)) break;
	}
	i++;
	S[i]=N;
	//出力
	for(int j=0;j<=i;j++) printf("%d",S[i-j]);
	printf("\n");

	return 0;
}



Measured memory_bytes: 128
class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]

N,M = map(int,input().split())
p = list(map(int,input().split()))
xy = [list(map(int,input().split())) for _ in range(M)]

uf = UnionFind(2*N)
for i in range(N):
    # 
    uf.Unite(N+i,p[i] -1)
for i in range(M):
    uf.Unite(N+xy[i][0]-1,N+xy[i][1] -1)
ans = 0
for i in range(N):
    if uf.isSameGroup(N+i,i):
        ans += 1
print(ans)





Measured memory_bytes: 39780
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

long long int n, a, b;
bool func(vector<long long int> h, long long int num) {
  long long int cnt = 0;
  long long int d = a - b;
  for(int i=0; i<n; i++){
    h[i] -= b * num;
    if(h[i] > 0){
      cnt += (h[i]+d-1) / d;
    }
  }
  return cnt <= num;
}

int main() {
  cin >> n >> a >> b;
  vector<long long int> h(n);
  for(int i=0; i<n; i++) cin >> h[i];

  long long int l = 0;
  long long int r = 1e9;
  long long int m = (l + r) / 2;
  for(int i=0; i<200; i++){
    m = (l + r) / 2;
    if(func(h, m)){
      r = m;
    }else {
      l = m;
    }
  }
  cout << r << endl;

  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#define ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug freopen("in.txt","r",stdin); freopen("out.txt","w",stdout)
using namespace std;
const int MAXN=20;
typedef long long ll;
int a[MAXN][MAXN],vis[MAXN],ans[MAXN],mon[MAXN];
int n,m,x,sum=0,price=1e9;
void dfs(int pos){
	if(pos==n+1){
		for(int i=1;i<=m;i++) if(ans[i]<x) return;
		price=min(price,sum); 
		return;
	}
	dfs(pos+1);
	for(int j=1;j<=m;j++) ans[j]+=a[pos][j];
	sum+=mon[pos];
	dfs(pos+1);
	for(int i=1;i<=m;i++) ans[i]-=a[pos][i];
	sum-=mon[pos];
}
int main()
{
	ios;
	cin>>n>>m>>x;
	for(int i=1;i<=n;i++){
		cin>>mon[i];
		for(int j=1;j<=m;j++){
			cin>>a[i][j];
		}
	}
	dfs(1);
	if(price==1e9) cout<<-1<<'\n';
	else cout<<price<<'\n';
	return 0;
}

Measured memory_bytes: 3196
//15
#include<iostream>
#include<algorithm>
#include<string>
#include<cctype>

using namespace std;

string b[9];
string p[9];

bool cn(char a,char b){
  return a!=b&&tolower(a)==tolower(b);
}

int dfs(int x,int u){
  if(x==9){
    return 1;
  }else{
    int r=0;
    for(int i=0;i<9;i++){
      if(!(u>>i&1)){
	for(int j=0;j<4;j++){
	  rotate(p[i].begin(),p[i].begin()+1,p[i].end());
	  if((x/3==0||cn(b[x-3][2],p[i][0]))&&(x%3==0||cn(b[x-1][1],p[i][3]))){
	    b[x]=p[i];
	    r+=dfs(x+1,u|1<<i);
	  }
	}
      }
    }
    return r;
  }
}

int main(){
  int n;
  cin>>n;
  while(n--){
    for(int i=0;i<9;i++){
      cin>>p[i];
    }
    cout<<dfs(0,0)<<endl;
  }
  return 0;
}
  
  

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;
int main() {
    ll n,m;
  cin>>n>>m;  //入力
  vector<ll> broken(n+1);  //壊れた段を記録する配列
   rep(i,m){
    ll a;
     cin>>a;
    broken[a]++;
 } //壊れた段を1として記録
  vector<ll> dp(n+1); //DP配列
    dp[1]=1; dp[2]=2;   //1、2段目が壊れていないときの初期条件
if(broken[1]!=0){
  dp[1]=0;
  dp[2]=1;
}  //1段目が壊れているときの初期条件
if(broken[2]!=0) dp[2]=0; //2段目が壊れているときの初期条件
  rep2(i,3,n+1){
   if(broken[i]==0) dp[i]=dp[i-1]%MOD+dp[i-2]%MOD;
else dp[i]=0;
    } //3段目以降DPをする
    cout<<dp[n]%MOD<<endl;  //出力
  return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll x, y;
  cin >> x >> y;

  cout << (x + y / 2) << endl;

  return 0;
}


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

int main() {
    int h, w;
    cin >> h >> w;
    vector<int> cnt(26);
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            char c;
            cin >> c;
            cnt.at(c - 'a')++;
        }
    }

    if (h % 2 == 0 && w % 2 == 0) {
        for (int i = 0; i < 26; i++) {
            if (cnt.at(i) % 4 > 0) {
                cout << "No" << endl;
                return 0;
            } 
        }
        cout << "Yes" << endl;
    }
    else if (h % 2 == 1 && w % 2 == 1) {
        int cnt4 = 0;
        int odd = 0;
        for (int i = 0; i < 26; i++) {
            if (cnt.at(i) >= 4) cnt4 += cnt.at(i) / 4;
            if (cnt.at(i) % 2 == 1) odd++;
        }
        
        if (cnt4 >= (h / 2) * (w / 2) && odd == 1) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else {
        int cnt4 = 0;
        for (int i = 0; i < 26; i++) {
            if (cnt.at(i) % 2 == 1) {
                cout << "No" << endl;
                return 0;
            }
            cnt4 += cnt.at(i) / 4;
        }

        if (cnt4 >= (h / 2) * (w / 2)) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}   

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int n,i,j,tmp,result=0;
  int cnt[3];
  scanf("%d",&n);
  for(i=0;i<3;i++){
    cnt[i]=0;
  }
  
  char s[n];
  char t[n];
  char u[n];
  scanf("%s %s %s",s,t,u);
  //printf("%s\n%s\n%s\n",s,t,u);
  
  for(i=0;i<n;i++){
    if(s[i]!=t[i] && t[i]!=u[i] && u[i]!=s[i]){
      result += 2;
    }
    else if((s[i]!=t[i] && t[i]==u[i]) || (s[i]==t[i] && t[i]!=u[i]) || (u[i]==s[i] && s[i]!=t[i])){
      result += 1;
    }
  }

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

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

int main(){

    int N;
    cin >> N;

    if(N == 0){
        cout << 0 << endl;
        return 0;
    }

    string ans;
    while(N != 0){
        if(N % 2 != 0){
            N--;
            ans = "1" + ans;
        }else{
            ans = "0" + ans;
        }
        N /= -2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int n;
int a[300000];
int b[300000];
int cnt = 0;

int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i];
    }

    for (int i = 1; i <= n; ++i)
    {
        b[i] = a[i];
    }

    for (int i = n / 2; i >= 1; i--)
    {
        int sum = 0;
        for (int j = 1;; ++j)
        {
            int idx = i * j;
            if (idx > n)
                break;
            sum += b[idx];
        }
        b[i] = sum % 2;
    }

    for (int i = 1; i <= n; ++i)
    {
        cnt += b[i];
    }

    cout << cnt << endl;

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

Measured memory_bytes: 2432
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

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

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	int n;
	cin >> n;
	vector<int> hs(n);
	for(auto &h : hs) cin >> h;
	int answer = 0, current = 0;
	for(int i = 1; i < n; ++i)
	{
		current = (hs[i] <= hs[i - 1] ? current + 1 : 0);
		answer = max(answer, current);
	}
	cout << answer << '\n';
}

Measured memory_bytes: 3704
#include <iostream>
#include <vector>

using namespace std;

int main(){
	int N;
	while(cin >> N){
		vector<vector<int>> g(N);
		for(int i=1;i<N;i++){
			int p; cin >> p;
			g[p-1].push_back(i);
		}
		vector<int> X(N);
		for(int& t : X) cin >> t;
		vector<int> Y(N, 0);
		bool ok = true;
		for(int i=N-1;i>=0;i--){
			vector<int> dp(X[i]+1, 0);
			vector<int> next(X[i]+1, 0);
			dp[0] = 1;
			int sum = 0;
			for(int t : g[i]){
				fill(next.begin(), next.end(), 0);
				for(int j=0;j<=X[i];j++){
					if(!dp[j]) continue;
					if(j+X[t] <= X[i]) next[j+X[t]] = 1;
					if(j+Y[t] <= X[i]) next[j+Y[t]] = 1;
				}
				dp = next;
				sum  += X[t] + Y[t];
			}
			int maxVal = -1;
			for(int j=0;j<=X[i];j++) if(dp[j]) maxVal = j;
			if(maxVal < 0){
				ok = false;
				break;
			}
			Y[i] = sum - maxVal;
		}
		cout << (ok ? "POSSIBLE" : "IMPOSSIBLE") << endl;
	}
}

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

using namespace std;

int main () {
	int d, w, h, n, r;
	while(true) {
		cin >> d >> w >> h;
		if (!d && !w && !h) break;

		int diagonal = min({
			d * d + w * w,
			d * d + h * h,
			h * h + w * w
		});

		cin >> n;
		while (n--) {
			cin >> r;
			cout << ((r * r * 4 > diagonal) ? "OK" : "NA") << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // AtCoder
    // template
    string s;
    cin >> s;
    ll a, b, c, d;
    a = s[0] - '0';
    b = s[1] - '0';
    c = s[2] - '0';
    d = s[3] - '0';
    if(a + b + c + d == 7)
        printf("%d+%d+%d+%d=7", a, b, c, d);
    else if(a + b + c - d == 7)
        printf("%d+%d+%d-%d=7", a, b, c, d);
    else if(a + b - c + d == 7)
        printf("%d+%d-%d+%d=7", a, b, c, d);
    else if(a + b - c - d == 7)
        printf("%d+%d-%d-%d=7", a, b, c, d);
    else if(a - b + c + d == 7)
        printf("%d-%d+%d+%d=7", a, b, c, d);

    else if(a - b + c - d == 7)
        printf("%d-%d+%d-%d=7", a, b, c, d);

    else if(a - b - c + d == 7)
        printf("%d-%d-%d+%d=7", a, b, c, d);

    else if(a - b - c - d == 7)
        printf("%d-%d-%d-%d=7", a, b, c, d);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,maxim;
string s;
map <string,int> mp;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>s;
        mp[s]++;
    }
    for(auto it: mp)
        maxim=max(maxim,it.second);
    for(auto it : mp)
    {
        if(it.second==maxim)
            cout<<it.first<<"\n";
    }
    return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 



int main() {
	ll n,m;
	cin>>n>>m;
	for(int i=m/n;i>=1;i--){
		if(m%i==0&&m>=i*n){
				cout <<i ;
				return 0;
			
		}
	}
	return 0;
}

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

int weak(string& s, int& i);
int strong(string& s, int& i);
int fc(string& s, int& i);
int inte(string& s, int& i);

int weak(string& s, int& i) {
	int buf = strong(s, i);
	while (s[i] == '+' || s[i] == '-') {
		if (s[i] == '+') {
			i++;
			buf += strong(s, i);
		}
		else {
			i++;
			buf -= strong(s, i);
		}
	}
	return buf;
}

int strong(string& s, int& i) {
	int buf = fc(s, i);
	while (s[i] == '*' || s[i] == '/') {
		if (s[i] == '*') {
			i++;
			buf *= fc(s, i);
		}
		else {
			i++;
			buf /= fc(s, i);
		}
	}
	return buf;
}

int fc(string& s, int& i) {
	if ('0' <= s[i] && '9' >= s[i])return inte(s, i);
	else {
		i++;
		int re = weak(s, i);
		i++;
		return re;
	}
}

int inte(string& s, int& i) {
	int buf = s[i] - '0';
	i++;
	while ('0' <= s[i] && '9' >= s[i]) {
		buf = buf * 10 + s[i] - '0';
		i++;
	}
	return buf;
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s; int j = 0;
		cin >> s;
		cout << weak(s, j) << endl;
	}
}

Measured memory_bytes: 3164
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = input()

nR = S.count("R")
nG = S.count("G")
nB = S.count("B")
ans = nR*nG*nB
for i in range(N):  # 開始 index
	for j in range(1, N//2+1):  # 幅
		if i+2*j >= N:
			continue
		a, b, c = S[i], S[i+j], S[i+2*j]
		if a != b and b != c and c != a:
			ans -= 1
print(ans)


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

using namespace std;

#define fin cin
#define fout cout
//ifstream fin("x.in"); ofstream fout("x.out");

typedef long long i64;

vector<pair<pair<int, int>, int>> v;

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

    int l, aux;
    cin >> l;

    aux = l;

    for (int i = 0; i <= 19; ++ i) {
        if (l & (1 << i)) {
            if (l == (1 << i) && i ==19)
                continue;

            v.push_back({{1, 20 - i}, l - (1 << i)});
            l -= (1 << i);
        }
    }

    if (aux & (1 << 19)) {
        v.push_back({{1, 2}, 0});
        v.push_back({{1, 2}, (1 << 18)});
    }

    for (int i = 2; i <= 19; ++ i) {
        v.push_back({{i, i + 1}, 0});
        v.push_back({{i, i + 1}, (1 << (20 - i - 1))});
    }

    cout << 20 << " " << v.size() << "\n";
    for (auto i : v)
        cout << i.first.first << " " << i.first.second << " " << i.second << "\n";

    return 0;
}


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


long long a, b, k;

int main()
{
    while(cin >> a >> b >> k)
    {
        for(int i = 0; i < k; i++)
        {
            if(i % 2)
            {

                if(b % 2)
                    b--;
                        a += b / 2, b /= 2;
            }
            else
            {

                if(a % 2)
                    a--;
                        b += a/2, a /= 2;
            }
        }

        cout << a << " " << b << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll a,b,c;
  cin>>a>>b>>c;
  if(a+b==c||b+c==a||c+a==b) {
cout<<"Yes"<<endl;
  }
  else {
cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
long long int dp[100007];

long long int RFrog1(vector<long long int >& v, long long int  i){
	long long int  n=v.size()-1;
	if(i>=n) return 0;
	if(dp[i]!=-1) return dp[i];
	if(i+1==n) return abs(v[i+1]-v[i]);
	else	dp[i] = min( abs(v[i+1]-v[i])+RFrog1(v, i+1), abs(v[i+2]-v[i])+RFrog1(v, i+2));
	return dp[i];
}

int main(){
	long long int  n;
	cin>>n;
	memset(dp, -1, sizeof(dp));
	vector<long long int > v(n);
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	cout<<RFrog1(v, 0);
}


Measured memory_bytes: 4992
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define P complex<double>
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
const double EPS = 1e-8;
const double INF = 1e12;
using namespace std;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}

P projection(const L &l, const P &p) {
  double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
  return l[0] + t*(l[0]-l[1]);
}

bool intersectSP(const L &s, const P &p) {
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}

double distanceSP(const L &s, const P &p) {
  const P r = projection(s, p);
  if (intersectSP(s, r)) return abs(r - p);
  return min(abs(s[0] - p), abs(s[1] - p));
}

double distanceSS(const L &s, const L &t) {
  if (intersectSS(s, t)) return 0;
  return min(min(distanceSP(s, t[0]), distanceSP(s, t[1])),
             min(distanceSP(t, s[0]), distanceSP(t, s[1])));
}

int main() {
  int N;
  while(cin >>N && N){
    double sx, sy, ex, ey; cin >>sx >>sy >>ex >>ey;
    L route = L(P(sx, sy), P(ex, ey));
    double ans = INF;
    REP(n, N){
      double minx, miny, maxx, maxy, h; cin >>minx >>miny >>maxx >>maxy >>h;
      vector<L> l;
      l.push_back(L(P(maxx, maxy), P(minx, maxy)));
      l.push_back(L(P(maxx, maxy), P(maxx, miny)));
      l.push_back(L(P(minx, miny), P(maxx, miny)));
      l.push_back(L(P(minx, maxy), P(minx, miny)));
      if(minx <= min(sx, ex) && maxx >= max(sx, ex) && miny <= min(sy, ey) && maxy >= max(sy, ey)) ans = 0.0;
      REP(i, 4){
        if(intersectSS(route, l[i])) ans = 0.0;
        double d = distanceSS(route, l[i]);
        double r = (d * d + h * h) / (2 * h);
        if(h > d) r = d;
        ans = min(ans, r);
      }
    }
    printf("%.9lf\n", ans);
  }
  return 0;
}

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

int main(){
	int N,A,B;
	cin>>N>>A>>B;
	vector<int>P(N);
	int s=0,m=0,l=0;
	rep(i,P.size()){
		cin>>P.at(i);
		if(P.at(i)<=A){
			s++;
		}else if(A+1<=P.at(i)&&P.at(i)<=B){
			m++;
		}else if(B+1<=P.at(i)){
			l++;
		}else{}
	}
	cout<<min(s,min(m,l))<<endl;;

return 0;}

/*compile
g++ code.cpp
./a.out
run*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N;
    vi a(N);
    cin >> a;
    REP(i, N)
    a[i]++;
    int mx = *max_element(ALL(a));
    vi mem(mx + 1);
    REP(i, N) {
        mem[a[i] + 1]++;
        mem[a[i] + 0]++;
        mem[a[i] - 1]++;
    }
    REP(i, mem.size())
    ans = max(ans, (ll)mem[i]);
    cout << ans << endl;
}

Measured memory_bytes: 4032
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int dp[300][301][301];

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  string s; cin >> s;
  int n = s.size();
  int k; cin >> k;
  for (int r = 1; r <= n; ++r) {
    for (int l = r - 1; l >= 0; --l) {
      for (int x = 0; x <= k; ++x) {
        if (r - l == 1) {
          dp[l][r][x] = 1;
        } else {
          dp[l][r][x] = max(dp[l][r - 1][x], dp[l + 1][r][x]);
          if (s[l] == s[r - 1]) {
            dp[l][r][x] = max(dp[l][r][x], dp[l + 1][r - 1][x] + 2);
          } else if (x) {
            dp[l][r][x] = max(dp[l][r][x], dp[l + 1][r - 1][x - 1] + 2);
          }
        }
      }
    }
  }
  cout << dp[0][n][k] << '\n';
}

Measured memory_bytes: 104704
#include<bits/stdc++.h>
#define N 1000011

using namespace std;

char c1[N],c2[N];

int main()
{
    int i,dap = 0;
    
    scanf("%s %s",&c1[1],&c2[1]);
    for(i=1;;i++){
        if(c1[i]==0) break;
        if(c1[i]!=c2[i]) dap++;
    }
    printf("%d",dap);
    return 0;
}


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

int main(){
  int N;
  string S;
  cin >> N >> S;
  int64_t r=0;
  int64_t g=0;
  int64_t b=0;
  for(int i=0;i<N;i++){
    if(S.at(i)=='R'){
      r++;
    }else if(S.at(i)=='G'){
      g++;
    }else{
      b++;
    }
  }
  int64_t ans=r*g*b;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      if(S.at(i)==S.at(j)){
        continue;
      }
      int k=2*j-i;
      if(k>=N){
        break;
      }
      if((S.at(i)!=S.at(k))&&(S.at(j)!=S.at(k))){
        ans--;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3608
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        R: [i32; n],
    }
    let mut min = R[0];
    let mut max = std::i32::MIN;

    for i in 1..R.len() {
        max = std::cmp::max(max, R[i] - min);
        min = std::cmp::min(min, R[i]);
    }
    println!("{}", max);
}



Measured memory_bytes: 5052
a = []
for i in iter(input, '0 0'):
    a.append(list(map(int, i.split())))
for i in range(len(a)):
    ans = 0
    for j in range(1, a[i][0]-1):
        for k in range(j+1, a[i][0]):
            for l in range(k+1, a[i][0]+1):
                if j+k+l == a[i][1]:
                    ans += 1
    print(ans)


Measured memory_bytes: 5596
import java.util.Arrays;
import java.util.Scanner;

class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int[] array = new int[] { sc.nextInt(), sc.nextInt(), sc.nextInt() };
		Arrays.sort(array);

		if (array[0] == 5 && array[1] == 5 && array[2] == 7) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


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

#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;


int main()
{
    int max = 110000;
    vector<int> mat(max, 1);
    vector<int> primes;
    for (int i=2; i<sqrt(max); i++) {
        if (mat[i]) {
            for (int j=i*2; j < max; j+=i) mat[j] = 0;
        }
    }
    for (int i=2; i<max; i++) {
        if (mat[i]) primes.push_back(i);
    }

     // for (auto n:primes) cout << n << endl;

    int n, p;
    while (cin >> n >> p) {
        if (n == -1) break;

        int start;
        for (int i = 0; i < primes.size(); i++) {
            if (n < primes[i]) {
                start = i;
                break;
            }
        }

        vector<int> nums;
        for (int i = start; i < start+100; i++) {
            for (int j = i; j < start+100; j++) {
                nums.push_back(primes[i]+primes[j]);
                //cout << primes[i] << '+' << primes[j] << '=' << primes[i]+primes[j] <<  endl;
            }
        }

        sort(all(nums));
//        cout << "sorted nums!---------" << endl;
//        for (auto n:nums) cout << n << endl;
//        cout << "sorted nums!---------" << endl;
        //loop(100,i) INSP(nums[i])
        cout << nums[p-1] << endl;

    }
}

Measured memory_bytes: 3144
#include <iostream>
using namespace std;
int num(int x)
{
	int sum=0;
	while (x)
	{
		sum+=x%10;
		x/=10;
	}
	return sum;
}
int main() 
{
	int n,a,b;
	cin>>n>>a>>b;
	int cnt=0;
	for (int i=1;i<=n;i++)
	{
		if (a<=num(i) && num(i)<=b)
			cnt+=i;
	}
	cout<<cnt<<endl;
	return 0;
}

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

int main(){
  int t1, t2;
  ll a1, a2, b1, b2;
  cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
  ll ab1 = (a1 - b1)*t1;
  ll ab2 = (a2 - b2)*t2;
  if(ab1+ab2 == 0){
    cout << "infinity" << endl;
    return 0;
  }
  if((ab1>0 && ab1+ab2>0) || (ab1<0 && ab1+ab2<0)){
    cout << 0 << endl;
    return 0;
  }
  ll ans = abs(ab1) / abs(ab1+ab2) *2 +1;
  if(abs(ab1) % abs(ab1+ab2) ==0) --ans;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define int long long
#define rep(i,n)for(long long i=0;i<n;i++)
#define ll getchar();getchar();return 0;
using namespace std;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n%i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x,int y) {
	int ans;
	for (int i = (min(x, y)); i >= 1; i--) {
		if (x%i == 0 && y%i == 0) {
			ans = i;
			break;
		}
	}
		return ans;
}
int yakusuunowa(int n) {
	int ans=0;
	for (int i = 1; i <= n; i++) {
		if (n%i == 0)ans += i;
	}
	return ans;
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int ketanowa(int n) {
	int cnt = 0, sum = 0;
	for (int i = 10; i <= n * 10; i *= 10) {
		if (i == 10)cnt += n % i;
		else sum += (n%i - n % (i / 10)) / (i / 10);
	}
	return cnt + sum;
}
pair<int, int>a[114514]; int n, k,cnt=0,ans;
signed main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> a[i].first >> a[i].second;
	sort(a, a + n);
	for (int i = 0; i < n; i++) {
		cnt += a[i].second;
		if (cnt >= k) {
			ans = a[i].first;
			break;
		}
	}
	cout << ans << endl;
	ll
}

Measured memory_bytes: 1792
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<unordered_map>

using namespace std;
const int N = 10 + 5;
const int D = 10 + 5;
const double eps = 1e-6;

int n, d;
int ar[N][D];
int res;

int main()
{
    scanf("%d%d", &n, &d);
    unordered_map<int,int> hash;
    for(int i = 0; i <= 200; i ++) hash[i * i] = 1;
    for(int i = 1; i <= n; i ++)
    {
        for(int j = 1; j <= d; j ++)
        {
            scanf("%d", &ar[i][j]);
        }
    }
    
    for(int i = 1; i <= n; i ++)
    {
        for(int j = i + 1; j <= n; j ++)
        {    
           
            int s = 0;
            for(int k = 1; k <= d; k ++)
            {
                
                s +=  (ar[i][k] - ar[j][k]) * (ar[i][k] - ar[j][k]);
            }
            if(hash[s]) res ++;
        }
    }
    
    printf("%d", res);
    
   return 0;
}

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

int main(){
    int A,B,K;
    cin >> A >> B >> K;
    int cnt = 0;
    int ans;
    for(int i=min(A,B);i>=1;i--){
        if(A%i == 0 && B%i == 0){
            cnt = cnt + 1;

            if(cnt == K){
                ans = i;
                break;
            }
        }
    }    

    cout << ans << endl;
}

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

for i in range(len(S)):
  if S[i] == "L":
    S[i] = 0
  else:
    S[i] = 1

count = 0
for i in range(len(S)-1):
  if S[i] - S[i + 1] == 0:
    count+=1

ans = count + 2 * K
if ans > len(S) - 1:
  ans = len(S) - 1
print(ans)

Measured memory_bytes: 4084
n, m = map(int, input().split())
dic = {}
for i in range(1,n+1):
    dic[i] = 0
for i in range(m):
    a, b = map(int, input().split())
    dic[a] += 1
    dic[b] += 1
for i in range(1,n+1):
    print(dic[i])

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

int main(){
  int x,y,n=0;
  cin >> x >> y;
  if(x==1) n += 300000;
  else if(x==2) n += 200000;
  else if(x==3) n += 100000;
  
  if(y==1) n += 300000;
  else if(y==2) n += 200000;
  else if(y==3) n += 100000;
  if(x==1&&y==1) n += 400000;
  
  cout << n <<endl;
}
    

Measured memory_bytes: 256
n = int(input())
x = list(map(int,input().split()))

p1 = sum(x)//len(x)
p2 = p1 + 1
s1 = 0
s2 = 0
for i in x:
  s1 += (p1-i)**2
  s2 += (p2-i)**2
print(min(s1,s2))

Measured memory_bytes: 3064
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

a = []
for i in range(N):
	A = INT()
	a.append([LIST() for _ in range(A)])

maxv = 0
for i in range(2**N):
	s = "{:0" + str(N) + "b}"
	F = [int(i) for i in s.format(i)]
	flag = 0
	for j in range(N):
		if F[j] == 1:
			for k in range(len(a[j])):
				if a[j][k][1] == 1:
				 	if F[a[j][k][0] - 1]*a[j][k][1] == 0:
				 		flag = 1
					 	break
				else:
					if F[a[j][k][0] - 1] == 0:
						continue
					if F[a[j][k][0] - 1]*a[j][k][1] == 0:
						flag = 1
						break

	if flag == 1:
		continue

	wa = sum(F)
	if maxv < wa:
		maxv = wa

print(maxv)

Measured memory_bytes: 69848
// C - Poll
#include <bits/stdc++.h>
using namespace std;
string in(){string x;cin>>x;return x;}

int main(){
	int N; cin>>N;
	int maxn = 0;
	map<string, int> M;
	while(N--) maxn = max(maxn, ++M[in()]);
	for(auto m:M) if(maxn == m.second) cout<< m.first<<endl;
}

Measured memory_bytes: 25216
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

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

  int flag = 0;
  int loop = (N / 7) + 1;
  for(int i=0;i<loop;i++){ // i が 7ドルのケーキの個数
    int tmp = N - 7*i;
    if(tmp % 4 == 0){
      flag = 1;
    }
  }

  if(flag == 1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


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

public class Hello
{
    public static void Main()
    {
        var line = System.Console.ReadLine();
        var a = int.Parse(line.Split(' ')[0]);
        var result = a + Math.Pow(a, 2) + Math.Pow(a, 3);
        Console.Write(result);
    }
}


Measured memory_bytes: 27920
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;
const int p=1000000007;

int main()
{
	long long H, W;
	cin >> H >> W;

	vector<string> maze(H);
	for(auto &s : maze) cin >> s;

	vector<vector<int> > dp(H, vector<int> (W, 0));
	for(int i=0; i<W; ++i)
	{
		if(maze[0][i] == '.') dp[0][i] = 1;
		else break;
	}
	for(int i=0; i<H; ++i)
	{
		if(maze[i][0] == '.') dp[i][0] = 1;
		else break;
	}


	for(int i=1; i<H; ++i)
	{
		for(int j=1; j<W; ++j)
		{
			if(maze[i][j]=='#') continue;
			else dp[i][j] = (dp[i-1][j] + dp[i][j-1])%p;
		}
	}
	cout << dp[H-1][W-1] << endl;
	
	return 0;
}

Measured memory_bytes: 5248