akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

using namespace std;
#ifdef ONLINE_JUDGE
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');
#endif

inline int findstr(const string& s, const int& begin, const int& end, const string& t, const int& tl) {
  for (int i = begin; i <= end - tl;) {
    for (int j = 0; j < tl; ++j) {
      if (s[i + j] != t[j]) goto cont;
    }
    return i;
  cont:
    ++i;
  }
  return -1;
}
int main() {
  string s;
  int k;
  cin >> s >> k;
  int n = s.size();
  string t(5, 0);
  for (char c = 'a'; c <= 'z'; ++c) {
    t[0] = c;
    int l0 = findstr(s, 0, n, t, 1);
    if (l0 < 0) continue;
    if (k == 1) {
      cout << t[0] << endl;
      return 0;
    }
    --k;
    for (char c = 'a'; c <= 'z'; ++c) {
      t[1] = c;
      int l1 = findstr(s, l0, n, t, 2);
      if (l1 < 0) continue;
      if (k == 1) {
        cout << t[0] << t[1] << endl;
        return 0;
      }
      --k;
      for (char c = 'a'; c <= 'z'; ++c) {
        t[2] = c;
        int l2 = findstr(s, l1, n, t, 3);
        if (l2 < 0) continue;
        if (k == 1) {
          cout << t[0] << t[1] << t[2] << endl;
          return 0;
        }
        --k;
        for (char c = 'a'; c <= 'z'; ++c) {
          t[3] = c;
          int l3 = findstr(s, l2, n, t, 4);
          if (l3 < 0) continue;
          if (k == 1) {
            cout << t[0] << t[1] << t[2] << t[3] << endl;
            return 0;
          }
          --k;
          for (char c = 'a'; c <= 'z'; ++c) {
            t[4] = c;
            int l4 = findstr(s, l3, n, t, 5);
            if (l4 < 0) continue;
            if (k == 1) {
              cout << t[0] << t[1] << t[2] << t[3] << t[4] << endl;
              return 0;
            }
            --k;
          }
        }
      }
    }
  }
}


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

struct RollingHash {
    const int base = 10007;
    static const int M = 2;
    const vector<int> mod = {999999937, 1000000007};
    vector<long long> hash[M], power[M];
    RollingHash(const string &s, int base = 9973) : base(base) {
        int n = s.size();
        for (int iter = 0; iter < M; ++iter) {
            hash[iter].assign(n + 1, 0);
            power[iter].assign(n + 1, 1);
            for (int i = 0; i < n; ++i) {
                hash[iter][i + 1] = (hash[iter][i] * base + s[i]) % mod[iter];
                power[iter][i + 1] = power[iter][i] * base % mod[iter];
            }
        }
    }
    long long get(int l, int r, int id = 0) {   // [l, r)
        long long ret = hash[id][r] - hash[id][l] * power[id][r-l] % mod[id];
        return (ret < 0 ? ret + mod[id] : ret);
    }
};

int main() {
    string s;
    while (cin >> s) {
        RollingHash rh(s);
        int n = s.size();
        int ans = n;
        int a = n % 2 == 0 ? 2 : 1;
        int b = n % 2 == 0 ? n / 2 - 1 : n / 2;
        int c = b + a;
        int d = n - a;
        while (a < b) {
            long long A = rh.get(0, a);
            if (rh.get(b, c) == A && rh.get(d, n) == A && rh.get(a, b) == rh.get(c, d)) {
                ans = min(ans, b);
            }
            a += 2; b -= 1; c += 1; d -= 2;
        }
        if (ans != n) {
            cout << "Love " << s.substr(0, ans) << '!' << endl;
        } else {
            cout << "mitomerarenaiWA" << endl;
        }
    }
    return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && b == c){
    cout << 1 << endl;
  }
  else if (a != b && b != c && c != a){
    cout << 3 << endl;
  }
  else{
    cout << 2 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

string s;

string target = "AKIHABARA";

int main() {
    cin >> s;

    int i = 0;
    int j = 0;

    while (i < s.size()) {
        if (j >= target.size()) {
            cout << "NO\n";
            return 0;
        }
        else if (s[i] == target[j]) {
            i++;
            j++;
        }
        else if (target[j] == 'A') {
            j++;
        }
        else {
            cout << "NO\n";
            return 0;
        }
    }

    if (j >= 8) cout << "YES\n";
    else cout << "NO\n";

    return 0;
}

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

std::vector<int> getInput(int n) {
  std::vector<int> input;
  for (int i = 0; i < n; i++) {
    int buf;
    std::cin >> buf;
    input.push_back(buf);
  }
  return input;
}

int getIndex(const std::vector<int> &vec, const int element) {
  for (int i = 0; i < vec.size(); i++) {
    if (vec[i] == element) return i;
  }
  return -1;
}

std::vector<int> getLabels(const std::vector<int> &mapping,
                           const std::vector<int> &labels) {
  auto newLabels = mapping;
  std::transform(mapping.begin(), mapping.end(), newLabels.begin(),
                 [&](int e) { return labels[e - 1]; });
  return newLabels;
}

bool isSame(const std::vector<int> &first, const std::vector<int> &second) {
  int secondStartIndex = getIndex(second, first[0]);
  std::vector<int> alignedSecond;
  for (int i = secondStartIndex; i < secondStartIndex + 4; i++) {
    alignedSecond.push_back(second[i % 4]);
  }
  return first == alignedSecond;
}

bool isSame(const std::vector<std::vector<int>> &dice,
            const std::vector<int> &first, const std::vector<int> &second) {
  for (int i = 0; i < dice.size(); i++) {
    auto firstLabels = getLabels(dice[i], first);

    int secondIndex = getIndex(second, first[i]);
    if (secondIndex == -1) return false;
    auto secondLabels = getLabels(dice[secondIndex], second);
    if (isSame(firstLabels, secondLabels)) return true;
  }
  return false;
}

int main() {
  std::vector<std::vector<int>> dice = {{5, 3, 2, 4}, {1, 3, 6, 4},
                                        {1, 5, 6, 2}, {1, 2, 6, 5},
                                        {1, 4, 6, 3}, {5, 4, 2, 3}};

  std::vector<int> first = getInput(6), second = getInput(6);

  if (isSame(dice, first, second)) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }
  return 0;
}



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

