akhauriyash/Code-Regression huggingface dataset:
N, X = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
result = 0

for i in range(N):
    X -= A[i]
    if X <= 0:
        if X == 0:
            result = i+1
        else:
            result = i
        break

if X > 0:
    result = N-1

print(result)


Measured memory_bytes: 38512
#pragma GCC optimize("Ofast")
#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 ln '\n'
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	int A,B; cin >> A >> B;
	cout << (A-1)*(B-1) << ln;
}


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

using namespace std;

int main(void) {
    int64_t N;
    cin >> N;
    vector<int64_t> a(N);
    for(int i=0; i<N; i++) {
        cin >> a[i];
    }

    int64_t ans = 0;
    sort(a.rbegin(), a.rend());
    while(a[0] >= N) {
        int64_t cnt = a[0] / N;
        ans += cnt;
        a[0] -= cnt*N;
        for(int i=1; i<N; i++) {
            a[i] += cnt;
        }
        sort(a.rbegin(), a.rend());
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

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

    int l,r,d; cin >> l >> r >> d;
    int res=0;
    range(i,l,r+1){
        if(i%d==0) res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3636
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
  n = int(input())

  if n < 100:
    print(min(9, n))
  elif n < 10000:
    print(min(909, n - 99 + 9))
  else:
    print(min(90909, n - 9999 + 909))


if __name__ == '__main__':
  main()


Measured memory_bytes: 38256
import sys
input = sys.stdin.readline

N = int(input())
T, A = map(int, input().split())

H = list(map(int, input().split()))

Th = [T-H[i]*0.006 for i in range(N)]
Td = [abs(Th[i]-A) for i in range(N)]
print(Td.index(min(Td))+1)


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

#define st first
#define nd second

typedef pair <int, pair <int, int> > III;

const int N = (int) 2e5 + 5;
const int LOGN = log2(N) + 2;
const int INF = (int) 1e9;

int n;
int logn;
int idx[N];
int a[N];
int b[N][LOGN], c[N][LOGN];

int get(int i, int j, int x[][LOGN]) {
	int k = log2(j - i + 1);
	return min(x[i][k], x[j - (1 << k) + 1][k]);
}

void build_rmq() {
	for (int k = 1; k <= logn; k++)
		for (int i = 1; (i + (1 << k) - 1) <= n; i++) {
			b[i][k] = min(b[i][k - 1], b[i + (1 << (k - 1))][k - 1]);
			c[i][k] = min(c[i][k - 1], c[i + (1 << (k - 1))][k - 1]);
		}
}

int main() {
	
	ios_base :: sync_with_stdio(false); cin.tie(NULL);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (i & 1) {
			b[i][0] = a[i];
			c[i][0] = INF;
		} else {
			b[i][0] = INF;
			c[i][0] = a[i];
		}
		idx[a[i]] = i;
	}
	logn = log2(n);
	build_rmq();
	
	vector <pair <int, int> > ans;
	priority_queue <III, vector <III>, greater <III> > q;
	q.push({get(1, n, b), {1, n}});
	while (true) {
		if (ans.size() == n / 2) break;
		III data = q.top(); q.pop();
		if (data.nd.st & 1) {
			int vf = get(data.nd.st, data.nd.nd, b);
			int vs = get(idx[vf] + 1, data.nd.nd, c);
			ans.push_back({vf, vs});
			int l[] = {data.nd.st, idx[vf] + 1, idx[vs] + 1};
			int r[] = {idx[vf] - 1, idx[vs] - 1, data.nd.nd};
			for (int x = 0; x < 3; x++) {
				if (l[x] >= r[x]) continue;
				if (l[x] & 1) q.push({get(l[x], r[x], b), {l[x], r[x]}});
				else q.push({get(l[x], r[x], c), {l[x], r[x]}});
			}
		} else {
			int vf = get(data.nd.st, data.nd.nd, c);
			int vs = get(idx[vf] + 1, data.nd.nd, b);
			ans.push_back({vf, vs});
			int l[] = {data.nd.st, idx[vf] + 1, idx[vs] + 1};
			int r[] = {idx[vf] - 1, idx[vs] - 1, data.nd.nd};
			for (int x = 0; x < 3; x++) {
				if (l[x] >= r[x]) continue;
				if (l[x] & 1) q.push({get(l[x], r[x], b), {l[x], r[x]}});
				else q.push({get(l[x], r[x], c), {l[x], r[x]}});
			}
		}
	}
	for (auto v: ans) cout << v.st << " " << v.nd << " ";
	return 0;
}

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

using namespace std;
typedef long long ll;

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

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    rep(i, h) cin >> a[i];

    vector<int> ck_w(w, 1), ck_h(h, 1);

    rep(i, w)
    {
        bool ck = true;
        rep(j, h)
        {

            if (a[j][i] == '#')
            {
                ck = false;
            }
        }
        if (ck)
        {
            ck_w[i] = 0;
        }
    }

    rep(i, h)
    {
        bool ck = true;
        rep(j, w)
        {

            if (a[i][j] == '#')
            {
                ck = false;
            }
        }
        if (ck)
        {
            ck_h[i] = 0;
        }
    }

    rep(i, h)
    {
        rep(j, w)
        {
            if (ck_h[i] && ck_w[j])
            {
                cout << a[i][j];
            }
        }
        if (ck_h[i])
        {
            cout << '\n';
        }
    }
    // cout << '\n';
    return 0;
}


Measured memory_bytes: 3608
import bisect

n,m,k = map(int,input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

a_li = [0]*(n+1)
b_li = [0]*(m+1)

for i in range(n):
    a_li[i+1] = a_li[i]+a[i]
    
for i in range(m):
    b_li[i+1] = b_li[i]+b[i]

ans = 0
#print(b_li)
#print(a_li)
for i in range(n+1):
    #print(i)
    tmp_k = k - a_li[i]
    if tmp_k < 0:
        break
    idx = bisect.bisect_right(b_li, tmp_k)
    #print(tmp_k,idx,idx,idx)
    #print(b_li[idx])
    #if idx <= 1:
    #    continue
    ans = max(ans,i+idx-1)
    #print(ans)
    #print(k,idx,b_li[idx-1])
    
print(ans)

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    ll n,k;
    cin>>n>>k;
    vl a(n);
    REP(i,n){
        cin>>a[i];
        a[i]--;
    }
    //DEBUG_VEC(a);

    vl route;

    ll now=0;

    ll loopidx = 0;
    route.emplace_back(0);
    map<int,int> mp;
    mp[0] = 1;
    ll cnt=0;
    do{
        if(mp[a[now]] >= 1){
            auto ret = find(ALL(route),a[now]);
            if(ret != route.end()){
                loopidx = ret-route.begin();
                break;
            }
        }
        
        cnt++;
        route.emplace_back(a[now]);
        mp[a[now]] += 1;
        now = a[now];
        //DEBUG(now);
    }while(cnt!=k);
    
    //route.pop_back();
    //DEBUG_VEC(route);

    k = k-loopidx;
    ll loopsz = route.size() - loopidx;
    //DEBUG2(loopidx,loopsz);
    ll ans = route[loopidx + (k % loopsz)];
    ans += 1;

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

Measured memory_bytes: 13580
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());
        var A = new int[N];
        for (int i = 0; i < N; i++)
            A[i] = int.Parse(ReadLine());

        var colors = new List<int>();

        for (int i = 0; i < N; i++)
        {
            var index = colors.UpperBound(A[i], true);

            if(colors.Count - 1 < index)
                colors.Add(A[i]);
            else
                colors[index] = A[i];
        }

        WriteLine(colors.Count);
    }
}

