akhauriyash/Code-Regression huggingface dataset:
#include <cstdio> 
#include <cstdlib> 
#include <numeric>
#include <cmath> 
#include <climits> 
#include <cfloat> 
#include <map> 
#include <cassert>
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
using namespace std; 
#define REP(i,b,n) for(int i=b;i<n;i++) 
#define rep(i,n)      REP(i,0,n) 
#define pb push_back  
#define mp make_pair 
#define ALL(C)   (C).begin(),(C).end() 
template<class T> void vp(T &a,int p){rep(i,p)cout << a[i]<<" ";cout << endl;}  

typedef complex<double>P; 
typedef long long ll; 
typedef unsigned long long ull; 
typedef pair<int,int> pii; 
const ll LIM = 1000000500000LL;
const int N = 2000010;
const int M = 700000;
const int RANGE=500000*2+1;
bool a[N];
int pr[M];
int generate(){
  rep(i,N)a[i]=i%2;
  for(int i=3;(ll)i*(ll)i <= N;i+=2){
    if (a[i])
      for(int j=2*i;j <= N;j+=i)
	a[j]=false;
  }
  int cnt=1;
  pr[0]=2;
  for(int i=3;i<N;i+=2)if (a[i])pr[cnt++]=i;
  return cnt;
}

bool isok(ll a,int index){
  int last=100;
  rep(i,index){
    if ((ll)pr[i]*pr[i] > a)break;
    if (a%pr[i] != 0)continue;
    int cnt=0;
    while(a%pr[i] == 0)a/=pr[i],cnt++;
    if (cnt > last)return false;
    last=cnt;
  }
  return true;
}

void bf(int index,ll low,ll lim){
  int cnt=0;
  for(ll i=low;i <= lim;i++){
    if (isok(i,index))cnt++;
  }
  cout << "verify " << cnt << endl;
}

int lastp[RANGE],curp[RANGE];
int vis[RANGE],que[RANGE];
int solve(int index,ll low,ll lim,ll b){
  int n=lim-low+1;
  rep(i,RANGE)lastp[i]=100,curp[i]=0,vis[i]=-1;
  rep(i,index){
    ll now = 1;
    int qp=0;
    while(true){
      now=now*pr[i];
      ll tmp = low%now == 0?0:(now-low%now);
      if (lim/now == 0)break;
      while(tmp < n){
	if (vis[tmp] < i && lastp[tmp] != -1){
	  vis[tmp]=i;
	  que[qp++]=tmp;
	}
	curp[tmp]++;
	tmp+=now;
      }
    }
    rep(k,qp){
      int j = que[k];
      if (lastp[j] == -1 || curp[j] == 0)continue;
      if (lastp[j] < curp[j])lastp[j]=-1;
      else lastp[j]=curp[j];
      curp[j]=0;
    }
  }
  int ret = 0;
  rep(i,n){
    if (lastp[i] != -1)ret++;//,cout << isok(low+i,index) << endl;
    /*
    if (((lastp[i] == -1 && !isok(low+i,index)) || 
	 (lastp[i] != -1 && isok(low+i,index))));
    else cout <<"invalid " << low+i << " " << lastp[i] << endl,assert(false);
    */
  }
  return ret;
}

main(){
  int index = generate();
  ll a,b;
  while(cin>>a>>b && a){
    //bf(index,max(2LL,a-b),a+b);
    cout << solve(index,max(2LL,a-b),a+b,b)<< endl;
  }
  return false;
}

Measured memory_bytes: 16000
using System;

public class p0510
{
	p0510(){
		string str;
		
		while((str=Console.ReadLine()) != null)
			Console.WriteLine("{0}", Math.Max(func(str.Split(' ')), func((Console.ReadLine()).Split(' '))));
	}

	public int func (string[] a)
	{
		int sm = 0;
		foreach (string s in a)
			sm += int.Parse (s);
		return sm;
	}
	
	public static int Main(string[] args){
		new p0510();
		return 0;
	}
}

Measured memory_bytes: 5568
#include<iostream>
#include<cstdio>
#include<queue>
#define MAX 100005
#define INF 10000005
using namespace std;
int dist[MAX];
queue<int> q;
int main()
{
	int k;
	int i,j;
	int f;
	cin>>k;
	for (i=0;i<=k-1;i++)
	{
		dist[i]=INF;
	}
	dist[1]=1;
	q.push(1);
	while (!q.empty())
	{
		f=q.front();
		q.pop();
		if (dist[(f * 10) % k]>dist[f])
		{
			dist[(f * 10) % k]=dist[f];
			q.push((f * 10) % k);
		}
		if (dist[(f + 1) % k]>dist[f]+1)
		{
			dist[(f + 1) % k]=dist[f]+1;
			q.push((f +1) % k);
		}
	}
	cout<<dist[0];
	return 0;
}

Measured memory_bytes: 768
import sys
def line():return sys.stdin.readline().strip()
def cin():return sys.stdin.readline().strip().split()
while True:
    N,M = [int(i) for i in cin()]
    if N == 0:break
    X = [int(line()) for _ in range(N)]
    Y = [int(line()) for _ in range(M)]
    c = 1
    for i in range(M):
        c+=int(Y[i])
        if c < N and X[c - 1] != 0:
            c+=X[c - 1]
        if c >= N:
            print(i + 1)
            break

Measured memory_bytes: 7756
#include <iostream>

using namespace std;