using namespace std;
using ll=long long;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL<<60;
ll dp[100010];
vector<int> g[100010];
int rec(int v){
    if(dp[v] != -1) return dp[v]; 
    int res = 0;   
    for(auto nv : g[v]){
        chmax(res,rec(nv)+1);
    }
    return dp[v] = res;
}

int main() {


int n,m,mx=0; cin >> n >> m;
for (int i = 0; i < n; ++i)
{
    dp[i]=-1;
}

//g.assign(n, vector<int>());
for (ll i = 0; i < m; ++i)
{
    int x,y; cin>>x>>y;--x;--y;
    g[x].push_back(y);
}
int res=0;
for (ll i = 0; i < n; ++i)
{
    chmax(res,rec(i));
}

cout << res;
return 0;
}




Measured memory_bytes: 8576
import sys
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    d = set()
    for _ in range(N):
        a = int(input())
        if a in d:
            d.remove(a)
        else:
            d.add(a)
    print(len(d))



if __name__ == "__main__":
    main()


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

using namespace std;

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

  uint64_t n;
  cin >> n;
  uint64_t luka[87];
  luka[0] = 2;
  luka[1] = 1;
  for (int i = 2; i <= n; ++i) {
    luka[i] = luka[i-1] + luka[i-2];
  }
  cout << luka[n] << "\n";
}


Measured memory_bytes: 256
// Author :
// Date :
// Problem:
// Solution:
// Comment:

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstring>

#define pp push
#define pb push_back
#define mp make_pair
#define xx first
#define yy second

using namespace std;
int cnt[1005]={0};

main(){
    for(int i = 1 ; i <= 1000 ; i++){
        for(int j = i+1 ; j <= 1000 ; j++){
            int sum = 0;
            for(int k = i ; k <= j ; k++){
                sum+=k;
            }
            if(sum<=1001) cnt[sum]++;
        }
    }
    
    int t;
    
    while(cin >> t){
        if(t == 0) break;
        cout << cnt[t] << endl;
    }
    #ifdef GEREL
        for(;;);
    #endif

    return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#define randome_generate srand(std::chrono::high_resolution_clock::now().time_since_epoch().count())
using namespace std;
long double dp[3000][3000],res;
int n;
long double h[3000],t[3000];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>h[i];
		t[i]=1.0000-h[i];
	}
	dp[0][0]=1.00000;
	for(int i=1;i<=n;i++){
		dp[i][0]=dp[i-1][0]*t[i];
		for(int j=1;j<=i;j++){
			dp[i][j]=dp[i-1][j-1]*h[i]+dp[i-1][j]*t[i];
		}
	}
	for(int i=(n+1)/2;i<=n;i++)
		res+=dp[n][i];
	cout<<fixed<<setprecision(20)<<res<<endl;
	return 0;
}


Measured memory_bytes: 139264
#include <stdio.h>

int main(void) {
	int a,b;
	
	scanf("%d %d",&a, &b);
	
	if(a > b){
		printf("a > b\n");
	}else if(a < b){
		printf("a < b\n");
	}else{
		printf("a == b\n");
	}
	return 0;
}



Measured memory_bytes: 2100
N, P=map(int,input().split())
def factorization(n):
  primen = []
  degree = []
  primend = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
      primen.append(i)
      degree.append(cnt)
      primend.append([i,cnt])
  if temp!=1:
    primen.append(temp)
    degree.append(1)
    primend.append([temp,1])
  if primen==[]:
    primen.append(n)
    degree.append(1)
    primend.append([n,1])
  return primend