static class BinarySearchExtensions
{
    public static int LowerBound<T>(this List<T> list, T item, bool isDescending = false) where T : IComparable<T> => 
        ~list.BinarySearch(item, new LowerAndUpperBoundCompare<T>(true, isDescending));
    public static int UpperBound<T>(this List<T> list, T item, bool isDescending = false) where T : IComparable<T> => 
        ~list.BinarySearch(item, new LowerAndUpperBoundCompare<T>(false, isDescending));

    public static int LowerBound<T>(this T[] array, T item, bool isDescending = false) where T : IComparable<T> => 
        ~Array.BinarySearch(array, item, new LowerAndUpperBoundCompare<T>(true, isDescending));
    public static int UpperBound<T>(this T[] array, T item, bool isDescending = false) where T : IComparable<T> => 
        ~Array.BinarySearch(array, item, new LowerAndUpperBoundCompare<T>(false, isDescending));

    private class LowerAndUpperBoundCompare<T> : IComparer<T> where T : IComparable<T>
    {
        public LowerAndUpperBoundCompare(bool isLowerBound, bool isDescending) => 
            (this.isLowerBound, this.isDescending) = (isLowerBound, isDescending);

        private readonly bool isLowerBound, isDescending;

        public int Compare(T x, T y) => Predicate(x, y) ? 1 : -1;

        private bool Predicate(T x, T y)
        {
            var compareResult = x.CompareTo(y);
            return (isDescending ? (compareResult < 0) : (compareResult > 0)) || (isLowerBound && (compareResult == 0));
        }
    }
}


Measured memory_bytes: 35892
#include<bits/stdc++.h>
#define ll long long
#define inc(a) sort(a.begin(), a.end())
#define dec(a) sort(a.rbegin(), a.rend())
#define loop(n) for(ll i = 0; i<n; i++)
using namespace std;

int main(){
    ll n, k, count = 0, x; cin>>n>>k;
    loop(n){
        cin>>x;
        (x>=k)?(count++):(1);
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 256
import sys
from random import *
from collections import *
from heapq import *

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]
dij = [(1, 0), (-1, 0), (0, 1), (0, -1)]

# 内部で1-indexedに変えるので入力は0-indexedでよい
# i項目までの和（i含む）
class BitSum:
    def __init__(self, n):
        self.n = n+1
        self.table = [0]*self.n

    def add(self, i, x):
        i += 1
        while i < self.n:
            self.table[i] += x
            i += i & -i

    # [0,i]の和
    def sum(self, i):
        i += 1
        res = 0
        while i > 0:
            res += self.table[i]
            i -= i & -i
        return res

    # [l,r)の和
    def sumlr(self, l, r):
        if l == r: return 0
        if l == 0: return self.sum(r-1)
        return self.sum(r-1)-self.sum(l-1)

    # 数列を度数分布とみたときに、x番目がどのインデックスにあるかを返す
    # xが大きすぎるときは配列の長さnを返す
    def rank(self, x):
        idx = 0
        for lv in range((self.n-1).bit_length()-1, -1, -1):
            mid = idx+(1 << lv)
            if mid >= self.n: continue
            if self.table[mid] < x:
                x -= self.table[mid]
                idx += 1 << lv
        return idx

n,q=MI()
aa=LI()
bit=BitSum(n)
for i,a in enumerate(aa):bit.add(i,a)
for _ in range(q):
    t,a,b=MI()
    if t:print(bit.sumlr(a,b))
    else:bit.add(a,b)


Measured memory_bytes: 65740
s = int(input())
a_prev = s
a_old = {s:1}
for i in range(2,1000001):
    if a_prev % 2:
        a = int(3 * a_prev + 1)
    else:
        a = int(a_prev / 2)
    if a in a_old:
        print(int(i))
        break
    else:
        a_old[a] = 1
        a_prev = a

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
#include  <cstdio>
#include  <sstream>
#include  <bitset>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using ld = long double;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vd = vector<double>;
using Vld = vector<long double>;
using Vll = vector<vector<ll> >;
using Vldd = vector<vector<ld> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Pli = pair<ll, int>;
using VPi = vector<Pi>;
using VPl = vector<Pl>;
using VPli = vector<Pli>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

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

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };

