akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif

signed main() {
    
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    
    if(a[0]+a[1]==a[2]) Yes;
    else No;

    
    return 0;
}


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

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		System.out.println(solve(n));
		in.close();
	}

	private static int solve(int n) {
		int r = 0;
		int l = 1;
		int h = 10;
		while (true) {
			if (n < l)
				return r;
			if (n < h)
				return r + n - l + 1;
			r += h - l;
			l *= 100;
			h *= 100;
		}
	}
}

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

using namespace std;
vector<int> sw[13];
bool temp[13];
bool p[13];
int n, m, x, t;
int ans;
void dp(int ct) {
	if (ct == n + 1) {

		for (int i = 1; i <= m; i++)
			if (temp[i] != p[i]) {
				return;
			}
		ans++;
		return;
	}
	for (int i = 1; i <= 2; i++) {
		dp(ct + 1);
		for (int j = 0; j < sw[ct].size(); j++)
			temp[sw[ct][j]] = !temp[sw[ct][j]];
	}
}
int main() {
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		cin >> t;
		for (int j = 1; j <= t; j++) {
			cin >> x;
			sw[x].push_back(i);
		}
	}

	for (int i = 1; i <= m; i++)
	{
		cin >> p[i];
	}
	dp(1);
	cout << ans;
	return 0;
}

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

#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORTASC(c) sort((c).begin(), (c).end())
#define SORTDESC(c, t) sort((c).begin(), (c).end(), std::greater<t>());
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

const double PI = acos(-1.0);

using ll = long long;
using namespace std;

int main()
{
    ll a, b, total = 0;

    cin >> a >> b;

    REP(i, 2){
        if (a >= b)
        {
            total += a;
            a--;
        }
        else
        {
            total += b;
            b--;
        }
    }
    
    cout << total << endl;

    return 0;
}