ret = factorization(P)
ans = 1
for pn in ret:
  ans *= pn[0]**(pn[1]//N)
print(ans)

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

#define int long long

int32_t main(){
	int a , b , c , d ;
	cin >> a >> b >> c >> d ;
	while(a > 0 && c > 0){
		c -= b ;
		if(c <= 0) break ;
		a -= d ;
	}
	if(a > 0){
		cout << "Yes" ;
	} else {
		cout << "No" ;
	}
	return 0 ;
}


Measured memory_bytes: 3584
from operator import itemgetter
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
a = list(map(int, input().split()))
b = []
for _ in range(m):
    tb, tc = map(int, input().split())
    b.append([tb, tc])
a.sort()
b.sort(key=itemgetter(1), reverse=True)

c = 0
flag = False
for j in range(m):
    if (flag):
        break
    for i in range(b[j][0]):
        if (c >= len(a) or a[c] >= b[j][1]):
            flag = True
            break
        a[c] = b[j][1]
        c += 1

print(sum(a))

Measured memory_bytes: 25560
n,a=open(0)
n=int(n)
a=sorted(map(int,a.split()))
if a[0]==a[-1]:
  if n-1==a[0]or n//a[0]>=2:
    print('Yes')
  else:
    print('No')
elif a[-1]-1==a[0]:
  x=a.count(a[0])
  if x<a[-1]and(n-x)//(a[-1]-x)>=2:
    print('Yes')
  else:
    print('No')
else:
  print('No')

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<int>> c(10, vector<int>(10));

  for (int i=0; i<10; i++) {
    for (int j=0; j<10; j++) {
      cin >> c.at(i).at(j);
    }
  } 
  for (int k=0; k<10; k++) {
    for (int i=0; i<10; i++) {
      for (int j=0; j<10; j++) {
        c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
      }
    }
  }


  vector<vector<int>> A(H, vector<int>(W));
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      cin >> A.at(i).at(j);
    }
  }

  int sum = 0;
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      if (abs(A.at(i).at(j)) != 1) sum += c.at(A.at(i).at(j)).at(1);
    }
  }

  cout << sum << endl;
} 

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
vector <int> numbers;
bool condition(int i){
	int max=numbers[i-1], min=max;
	for(int j=i;j<=i+1; j++){
		if(numbers[j]>max) max = numbers[j];
		if(numbers[j]<min) min = numbers[j];
	}
	if (numbers[i] == min || numbers[i] == max) return false;
	return true; 
}

int main(){
	int n, x, cont=0;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >>x;
		numbers.push_back(x);
	}
	for(int i=1;i<n-1; i++){
		if (condition(i)) cont++;
	}
	cout << cont;
	return 0;
}

Measured memory_bytes: 3648
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

def gcd(a, b):  
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    r = a % b
    return gcd(b, r)

N = ii()
A = li()

forward = [0]*(N+1)
backward = [0]*(N+1)

forward[0] = 0
for i in range(1, N+1):
    forward[i] = gcd(A[i-1], forward[i-1])

backward[0] = 0
for i in reversed(range(1, N+1)):
    backward[N+1-i] = gcd(A[i-1], backward[N-i])

#print(forward)
#print(backward)
ans = 0
for i in range(N):
    #print(forward[i], forward[N-1-i], ans)
    ans = max(ans, gcd(forward[i], backward[N-1-i]))

print(ans)


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

const int maxn(2e5 + 5);

struct Edge {
	int u, v;
	ll w;
};
inline int operator <(const Edge &a, const Edge &b) {  return a.w < b.w;  }

int fa[maxn], n, w[maxn], cnt, size[maxn], vis[maxn], mx[maxn], nsz, rt;
Edge edge[maxn * 30];
ll ans;
vector < pair <int, int> > son[maxn];

inline int Find(int x) {  return (fa[x] ^ x) ? fa[x] = Find(fa[x]) : x;  }

inline void AddEdge(int u, int v, int f) {
	son[u].push_back(make_pair(v, f)), son[v].push_back(make_pair(u, f));
}

inline void Init() {
	int i, u, v, f;
	scanf("%d", &n);
	for (i = 1; i <= n; ++i) scanf("%d", &w[i]), fa[i] = i;
	for (i = 1; i < n; ++i) scanf("%d%d%d", &u, &v, &f), AddEdge(u, v, f);
}

void Getroot(int u, int ff) {
	size[u] = 1, mx[u] = 0;
	for (auto v : son[u])
		if (!vis[v.first] && (v.first ^ ff)) {
			Getroot(v.first, u);
			size[u] += size[v.first];
			mx[u] = max(mx[u], size[v.first]);
		}
	mx[u] = max(mx[u], nsz - size[u]);
	if (!rt || mx[u] < mx[rt]) rt = u;
}

void Dfs1(int u, int ff, ll &mn, int &ps, ll d) {
	if (d + w[u] < mn) mn = d + w[u], ps = u;
	for (auto v : son[u])
		if (!vis[v.first] && (v.first ^ ff)) Dfs1(v.first, u, mn, ps, d + v.second);
}

void Dfs2(int u, int ff, ll mn, int ps, ll d) {
	edge[++cnt] = (Edge){u, ps, mn + d + w[u]};
	for (auto v : son[u])
		if (!vis[v.first] && (v.first ^ ff)) Dfs2(v.first, u, mn, ps, d + v.second);
}

inline void Solve(int u) {
	ll mn = w[u];
	int ps = u;
	vis[u] = 1, Dfs1(u, 0, mn, ps, 0), Dfs2(u, 0, mn, ps, 0);
	for (auto v : son[u])
		if (!vis[v.first]) {
			nsz = size[v.first], rt = 0;
			Getroot(v.first, u), Solve(rt);
		}
}

inline void Get_Edge() {  nsz = n, Getroot(1, 0), Solve(rt);  }

inline void Kruskal() {
	int i, fx, fy;
	sort(edge + 1, edge + cnt + 1);
	for (i = 1; i <= cnt; ++i)
		if ((fx = Find(edge[i].u)) ^ (fy = Find(edge[i].v))) ans += edge[i].w, fa[fx] = fy;
	printf("%lld\n", ans);
}

int main() {
	Init(), Get_Edge(), Kruskal();
	return 0;
}

Measured memory_bytes: 80384
#include <iostream>

using namespace std;

int main(){
  int ary[3];
  int i, j, tmp;

  cin>>ary[0]>>ary[1]>>ary[2];
  for(j = 0; j < 2; j++){
    for(i = 0; i < 2; i++){
      if(ary[i] > ary[i+1]){
        tmp = ary[i];
        ary[i] = ary[i+1];
        ary[i+1] = tmp;
      }
    }
  }

  cout<<ary[0]<<" "<<ary[1]<<" "<<ary[2]<<endl;

}