int main()
{
	int n;
	cin >> n;
	
	//Vl ans(n + 1, 0);
	ll ans = 0;
	for (int i = 1; i <= n - 1; i++) {
		ll tmp = 0;
		bool f = false;
		for (int j = 1; j * j <= i; j++) {
			if (i % j == 0) tmp++;
			if (j * j == i) f = true;
		}
		if (f) {
			ans += tmp * 2 - 1;
		}
		else {
			ans += tmp * 2;
		}
	}

	cout << ans << endl;
}


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

#define  ll         long long
#define  llu        unsigned long long
#define  mod        1000000007
#define  pi         ((2.0)*acos(0.0))
#define  pb         push_back
#define  pf         push_front
#define  eb         emplace_back
#define  mp         make_pair
#define  all(x)     (x).begin(),(x).end()
#define  X          first
#define  Y          second

/*loop*/
#define  fr(i,m,n)   for(ll i=m;i<n;++i)

/*output shortcuts*/
#define  nl         "\n"
#define  Yes        cout<<"Yes\n"
#define  yes        cout<<"yes\n"
#define  YES        cout<<"YES\n"
#define  No         cout<<"No\n"
#define  no         cout<<"no\n"
#define  NO         cout<<"NO\n"

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

    ll n;
    cin>>n;
    ll a[n][3];

    fr(i,0,n)
        fr(j,0,3)
            cin>>a[i][j];

    //ll r=1;
    ll dp[n][3]={-1};

    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];

    fr(r,1,n)
    {
    for(ll i=0;i<3 && r<n; i++)  // cur_row
    {
        for(ll j=0;j<3;j++) // pre_row
        {
            if(j==i)
                continue;
            dp[r][i]=max(dp[r][i], dp[r-1][j]+a[r][i] );
        }
    }
    }

    /*cout<<nl<<nl;
    fr(i,0,n)
        {
            fr(j,0,3)
            {cout<<dp[i][j]<<" ";}
            cout<<nl;
        }
    */
    cout<< max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));

return 0;
}



Measured memory_bytes: 8164
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt(),a=sc.nextInt();
		int[] x=new int[n];
		long sum = 0;
		for(int i=0;i<n;i++){
			x[i] = sc.nextInt();
		}
		for(int i=0;i<n-1;i++){
			if(x[i]+x[i+1]>a){
				int t=x[i]+x[i+1]-a;
				sum+=t;
				if(x[i+1]>=t)
					x[i+1]-=t;
				else{
					x[i+1]=0;
				}
			}
		}
		System.out.print(sum);
	}
}


Measured memory_bytes: 49952
<?php
fscanf(STDIN, "%d %d %d", $a, $b, $c);

$sum = $a + $b + $c;

if ($a == $b && $a == $c) {
    echo "No";
    exit;
} else {
    if (
    ($a == $b && $a != $c) ||
    ($b == $c && $b != $a) ||
    ($c == $a && $c != $b)
    ) {
        echo "Yes";
        exit;
    }
}

echo "No";




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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    ll sum = 0;
    rep(i, m) cin >> a[i];
    rep(i, m) sum += a[i];
    if (sum > n)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << n - sum << endl;
    }
    return 0;
}

Measured memory_bytes: 3664
/* ex4_3
  bonbonc */

#include<stdio.h>
int solve(int diff,int west_height);/*プロトタイプ宣言*/

int main(void){
	int west_height,east_height,diff,total_height;
	scanf("%d%d",&west_height,&east_height);
	diff = east_height-west_height;/*西の塔と東の塔の高さの差*/

	printf("%d",solve(diff,west_height));

	return 0;
}

int solve(int diff,int west_height){
	int real_west_height;/*西の塔の地面からの高さ*/
	real_west_height = diff*(diff-1)/2;/*西の塔はdiff-1番目の塔なのでこの式で地面からの高さが求まる。*/

	return real_west_height-west_height;/*地面からの高さと雪の上に出ている部分の高さの差を返す。*/
}

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

using namespace std;
using ll = long long;

const ll nax = 1e5 + 12;
const ll md = 1e9 + 7;
ll n, k;
ll ans = 1;

vector<ll>v[nax];