int main() {
	double r;
	while (cin >> r, r >= 0) {
		bool is_find = false;
		int n = r; r -= n;
		string ans;
		for (int i = 0; i < 8; ++i) {
			ans = (char)((n & 1) + '0') + ans;
			n >>= 1;
		}

		double nums[4][2] = {
			{0, 1/2.0},
			{0, 1/4.0},
			{0, 1/8.0},
			{0, 1/16.0}
		};

		for (int a = 0; a <= 1; ++a)
			for (int b = 0; b <= 1; ++b)
				for (int c = 0; c <= 1; ++c)
					for (int d = 0; d <= 1; ++d)
						if (nums[0][a] + nums[1][b] + nums[2][c] + nums[3][d] == r) {
							is_find = true;
							ans += ".";
							ans += a + '0';
							ans += b + '0';
							ans += c + '0';
							ans += d + '0';
						}

		if (is_find) cout << ans << endl;
		else cout << "NA" << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repeq(i,a,b) for(int i=a;i<=(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
struct Tree {
    typedef int T;
    const T LOW = 1234567890;
    T f(T a, T b) { return min(a,b); }

    int n;
    vi s;
    Tree() {}
    Tree(int m, T def=0) { init(m, def); }
    void init(int m, T def) {
        n = 1; while(n < m) n *=2;
        s.assign(n+m,def);
        s.resize(2*n, LOW);
        for(int i=n;i-->1;)
            s[i] = f(s[i*2],s[i*2+1]);
    }
    void update(int pos, T val) {
        pos += n;
        s[pos] = val;
        for(pos/=2; pos>=1; pos/=2)
            s[pos] = f(s[pos*2], s[pos*2+1]);
    }
    T query(int l, int r) { return que(1, l, r, 0, n); }
    T que(int pos, int l, int r, int lo, int hi) {
        if(r<=lo || hi<=l) return LOW;
        if(l<=lo && hi<=r) return s[pos];
        int m = (lo+hi)/2;
        return f(que(2*pos, l, r, lo, m),
                 que(2*pos+1, l, r, m, hi));
    }
};
vi sum;
inline int onesIn(int l, int r) // exclusive
{
    return (l==0)?sum[r-1]:sum[r-1]-sum[l-1];
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    vi b;
    int Q;
    vector<pii> queries;
    cin >> n;
    b.resize(n);
    rep(i,0,n) cin >> b[i];
    sum.resize(n);
    sum[0] = b[0];
    rep(i,1,n) sum[i]=sum[i-1]+b[i];
    cin >> Q;
    rep(i,0,Q) {
        int l, r;
        cin >> l >> r;
        --l;
        queries.emplace_back(l,r);
    }
    sort(queries.begin(), queries.end());
    vi okAt(n, n+1);
    ll acc = 0;
    int j = 0;
    Tree st(n, n+5);
    rep(i,0,n) {
        while(j<Q && queries[j].first == i) {
            int r = queries[j].second;
            int best = acc + (r - i - onesIn(i, r));
            int qb = st.query(i, r);
            qb -= (n - r) - onesIn(r, n); // sub extra cost
            best = min(best, qb);
            okAt[r-1] = min(okAt[r-1], best);
            qb = best + (n - r) - onesIn(r, n);
            st.update(r - 1, qb);
            ++j;
        }
        if(b[i]) ++acc;
        acc = min<int>(acc, okAt[i]);
    }
    cout<<acc<<endl;
}


Measured memory_bytes: 9584
class Queue:
    def __init__(self):
        self.data = []

    def enqueue(self, data):
        self.data.append(data)

    def dequeue(self):
        res = self.data.pop(0)
        return res

    def getLength(self):
        return len(self.data)

n, q = map(int, input().split())
time = 0
processes = Queue()

for i in range(n):
    name, cost = input().split()
    processes.enqueue([name, int(cost)])

while processes.getLength() > 0:
    currentProcess = processes.dequeue()
    processName = currentProcess[0]
    processCost = currentProcess[1]

    if processCost <= q:
        time += processCost
        print(' '.join([processName, str(time)]))
        continue

    time += q
    processes.enqueue([processName, processCost - q])

Measured memory_bytes: 15568
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int N, A, B, C; 
vector<int> l(9); 
int answer = INT_MAX;
void  dfs(int cur, int a, int b, int c, int s)
{
	if(cur > N){
		if(a && b && c) answer = min(answer,s + abs(A-a) + abs(B-b) + abs(C-c));
		return; 
	} 
	dfs(cur+1, a, b, c, s);
	dfs(cur+1, a+l[cur], b, c, s+10*(a>0));
	dfs(cur+1, a, b+l[cur], c, s+10*(b>0));
	dfs(cur+1, a, b, c+l[cur], s+10*(c>0));
}
int main(){
	cin >> N >> A >> B >> C;
	REP(i, N) cin >> l[i+1];
	dfs(1,0,0,0,0);
	cout << answer << endl;	
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
	ll k;
	string s;
	cin >> k;
	cin >> s;
	if (k >= s.length())
	{
		cout << s << endl;
	}
	else
	{
		for (int i = 0; i < k; i++)
		{
			cout << s[i];
		}
		cout << "..." << endl;
	}
	return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,check[5];
  cin>>a;
  check[a]=1;
  cin>>b;
  check[b]=1;
  cin>>c;
  check[c]=1;
  cin>>d;
  check[d]=1;
  if((check[1]==1)&&(check[9]==1)&&(check[7]==1)&&(check[4]==1))
    cout<<"YES";
  else
    cout<<"NO";
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n,m,a,b,ch[100000][3],S,G,ok;
vector<ll>v[100000];
queue<P>que;
int main(void){
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        a--,b--;
        v[a].push_back(b);
    }
    cin>>S>>G;
    S--,G--;
    ch[S][0]=1;
    que.push({S,0});
    while(!que.empty()){
        auto q=que.front();
        que.pop();
        for(auto x:v[q.F]){
            if(ch[x][(q.S+1)%3]==0){
                if(x==G&&(q.S+1)%3==0){
                    cout<<(q.S+1)/3<<endl;
                    return 0;
                }
                ch[x][(q.S+1)%3]=1;
                que.push({x,q.S+1});
            }
        }
    }
    cout<<-1<<endl;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
using namespace std;
using Int = long long;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<55)+1e9; // ~ 3.6 * 1e16
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
using T = tuple<Int,Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
ostream& operator<<(ostream& o,T t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){Int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int a, b;
  cin>>a>>b;

  if(a + b == 15) cout<<"+"<<endl;
  else if(a * b == 15) cout<<"*"<<endl;
  else cout<<"x"<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <cstdint>
#include <iostream>
#include <string>
#include <memory>
#include <queue>
#include <stack>
#include <limits>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <utility>
#include <sstream>
#include <random>
#include <functional>
#include<algorithm>
#include <array>
#include<random>
using namespace std;
uint64_t CH(uint64_t n){
	return n * (n - 1) / 2;
}

int main() {
	uint64_t N;
	cin >> N;
	vector<uint64_t> SA(N + 1);
	SA[0] = 0;
	for (uint64_t i = 1; i < N + 1; i++)
	{
		uint64_t A;
		cin >> A;
		SA[i] = SA[i - 1] + A;
	}
	unordered_map<uint64_t, uint64_t>p;
	p.reserve(N + 1);
	for (uint64_t i = 0; i < N + 1; i++)
	{
		auto r = p.find(SA[i]);
		if (r == p.end()) {
			p[SA[i]] = 1;
		}
		else {
			++p[SA[i]];
		}
	}

	uint64_t res = 0;
	for (auto e : p) {
		res += CH(e.second);
	}

	cout << res;

	return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1 LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    LL K,N;cin >> K >> N;
    vector<LL> A(N);
    rep(i,N)cin >> A[i];


    LL ans = A[N-1] - A[0];

    rep(i,N-1){
        ans = min(ans,A[i] + K - A[i+1]);
    }
    cout << ans << endl;
}

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

int main(){
    using namespace std;
    unsigned long N, K;
    cin >> N >> K;
    if(N == K)return 0 & puts("0");
    vector<unsigned long> H;
    H.reserve(N + 2);
    H.push_back(0);
    copy_n(istream_iterator<unsigned long>(cin), N, back_inserter(H));
    H.push_back(0);
    unsigned long ans{0};
    for(unsigned long i = 0; i < N; ++i)ans += max(H[i + 1], H[i]) - H[i];
    vector<vector<unsigned long>> table(K + 1);
    table[0].resize(N);
    for(unsigned long i = 1; i <= K; ++i){
        table[i].resize(N - i + 1);
        for(unsigned long j = 0; j + i <= N; ++j){
            for(unsigned long k = 0; k <= i; ++k){
                table[i][j] += max(H[j + k + 1], H[j + k]) - min(H[j + k + 1], H[j + k]);
            }
            table[i][j] -= max(H[j], H[i + j + 1]) - min(H[j], H[i + j + 1]);
            table[i][j] /= 2;
        }
    }
    vector<vector<unsigned long>> dp(K + 1);
    vector<unsigned long> dpp(K + 1);
    for(unsigned long i = 0; i <= K; ++i)dp[i].resize(i + 1);
    for(unsigned long i = 0; i < N; ++i){
        for(unsigned long j = min(K, i + 1) + 1; j--; ){
            dp[j][0] = dpp[j];
            for(unsigned long k = 1; k <= j; ++k){
                dpp[j] = max(dpp[j], dp[j][k] = dp[j - 1][k - 1] + table[k][i - k + 1] - table[k - 1][i - k + 1]);
            }
        }
    }
    cout << ans - dpp.back() << endl;
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
const int logD= 40;

int64_t dp(int64_t Xmax, int digit, int64_t N, const vector<int64_t>& data){
  if(digit==logD){
    return 0LL;
  }
  else{
    int64_t offset1= (1LL << digit)* (N- data.at(digit));
    int64_t offset0= (1LL << digit)* data.at(digit);

    if(Xmax & 1) return dp(Xmax>>1, digit+1, N, data)+ max(offset1, offset0);
    else if (Xmax > 0) return max(dp((Xmax>>1)-1, digit+1, N, data)+ offset1, dp(Xmax>>1, digit+1, N, data)+ offset0);
    else               return dp(0LL, digit+1, N, data)+ offset0;
  }
}

int main(){
  int64_t N,Xmax,buf;
  cin >> N >> Xmax;

  vector<int64_t> data(logD);
  for(int64_t i=0; i<N; i++){
    cin >> buf;
    int cnt= 0;
    while(buf > 0){
      if(buf & 1){ data.at(cnt)++; }

      cnt++;
      buf>>= 1;
    }
  }

  cout << dp(Xmax, 0, N, data) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int N,a[1001],b[1001],i,sum=0;
	scanf("%d",&N);
	for(i=0;i<N;i++){scanf("%d %d",&a[i],&b[i]);sum+=b[i]-a[i]+1;}
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 128
n, k, q = STDIN.gets.split(/\s+/).map(&:to_i)
answer_count = Hash.new(0)
q.times.each{ answer_count[STDIN.gets.to_i] += 1 }
participants_survived = (1..n).map{|i| k > q - answer_count[i] }
participants_survived.each { |participant_survived| puts (participant_survived ? "Yes": "No")}



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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)

int main(void){
  string s;
  cin>>s;
  s.erase(0,4);
  s="2018"+s;
  cout<<s<<endl;

return 0;}


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

int main() {
	int n;cin>>n;
	string s;
	cin>>s;
	int countl[n];
	int countr[n];
	for(int i=0;i<n;i++){
		if(s[i]=='W'){
			countl[i]=1;
		}else{
			countl[i]=0;
		}
		if(s[n-1-i]=='E'){
			countr[n-1-i]=1;
		}else{
			countr[n-1-i]=0;
		}
	}
	for(int i=1;i<n;i++){
		countl[i]+=countl[i-1];
		countr[n-1-i]+=countr[n-i];
	}
	int ans=1000*1000;
	if(countl[n-2]<countr[1]){
		ans=countl[n-2];
	}else{
		ans=countr[1];
	}
	for(int i=1;i<n-1;i++){
		if(ans>(countl[i-1]+countr[i+1])){
			ans=countl[i-1]+countr[i+1];
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2948
a,b = input().split()
a = int(a)
b = int(b)
string = ""
if a>b:
    for i in range(a):
        string = string+str(b)
elif b>a:
    for i in range(b):
        string = string+str(a)
else:
    for i in range(a):
        string =  string+str(a)
print(string)


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

int main(){
  int n;
  int a[10000] = {};
  int count = 0;
  int k = 0;
  int i = 0;
  int b = 0;
  int answer = 0;
  
  cin >> n;
  for (i = 0; i < n; i++){
    cin >> a[i];
  }
  
  for (i = 0; i < n; i++ ){
    k = a[i];
    for ( ; ; ){
      if (k % 2 == 1 ){
        break;
      }
      k = k / 2;
      b++;
      }
      if (b > count){
        count = b;
      }
    }
  answer = answer + count;
  cout << answer;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ld double
using namespace std;
#define SZ 666666
#define Edg int M = 0,fst[SZ],vb[SZ],nxt[SZ]
#define es(x,e) (int e = fst[x]; e; e = nxt[e])
#define esb(x,e,b) (int e = fst[x], b = vb[e]; e; e = nxt[e], b = vb[e])
int n,d[SZ]; Edg;
void ad_de(int a,int b)
{
	++ M;
	nxt[M] = fst[a];
	fst[a] = M;
	vb[M] = b;
}
void adde(int a,int b)
{
	ad_de(a,b);
	ad_de(b,a);
}
ld f[SZ],ca=0;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
void dp1(int x,int fa=0)
{
	f[x] = 0;
	for esb(x, e, b)
		if(b != fa)
			dp1(b,x), f[x] += (f[b] + 1) / ld(d[x] - bool(fa));
}
ld anss[SZ];
void dp2(int x, int fa = 0)
{
	ld cc = ca;
	anss[x] = cc;
	for esb(x,e,b)
		if(b != fa)
		{
			ld ts = (f[b]+1)/ld(d[x]);
			ld ot = 0;
			if(fabs(cc - ts) > 1e-6)
				ot = (cc - ts) / (1 - 1.0 / ld(d[x]));
			ot ++;
			ca = f[b] * (1 - 1.0 / ld(d[b])) + ot * 1.0 / ld(d[b]);
			dp2(b,x);
		}
}
int main()
{
	scanf("%d",&n);
	for(int i = 1; i < n; i ++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		adde(a, b);
		d[a] ++;
		d[b] ++;
	}
	dp1(1);
	ca = f[1];
	dp2(1);
	for(int i = 1; i <= n; i ++)
		printf("%.10lf\n",anss[i]);
}


Measured memory_bytes: 22400
n = int(input())
d = [list(map(int, input().split())) for _i in range(n)]

c = 0
for i, j in d:
    if i==j:
        c += 1
        if c == 3:
            print('Yes')
            import sys
            sys.exit()
    else:
        c = 0
print('No')

Measured memory_bytes: 9160
n = int(input())
t0=0
x0=0
y0=0

for i in range(n):
    t, x, y = map(int, input().split())
    kyori = abs(x - x0)+ abs(y - y0)
    dt = t - t0
    t0 = t
    x0 = x
    y0 = y
    if kyori > dt or (dt - kyori) % 2:
        print("No")
        exit(0)
print("Yes")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
//main definations
#define UI unsigned int
#define LLI long long int
#define ULLI unsigned long long int
#define PI   3.14159258
void read_array(int *a, int n);
void write_array(int *a, int n);
void sort_array(int *a, int n);
//codechef only
#define TC for(UI defined_i=1;defined_i<=t;defined_i++)
using namespace std;
int main(){
	int t, ans=0;
	cin>>t;
	TC{
		int a, b;
		cin>>a>>b;
		ans=ans+(b-a)+1;
		
	}
	cout<<ans<<endl;
    return 0;
}
void read_array(int *a, int n){
	for(int i=0;i<n;i++){
		cin>>*(a+i);
	}
}
void write_array(int *a, int n){
	for(int i=0;i<n;i++){
		cout<<*(a+i)<<" ";
	}
}
void sort_array(int *a, int n){
	sort(a,a+n);
}

Measured memory_bytes: 256
# import bisect
# # import heapq
# # from copy import deepcopy
# # from collections import deque
# # from collections import Counter
# # from itertools import accumulate
# # from itertools import permutations
# import numpy as np
# # import math
n, a, b = map(int, input().split())
twos = 1
count = 0
# p = list(map(int, input().split()))
# n = int(input())
mod = 10 ** 9 + 7
def fac(n,a,mod):
    x,y = 1,1
    for _ in range(a):
        x *= n; y *= a
        x %= mod; y %= mod
        n -= 1; a -= 1

    return (x * pow(y,mod-2,mod)) % mod



ans= (pow(2,n,mod)-1-fac(n,a,mod)-fac(n,b,mod)) % mod

print(ans)




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

typedef long long ll;

int main() {
  int N, Y; cin >> N >> Y;
  int x = -1,y = -1,z = -1;
  for ( int i = 0; i <= N; i++ ) {
    for ( int j = 0; j <= N; j++ ) {
      int rem = N - (i+j);
      int tmp = Y;
      tmp -= 1000*i+5000*j;
      if ( tmp >= 0 && tmp == rem*10000 ) {
	x = rem;
	y = j;
	z = i;
	break;
      }
    }
  }

  if( x == -1 && y == -1 && z == -1 ) cout << -1 << " " << -1 << " "
					   <<-1 << endl;
  else cout << x << " " << y << " " << z << endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if ((abs(a - b) <= d && abs(b - c) <= d) || abs(a-c) <= d) cout << "Yes";
	else cout << "No";

	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

#define TRACE(x) cerr << #x << " = " << x << endl
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define _ << " " <<

typedef long long ll;
typedef pair<int, int> P;
#define X first
#define Y second

const int MAX = 1<<19;

int p[MAX];

int main()
{
  int n, m;
  scanf("%d%d", &n, &m);

  REP(i, m) {
    int a, b;
    scanf("%d%d", &a, &b);
    p[a] ^= 1; p[b] ^= 1;
  }

  REP(i, MAX) {
    if (p[i]) {
      printf("NO\n");
      return 0;
    }
  }

  printf("YES\n");

  return 0;
}


Measured memory_bytes: 768
#include <iostream>
using namespace std;
 
int N, M, Q, p[509][509];
int main() {
	cin >> N >> M >> Q;
	for (int i = 1; i <= M; i++) { int L, R; cin >> L >> R; p[L][R]++; }
	for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) p[i][j] += p[i][j - 1]; }
	for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) p[i][j] += p[i - 1][j]; }
 
	for (int i = 1; i <= Q; i++) {
		int L, R; cin >> L >> R;
		cout << p[R][R] + p[L - 1][L - 1] - p[L - 1][R] - p[R][L - 1] << endl;
	}
	return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include<vector>
#include<algorithm>
 
using namespace std;
 
int gcd(int a,int b)
{
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}
 
int main(){
  int n; cin >> n;
  long long int m; cin >> m;
  vector<long long int> a(n); 
  for(int i=0;i<n;i++) cin >> a[i];
  long long int lc = 1;
  for(int i=0;i<n;i++){
    a[i] = a[i] / 2;
  	long long int t = gcd(lc, a[i]);
    lc = (lc * a[i]) / t;
  }
  for(int i=0;i<n;i++) if((lc / a[i]) % 2 ==0){cout << 0 << endl; return 0;}
  
  cout << (m / lc + 1) / 2 << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts> auto make_v(size_t a,Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T> void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U> void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl

struct edge { int to, cost; };

const int INF = 1LL<<60;
const int MOD = 1e9+7;

signed main()
{
   int n; cin >> n;
   string s; cin >> s;

   map<char,int> cnt;
   for (int i = 0; i < n; ++i) {
      ++cnt[s[i]];
   }

   if (cnt['R'] > cnt['B']) {
      cout << "Yes" << endl;
   } else {
      cout << "No" << endl;
   }

   return 0;
}


Measured memory_bytes: 256
//#include <algorithm>
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include<map>


using namespace std;

typedef unsigned long long ULONG;
typedef long long LONG;

//#define PI 3.1415926535897932384626433
//#define _DBG_

ULONG A, B, C, D;
map<ULONG, ULONG> ma;

ULONG solveOne(ULONG cur) {

	//メモ化済み
	if (ma.find(cur) != ma.end()) {
		return ma[cur];
	}

	if (cur <= 0) {
		return (ULONG)1e18;
	}
	else if (cur == 1) {
		return D;
	}

	ULONG res = cur * D;


	int mod = cur % 2;
	if (mod == 0) {
		res = min(solveOne(cur / 2) + A, res);
	}
	else {
		res = min(solveOne((cur - mod)/2) + A + D * (mod), res);
		res = min(solveOne((cur + (2 - mod))/2) + A + D * (2 - mod), res);
	}

	mod = cur % 3;
	if (mod == 0) {
		res = min(solveOne(cur / 3) + B, res);
	}
	else {
		res = min(solveOne((cur - mod)/3) + B + D * (mod),  res);
		res = min(solveOne((cur + (3 - mod))/3) + B + D * (3 - mod), res);
	}

	mod = cur % 5;
	if (mod == 0) {
		res = min(solveOne(cur / 5) + C, res);
	}
	else {
		res = min(solveOne((cur - mod)/5) + C + D * (mod), res);
		res = min(solveOne((cur + (5 - mod))/5) + C + D * (5 - mod), res);
	}


	ma[cur] = res;
	return res;
}

int main(void) {
	
	//LONG N;
	//N = 32;
	//A = 10;
	//B = 8;
	//C = 5;
	//D = 4;
	//ma.clear();
	//LONG ans = solveOne(N);
	//cout << ans << endl;
	//cin >> N;
	

	
	int T;
	cin >> T;

	vector<vector<ULONG>> param(T, vector<ULONG>(5));
	vector<ULONG>ans(T);
	for (int t = 0; t < T; t++) {
		ULONG N, A, B, C, D;
		cin >> N >> A >> B >> C >> D;
		param[t][0] = N;
		param[t][1] = A;
		param[t][2] = B;
		param[t][3] = C;
		param[t][4] = D;
	}
	for (int t = 0; t < T; t++) {
		ULONG N;
		N = param[t][0];
		A = param[t][1];
		B = param[t][2];
		C = param[t][3];
		D = param[t][4];
		ma.clear();
		ans[t]=solveOne(N);
	}
	for (int t = 0; t < T; t++) {
		cout << ans[t] << endl;
	}


#ifdef _DBG_
	int tmpi;
	cin >> tmpi;
#endif
}


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

namespace AC
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var N = input[0];
            var M = input[1];
            var AC = new bool[N];
            var WA = new int[N];
            for (int i = 0; i < M; i++)
            {
                var line = Read().Split(' ');
                var p = int.Parse(line[0]) - 1;
                var S = line[1];
                if (AC[p]) continue;
                if (S == "WA") WA[p]++;
                else AC[p] = true;
            }
            var ac = AC.Count(b => b == true);
            var wa = 0L;
            for (int i = 0; i < N; i++) if (AC[i]) wa += WA[i];

            Console.WriteLine(ac + " " + wa);
            Console.ReadKey();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 17472
ary = []
for i in range(0, 3):
    ary.append(list(map(int, input().split())))
n = int(input())
ans = False
call = []
for i in range(0, n):
    call.append(int(input()))

for i in range(0, 3):
    # 横チェック
    if (ary[i][0] in call and ary[i][1] in call and ary[i][2] in call):
        print("Yes")
        exit()
    # 縦チェック
    if (ary[0][i] in call and ary[1][i] in call and ary[2][i] in call):
        print("Yes")
        exit()
# 斜めチェック
for i in range(0, 2):
    if (ary[0][0] in call and ary[1][1] in call and ary[2][2] in call) or (ary[0][2] in call and ary[1][1] in call and ary[2][0] in call):
        print("Yes")
        exit()
print("No")


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

map<string, int> item;
map<string, vector<string>> recipe;
int rec(string s) {
    if (!recipe.count(s)) return item[s];
    int cost = 0;
    for (string t: recipe[s]) cost += rec(t);
    return min(item[s], cost);
}

int main() {
    int n;
    while (cin >> n, n) {
        item.clear();
        while (n--) {
            string s; int p; cin >> s >> p; item[s] = p;
        }
        int m; cin >> m;
        recipe.clear();
        while (m--) {
            string s; int k; cin >> s >> k;
            while (k--) {
                string t; cin >> t; recipe[s].emplace_back(t);
            }
        }
        string r; cin >> r;
        cout << rec(r) << endl;
    }
    return 0;
}


Measured memory_bytes: 3160
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define ALL(c) (c).begin(), (c).end()
#define dump(x) cout << #x << " = " << (x) << endl

int main() {
  string S;
  cin >> S;
  string ans;
  if (S == "Sunny") {
    ans = "Cloudy";
  } else if (S == "Cloudy") {
    ans = "Rainy";
  } else if (S == "Rainy") {
    ans = "Sunny";
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main () {
	int i, j, minj, A[100], N, x, c = 0;

	scanf ( "%d", &N);
	for ( i = 0; i < N; i++ ) {
		scanf ( "%d", &A[i]);
	}
	
	for ( i = 0; i <= N-1; i++ ) {
		minj = i;
		for ( j = i; j <= N-1; j++ ) {
			if ( A[j] < A[minj] ) {
				minj = j;
			}
		}
	
		if ( i != minj ) {
			x = A[minj];
			A[minj] = A[i];
			A[i] = x;
			c++;
		}
	}
	for ( i = 0; i < N-1; i++){
		printf ( "%d ",A[i]);
	}
	printf ( "%d\n%d\n", A[N-1],c);

	return 0;
}


Measured memory_bytes: 2124
#pragma GCC optimize ("O3")
// #pragma GCC target ("avx")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}
namespace TRIE {

struct Node;
Node* new_node(char c);

struct Node {
    char c; // character from parent;
    int val;
    Node *left, *right;

    Node* lookup(char alpha, bool add, bool move_to_front) {
	Node *ch = left, *prv = 0;
	while (ch) {
	    if (ch->c == alpha) {
		if (move_to_front && prv) {
		    prv->right = ch->right;
		    ch->right = left;
		    left = ch;
		}
		return ch;
	    }
	    prv = ch;
	    ch = ch->right;
	}
	if (add) {
	    // push front;
	    ch = new_node(alpha);
	    ch->right = left;
	    left = ch;
	}
	return ch;
    }
};

const int NODES = 1000011;
int node_i;
Node nodes[NODES];

void clear() {
    node_i = 0;
}

Node* new_node(char c) {
    Node *x = nodes + node_i;
    node_i++;
    x->c = c;
    x->val = 0;
    x->left = x->right = 0;
    return x;
}

Node* new_root() {
    return new_node(0);
}

void add(Node *root, const string &s, LL num) {
    Node *x = root;
    // x->sum += num;
    REP (i, s.size()) {
	x = x->lookup(s[i], true, true);
	// x->sum += num;
    }
    x->val += num;
}


}; // namespace TRIE;

using namespace TRIE;

int N;
char buf[1000111];
string S[200011];

struct ByLen {
    bool operator()(const string &s, const string &t) const {
	return s.size() != t.size() ? s.size() < t.size()
	    : s < t;
    }
} byLen;

int C[26];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) {
	scanf("%s", buf);
	S[i] = buf;
	reverse(S[i].begin(), S[i].end());
    }

    sort(S, S+N, byLen);
    Node *root = new_root();

    LL ans = 0;
    REP (i, N) {
	const string &s = S[i];
	memset(C, 0, sizeof C);
	REP (j, s.size()) C[s[j]-'a']++;

	Node *x = root;
	LL tmp = 0;
	tmp += x->val;
	REP (j, s.size()) {
	    Node *y = x->left;
	    while (y) {
		// eprintf("%s %c\n", s.c_str(), y->c);
		if (C[y->c-'a']) tmp += y->val;
		y = y->right;
	    }

	    char c = s[j];
	    C[c-'a']--;
	    x = x->lookup(c, false, true);
	    if (!x) break;
	}

	add(root, s, 1);
	ans += tmp;
    }

    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	string S;
	ll K;
	cin >> S >> K;
	if (S[0]!=S[S.size()-1]) {
		ll ans = 0;
		fx(S.size()-1) {
			if (S[x]==S[x+1]) {
				ans++;
				x++;
			}
		}
		ce(ans*K)
	}
	else {

		if (S.size()==1) {
			ce(K/2)
		}else if (S[0]==S[1] || S[S.size()-1]==S[S.size()-2]) {
				ll sum = 0, ans = 0;
				int i = 0, j = S.size() - 1;
				while (i<S.size()&&S[i]==S[0]) {
					i++;
				}
				while (j>=0&&S[j]==S[S.size()-1]) {
					j--;
				}
				if (i==S.size()) {
					ce(K*S.size()/2)
				}
				else {
					sum = (i + S.size() - 1 - j)/2;
					//ce(sum)
					fyg(j,i) {
						if (S[y]==S[y+1]) {
							ans++;
							y++;
						}
					}
					//doublece(i / 2 , (S.size() - j -1) / 2)
					ce(ans*K+sum*(K-1)+i/2+ (S.size() - j-1) / 2)
				}
		}
		else {
			ce(K-1)
		}
	}
    return 0;
}



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

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

int main(){
int n;
cin>>n;
ll X[n],Y[n];
rep(i,n){
cin>>X[i];
Y[i]=X[i];
}
sort(Y,Y+n);

double H=((double)Y[n/2-1]+(double)Y[n/2])/2;
//cout<<H<<endl;
rep(i,n){
if(X[i]>=H){
  cout<<Y[n/2-1]<<endl;
}else
{
  cout<<Y[n/2]<<endl;
}


}
  return 0;
}


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

#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(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    int N; cin >> N;
    ll x=1, y=1;
    REP(i,N){
        ll t,a; cin >> t >> a;
        ll k1,k2;
        k1 = (x-1)/t + 1;
        k2 = (y-1)/a + 1;
        ll k = max(k1,k2);
        x = t*k;
        y = a*k;
        //cout << x << ", " << y << endl;
    }
    cout << x+y << endl;
    return 0;
}

Measured memory_bytes: 3648
#![allow(unused_imports)]
use petgraph::unionfind::UnionFind;
use proconio::*;
use std::cmp::*;
use std::fs;
use std::io::*;

#[fastout]
fn main() {
   input! {
      mut n: usize,
   }
   while n>0 {
      match n%10 {
          7 => {println!("Yes"); return;},
          _ => n/=10
      }
   }
   println!("No");
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define ff first
#define ss second
#define inf 2000000007
#define pb push_back
#define MAXN 200100
using namespace std;
typedef pair<int,int> pii;

int32_t main(){
	fastio;
	int P,Q,R;
	cin>>P>>Q>>R;
	cout<<min(P+Q,min(P+R,Q+R))<<endl;
	
}

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


int main(){
    int n, m;
	cin >> n >> m;
	map<long,int> price;
	long sum=0;
	for(int i=0; i<n; i++){
		long num;
		cin >> num;
		if(price.find(num)!=price.end()){
			price[num]++;
		}else{
			price[num]=1;
		}
		sum+=num;
	}
	while(m>0){
		long max_price = (--price.end())->first;
		long new_price = max_price/2;
		sum -= max_price - new_price;
		if(price.find(new_price)!=price.end()){
			price[new_price]++;
		}else{
			price[new_price]=1;
		}
		price[max_price]--;
		if(price[max_price]==0) price.erase(max_price);
		m--;
	}
	cout << sum << endl;
	
    return 0;
}

Measured memory_bytes: 6528
#include<stdio.h>

int main(void)
{
	int a,b,c,d,i=0,j;
	int kai[1000]={0},atai[1000];
	while(kai[0] ==0)
	{
		scanf("%d",&atai[i]);
		
		if(atai[i]<=0 || 50<atai[i])break;

		i=i+1;
	}
	
	for(j=0;j<i;j++)
	{
		for(a=0;a<10;a++)
		{
			if(a>atai[j])break;
			for(b=0;b<10;b++)
			{
				if(a+b > atai[j])break;
				for(c=0;c<10;c++)
				{
					if(a+b+c>atai[j])break;
					for(d=0;d<10;d++)
					{
						if(a+b+c+d == atai[j])
						{
							kai[j]=kai[j]+1;
						}
						else if(a+b+c+d>atai[j])break;
					}
				}
			}
		}
	}
	for(j=0;j<i;j++)
	  printf("%d\n",kai[j]);

	return 0;
}

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

int main() {
  vector<int> data(3);
  cin >> data.at(0) >> data.at(1) >> data.at(2);
  sort(data.begin(), data.end());
  vector<int> answer = {5, 5, 7};
  if (data == answer) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
(defrecord Pair [^int y ^int x])
(def ^:const D-Y-X
  [(Pair. -1 -1) (Pair. -1 0) (Pair. -1 1)
    (Pair. 0 -1) (Pair. 0 1)
    (Pair. 1 -1) (Pair. 1 0) (Pair. 1 1)])
(def ^:const Zero (unchecked-int \0))

(defn get_H_W []
  (->> (clojure.string/split (read-line) #"\s")
    (map #(Integer/parseInt %))))

(defn set_Array [^"[[C" Array H W]
  (dotimes [h H]
    (->> (read-line)
      (char-array W)
      (aset Array h))))

(defn Minesweeper [^"[[C" Array H W]
  (let [X (apply vector-of :int (range W))
        Y (apply vector-of :int (range H))]
    (doseq [x X
            y Y
            :when (not= \# (aget ^"[C" (aget Array y) x))]
      (with-local-vars [counts (unchecked-int 0)]
        (doseq [d-y-x D-Y-X
                :let [dx (unchecked-add-int x (:x d-y-x))
                      dy (unchecked-add-int y (:y d-y-x))]
                :when (and
                        (<= 0 dx)
                        (< dx W)
                        (<= 0 dy)
                        (< dy H)
                        (= \# (aget ^"[C" (aget Array dy) dx)))]
          (var-set counts (unchecked-inc-int @counts)))
        (->> @counts
          (unchecked-add-int Zero)
          unchecked-char
          (aset ^"[C" (aget Array y) x))))))

(defn output [^"[[C" Array]
  (-> (areduce Array idx ret ""
        (str ret
          (apply str (aget Array idx))
          "\n"))
    print))

(let [[H W] (get_H_W)]
  (doto (make-array Character/TYPE H W)
    (set_Array H W)
    (Minesweeper H W)
    (output)))

Measured memory_bytes: 70776
#include<iostream>

using namespace std;

int main() {
	int st[5], res[5];
	int g[3], n = 0;
	int val = 0;
	
	while(1) {
	
		for( int i=0; i<3; i++) g[i] = 0;
		n = 0;
		val = 0; // val -> winner

		// Input
		for( int i=0; i<5; i++) {
			cin >> st[i];
			if(st[i]==0) break;
			if(!g[ st[i]-1 ]) {
				n++;
				g[ st[i]-1 ] = 1;
				if( val==0) val = st[i];
				if( val-1==(st[i]%3)) val = st[i];
			}
		}
		if(st[0]==0) break;
		
		if( n==2) {
			for( int i=0; i<5; i++)
				if( val==st[i]) res[i] = 1; else res[i] = 2;
		}else {
			for( int i=0; i<5; i++) res[i] = 3;
		}

		// Output
		for( int i=0; i<5; i++) cout << res[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#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 endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define FOR(i, n) for (int(i) = 0; (i) < n; (i)++)
#define PI (3.141592653589)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>

#define MOD 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed;
    cout.precision(10);
    // Those who cannot acknowledge themselves, will invariably fail

    int n;
    cin >> n;
    long long arr[n];
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    long long sol = 0ll;
    long long dp[n-1][2];
    dp[0][0] = arr[0] + arr[1];
    dp[0][1] = -(arr[0] + arr[1]);
    for(int i = 1;i<n-1;i++)
    {
        dp[i][0] = arr[i+1] + max(dp[i-1][0], dp[i-1][1]);
        dp[i][1] = -arr[i+1] + max(dp[i-1][0] - 2*arr[i], dp[i-1][1] + 2*arr[i]);
    }
    cout << max(dp[n-2][0], dp[n-2][1]);
    return 0;
}

Measured memory_bytes: 2560
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gcd
from operator import mul
from functools import reduce
from operator import mul


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007




def least_bit_set(x):
    return x & (-x)


def delete_zeros_from(values, start):
    i = start
    for j in range(start, len(values)):
        if values[j] != 0:
            values[i] = values[j]
            i += 1
    del values[i:]


def eliminate(values):
    values = list(values)
    i = 0
    while True:
        delete_zeros_from(values, i)
        if i >= len(values):
            return values
        j = i
        for k in range(i + 1, len(values)):
            if least_bit_set(values[k]) < least_bit_set(values[j]):
                j = k
        values[i], values[j] = (values[j], values[i])
        for k in range(i + 1, len(values)):
            if least_bit_set(values[k]) == least_bit_set(values[i]):
                values[k] ^= values[i]
        i += 1


def in_span(x, eliminated_values):
    for y in eliminated_values:
        if least_bit_set(y) & x != 0:
            x ^= y
    return x == 0


t = I()
for _ in range(t):
    n = I()
    A = LI()
    s = S()
    flg = 0
    values = []
    for j in range(n - 1, -1, -1):
        if int(s[j]) == 0:
            values += [A[j]]
            values = eliminate(values)
        else:
            if not in_span(A[j], values):
                print(1)
                break
    else:
        print(0)








Measured memory_bytes: 80124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323846
#define fi first
#define se second

ll mod = 1e9+7;

ll max(ll a, ll b ) {
	if(a>b)
		return a;
	else return b;
}
ll min(ll a, ll b ) {
	if(a<b)
		return a;
	else return b;
}
/*
ll gcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = gcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}
ll inv(ll a) {
	ll x, y;
	ll g = gcd(a, mod, x, y);
	x = (x % mod + mod) % mod;
	return x;
}
ll binpow(ll a, ll b, ll m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a%m;
        a = a * a%m;
        b >>= 1;
    }
    return res;
}
*/
int main() {
	int t;
	//cin>>t;
	t = 1;
	while(t--) {
		ll k; cin>>k;
		ll d = 7;
		if(k%2==0) cout<<-1;
		else {
			ll ct = 1;
			while(d/k==0) {
				d = 10*d + 7;
				ct++;
			}
			vector<ll> mp(1000001,0);
			//cout<<ct;
			ll rem1 = d%k;
			mp[rem1] = 1;
			if(rem1==0) cout<<ct;
			else {
				ll rem2 = (rem1*10 + 7)%k;
				mp[rem2] = 1;
				ct++;
				ll temp = rem2;
				int flag = 0;
				while(rem2!=0) {
					rem2 = (rem2*10 + 7)%k;
					if(mp[rem2]==1) {flag = 1; break;}
					else mp[rem2] = 1;
					ct++;
				}
				if (flag == 0) cout<<ct;
				else cout<<-1;
			} 
		}
	}
	return 0;
}



Measured memory_bytes: 11112