Measured memory_bytes: 1164
#include <stdio.h>
int main(void){
    int N; scanf("%d", &N);
    int Ai[N];
    int i, tempmax, tempmin;
        for (i = 0; i < N; i++){
            scanf("%d",&Ai[i]);
        }
        tempmax = Ai[0];
        tempmin = Ai[0];
        for (i = 0; i < N; i++){
            if (Ai[i] > tempmax)
            tempmax = Ai[i];
            if (Ai[i] < tempmin)
            tempmin = Ai[i];
        }
        printf("%d\n",tempmax - tempmin);
    return 0;
}    

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef string st;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef vector<string>si;
typedef list<int>li;
typedef multiset<int>msi;
typedef map<int,int>ma;
typedef stack<int>sta;
typedef queue<string,int>que;
typedef priority_queue<int,vector<int>,greater<int> >pq;
#define dd(x) cout<<#x<<"="<<x<<",";
#define de(x) cout<<#x<<"="<<x<<endl;
#define df(x) cout<<x<<endl;
#define dg(x) cout<<x<<" ";
#define rep(i,a,b) for(i=a;i<b;++i)
#define per(i,a,b) for(i=b-1;i>=a;--i)
#define rpp(i,a,b) for(i=a;i<2*b-1;i+=2)
#define all(x) (x).begin(),(x).end()
#define sz(x) (x).size()
#define mp make_pair
#define pb push_back
#define po2 pop_back
#define po1 front_back
#define fi first
#define se second
#define Nmax 200005
//erase  merge atoi atof
const int N=575757;
int main()
{
	ll n, m, i, j, count = 0;
	cin >> n;
	ll s[n];
	rep(i, 0, n){
		cin>>s[i];
	}
	cin>>m;
	ll t[m];
	rep(i, 0, m)
	cin >> t[i];
	sort(s, s + n);
	sort(t, t + m);
	rep(i, 0, n){
		rep(j, 0, m){
			if(s[i] == t[j] && t[j] != -100000){
			count++;
			t[j] = -100000;
			}
		}
	}
	df(count);
	return 0;
}



Measured memory_bytes: 3168
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  int N;
  cin >> N;
  vi v(N);
  rep(i, N) cin >> v[i];
  
  sort(all(v));
  
  double sum = v[0];
  for(int i = 0; i < N - 1; i++) {
    sum = (sum + v[i+1]) / 2;
  }

  fin(sum);
}


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

#ifdef LOCAL 
string to_string(char a) { return string(1,a); }
string to_string(bool a) { return a ? "1" : "0"; }
string to_string(const char* a) { return (string)a; }
string to_string(string a) { return a; }
string to_string(vector<bool> v) {
	string s = "["; for(unsigned i=0;i<v.size();i++){ s += ((i>0)?" ":"");
    s += char('0'+v[i]); } 	s += "]"; return s; }
template<class A, class B> string to_string(pair<A,B> p);
template<class T> string to_string(T v) {
	bool b = 1; string s = "["; for (const auto& x: v) {
		if (!b) {s += ", ";} b = 0; s += to_string(x); } s += "]"; return s; }
template<class A, class B> string to_string(pair<A,B> p) {
	return "("+to_string(p.first)+", "+to_string(p.second)+")"; }
void dbgf() { cerr << endl; }
template<class H, class... T> void dbgf(H h, T... t) {
	cerr << to_string(h); if (sizeof...(t)) cerr << ", ";
	dbgf(t...); }
#define dbg(...) cerr << #__VA_ARGS__ << " = ", dbgf(__VA_ARGS__)
#else
#define dbg(...) 0
#endif
#define boolout(x) cout<<(x?"YES":"NO")<<endl;
typedef long long ll;


void solve()
{
    int n, W;
    cin >> n >> W;
    vector<int> w(n);
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> w[i] >> v[i];
    }

    int maxV=100000;
    vector<ll> dp(maxV+1, 1e18+5);

    ll res = 0;
    dp[0] = 0;

    for (int i = 0; i < n; ++i) {
        for (int j = maxV; j >= 0; --j) {
            if (j + v[i] <= maxV) {
                dp[j + v[i] ] = min(dp[j + v[i]], dp[j] + w[i]);
            }
        }
    }
    //dbg(dp);
    for (ll i = 0; i < maxV+1; ++i) {
        if (dp[i]<=W) {
            res = max(res, (ll) i);
        }
    }

    cout << res << endl;

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t; // read t. cin knows that t is an int, so it reads it as such.
    for (int i = 1; i <= t; ++i) {
        solve();
    }
    return 0;
}



Measured memory_bytes: 1024
main=do
 getLine
 t<-map read.words<$>getLine
 let s=sum t
 getLine
 c<-map(map read.words).lines<$>getContents
 sequence$f s t c
f s t[]=[]
f s t([i,u]:c)=(print$s-(t!!(i-1))+u):f s t c

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

num_list = [0]*(10**5 + 1)
for a in A:
    num_list[a] += 1

ans = sum(A)

Q = int(input())
for i in range(Q):
    B, C = map(int, input().split())
    value = num_list[B]
    ans = ans - B*value + C*value
    print(ans)
    num_list[B] = 0
    num_list[C] += value
# BC = [list(map(int, input().split())) for _ in range(Q)]

Measured memory_bytes: 20872
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define __lcm(a, b) std::__detail::__lcm(a, b)
typedef long long ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int A, P, ans;
  cin >> A >> P;
  ans = (A * 3 + P) / 2;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Code author: Saurabh Singhal