void dfs (ll s, ll p = -1)
{
  ll cnt = k - 1;
  if (p != -1) {
    cnt--;
  }
  for (auto w : v[s]) {
    if (w != p) {
      if (cnt <= 0) {
        ans = 0;
        return;
      }
      ans = ans * cnt % md;
      cnt--;
      dfs (w, s);
    }
  }
}

int main()
{
  ios_base::sync_with_stdio (0);
  cin.tie (0);
  cin >> n >> k;
  for (ll i = 0; i < n - 1; i++) {
    ll a, b;
    cin >> a >> b;
    v[a].push_back (b);
    v[b].push_back (a);
  }
  ans = k;
  dfs (1);
  cout << ans << '\n';
  return 0;

}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;

# define MAX_N 100010 // 10^5 + 10

// UnionFindTree
// 使い方(インスタンス名 : tree)
// インスタンス生成 : UnionFind tree;
// tree.init(要素数)
// uniteしたりsameかどうか判定したり

class UnionFind{
    private:
        int par_[MAX_N];
        int rank_[MAX_N];
        int size[MAX_N];
        int groups_;
    
    public:
        void init(int n){ // initializes the tree 
            for(int i=0; i<n; i++){
                par_[i] = i;
                rank_[i] = 0;
                size[i] = 1;
            }
            groups_ = n;
        } 
        int rootOf(int x){ // returns the root of x 
            if(par_[x] == x){
                return x;
            }
            else{
                return par_[x] = rootOf(par_[x]);
            }
        } 
        void unite(int x, int y){ // unites x and y 
            x = rootOf(x);
            y = rootOf(y);
            if(x == y) return;
            if(rank_[x] < rank_[y]){
                par_[x] = y;
                groups_--;
                size[y] += size[x];
            }
            else{
                par_[y] = x;
                groups_--;
                size[x] += size[y];
                if(rank_[x] == rank_[y]) rank_[x]++;
            }
        }
        bool isSameGroupe(int x, int y){ // whether x and y are united
            return rootOf(x) == rootOf(y);
        }
        int countGroups(){ // returns the number of groups
            return groups_;
        }
        // 6 / 19 Updated!! (連結成分のサイズを返す)
        int sizeOf(int x){
            return size[rootOf(x)];
        }
};

int main(void){
    ll n, k;
    cin >> n >> k;
    vector<ll> p(n);
    vector<ll> c(n);
    UnionFind tree;
    tree.init(n);
    for(int i = 0; i < n; i++){
        cin >> p[i];
        p[i]--;
        tree.unite(i, p[i]);
    }
    for(int i = 0; i < n; i++){
        cin >> c[i];
    }

    // scr[i][j] := i から出発して j回 移動した時のスコア
    ll scr[5050][5050];
    memset(scr, 0, sizeof(scr));

    for(int i = 0; i < n; i++){
        ll now = i;
        for(int j = 0; j <= n; j++){
            if(j-1 >= 0){
                now = p[now];
                scr[i][j] = scr[i][j-1] + c[now];
            }
            else{
                scr[i][j] = 0;
            }
        }
    }

    // ループを調べる
    vector<ll> lp(n); // lp[i] := i が含まれるループのスコアの総和
    for(int i = 0; i < n; i++){
        lp[i] += c[i];
        for(int j = 0; j < n; j++){
            if(i != j && tree.isSameGroupe(i, j)){
                lp[i] += c[j];
            }
        }
    }

    ll ans = ll(-10e11);
    for(int i = 0; i < n; i++){
        ll len = tree.sizeOf(i); // i が含まれるループの長さ

        for(int r = 0; r < len; r++){
            if(r > k) continue;
            ll q = (k - r) / len;
            if(r == 0 && q == 0) continue;
            if(lp[i] > 0) ans = max(ans, lp[i] * q + scr[i][r]);
            else if(r > 0) ans = max(ans, scr[i][r]);
        }
        
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 203060
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back
#define inf 1000000000000000000
#define N 1000000007
#define mp make_pair
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}
template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}