Measured memory_bytes: 256
/*Arnab's Code
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define vll vector<ll>
#define vii vector<int>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define take(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define takes(a,n,st) for(ll i=st;i<n+st;i++)cin>>a[i]
ll sum(ll a[],ll n,ll s){ for(ll i=0;i<n;i++)s+=a[i]; return s;}
#define mod 1000000009
ll power(ll x, ll y, ll p)  {  
    ll res = 1;  
    x = x % p;   
    if (x == 0) return 0;  
    while (y > 0){  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
ll a[100017];
void solve(){
	ll n,l,mini,i,x,minp;
	cin>>n>>l;
	take(a,n);
	mini=-1;
	for(i=1;i<n;i++){
		x=a[i]+a[i-1];
		if(x>=l and x>mini){
			mini=x;
			minp=i;
		}
	}
	if(mini == -1){
		cout<<"Impossible";
		return;
	}
	cout<<"Possible\n";
	for(i=1;i<minp;i++){
		cout<<i<<"\n";
	}
	for(i=n-1;i>=minp;i--)
		cout<<i<<"\n";
//	cout<<minp;
	return;
}
int main(){
//	ios::sync_with_stdio(false);
//	cin.tie(NULL);
//	#ifndef ONLINE_JUDGE
//		freopen("input.txt","r",stdin);
//		freopen("output.txt","w",stdout);
//	#endif
	ll t,T;
//	cin>>T;
	T=1;
	for(t=1;t<=T;t++){
//		cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 4420
#include<stdio.h>

int main(){
    int a,b;
    int pls,min,sub,max;

    scanf("%d %d",&a,&b);
    pls = a + b;
    min = a - b;
    sub = a * b;

    max = pls;
    if(max < min){
        max = min;
    }
    if(max < sub){
        max = sub;
    }

    printf("%d",max);
    return 0;

}

Measured memory_bytes: 128
import numpy
import heapq
import math

N,M = map(int, input().split())
A = list(map(int,input().split()))
A = [i*-1 for i in A]
A.sort()
heapq.heapify(A)

for i in range(M):
    a = heapq.heappop(A)
    a /= 2.0
    heapq.heappush(A,a)

amount = 0
for a in A:
    amount += math.floor(-a)
print(amount)

Measured memory_bytes: 23132
-- Question C

import Control.Applicative

main = do
  [n,m] <- map read . words <$> getLine
  putStrLn $ show ((check n m)  `mod` (10^9+7))
  
fact a = if a==0 then 1 else (a*fact (a-1))`mod` (10^9+7)
check n m 
  | abs (n-m) >1 = 0
  | n==m+1 = fact n * fact m
  | m==n+1 = fact n * fact m
  | otherwise = (fact n ^2) * 2



Measured memory_bytes: 7804
n = gets.to_i
a = gets.split.map(&:to_i).sort
cnt = 1
sum = a[0]
n.pred.times do |i|
  if sum * 2 >= a[i + 1]
    cnt += 1
    sum += a[i + 1]
  else
    cnt = 1
    sum = a[0..i + 1].inject(:+)
  end
end
puts cnt

Measured memory_bytes: 22292
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define put(i) cout<<fixed<<i<<endl
using namespace std;
using ll = long long;

int main(){
    int n; cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];

    put(accumulate(p.begin(),p.end(),0) - *max_element(p.begin(),p.end()) / 2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair
#define sz(x)       int(x.size())
#define int         int64_t

using namespace std;

typedef pair<int, int> pii;
const int N = 1e3 + 1;
const int M = 2e5 + 1;
const ll inf = (ll)1e18;

int p[11];

bool get(int x) {
    cout << "? " << x << '\n';
    char c; cin >> c;
    return c == 'Y';
}

void answer(int x) {cout << "! " << x << '\n'; exit(0);}

int getLeng() {
   int low = 1, mid, high = 10; bool ans;
   while(low <= high) {
       mid = (low + high) >> 1;
       ans = get(p[mid - 1]);
       if(ans) low = mid + 1;
       else high = mid - 1;
   }
   return high;
}

int L, low, high, mid, n;

void check() {
    if(!get(p[10])) return;
    int low = 1, high = 10, mid; bool ans;
    while(low <= high) {
        mid = (low + high) >> 1;
        if(get(2ll * p[mid - 1])) high = mid - 1;
        else low = mid + 1;
    }
    answer(p[high]);
}

int32_t main() {
//    ios_base::sync_with_stdio(0);
//    cin.tie(0), cout.tie(0);
//    #define Task        "test"
//    if(fopen(Task".inp", "r")) {
//        freopen(Task".inp", "r", stdin);
//        freopen(Task".out", "w", stdout);
//    }
    p[0] = 1;
    for(int i = 1; i <= 10; ++i) p[i] = 1ll * p[i - 1] * 10;
    check(); L = getLeng(); n = 0;
    for(int i = 1; i < L; ++i) {
        low = i == 1? 1: 0; high = 9;
        while(low <= high) {
            mid = low + high >> 1;
            if(get(n * 10 + mid)) low = mid + 1;
            else high = mid - 1;
        }
        n = n * 10 + high;
    }
    low = L == 1? 1: 0; high = 9;
    while(low <= high) {
        mid = low + high >> 1;
        if(get((ll)(1ll * n * 100 + mid * 10))) high = mid - 1;
        else low = mid + 1;
    }
    n = n * 10 + low;
    answer(n);
}


Measured memory_bytes: 596
#include<iostream>
#include<queue>
#include<algorithm>
#include<vector>
#include<functional>
using namespace std;
long long N, M, K, A, B, C, T;
class point {
public:
	long long time;
	long long num;
	point(long long a, long long b) :time(a), num(b) {

	}
};
bool operator<(const point a, const point b) {
	return min(a.time / A, a.num) < min(b.time / A, b.num);
}
bool operator>(const point a, const point b) {
	return min(a.time / A, a.num) > min(b.time / A, b.num);
}
int main() {
	cin >> N >> M >> K >> A >> B >> C >> T;
	vector<int> line(M + 1);
	for (int i = 0; i < M; ++i) {
		cin >> line[i];
	}
	line[M] = N + 1;
	int ans = -1;
	int pa;
	priority_queue<point, vector<point> > que;
	for (int i = 0; i < M; ++i) {
		if ((line[i] - 1)*B <= T) {
			++ans;
			pa = min((long long)line[i + 1] - line[i] - 1, (T - (line[i] - 1)*B) / A);
			ans += pa;
			long long dtime = T - (line[i] - 1)*B - (pa + 1)*C;
			long long dnum = line[i + 1] - line[i] - 2 - pa;
			if (dtime >= 0&&dnum>=0) {
				que.push(point(dtime, dnum));
			}
		}
		else {
			break;
		}
	}
	for (int i = 0; i < K - M; ++i) {
		if (que.empty()) {
			break;
		}
		point dp = que.top(); que.pop();
		int pa = min(dp.time / A, dp.num);
		++ans;
		ans += pa;
		dp.time -= (pa + 1)*C;
		dp.num -= pa + 1;
		if (dp.time >= 0 && dp.num >= 0) {
			que.push(dp);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3140
def main():
    S = input()
    ans = 0
    cnt = 0

    for i in range(len(S)):
        if S[i] in "ACGT":
            cnt += 1

        if S[i] not in "ACGT" and cnt > ans:
            ans = cnt
            cnt = 0

        if i == len(S) - 1 and cnt > ans:
            ans = cnt
            cnt = 0

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9028
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
#define fi first
#define se second
#define sc scanf
#define pr printf
#define pb push_back
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
using namespace std;
ll exp(ll a , ll b){
	if(b == 0)	return 1;
	int x = b % 2 == 0 ?   ((exp(a , b/2)%mod)*(exp(a , b / 2)%mod))%mod :  (a%mod*exp(a , b - 1) % mod)%mod;
	return x;
}
ll ans[10000];
int main(int argc,char ** argv){
	dhoom;
	int temp,x , y , a , b , c;
	cin >> x >> y >> a >> b >> c;
	vector< ll > aa , bb , cc;
	for(int i = 0 ; i < a ; i++)
	{	
		cin >> temp;
		aa.pb(temp);
	}
	for(int i = 0 ; i < b ; i++)
	{
		cin >> temp;
		bb.pb(temp);
	}
	for(int i = 0 ; i < c ; i++){
		cin >> temp;
		cc.pb(temp);
	}
	sort(aa.rbegin() , aa.rend());
	sort(bb.rbegin() , bb.rend());
	for(int i = 0 ; i < x ; i++)
		cc.pb(aa[i]);
	for(int i = 0 ; i < y ; i++)
		cc.pb(bb[i]);
	sort(cc.rbegin() , cc.rend());
	ll ans = 0;
	for(int i = 0 ; i < x + y ; i++)
		ans += cc[i];
	cout << ans << endl;
	return 0;
	
}


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

int main() {
	int a,b; cin>>a>>b;
	string s; cin>>s;

	for (int i=0; i<a; i++) {
		if (s[i] < '0' or s[i] > '9') {
			cout << "No" << endl;
			return 0;
		}
	}
	
	if (s[a] != '-') {
		cout << "No" << endl;
		return 0;
	}

	for (int i=a+1; i<a+b+1; i++) {
		if (s[i] < '0' or s[i] > '9') {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	return 0;
}

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

int main(){
    int i, n;
    string s;
    cin >> s;
    n = s.length();
    if(n%2 == 1){
        cout << "No\n";
      return 0;
    }else{
        for(i=0; i<n; i+=2){
            if(s[i] != 'h' || s[i+1] != 'i'){
                cout << "No\n";
                return 0;
            }
        }
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <math.h>
#include <queue>
#define ll long long
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define f first
#define s second
#define mp make_pair
#define forn(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    char c;
    vector<char> s(n),t(n);
    c=getchar();
    forn(i,n)
    {
        s[i]=getchar();
    }
    c=getchar();
    forn(i,n)
    {
        t[i]=getchar();
    }
    forn(i,n)
    {
        printf("%c%c",s[i],t[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n); for(ll i = 0; i < ll(n); i++)
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
int gcd(int a, int b){ //a>=0,b>=0,￢(a=b=0)
  while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);
}



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

  int ans=1e8;

  for(int i=-100;i<=100;i++){
    int cost=0;
    rep(j,n) cost += (a[j]-i)*(a[j]-i);
    if(ans>cost) ans = cost;
  }
  
  
  
  cout<< ans<<endl;
  return 0;
}


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

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<string> grid;
	vector<vector<pair<int, int>>> ptr(n, vector<pair<int, int>>(m));
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		grid.push_back(s);
	}
	for (int i = 0; i < n; i++) {
		int pre = m;
		for (int j = m - 1; j >= 0; j--) {
			if (grid[i][j] == '#') {
				pre = j;
			}
			ptr[i][j].first = pre;
		}
		pre = -1;
		for (int j = 0; j < m; j++) {
			if (grid[i][j] == '#') {
				pre = j;
			}
			ptr[i][j].first -= pre + 1;
		}
	}
	for (int j = 0; j < m; j++) {
		int pre = n;
		for (int i = n - 1; i >= 0; i--) {
			if (grid[i][j] == '#') {
				pre = i;
			}
			ptr[i][j].second = pre;
		}
		pre = -1;
		for (int i = 0; i < n; i++) {
			if (grid[i][j] == '#') {
				pre = i;
			}
			ptr[i][j].second -= pre + 1;
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			ans = max(ans, ptr[i][j].first + ptr[i][j].second - 1);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 35712
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, K, S; cin >> N >> K >> S; 
	if(N == K){
		for(int i = 0; i < N; i++){
			cout << S << " "; 
		}
		cout << endl; 
	}
	else if(S > N-K){
		for(int i = 0; i < N; i++){
			if(i % (N-K+1) == 0) cout << S - (N - K) << " "; 
			else cout << 1 << " "; 
		}
		cout << endl; 
	}
	else{
		for(int i = 0; i < K; i++) cout << S << " "; 
		for(int i = K; i < N; i++) cout << 1000000000 << " "; 
		cout << endl; 
	}
}

Measured memory_bytes: 1280
n = gets.to_i
list = []
n.times do |time|
    a = gets.to_i    
    list << a
end
max = list.max
sorted_list = list.sort
second_max = sorted_list[-2]
list.length.times do |n|
    if list[n] != max
        puts max
    else
        puts second_max
    end
end


Measured memory_bytes: 8224
#include <bits/stdc++.h>
using namespace std;
inline void read (int &x) {
	char ch = getchar(); x = 0;
	while (!isdigit(ch)) ch = getchar();
	while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
} const int N = 1e6 + 10;
int n, qwq; char ch[N]; int suma, sumb;
vector<pair<int, int> > va, vb;
signed main() {
	read (n);
	for (int i = 1; i <= n; ++i) {
		scanf ("%s", ch + 1);
		int s = 0, sa = 0, sb = 0, l = strlen (ch + 1);
		for (int j = 1; j <= l; ++j) {
			ch[j] == '(' ? ++s : --s;
			if (s < 0) sa -= s, suma -= s, s = 0;
		} sb += s, sumb += s;
		if (sa > sb) vb.push_back (make_pair (sb, sa));
		else va.push_back (make_pair (sa, sb)); 
	} if (suma != sumb) return puts ("No"), 0;
	sort (va.begin(), va.end()), sort (vb.begin(), vb.end());
	for (int i = 0; i < va.size(); ++i) {
		qwq -= va[i].first;
		if (qwq < 0) return puts ("No"), 0;
		qwq += va[i].second;
	} for (int i = vb.size() - 1; i >= 0; --i) {
		qwq -= vb[i].second;
		if (qwq < 0) return puts ("No"), 0;
		qwq += vb[i].first;
	} return puts ("Yes"), 0;
}

Measured memory_bytes: 11272
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, K;
  cin >> N >> K;
  vector<ll> P(N), C(N);
  for (ll i = 0; i < N; ++i) {
    ll p;
    cin >> p;
    P.at(i) = p - 1;
  }
  for (ll i = 0; i < N; ++i) {
    cin >> C.at(i);
  }
  vector<vector<ll>> biggest(N, vector<ll>(N));
  vector<ll> loop_cost(N);
  vector<ll> loop_len(N);
  for (ll i = 0; i < N; ++i) {
    ll now = i;
    ll point = 0;
    ll big = 0;
    for (ll j = 0; j < N; ++j) {
      now = P.at(now);
      biggest.at(i).at(j) = big;
      point += C.at(now);
      big = max(big, point);
      if (now == i) {
        loop_len.at(i) = j + 1;
        loop_cost.at(i) = point;
      }
    }
  }

  // for (ll i = 0; i < N; ++i) {
  //   cout << loop_len.at(i) << " ";
  // }
  // cout << "\n";
  bool all = true;
  for (ll i = 0; i < N; ++i) {
    if (C.at(i) >= 0) {
      all = false;
    }
  }
  ll ans = -INF;
  if (all) {
    for (ll i = 0; i < N; ++i) {
      ans = max(C.at(i), ans);
    }
    cout << ans << "\n";
    return 0;
  }
  for (ll i = 0; i < N; ++i) {
    ll temp = 0;
    temp = biggest.at(i).at(min(N - 1, K));
    if (loop_cost.at(i) > 0) {
      for (ll j = 0; j <= K / loop_len.at(i); ++j) {
        temp = max(temp, loop_cost.at(i) * (j) + biggest.at(i).at(min(K - j * loop_len.at(i), loop_len.at(i) - 1)));
      }
    }
    ans = max(ans, temp);
  }
  cout << ans << "\n";
}


Measured memory_bytes: 199080
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        int n = sc.nextInt();
        int t = sc.nextInt();
        double a = sc.nextDouble();
        double min = Double.MAX_VALUE;
        int index = 0;
        for (int i = 0; i < n; i++) {
            int h =sc.nextInt();
            double tmp = t - h * 0.006d;
            if (min > Math.abs(tmp - a)) {
                min = Math.abs(tmp - a);
                index = i + 1;
            }
        }
        System.out.println(index);
    }
}

Measured memory_bytes: 25696
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

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

int main() {
  int n, m; cin >> n >> m;
  vector<vector<int>> s(m);
  REP(i, m){
    int k; cin >> k;
    REP(j, k){
      int t; cin >> t;
      --t;
      s[i].push_back(t);
    }
  }
  
  vector<int> p(m);
  REP(i, m) cin >> p[i];

  int ans = 0;
  REP(b, 1 << n){
    bool f = true;
    REP(i, m){
      int cnt = 0;
      REP(j, s[i].size()){
        if((b >> s[i][j]) & 1) cnt++;
      }

      if(cnt % 2 != p[i]) f = false;
    }

    if(f) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import numpy as np
import copy
h, w, k = map(int, input().split())
m = []
for i in range(h):
  tmp_m = []
  s = input()
  for j in range(w):
    if s[j] == ".":
      tmp_m.append(0)
    else:
      tmp_m.append(1)
  m.append(tmp_m)

m = np.array(m)
n = h + w
cnt = 0
for i in range(2 ** n):
  l = []
  for j in range(n):
    if ((i >> j) & 1):
      l.append(j)
  curr_m = copy.deepcopy(m)
  for a in l:
    if a < w:
      if a != w:
        curr_m[:, a] = 0
    else:
      a -= w
      if a != h:
        curr_m[a, :] = 0
  if np.sum(curr_m) == k:
    cnt += 1

print(cnt)


Measured memory_bytes: 27140
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}
	
	private void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		while (n-- > 0) {
			double xa = scan.nextDouble();
			double ya = scan.nextDouble();
			double ra = scan.nextDouble();
			double xb = scan.nextDouble();
			double yb = scan.nextDouble();
			double rb = scan.nextDouble();
			
			double ab = Math.sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb));
			
			if (ab > ra + rb) {
				System.out.println(0);
			}else if (ra > ab + rb) {
				System.out.println(2);
			}else if (rb > ab + ra) {
				System.out.println(-2);
			}else {
				System.out.println(1);
			}
		}
	}
	
	private void debug() {
		System.out.println();
	}

}

Measured memory_bytes: 20472
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner s = new Scanner(System.in);
        int a;
        for(int i = 0; i < 5; i++){
            a = s.nextInt();
            if(a == 0){
                System.out.println(i + 1);
                return;
            }
        }
        
    }
}


Measured memory_bytes: 35692
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
alpha =0
kiso_score = sum(B)
for i in range(N-1):
    ind = A[i+1] - A[i]
    if ind ==1:
        alpha += C[A[i]-1]
print(kiso_score+alpha)

Measured memory_bytes: 3064
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include <array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
//AtCoderC++.cpp

using namespace std;

vector<string> split(string& content, char delim) {
	auto ss = vector<string>();
	string s = "";
	for (size_t i = 0; i < content.length(); i++) {
		if (content[i] == delim) {
			ss.push_back(s);
			s = "";
			continue;
		}
		s += content[i];
	}
	if (s != "")ss.push_back(s);
	return ss;
}

int main() {
	int input; int count5 = 0, count7 = 0;
	for (size_t i = 0; i < 3; i++) {
		cin >> input;
		if (input == 5)count5++;
		if (input == 7)count7++;
	}
	if (count5 == 2 && count7) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(X: int):
    for n in range(X//100-50,X//100+1):
        if n*105 >= X >= n*100:
            print(1)
            return
    print(0)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <string>
using namespace std;
string s,t,u;
int main(){
	int i,n;
	cin >> n >> s >> t;
	for(i=0;i<n;i++){
		u.push_back(s[i]);
		u.push_back(t[i]);
	}
	cout << u << endl;
}
	

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

public class Main {
	public static void main (String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] firstLine = br.readLine().split(" ", 4);
		int x = Integer.parseInt(firstLine[0]);
		int y = Integer.parseInt(firstLine[1]);
		int z = Integer.parseInt(firstLine[2]);
		int k = Integer.parseInt(firstLine[3]);
		long[] xs = new long[x];
		String[] secondLine = br.readLine().split(" ", x);
		for (int i = 0; i < x; i++) {
			xs[i] = Long.parseLong(secondLine[i]);
		}
		
		long[] ys = new long[y];
		String[] thirdLine = br.readLine().split(" ", y);
		for (int i = 0; i < y; i++) {
			ys[i] = Long.parseLong(thirdLine[i]);
		}
		long[] zs = new long[z];
		String[] fourthLine = br.readLine().split(" ", z);
		for (int i = 0; i < z; i++) {
			zs[i] = Long.parseLong(fourthLine[i]);
		}
		Arrays.sort(xs);
		Arrays.sort(ys);
		Arrays.sort(zs);
		ArrayList<Long> list = new ArrayList<>();
		for (int i = 0; i < Math.min(k + 1, x); i++) {
			for (int j = 0; j < y && (i + 1) * (j + 1) <= k; j++) {
				for (int l = 0; l < z && (i + 1) * (j + 1) * (l + 1) <= k; l++) {
					list.add(xs[x - 1 - i] + ys[y - 1 - j] + zs[z - 1 - l]);
				}
			}
		}
		Collections.sort(list);
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < k; i++) {
			sb.append(list.get(list.size() - 1 - i)).append("\n");
		}
		System.out.print(sb);
	}
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 要素の入力、格納
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		double v[] = new double[N];
		for (int i = 0; i < N; i++) {
			v[i] = sc.nextLong();
		}
		Arrays.sort(v);

		// パスカル三角形の準備
		long pascal[][] = Pascal(N);

		// A個の際の平均値の計算
		double suma = 0;
		for (int i = 0; i < A; i++) {
			suma = suma + v[N - 1 - i];
		}
		double avea = (double) suma / A;
		String ansave = String.format("%.6f", avea);

		// A個の場合の組み合わせ
		// A以上の中にAと同値がいくつあるか
		int samea = 1; // 自分自身
		for (int i = 0; i < A - 1; i++) {
			if (v[N - A] == v[N - A + 1 + i]) {
				samea += 1;
			} else {
				break;
			}
		}
		int bunboa = samea;
		// A以下の中にAと同値がいくつあるか
		for (int i = 0; i < N - A; i++) {
			if (v[N - A] == v[N - A - i - 1]) {
				samea += 1;
			} else {
				break;
			}
		}
		int bunshia = samea;
		long comba = pascal[bunshia][bunboa]; // bunshia C bunboa の計算

		// A個以上の場合
		int sameb = 0;
		long combb = 0;
		long sumcombb = 0;
		if (B > A) {
			// 最大値と同値がいくつあるか
			for (int i = 0; i < N; i++) {
				if (v[N - 1 - i] == v[N - 1]) {
					sameb += 1;
				}
			}
			// A+1〜Bについてそれぞれの組み合わせ数を累計
			for (int i = 0; i < B - A; i++) {
				combb = pascal[sameb][A + 1 + i];
				sumcombb += combb;
			}
		}

		long sumcombab = comba + sumcombb;
		// 出力
		System.out.println(ansave);
		System.out.println(sumcombab);
	}

	// パスカル三角形導出メソッド
	public static long[][] Pascal(int max) {
		long pascal[][] = new long[max + 1][max + 1];
		pascal[0][0] = 1;
		for (int i = 0; i < max + 1; i++) {
			for (int j = 0; j < i + 1; j++) {
				if (i == 0 && j == 0) {
					continue;
				} else if (j == 0) {
					pascal[i][j] = pascal[i - 1][j];
				} else if (j == i) {
					pascal[i][j] = pascal[i - 1][j - 1];
				} else {
					pascal[i][j] = pascal[i - 1][j - 1] + pascal[i - 1][j];
				}
			}
		}
		return pascal;
	}
}


Measured memory_bytes: 23764
CHARACTER(10) H
INTEGER ANS,CNT
READ*,H
CNT=0
ANS=0
DO I=1,10
 IF(H(I:I)=="A".OR.H(I:I)=="G".OR.H(I:I)=="C".OR.H(I:I)=="T")THEN
  CNT=CNT+1
 ELSE
  CNT=0
 ENDIF
 ANS=MAX(ANS,CNT)
END DO
PRINT"(I0)",ANS
END

Measured memory_bytes: 768
#include<cstdio>

int n;
int a[1000000], cnt[1000001];

int prime[1000];
bool is_prime[1001];

int sieve(int n) {
    int p = 0;
    for (int i = 0; i <= n; i++) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= n; i++) {
        if (is_prime[i]) {
            prime[p++] = i;
            for (int j = 2 * i; j <= n; j += i) is_prime[j] = false;
        }
    }
    return p;
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    
    int p = sieve(1000);
    for (int i = 0; i < p; i++) {
        for (int j = 0; j < n; j++) {
            int pi = prime[i];
            if (a[j] % pi == 0) cnt[pi]++;
            while (a[j] % pi == 0) a[j] /= pi;
        }
    }
    for (int i = 0; i < n; i++) {
        if (a[i] > 1000) cnt[a[i]]++;
    }
    int ans = 0;
    for (int i = 2; i <= 1000000; i++) {
        if (cnt[i] > 1) ans = 1;
        if (cnt[i] == n) {
            ans = 2;
            break;
        }
    }

    if (ans == 0) printf("pairwise coprime\n");
    if (ans == 1) printf("setwise coprime\n");
    if (ans == 2) printf("not coprime\n");
    return 0;
}



Measured memory_bytes: 9360
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
using namespace std;
//using namespace boost::multiprecision;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int n;
  cin>>n;
  int x[n];
  REP(i,n){
    cin>>x[i];
  }
  int L;
  cin>>L;
  int s[n][31];
  REP(i,n){
    int l = i, r = n;//[l,r)
    while(r - l > 1){
      int m = (l+r)/2;
      if(x[m] - x[i] <= L){
        l = m;
      }else{
        r = m;
      }
    }
    s[i][0] = l;
  }
  REP(k,31){
    REP(i,n){
      if(k == 0)continue;
      s[i][k] = s[s[i][k-1]][k-1];
    }
  }
  int q;
  cin>>q;
  int a[q],b[q];
  REP(i,q){
    cin>>a[i]>>b[i];
    a[i]--;b[i]--;
    if(a[i] > b[i]){
      swap(a[i], b[i]);
    }
  }
  int ans[q];
  REP(i,q){
    int l = 0, r = 1e9 + 10;//(l,r]
    while(r - l > 1){
      int d = (l+r)/2;
      int now = a[i];
      REP(k,31){
        if(d & (1<<k)){
          now = s[now][k];
        }
      }
      if(now >= b[i]){
        r = d;
      }else{
        l = d;
      }
    }
    ans[i] = l;
  }
  REP(i,q){
    cout<<ans[i] + 1<<endl;
  }
  return 0; 
}

Measured memory_bytes: 14464
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

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 int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

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

    int H, W, K;
    cin >> H >> W >> K;
    vector<string> S(H);
    rep(i,H)cin >> S[i];

    
    int ans = INF;
    for(int k = 0; k < bit(H-1);k++){
        int tmp = 0; //新たに入れた仕切りの数
        vector<int> div;
        div.push_back(0);
        for(int l = 0; l < H-1;l++){
            if(k & bit(l)){
                div.push_back(l+1);
                tmp++;
            }
        }
        div.push_back(H);
        auto mini = [&](vector<int>& v){
            int res = tmp;
            int m = v.size() - 1;
            int len = 0;
            vector<int> sum(m, 0);
            rep(j,W){
                vector<int> nxt(m, 0);
                int maxx = 0;
                rep(a, m){
                    int u = v[a];
                    int d = v[a+1];
                    nxt[a] += sum[a];
                    for(int i = u;i < d;i++){
                        nxt[a] += S[i][j] - '0';
                    }
                    chmax(maxx, nxt[a]);
                }
                if(maxx <= K){
                    len++;
                    swap(sum, nxt);
                }
                else{
                    if(len == 0)return INF;
                    j--;
                    sum.assign(m, 0);
                    res++;
                    len = 0;
                }
            }
            return res;
        };
        /*
        cerr << endl;
        print(div);
        int res = mini(div);
        dump(tmp);
        dump(res);
        */
        chmin(ans, mini(div));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0) return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1;  // 分母
  ll numerator = 1;    // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
 private:
  vector<ll> parents;

 public:
  UnionFind(ll n) : parents(n, -1) {}

  bool issame(ll x, ll y) { return root(x) == root(y); }

  bool merge(ll x, ll y) {
    if (issame(x, y)) return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry]) swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) { return -parents[root(x)]; }

 private:
  ll root(ll x) {
    if (parents[x] < 0) return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

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

  // AGC
  // ACG
  // GAC
  // A*GC
  // AG*C

  // 0: dummy
  // 1: A
  // 2: G
  // 3: C
  // 4: T
  ll dp[101][5][5][5] = {};

  // dp[n][i][j][k]
  // n文字目まで考える
  // k: 直前の文字
  // j: kのひとつ前の文字
  // i: jのひとつ前の文字
  dp[0][0][0][0] = 1;
  for (ll n = 0; n < N; n++) {
    for (ll i = 0; i < 5; i++) {
      for (ll j = 0; j < 5; j++) {
        for (ll k = 0; k < 5; k++) {
          // 文字列 ijk に l を加える
          for (ll l = 1; l < 5; l++) {
            // AGC
            if (j == 1 && k == 2 && l == 3) continue;
            // ACG
            if (j == 1 && k == 3 && l == 2) continue;
            // GAC
            if (j == 2 && k == 1 && l == 3) continue;
            // A*GC
            if (i == 1 && k == 2 && l == 3) continue;
            // AG*C
            if (i == 1 && j == 2 && l == 3) continue;

            dp[n + 1][j][k][l] += dp[n][i][j][k];
            dp[n][j][k][l] %= MOD;
          }
        }
      }
    }
  }

  ll ans = 0;
  for (ll i = 1; i < 5; i++) {
    for (ll j = 1; j < 5; j++) {
      for (ll k = 1; k < 5; k++) {
        ans += dp[N][i][j][k];
      }
    }
  }

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


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

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

    int ans = 1;
    int sum = a;
    if (b == 1) {
        cout << 0 << endl;
    }
    else {
        while(sum < b) {
            sum--;
            sum += a;
            ans++;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
inline ll mask(const ll &k) { return (1LL << k) - 1LL; }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
template <class T>
int lwb(V<T> &v, const T &x) { return lower_bound(all(v), x) - v.begin(); }
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
//////////////////////////////////////////////INSERT ABOVE HERE
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    V<int> a(n);
    read(a);
    for (int i = 0; i < min(200, k); i++) {
        V<int> b(n);
        for (int j = 0; j < n; j++) {
            b[max(0, j - a[j])]++;
            if (j + a[j] + 1 < n) b[j + a[j] + 1]--;
        }
        for (int j = 1; j < n; j++) {
            b[j] += b[j - 1];
        }
        swap(a, b);
        // print(a);
    }
    print(a);
}

Measured memory_bytes: 4784
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N, M;
    cin >> N >> M;

    vector<ll> C(N); // count
    fill(ALL(C), 1);

    vector<bool> Red(N);
    fill(ALL(Red), false);
    Red[0] = true;

    FOR(i, 0, M){
        ll x, y;
        cin >> x >> y;
        x--;
        y--;

        if(Red[x]){
            if(C[x]==1){
                Red[x] = false;
                Red[y] = true;
                C[x]--;
                C[y]++;
            }else{
                Red[y] = true;
                C[x]--;
                C[y]++;
            }
        }else{
            C[x]--;
            C[y]++;
        }
    }

    ll count = 0;
    for(bool isRed : Red){
        if(isRed){
            count++;
        }
    }
    p(count);

    
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>

using namespace std;
int main()
{/*二日目*/
	//abc167-a
	string s, t;cin >> s >> t;
	int len = s.length();
	bool same;
	for (int i = 0;i < len;i++) {
		if (t.length()-len==1 and s[i] == t[i] )
			same = true;
		else {
			same = false;
			break;
		}
	}if (same)
		cout << "Yes";
	else
		cout << "No";
	
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
#define nax 100000
long long maxF(int a , int b){
	return a>b ? a:b;
}

long long Min(int a,int b){
	return a>b? b:a;
}

long long Abs(int a){
	return a>0? a:-a;
}

int main(){
	long long n,h[nax],dp[nax];
	scanf("%d",&n);
	for(int i = 0 ; i < n ; i++){
		scanf("%ld",&h[i]);
	}
	dp[0] = 0;
	dp[1] = Abs(h[0]-h[1]);
	for(int i = 2; i < n ; i++){
		dp[i] = Min(dp[i-1]+Abs(h[i]-h[i-1]),
					dp[i-2]+Abs(h[i]-h[i-2]));
	}
	printf("%ld",dp[n-1]);

	return 0;
}

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

using namespace std;


int a[110];
int main(){
  int n;
  cin>>n;
  for(int i = 0;i<2*n;i++){
    cin>>a[i];
  }
  sort(a,a+2*n);
  int ans=0;
  for(int i=0;i<n*2;i+=2){
    ans+=a[i];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sun May 12 12:43:56 2019

@author: Yamazaki Kenichi
"""

R,G,B,N = map(int,input().split())
RGB = [R, G, B]

dp = [[0,0,0] for i in range(N+1)]
dp[0] = [1,0,0]
for i in range(1,N+1):
    if R <= i:
        dp[i][0] += dp[i-R][0]
    if G <= i:
        dp[i][1] += (dp[i-G][0] + dp[i-G][1])
    if B <= i:
        dp[i][2] += (dp[i-B][0] + dp[i-B][1] + dp[i-B][2])
print(sum(dp[N]))

Measured memory_bytes: 3444
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int H = sc.nextInt();
    int W = sc.nextInt();
    int[] A = new int[N];
    int[] B = new int[N];
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
      B[i] = sc.nextInt();
    }
    int count = 0;
    for (int i = 0; i < N; i++) {
      if (H <= A[i] && W <= B[i]) {
        count++;
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 26980
import java.util.Scanner;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		int x = Integer.parseInt(a+b);
		for(int i=0; i<1000; i++){
			if(i*i == x){
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
 
	}
}

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

int compar(const int *val1,const int *val2){
    return *val1-*val2;
}
int main(void){
    int map[4]={0},i,sign=0,sum=0;
    for(i=0;i<4;i++)
        scanf("%d",&map[i]);
    qsort(map,4,sizeof(int),(int(*)(const void *,const void *))compar);
    for(i=0;i<3;i++){
        if(map[i] != map[i+1]){
            sum++;
            sign=i;
        }
    }
    if((sign == 0 || sign == 1) && (sum == 0 || sum == 1))
        printf("yes\n");
    else
        printf("no\n");
    return 0;
}

Measured memory_bytes: 584
#include<stdio.h>

int main(){
  int i,j,n,q,key,c=0;
  int left=0,right=n,mid;
  scanf("%d",&n);
  int s[n];
  for(i=0;i<n;i++) scanf("%d",&s[i]);
  scanf("%d",&q);
  for(j=0;j<q;j++){
    int left=0,right=n,mid;
    scanf("%d",&key);
    
    while(left<right){
      mid=(left+right)/2;
      if(s[mid]==key){c++;break;}
      else if (key<s[mid])right=mid;
      else left=mid+1;
    }
  }
  printf("%d\n",c);
    return 0;
}



Measured memory_bytes: 2112
#include<stdio.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<ctime>
#include<complex>
#include<list>
using namespace std;

const int N=100005;
int n,side;
int fa[N];
long long ans;
pair<int,int> X[N],Y[N];
priority_queue<pair<int,pair<int,int> > > pq;

inline int Find(int x){
	if(fa[x]==x) return x;
	else return fa[x]=Find(fa[x]);
}

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		X[i]=make_pair(x,i);
		Y[i]=make_pair(y,i);
	}
	for(int i=0;i<n;i++) fa[i]=i;
	sort(X,X+n);
	sort(Y,Y+n);
	for(int i=0;i<n-1;i++) pq.push(make_pair(X[i].first-X[i+1].first,make_pair(X[i].second,X[i+1].second)));
	for(int i=0;i<n-1;i++) pq.push(make_pair(Y[i].first-Y[i+1].first,make_pair(Y[i].second,Y[i+1].second)));
	while(side<n-1){
		pair<int,pair<int,int> > p=pq.top();
		pq.pop();
		int x=p.second.first;
		int y=p.second.second;
		int dis=-p.first;
		x=Find(x);
		y=Find(y);
		if(x!=y){
			fa[x]=y;
			side++;
			ans+=dis;
		}
	}
	printf("%I64d\n",ans);
	return 0;
}

Measured memory_bytes: 6900
#include <iostream>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
int main() {
    int N,A;
    cin >> N >> A;
	cout << (N*N-A) << endl;
	return 0;
}

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

struct Node{
	long id, left, right; 
	long parent, sibling, degree, depth, height;
};

void setDepth(struct Node T[], long id, long depth){
	T[id].depth = depth;
	if (T[id].left != -1) setDepth(T, T[id].left, depth + 1);
	if (T[id].right != -1) setDepth(T, T[id].right, depth + 1); 
}

void setHeight(struct Node T[], long id, long height){
	if (T[id].height < height) T[id].height = height;
	if (T[id].parent != -1) setHeight(T, T[id].parent, height + 1);
}

void print(struct Node T[], long id){
	cout << "node " << T[id].id << ": ";
	cout << "parent = " << T[id].parent << ", ";
	cout << "sibling = " << T[id].sibling << ", ";
	cout << "degree = " << T[id].degree << ", ";
	cout << "depth = " << T[id].depth << ", ";
	cout << "height = " << T[id].height << ", ";
	if (T[id].parent == -1) cout << "root";
	else if (T[id].degree == 0) cout << "leaf";
	else cout << "internal node";
	cout << endl;
}

int main(){
	long n;
	cin >> n;
	struct Node T[25];
	for (long i = 0; i < n; i++){
		T[i].id = T[i].left = T[i].right = -1;
		T[i].parent = T[i].sibling = T[i].depth = T[i].height = -1;
	}
	for (long i = 0; i < n; i++){
		long id, left, right;
		cin >> id >> left >> right;
		T[id].id = T[left].parent = T[right].parent = id;
		T[id].left = T[right].sibling = left;
		T[id].right = T[left].sibling = right;
		long degree = 0;
		if (left != -1) degree++;
		if (right != -1) degree++;
		T[id].degree = degree;
	}
	long rootid = -1;
	for (long i = 0; i < n; i++){
		if (T[i].parent == -1){
			rootid = i;
			break;
		}
	}
	setDepth(T, rootid, 0);
	for (long i = 0; i < n; i++){
		if (T[i].degree == 0) setHeight(T, i, 0);
	}
	for (long i = 0; i < n; i++){
		print(T, i);
	}
	return 0;
}

Measured memory_bytes: 1160