Code copy karne vaale tera muh kaala
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/

#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back

using namespace std;
typedef long long int ll;
typedef vector<int> vi_t;
typedef vector<ll> vll_t;
int t=1;
vll_t a,b;
int  main(){
	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif
	ll n;
	cin>>n;
	vector<ll>v(n);
	double ans=0.0;
	for(ll i=0;i<n;i++){
		double a;
		cin>>a;
		ans+=(1/(double)a);
	}
	double res=(1/(double)ans);
	printf("%0.5f\n",res);
}

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

const int maxn=1e5+100;
typedef long long ll;

bool f[maxn];
vector <pair<int,int> > v;
vector <int> g[maxn];
vector <int> lft,hv;
int n,m,k=0;

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		int idx,d;
		scanf("%d%d",&idx,&d);
		g[idx].push_back(d);
		v.push_back(make_pair(d,idx));
		k=max(idx,k);
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	ll cnt=0,sum=0,ans=0;
	for(int i=0;i<m;i++){
		int d=v[i].first;
		cnt+=d;
		int idx=v[i].second;
		if(f[idx]) hv.push_back(d);
		else{
			f[idx]=1;
			sum++;
		}
	}
	ans=cnt+sum*sum;
	for(int i=1;i<=k;i++){
		sort(g[i].begin(),g[i].end());
		reverse(g[i].begin(),g[i].end());
	}
	for(int i=1;i<=k;i++){
		if(!f[i]&&g[i].size()>0){
			lft.push_back(g[i][0]);
		}
	}
	sort(hv.begin(),hv.end());
	sort(lft.begin(),lft.end());
	reverse(lft.begin(),lft.end());
	for(int i=0;i<min(hv.size(),lft.size());i++){
		cnt-=hv[i];
		cnt+=lft[i];
		sum++;
		ans=max(ans,cnt+sum*sum);
	}
	printf("%lld",ans);
	return 0;
}

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

int main(){
    int N; cin>>N;
    vector<long long>vx(N),vy(N),vh(N);
    int si=-1;
    for(int i=0;i<N;i++){
        cin>>vx[i]>>vy[i]>>vh[i];
        if(vh[i]>0)si=i;
    }
    long long resx=-1,resy=-1,resh=-1;
    for(long long x=0;x<=100;x++){
        for(long long y=0;y<=100;y++){
            long long h=vh[si]+abs(x-vx[si])+abs(y-vy[si]);
            bool ok=true;
            for(int i=0;i<N;i++){
    
                if(vh[i]>0 && h-vh[i]!=abs(x-vx[i])+abs(y-vy[i])){
                ok=false;
                }
                if(vh[i]==0 && h>abs(x-vx[i])+abs(y-vy[i])){
                ok=false;
                }
            }
            if(ok) resx=x,resy=y,resh=h;
        }
    }
    cout<<resx<<" "<<resy<<" "<<resh<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin >> s;
    string ans;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] == 'B' ){ 
            if (ans.begin() != ans.end() )ans.erase(ans.end()-1);
        }
        else ans += s[i];
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
    int N, M, X;
    cin >> N >> M >> X;
    int A[101];
    int end;
    for(int i=0;i<M;i++){
        cin >> A[i];
        end = i;
    }

    int cost0 = 0, costn = 0;
    int flag = 0;
    for(int i=X;i!=0;i--){
        for(int j=0;j<M;j++){
            if(i == A[j])
                flag = 1;
        }
        if(flag == 1)
            cost0++;
        flag = 0;
    }


    for(int i=X;i!=N;i++){
        for(int j=0;j<M;j++){
            if(i == A[j])
                flag = 1;
        }
        if(flag == 1)
            costn++;
        flag = 0;
    }

    if(cost0 < costn)
        cout << cost0 << '\n';
    else
        cout << costn << '\n';
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

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

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

int main(){
	int n,k,q;
	cin>>n>>k>>q;
	VI pnt(n,0);
	rep(i,q){
		int a;
		cin>>a;
		a--;
		pnt.at(a)++;
	}
	rep(i,n){
		if(pnt.at(i)>q-k){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}	
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <limits.h>
#include <queue>
#include <algorithm>
#include <map>
#include <cstring>

#define dprintf(s,...) printf("%s:%d" s,__func__,__LINE__,__VA_ARGS__)
using namespace std;

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

int r,c,a1,a2,b1,b2;
int mod=100000007;

int extgcd(int a, int b, int &x, int &y){//ax+by=gcd(a,b)
  int d=a;
  if(b!=0){
    d = extgcd(b, a%b, y, x);
    y-= (a/b)*x;
  }else{
    x=1; y=0;
  }
  return d;
}

int mod_inv(int a){
  int x,y;
  extgcd(a,mod,x,y);
  return(mod + x%mod) % mod;
}

ll conb(int n,int r){

  ll ret = 1,tmp = 1;

  while(r!=0){
    int N = n%mod;
    int R = r%mod;
    if(N<R) return 0;

    for(int i=0;i<R;i++)
      ret = ret*(N-i) % mod;
    for(int i=0;i<R;i++)
      tmp = tmp*(i+1) % mod;

    ret = ret*mod_inv(tmp) % mod;
    n /= mod;
    r /= mod;
  }
  return ret;
}

int solve(){

  ll ret=0;
  int t=1;
  
  int rr=min(abs(a1-b1), r-abs(a1-b1));
  int cc=min(abs(a2-b2), c-abs(a2-b2));

  if(r==abs(a1-b1)*2) t*=2;
  if(c==abs(a2-b2)*2) t*=2;
  
  ret = conb(rr+cc, cc)*t % mod;    
   
  return ret;
}

int main(){

  cin>>r>>c>>a1>>a2>>b1>>b2;
  cout<<solve()<<endl;

  return 0;
}

Measured memory_bytes: 3084
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
		int q=sc.nextInt();
  	   	int[] a=new int[q];
  		int[] b=new int[n];
		for(int c=0;c<q;c++){
    		a[c]=sc.nextInt();
    	}
  		
  		for(int p=0;p<n;p++){
        	b[p]=0;
        }
  		
  		for(int d=0;d<q;d++){
          	b[a[d]-1]++;
        }
          
    	for(int f=0;f<n;f++){
 		if((k-q+b[f])<=0){
    		System.out.println("No");
    	}else{
     		System.out.println("Yes");
   	 }

        }
    }
}