//try thinking from a different angle after spending some time
//edge cases when n=1,m=1.wrong variable in loop.if<->while;merge resize;LLONG_MAX
signed main()
{
    speed
    //global var
    int n;cin>>n;
    std::vector<int> inp(n);
    set<int> st;
    map<int,int> mp;
    for (int i = 0; i < n; ++i)
    {
        cin>>inp[i];
        ++mp[inp[i]];
        st.insert(inp[i]);
    }
    for(auto it:st){
        for(int i=2*it;i<=1500000;i+=it)
        {
            if(mp.find(i)!=mp.end()){++mp[i];}
        }
    }
    int ans=0;
    for(auto it:mp){
        if(it.second==1){++ans;}
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 26652
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;
const ll MAXN = 1e5+10 ; 
ll n , W ; 
vector<ll> w; 
vector<ll> v; 
ll dp[110][MAXN] ; 

ll dfs(int x,int currWeight){
	if ( x == 0 || currWeight == 0 ) return 0 ; 
	if ( w[x-1] > currWeight )
		return dfs(x-1,currWeight) ; 
	if ( dp[x-1][currWeight] ) return dp[x-1][currWeight] ; 
	ll first = dfs(x-1,currWeight) ; 
	ll second = v[x-1] + dfs(x-1,currWeight-w[x-1]) ; 
	ll val = max(first,second) ; 
	dp[x-1][currWeight] = val ; 
	return val ; 
}


int main(){
	cin >> n >> W ; 
	w.resize(n) ; 
	v.resize(n) ; 
	for(ll i=0;i<n;i++){
		cin >> w[i] >> v[i] ; 
	}
	cout << dfs(n,W) << endl;
    return 0 ;
}


Measured memory_bytes: 79744
import sys
import collections
import itertools
import math
import re
from collections import deque

# MOD = 10 ** 9 + 7

N = int(input())
T = [int(x) for x in input().split()]
M = int(input())
s = sum(T)
for i in range(M):
    p, x = [int(x) for x in input().split()]
    print(s - T[p-1] + x)


Measured memory_bytes: 3564
N = int(input())
L = list(map(int,input().split()))
M = []
for i in range(N):
  if i+1 > L[i]:
    M.append((L[i],i+1))
  else:
    M.append((i+1,L[i]))
M = list(set(M))
print(len(L)-len(M))

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

int main(void){
    string w;
    cin >> w;
    
    int ab[26] = {0};
    int i;
    for(i = 0; i < w.length(); i++){
        ab[w[i] - 'a']++;
    }
    
    for(i = 0; i < 26; i++){
        if(ab[i] % 2 == 1){
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n,m;
    cin >> n >> m;
    if(n==m)puts("Yes");
    else puts("No");

    // cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

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

#define all(x) (x).begin(),(x).end()
#define loop(i,n) for(int i=0;i<(n);i++)
#define cont(i,n) for(int i=1;i<=(n);i++)
#define circ(i,a,b) for(int i=(a);i<=(b);i++)
#define range(i,a,b,c) for(int i=(a);((c)>0?i<=(b):i>=(b));i+=(c))
#define foreach(it,v) for(__typeof((v).begin()) it=(v).begin(),_e_D_=(v).end();it!=_e_D_;it++)
#define y0 y0O0OO00OO0OO0OO0OOO00OO0OO0O0O000OO0
#define y1 y1II11II11III11I1III11II111IIII1II1I1
#define pub push_back
#define pob pop_back
#define mak make_pair

typedef long long ll;
typedef long double lf;
const int Inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3fll;
/* Source code starts here */

const int jt=924844033,rg=5;

int n;
vector<int> nei[1<<19];
int f[1<<19],g[1<<19],sz[1<<19];
int jc[1<<19],fjc[1<<19];
int hoddie[1<<19];

int ksmii(int a,int b){
	if(!b)return 1;
	int x=ksmii(a,b>>1);
	x=1ll*x*x%jt;
	if(b&1)x=1ll*x*a%jt;
	return x;
}

void fft(int a[],int inv){
	loop(i,1<<19)hoddie[i]=((hoddie[i>>1]>>1)|((i&1)<<18));
	loop(i,1<<19)if(i<hoddie[i])swap(a[i],a[hoddie[i]]);
	range(i,1,(1<<19)-1,i){
		int omega=ksmii(rg,(jt-1)+inv*(jt-1)/(i<<1));
		range(j,0,(1<<19)-1,i<<1){
			int omg=1;
			loop(k,i){
				int x=a[j+k],y=1ll*omg*a[j+k+i]%jt;
				a[j+k]=(x+y)%jt;
				a[j+k+i]=(x-y+jt)%jt;
				omg=1ll*omg*omega%jt;
			}
		}
	}
	if(inv==-1){
		int rn=ksmii(1<<19,jt-2);
		loop(i,1<<19)a[i]=1ll*a[i]*rn%jt;
	}
}

void dfs(int now,int lst){
	sz[now]=1;
	foreach(i,nei[now]){
		if(*i==lst)continue;
		dfs(*i,now);sz[now]+=sz[*i];
		f[sz[*i]]++;
	}
	f[n-sz[now]]++;
}

int main(){
	scanf("%d",&n);
	cont(i,n-1){
		int a,b;scanf("%d%d",&a,&b);
		nei[a].pub(b);nei[b].pub(a);
	}
	jc[0]=1;cont(i,n)jc[i]=1ll*jc[i-1]*i%jt;
	fjc[n]=ksmii(jc[n],jt-2);range(i,n,1,-1)fjc[i-1]=1ll*fjc[i]*i%jt;
	dfs(1,0);cont(i,n)f[i]=1ll*f[i]*jc[i]%jt,g[i]=fjc[n-i];
	fft(f,1);fft(g,1);loop(i,1<<19)f[i]=1ll*f[i]*g[i]%jt;fft(f,-1);
	cont(i,n){
		int ans=1ll*n*jc[n]%jt*fjc[i]%jt*fjc[n-i]%jt;
		ans=(ans+jt-1ll*f[n+i]*fjc[i]%jt)%jt;
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 44016
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rp(i,n) for (int i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define all_acc(x) (x).begin(), (x).end(), 0LL
#define int long long
#define absSort(v) sort(a.begin(), a.end(), [](int i, int j) -> bool { return abs(i) < abs(j); });
using namespace std;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
using ll = long long;
double pi=3.14159265359;

//出力するよ
void output_tate(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        //if (i != 0)
        //    cout << " ";
        cout << s[i]<<endl;
    }
    //cout << endl;
}

void output_yoko(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        if (i != 0)
            cout << " ";
        cout << s[i];//<<endl;
    }
    cout << endl;
}

int MOD = pow(10, 9) + 7;

int kaijou(int n){
    if(n==0) return 1;
    else{
        return ((n%MOD)*(kaijou(n-1)%MOD))%MOD;
    }
}

bool ispow(int n){
    int rn=sqrt(n);
    if(rn*rn==n) return true;
    else return false;
}

int n,pos;
vector<int> preorder(n),inorder(n);
vector<int> post;

void rec(int l,int r){
    if(l>=r) return;
    int root =preorder[pos++];
    int m=distance(inorder.begin(),find(all(inorder),root));
    rec(l,m);
    rec(m+1,r);
    post.push_back(root);
}

void solve(){
    pos=0;
    rec(0,preorder.size());
    output_yoko(post);
}

signed main() {
    cin>>n;
    preorder.assign(n,0);
    inorder.assign(n,0);
    
    rp(i,n) cin>>preorder[i];
    rp(i,n) cin>>inorder[i];

    solve();


}



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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

namespace IO {
    #define gc getchar()
    template <typename T>
    inline void read(T& x) {
        x = 0; bool f = 1; char ch;
        for (ch = gc; ch < '0' || '9' < ch; ch = gc) if (ch == '-') f ^= 1;
        for (; '0' <= ch && ch <= '9'; ch = gc) x = (x << 3) + (x << 1) + (ch ^ 48);
        x = f ? x : -x;
    }
    #undef gc
}

typedef long long ll;

const int MAXN = 2e5 + 10;

int n, d;
struct Node { ll x, y; double dis; bool operator <(const Node& _) { return dis < _.dis; } } p[MAXN];
double arr[MAXN];

int main() {
    IO::read(n), IO::read(d);
    rep(i, 1, n) IO::read(p[i].x), IO::read(p[i].y), p[i].dis = sqrt(p[i].x * p[i].x + p[i].y * p[i].y);
    sort(p + 1, p + n + 1);
    int cnt = 0;
    // Node tmp = {0, 0, 1.* d};
    rep(i, 1, n) {
        if (p[i].dis > d) { break; }
        cnt++;
    } 
    printf("%d\n", cnt);
    // printf("%d\n", upper_bound(p + 1, p + n + 1, tmp) - p - 1);
    return 0;
}

Measured memory_bytes: 8316
use std::io::Read;
use std::str::FromStr;

fn f(s:&str) -> i64{
    let l = s.len();
    if l == 0 {
        return 0;
    }
    let ret:i64 = (1..l)
        .map(|x| i64::from_str(&s[..x]).unwrap() * (1<<(l-1-x)) + f(&s[x..]))
        .sum();
    ret + i64::from_str(&s).unwrap()
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let s:&str = iter.next().unwrap();
    
    println!("{}",f(s));
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, m;
namespace Disjoint_Set
{
	int fa[N], Size[N];
	inline int query(int x)
	{
		if (x == fa[x]) return fa[x];
		return fa[x] = query(fa[x]);
	}
	inline void merge(int x, int y)
	{
		x = query(x); y = query(y);
		if (x == y) return;
		fa[x] = y; Size[y] += Size[x];
	}
}
using namespace Disjoint_Set;
int main(){
	scanf ("%d%d", &n, &m);
	for (int i = 1; i <= n; i++)
	{
		fa[i] = i;
		Size[i] = 1;
	}
	
	for (int i = 1, x, y; i <= m; i++)
	{
		scanf ("%d%d", &x, &y);
		merge(x, y);
	}
	
	int ans = 0;
	for (int i = 1; i <= n; i++) ans = max(ans, Size[query(i)]);
	printf ("%d\n", ans);
  return 0;
}

Measured memory_bytes: 11436
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define ri rd<int>
using namespace std;
typedef long long LL;
const int maxN = 507;

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}

int H, W, h, w, S;
int a[maxN][maxN];
LL sum = 0;

int main() {

	H = ri(), W = ri(), h = ri(), w = ri();
	rep (i, 1, H) rep (j, 1, W) a[i][j] = 1000;
	S = (h * w - 1) * 1000;
	for (int i = h; i <= H; i += h)
	for (int j = w; j <= W; j += w) a[i][j] = - S - 1;
	rep (i, 1, H) rep (j, 1, W) sum += a[i][j];
	
	if (sum <= 0) puts("No");
	else {
		puts("Yes");
		rep (i, 1, H) rep (j, 1, W) printf("%d%c", a[i][j], " \n"[j == W]);
	}

	return 0;
}

Measured memory_bytes: 2432
#include<stdio.h>
int main()
{
	char s[27],t[27]={};

	scanf("%s",s);

	for(int i=0;i<strlen(s);i++){
		t[s[i]-'a']++;
		if(t[s[i]-'a']==2){
			puts("no");
			return 0;
		}
	}
	puts("yes");
	return 0;
}

Measured memory_bytes: 128
s = input()
t = input()

table = [[0 for j in range(len(t) + 1)] for i in range(len(s) + 1)]

for i, si in enumerate(s):
    table_pre = table[i]
    table_cur = table[i + 1]
    for j, tj in enumerate(t):
        if si == tj:
            table_cur[j + 1] = table_pre[j] + 1
        else:
            table_cur[j + 1] = max(table_cur[j], table_pre[j + 1])

ls, lt = len(s), len(t)
ans = ''
while ls and lt:
    if table[ls][lt] == table[ls][lt - 1]:
        lt -= 1
    elif table[ls][lt] == table[ls - 1][lt]:
        ls -= 1
    else:
        ans = s[ls - 1] + ans
        ls -= 1
        lt -= 1
print(ans)


Measured memory_bytes: 119772
N, K = map(int, input().split())
T_list = list(map(int, input().split()))
T_list = [T_list[i]-1 for i in range(N)]
point = 0
syuuki = 0

if K < N:
  i = 0
  while i < K:
    point = T_list[point]
    i += 1  

else:
  i = 0
  while i < N:
    point = T_list[point]
    if point == 0:
      syuuki = i+1
      break
    i += 1
  second_point = point
  
  if syuuki != 0:
    L = K % syuuki

  else:
    j = 0
    while j < N:
      point = T_list[point]
      if point == second_point:
        syuuki = j+1
        break
      j += 1
    L = (K-i) % syuuki

  k = 0
  while k < L:
    point = T_list[point]
    k += 1
  
print(point+1)

Measured memory_bytes: 32248
N = int(input())

n10 = 1
n8 = 1
n9 = 1
for _ in [0]*N:
    n10 = n10*10 %(10**9+7)
    n8 = n8*8 %(10**9+7)
    n9 = n9*9 %(10**9+7)

ans = (n10+n8-2*n9)%(10**9+7)
print(ans)

Measured memory_bytes: 71092
N = int(input())
lis = []
xor = 0

for i in range(N):

    a = int(input())
    xor ^= a

    now = 0

    while a % (2 ** now) == 0:
        now += 1

    lis.append(now-1)

lis.sort()
lis.reverse()
#print (a,lis)

ans = 0

for i in lis:

    if xor == 0:
        break

    if xor >= (2 ** i) and xor ^ (2 ** (i+1) - 1) != xor:
        xor = xor ^ (2 ** (i+1) - 1)
        ans += 1



if xor == 0:
    print (ans)

else:
    print (-1)


Measured memory_bytes: 4328
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<queue>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include <cctype>
#include <climits>
using namespace std;
#define REP(i,a,n) for(int i = a ; i < n ; i++)
#define rep(i,n) REP(i,0,n)

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

#define INF P(INT_MAX,INT_MAX)

int dx[] = {0,1,0,-1};
int dy[] = {-1,0,1,0};

int h,w;
char t[502][502];
char t2[502][502];

P getPlace(int x,int y,int dir){
  for(;0<=x && x<w && 0<=y && y<h;x+=dx[dir],y+=dy[dir]){
    if(isalpha(t[y][x])){
      return P(x,y);
    }
  }
  return INF;
}

bool attack(int x,int y){
  if(t[y][x] != '.'){
    return false;
  }

  vector<P> v;
  P tmp = getPlace(x,y,0);
  if(tmp != INF) v.push_back(tmp);
  tmp = getPlace(x,y,1);
  if(tmp != INF) v.push_back(tmp);
  tmp = getPlace(x,y,2);
  if(tmp != INF) v.push_back(tmp);
  tmp = getPlace(x,y,3);
  if(tmp != INF) v.push_back(tmp);

  rep(i,v.size()){
    REP(j,i+1,v.size()){
      int x1 = v[i].first;
      int y1 = v[i].second;
      int x2 = v[j].first;
      int y2 = v[j].second;

      if(t[y1][x1] == t[y2][x2]){
        t[y1][x1] = t[y2][x2] = '.';
        return true;
      }
    }
  }

  return false;
}

void solve(){
  int res = 0;

  while(1){
    bool tmp = false;
    rep(i,h){
      rep(j,w){
        bool flg = attack(j,i);
        if(flg){
          res += 2;
          tmp = true;
          break;
        }
      }
      if(tmp) break;
    }

    if(!tmp){
      cout<<res<<endl;
      return;
    }
  }
}

int main(){
  while(scanf("%d%d",&h,&w) != EOF){
    string del;
    rep(i,w)del+=".";
    bool f = false;
    int count = 0;
    rep(i,h){
      string s;
      cin>>s;
      if(del == s){
        if(f){
          count++;
          continue;
        }
        f = true;
      }else{
        f = false;
      }
      rep(j,w){
        t2[i-count][j] = s[j];
      }
    }
    f = false;
    h -= count;
    del = "";
    count=0;
    rep(i,h){
      del+=".";
    }
    rep(i,w){
      string s;
      rep(j,h){
        s += t2[j][i];
      }
      if(s == del){
        if(f){
          count++;
          continue;
        }
        f = true;
      }
      else{
        f = false;
      }
      rep(j,h){
        t[j][i-count] = s[j];
      }
    }

    w -= count;

    /*
    rep(i,h){
      rep(j,w){
        cout<<t[i][j]<<" ";
      }
      cout<<endl;
    }
    */

    solve();
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;(int) (n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
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; }
using namespace std;
int main(){
  double l;
  cin >> l;
  double ans;
  ans=l*l*l/27.0;
  printf("%.12f\n",ans);
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
string s;
int main() {
	cin >> s;
	bool ok = false;
	for (int i = 0; i < s.size(); i++) {
		for (int j = i + 1; j < s.size(); j++) {
			if (s[i] == 'C' && s[j] == 'F') ok = true;
		}
	}
	cout << (ok ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 764
import java.util.*;
public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int d = sc.nextInt();
	int t = sc.nextInt();
	int s = sc.nextInt();

	if(s*t>=d) System.out.println("Yes");
	else System.out.println("No");
    }
}

Measured memory_bytes: 35640
#include <stdio.h>
#include <stdlib.h>
typedef struct data{
	int u,v,w;
}data;
int djs[10001];
int cmp(void const *a,void const *b){
	return ((data*)a)->w > ((data*)b)->w;
}
int find(int x){
	if(djs[x]==-1)return x;
	else{
		djs[x]=find(djs[x]);
		return djs[x];
	}
}
int Union(int x,int y){
	djs[x]=y;
}
int main(){
	int i,n,u,v,w,sum,m,C,k; 
	data E[100001];
	scanf("%d%d",&n,&m);

	for(i=0;i<=n;i++){
		djs[i]=-1;
	}
	i=0;
	for(i=0;i<m;i++){
		scanf("%d%d%d",&u,&v,&w);
		E[i].u=u;
		E[i].v=v;
		E[i].w=w;
	}
	qsort(E,m,sizeof(data),cmp);
	
	int selected = 0;
	i=0;
	sum=0;
	while(selected<n-1){
		if(find(E[i].u)!=find(E[i].v)){
			selected++;
			sum+=E[i].w;
			Union(find(E[i].u),find(E[i].v));
		}
		i++;
		//printf("xxxx");
	}
	printf("%d\n",sum);
	return 0;
}

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

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

    for (const char & c: A ){
        if(c == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

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

int main(){
    int a;cin>>a;
    int b;cin>>b;
    int c;cin>>c;
    int x;cin>>x;
    int count=0;
    for(int i=0;500*i<=x&&i<=a;i++){
        for(int j=0;500*i+100*j<=x&&j<=b;j++){
            for(int k=0;500*i+100*j+50*k<=x&&k<=c;k++){
                if(500*i+100*j+50*k==x){
                    count++;
                }
            }
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod


#include <bits/stdc++.h>
using namespace std;
int ten(int i){
    int C = 1;
    while(i>0){
        C *= 10;
        i --;
    }
    return C;
}
signed main(){
    int N; cin>>N;
  Out(N*N);
}

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  ll A,B,C,X;
  cin>>A>>B>>C>>X;
  ll res=0;
  FOR(i,0,A+1){
    FOR(j,0,B+1){
      FOR(k,0,C+1){
        if(i*500+j*100+k*50==X) res++;
      }
    }
  }
  cout<<res<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n,k,m,i;
	while(scanf("%d",&n),n!=0){
		m=0;
		for(i=0;i<9;i++){
			scanf("%d",&k);
			m+=k;
		}
		printf("%d\n",n-m);
	}
	return 0;
}


Measured memory_bytes: 2068
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
signed main(){
  int a;
  cin>>a;
  vector<int> b(a);
  rep(i,a)
    cin>>b.at(i);
  sort(all(b));
  cout<<b.at(a-1)-b.at(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
  int n,p,d1,d2,mp,mc;
  while(1){
    cin>>n;
    if(n==0)break;
    mc=0;
    mp=0;
    for(int i=0;i<n;i++){
      cin>>p>>d1>>d2;
      if(d1+d2>mc){
	mc=d1+d2;
	mp=p;
      }
    }
    cout<<mp<<" "<<mc<<endl;
  }
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<set>
#include<cstring>
#include<algorithm>
#include<cmath>
#define max_n
using namespace std;
typedef long long ll;

int main ()
{
	ll t1,t2,t3;
	scanf("%lld %lld %lld",&t1,&t2,&t3);
	if(t1==t2&&t1==t3)
	{
		if(t1%2==1)
			cout<<"0"<<endl;
		else
			cout<<"-1"<<endl;
	}
	else
	{
		int ans=0;
		while(1)
		{
			if(t1%2||t2%2||t3%2)
			{
				cout<<ans<<endl;
				break;
			}
			ll tt1,tt2,tt3;
			tt1=t1; tt2=t2; tt3=t3;
			t1=(tt2+tt3)/2; t2=(tt1+tt3)/2; t3=(tt1+tt2)/2;
			ans++;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i < n; ++i)
using namespace std;
const int INF = 2147483647;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,m;
    cin >> n >> m;
    if (n==1&&m==1){
        cout << 1 << endl;
    }
    else if(n==1||m==1){
        if(m==1) swap(n,m);
        cout << m-2 << endl;
    }
    else
    cout << n*m-2*(m+n)+4 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 60
#define browse for (int i = 0; i < MAX; ++i) for (int j = 0; j < MAX; ++j) for (int ii = 0; ii < MAX; ++ii) for (int jj = 0; jj < MAX; ++jj)

using namespace std;

int n, cnt[MAX][MAX], a, b;
long long y, ans;
long double x;


int main() {
    cin >> n;

    while (n--) {
        cin >> x;

        y = (long long)(x * 1e9 + 0.5);
        a = 0;
        b = 0;

        while (y % 2 == 0) {
            y /= 2;
            ++a;
        }

        while (y % 5 == 0) {
            y /= 5;
            ++b;
        }

        ++cnt[a][b];
    }

    browse
        if (make_pair(i, j) <= make_pair(ii, jj) && i + ii >= 18 && j + jj >= 18) {
            if (i == ii && j == jj)
                ans += (long long) cnt[i][j] * (cnt[i][j] - 1) / 2;
            else
                ans += (long long) cnt[i][j] * cnt[ii][jj];
        }

    cout << ans;
    return 0;
}

Measured memory_bytes: 3728