Measured memory_bytes: 62428
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

bool kai(string s){
    bool ch=1;
    rep(i,s.size()/2)if(s[i]!=s[s.size()-1-i])ch=0;
    return ch;
}

int main() {
    
    // double l;
    // cin>>l;
    // printf("%.6f\n",(l/3.0)*(l/3.0)*(l/3.0));
    string s;
    cin>>s;
    bool ch=1;
    ch&=kai(s);
    // fin(ch);
    ch&=kai(s.substr(0,ceil((s.size()-1)/2.0)));
    // fin(ch);
    ch&=kai(s.substr( ceil((s.size()+1)/2.0) ));
    // fin(s.substr( ceil((s.size()+1)/2.0) ));
    Yn(ch);
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)
	as := make([]int, n)
	for i := range as {
		fmt.Scan(&as[i])
	}

	ans := make([]string, n)
	for i, a := range as {
		ans[a-1] = strconv.Itoa(i + 1)
	}

	fmt.Println(strings.Join(ans, " "))
}


Measured memory_bytes: 6528
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; //↑→↓←
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  ll a, b, n;
  cin >> a >> b >> n;
  if(n < b) cout << a * n / b << endl;
  else{
    ll kake = n/b;
    cout << a * (b * kake - 1) / b - a * ((b * kake - 1) / b) << endl;
  }

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("2");
            WillReturn.Add("3 5 2");
            WillReturn.Add("4 5");
            //9
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("3");
            WillReturn.Add("5 6 3 8");
            WillReturn.Add("5 100 8");
            //22
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("2");
            WillReturn.Add("100 1 1");
            WillReturn.Add("1 100");
            //3
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] AArr = InputList[1].Split(' ').Select(X => int.Parse(X)).ToArray();
        int[] BArr = InputList[2].Split(' ').Select(X => int.Parse(X)).ToArray();

        long Answer = 0;

        for (int I = 0; I <= BArr.GetUpperBound(0); I++) {
            //その添字のモンスターを倒す
            int DecVal = Math.Min(AArr[I], BArr[I]);
            AArr[I] -= DecVal;
            BArr[I] -= DecVal;
            Answer += DecVal;

            //その添字+1のモンスターを倒す
            if (I + 1 <= AArr.GetUpperBound(0)) {
                DecVal = Math.Min(AArr[I+1], BArr[I]);
                AArr[I+1] -= DecVal;
                BArr[I] -= DecVal;
                Answer += DecVal;
            }
        }
        Console.WriteLine(Answer);
    }
}


Measured memory_bytes: 34908
from collections import deque

def main():
    S = raw_input().split()
    D = deque([])
    for s in S:
        if s == '+':
            b = D.pop()
            a = D.pop()
            D.append(a+b)   
        elif s == '-':
            b = D.pop()
            a = D.pop()
            D.append(a-b)
        elif s == '*':
            b = D.pop()
            a = D.pop()
            D.append(a*b)
        else:
            D.append(int(s))
    print D.pop()
    return 0

main()

Measured memory_bytes: 6800
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FR(i,a,b) for(int i=a; i<b; ++i)
#define BR(i,a,b) for(int i=(b-1); i>=0; --i)
#define FA(i,a) for(auto i : a)
#define PB emplace_back
#define trace(x) cerr<<#x<<":"<<x<<'\n';
#define trace2(a,n) { cerr<<#a<<" = "; FR(_,0,n) cerr << a[_] << ' '; cerr <<'\n'; }


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

	string s,t;
	cin>>s>>t;
	int n = s.size();
	map<char,char> data;
	for(int i=0; i<n; ++i){
		data[s[i]] = t[i];
	}
	for(char x = 'a'; x <= 'z'; ++x){
		for(char y = 'a'; y <= 'z'; ++y){
			if( (data.count(x)) == 0 or (data.count(y) == 0) or (x == y) ){ continue; }
			if( data[x] == data[y] ){
				cout<<"No\n";
				return 0;
			}
		}
	}
	for(int i=0; i<n; ++i){
		s[i] = data[s[i]];
	}
	if( s == t ){ cout<<"Yes\n"; }
	else{ cout<<"No\n"; }


	#ifdef LOL
	    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	#endif
	return 0;
}


Measured memory_bytes: 916
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<set>

using namespace std;

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

#define f first
#define s second
int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0)break;
		pair<int,int> t[3333];
		
		rep(i,n){
			int a,b;
			cin>>a>>b;
			t[i].f=a;
			t[i].s=b;
		}
		
		sort(t,t+n);
		
		int ans=0;
		
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				int dx=t[j].f-t[i].f;
				int dy=t[j].s-t[i].s;
				int flg=1;
				int flg2=0;
				/*
				printf("%d %d\n",i,j);
				printf("%d,%d %d,%d %d,%d\n",t[i].f,t[i].s,t[j].f,t[j].s,dx,dy);*/
				if(binary_search(t,t+n,make_pair(t[j].f-dy,t[j].s+dx))==0){
					flg=0;
				}
				if(flg==1 && binary_search(t,t+n,make_pair(t[i].f-dy,t[i].s+dx))==0){
					flg=0;
				}
				/*
				if(binary_search(t,t+n,make_pair(t[j].f+dy,t[j].s-dx))==0){
					flg2=0;
				}
				if(flg2==1 && binary_search(t,t+n,make_pair(t[i].f+dy,t[i].s-dx))==0){
					flg2=0;
				}*/
				
				if(flg==1||flg2==1){
					ans=max(ans,dx*dx+dy*dy);
				}
			}
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 896
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//↑templete
#define int long long
signed main(){
	ll T1, T2;
	cin>>T1>>T2;
	ll A1, A2;
	cin>>A1>>A2;
	ll B1, B2;
	cin>>B1>>B2;

	//相対速度に
	ll a=min(A1, B1), b=min(A2, B2);
	A1-=a;
	B1-=a;
	A2-=b;
	B2-=b;

	//cout<<"A "<<A1<<" "<<A2<<endl;
	//cout<<"B "<<B1<<" "<<B2<<endl;

	if(T1*A1+T2*A2 == T1*B1+T2*B2){
		//cout<<T1*A1+T2*A2<<" "<<T1*B1+T2*B2<<endl;
		cout<<"infinity"<<endl;
		return 0;
	}
	if((A1 && A2) || (B1 && B2)){
		cout<<0<<endl;
		return 0;
	}
	if(B1){
		swap(A1, B1);
		swap(A2, B2);
	}

	//以降、必ずA1が速く、B2が速い
	ll round=A1*T1-B2*T2;	//1ターンに離れる距離

	if(round>0){
		cout<<0<<endl;
		return 0;
	}
	round*=-1;

	//以降、必ずA1*T1<B2*T2
	ll turn=((A1*T1+round-1)/round); //行われるラウンド数

	if(turn*round==A1*T1)
		cout<<turn*2<<endl;
	else
		cout<<turn*2-1<<endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
g = []
for i in range(n):
    a = list(map(int,input().split()))
    g.append(a[2:])
d = [0]*n
f = [0]*n
global t
t = 1
d[0] = 1
x = 1
def find(x):
    global t
    if len(g[x-1]) == 0:
        t += 1
        f[x-1] = t
    else:
        for i in g[x-1]:
            if d[i-1] == 0:
                t += 1
                d[i-1] = t
                find(i)
        t += 1
        f[x-1] = t

find(x)
for i in range(n):
    if d[i] == 0:
        t += 1
        d[i] = t
        find(i+1)
for i in range(n):
    print(i+1, d[i], f[i])



Measured memory_bytes: 5656
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d;
    int e,f,g,h;
    cin>>a>>b>>c>>d;
    cin>>e>>f>>g>>h;
    int s=a+b+c+d;
    int t=e+f+g+h;
    if(s>t)
        cout<<s<<endl;
    else
        cout<<t<<endl;
    }


Measured memory_bytes: 3032
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

n = int(input())
sum = 0

for i in range(1, n + 1):
    for j in range(1, n + 1):
        for k in range(1, n + 1):
            sum += gcd(i, j, k)

print(sum)


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

int main(){
  string S; cin >> S;
  string disp = {};
  
  for(char c:S){
  	  if(c == '0'){
        disp.push_back('0');
        
      }else if(c == '1'){
        disp.push_back('1');
        
      }else if(c == 'B'){
        if(disp.size() != 0){ 
        	disp.pop_back();
        }
      }
  }
  
  cout << disp << endl;
}




Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long ll;

const int maxn = 1e5 + 5;
vector<int>G[maxn];
bool ok = true;
int vis[maxn];
ll ans[5];

void dfs(int u,int fa,int k){
	if(vis[u] == -1) vis[u] = k;
	else if(vis[u] != k){
		ok = false;
		return;
	}
	else return;
	for(int i = 0;i < G[u].size();i++){
		int v = G[u][i];
		if(v != fa) dfs(v,u,k ^ 1);
	}
}

int main(){
	ll n,m;
	scanf("%lld %lld",&n,&m);
	memset(vis,-1,sizeof(vis));
	for(int i = 1;i <= m;i++){
		int u,v;
		scanf("%d %d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(1,0,1);
	for(int i = 1;i <= n;i++){
		if(vis[i]) ans[1]++;
		else ans[0]++;
	}
	if(ok) printf("%lld\n",ans[0] * ans[1] - m);
	else printf("%lld\n",n * (n - 1) / 2 - m);
}

Measured memory_bytes: 7296
fun main(args: Array<String>) {
    val (h, w, a, b) = readLine()!!.split(' ').map { it.toInt() }
    for (i in 0 until h) {
        val l = if (i < b) {
            "0".repeat(a) + "1".repeat(w - a)
        } else {
            "1".repeat(a) + "0".repeat(w - a)
        }
        println(l)
    }
}


Measured memory_bytes: 41736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    int p=inf,q=0;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        chmin(p,a[i]);
        chmax(q,a[i]);
    }
    if(q-p>1){
        cout << "No" << endl;
        return 0;
    }
    int x=0,y=0;
    for(int i=0;i<n;i++){
        if(a[i]==p){
            x++;
        }
        else{
            y++;
        }
    }
    if(p==q){
        if(p==n-1||p*2<=n){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    else{
        if(x<q&&2*(q-x)<=y){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
}

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

int main(){
	int N,M,X,Y;
	cin >> N >> M >> X >> Y;
	int roop,cinno,xm=X,ym=Y;;
	for(roop=0;roop<N;roop++){
		cin >> cinno;
		if(cinno>xm){
			xm=cinno;
		}
	}
	for(roop=0;roop<M;roop++){
		cin >> cinno;
		if(cinno<ym){
			ym=cinno;
		}
	}
	if(xm<ym){
		cout << "No War" << endl;
	}else{
		cout << "War" << endl;
	}
	return 0;
}


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

int main()
{
    int n;
    cin >> n;
    long long S[n];
    for (int i = 0; i < n; i++)
    {
        cin >> S[i];
    }
    int q;
    cin >> q;
    long long T[q];
    for (int i = 0; i < q; i++)
    {
        cin >> T[i];
    }
    sort(S, S + n);
    int count = 0;
    for (int i = 0; i < q; i++)
    {
        int lb = lower_bound(S, S + n, T[i]) - S;
        if (S[lb] == T[i])
        {
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 4252
S = list(input())
N = len(S)
#print('S',S)

dammy1=[0]*(N+1)
A=0
for i in range(1,N+1):
    if S[i-1]=='<':
        A+=1
        dammy1[i]=A
    elif S[i-1]=='>':
        A=0
        dammy1[i]=A

dammy2=[0]*(N+1)
B=0
for i in range(1,N+1):
    if S[-i]=='>':
        B+=1
        dammy2[-(i+1)]=B
    elif S[-i]=='<':
        B=0
        dammy2[-(i+1)]=B

#print('dammy1', dammy1)
#print('dammy2', dammy2)

out=[0]*(N+1)
for i in range(N+1):
    out[i] = max(dammy1[i], dammy2[i])

#print('out', out)
print(sum(out))

Measured memory_bytes: 93916
import bisect

N = int(input())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))

ans = 0
for i in B:
    ans += bisect.bisect_left(A,i)*(N - bisect.bisect_right(C,i))
print(ans)

Measured memory_bytes: 29548
#include <bits/stdc++.h>
using namespace std;
#define FASTIO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define vi vector<ll>
#define all(a) (a).begin(), (a).end()
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define tr(it, a)   for(auto it=a.begin();it!=a.end();it++)
#define pb push_back
#define endl  "\n"
const ll MAX=1e5+5;
const ll mod=1e9+7;
vi v(MAX);
void fun(ll n,ll k)
{
    ll dp[105][MAX];
    memset(dp,0,sizeof(dp));
    ll prefixsum[MAX];
    for(ll i=0;i<=n;i++)
    {
        dp[i][0]=1;
    }
    for(ll i=1;i<=n;i++)
    {
        prefixsum[0]=0;
        for(ll j=1;j<=k+1;j++)
        {
            prefixsum[j]=prefixsum[j-1]+dp[i-1][j-1];
        }
        for(ll j=1;j<=k;j++)
        {
            dp[i][j]=(prefixsum[j+1]-prefixsum[max((ll)0,j-v[i])]+mod)%mod;
        }
    }
    /*rep(i,0,n+1)
    {
        rep(j,0,k+1)
        {
            cout<<dp[i][j]<<"  ";

        }
        cout<<endl;
    }*/
    cout<<dp[n][k];
}
int main()
{
    ll t=1;
   // cin>>t;
    while(t--)
    {

   ll n,k;
   cin>>n>>k;
   rep(i,1,n+1)
   cin>>v[i];
   fun(n,k);
    }
    return 0;
}
/*
//another method using combinatroics but giving answer for some cases(may be large)
#include <bits/stdc++.h>
using namespace std;
#define FASTIO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define vi vector<ll>
#define all(a) (a).begin(), (a).end()
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define tr(it, a)   for(auto it=a.begin();it!=a.end();it++)
#define pb push_back
#define endl  "\n"
const ll MAX=1e6;
const ll mod=1e9+7;
bool comp(pair<ll,ll> a,pair<ll,ll> b)
{
    return a.second>b.second;
}
 
int arr[MAX];
ll fexp(ll a,ll b){
    ll ans=1;
 
    while(b){
        if(b&1){
            ans=((ans%mod)*(a%mod))%mod;
        }
        b>>=1;
        a=((a%mod)*(a%mod))%mod;
    }
 
    return ans%mod;
}
 
ll ncr(ll n,ll r){
 
    ll ans=((arr[n-r]%mod)*(arr[r]%mod))%mod;
    return(((arr[n]%mod)*(fexp(ans,mod-2)%mod))%mod);
}
int main()
{
   FASTIO
   int t=1;
   //cin>>t;
   ll p=1;
   arr[0]=1;
   for(int i=1;i<MAX;i++){
        p=((p%mod)*(i%mod))%mod;
        arr[i]=p;
   }
   while(t--)
    {
    ll n,k;cin>>n>>k;
    ll a[n+2];
    for(ll i=0;i<n;i++)
        cin>>a[i];
    ll ans=ncr(n+k-1,n-1);
    //cout<<ans<<" ";
    for(ll i=0;i<n;i++){
        ans-=ncr(n+k-1-a[i]-1,n-1);
    }
    cout<<ans<<"\n";
    }
 return 0;
}*/

Measured memory_bytes: 83840