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

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

i64 k, n;

i64 sum(i64 x) {
    return ((x + 1) * x / 2);
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin);
#endif

	cin >> n >> k;
	vi64 p(n);
	forn(i, n) cin >> p[i];
	double now = 0;
	for (int i = 0; i < k; ++i) {
        now += 1.0 * sum(p[i]) / p[i];
	}
	double ans = now;
	for (int i = k; i < n; ++i) {
        now += 1.0 * sum(p[i]) / p[i];
        now -= 1.0 * sum(p[i - k]) / p[i - k];
        ans = max(ans, now);
	}
	cout << ans << '\n';

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define pb push_back
#define pu push
#define mp make_pair
#define fi first
#define sc second

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

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


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

    int x; cin >> x;
    int i = 1;
    while (i * (i + 1) / 2 < x) i++;
    cout << i;
}

Measured memory_bytes: 256
from itertools import combinations
import math
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n = int(readline())
m = map(float,read().split())
points = [[x, y] for x, y in zip(m, m)]


def center(a, b, c):
    M = pow(a[0], 2) - pow(b[0], 2) + pow(a[1], 2) - pow(b[1], 2)
    N = pow(a[0], 2) - pow(c[0], 2) + pow(a[1], 2) - pow(c[1], 2)
    Yab = a[1] - b[1]
    Xab = a[0] - b[0]
    Yac = a[1] - c[1]
    Xac = a[0] - c[0]
    d1 = Yac * Xab - Yab * Xac
    d2 = Xac * Yab - Xab * Yac
    if d1 == 0 or d2 == 0:
        return None
    x = (M * Yac - N * Yab) / (2 * d1)
    y = (M * Xac - N * Xab) / (2 * d2)
    return (x, y)


centers = []
for a, b, c in combinations(points, 3):
    cen = center(a, b, c)
    if cen is None:
      continue
    centers.append(cen)

for a, b in combinations(points, 2):
    cen = ((a[0]+b[0])/2,(a[1]+b[1])/2)
    centers.append(cen)

res = 1000
for cx, cy in centers:
    r = 0
    for x, y in points:
        tr = math.hypot(x - cx, y - cy)
        if tr > r:
            r = tr
    if r < res:
        res = r
print(res)


Measured memory_bytes: 5492
/*
 * short          2^15-1 ~ 3e4
 * int, long x86  2^31-1 ~ 2e9
 * long long      2^63-1 ~ 9e18
 */
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define fr(a, b) for (int a = 0; a < b; ++a)
using namespace std; typedef long long ll; const int inf = numeric_limits<int>::max(); void print() {cerr << endl;}
template<typename T, typename... Ts> void print(T&&a, Ts&&...etc) {cerr << a << ' '; print(etc...);}
template<typename T, typename U> ostream& operator<<(ostream& s, const pair<T,U>&p) {s << "<" << p.x << ", " << p.y << ">"; return s;}
template<typename T> ostream& operator<<(ostream& s, const vector<T>&v) {s << "["; for (auto &x : v) s << x << ", "; if (!v.empty()) s << "\b\b"; s << "]"; return s;}
struct io{io(){ios_base::Init i; ios_base::sync_with_stdio(0); cin.tie(0);}}io;

int main() {
    ll n, m;
    ll sum = 0;
    cin >> n  >> m;
    vector<ll> a(n);
    fr(i, n) {
        cin >> a[i];
        sum += a[i];
    }
    sort(a.rbegin(), a.rend());
    if (a[m-1] * 4ll * m >= sum) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;}
}


Measured memory_bytes: 256
from itertools import accumulate

N, K = map(int, input().split())
P = list(map(int, input().split()))

cumsum = [0] + list(accumulate(P))
# print(cumsum)

res = []
for i in range(N-K+1):
    res.append(cumsum[i+K] - cumsum[i])

print((max(res)+K)/2)


Measured memory_bytes: 77704
// g++ -std=c++14
#include<bits/stdc++.h>

typedef long long ll;
typedef long double lld;
using namespace std;

#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define endl "\n"
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(c) c.begin(),c.end()
#define LET(x, a)  __typeof(a) x(a)
#define foreach(it, v) for(LET(it, v.begin()); it != v.end(); it++)

#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename S, typename T>
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.fi<<", "<<p.se<<')';return out;}

template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
ll l=v.size();for(ll i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

int main(){
  _
  ll n, k;
  cin >> n >> k;
  if(n == 0){
  	cout << "0\n";
  	return 0;
  }
  ll a = n%k;
  ll b = (k - a)%k;
  // tr(a); tr(b);
  cout << min(a, b) << "\n";
  return 0;
}


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

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

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int main()
{
    int n; cin >> n;
    int a[n];
    int l = 0,sum = 0;
    rep(i,n){
        cin >> a[i];
        sum += a[i];
        l = max(l,a[i]);
    }
    if(l < sum - l){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
int n,a,b;
cin>>n>>a>>b;
int ans = 0 ;
for( int i = 1 ; i <= n ; i++)
{
int c = 0 , t = i ;
while(t!=0)
{c += t % 10 ; t /= 10;}
if(  a<=c && c<=b ) ans += i ;
}
cout<<ans;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main () {

string s;
cin >> s;
if (s.at(0) == s.at(1) || s.at(1)==s.at(2) || s.at(2)==s.at(3) ) {
  cout <<"Bad"<<endl;
}
else {
  cout <<"Good"<<endl;
}

}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scanf("%d %d", &a, &b)
	p := int(float64(b) / 0.1)
	ans := -1
	for i := 0; i < 10; i++ {
		if int(float64(p+i)*0.08) == a {
			ans = p + i
			break
		}
	}
	fmt.Printf("%d", ans)
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
using namespace std;
long long INF = 1000000000000000;
int main(){
	int N, K;
	cin >> N >> K;
	vector<int> H(N);
	for (int i = 0; i < N; i++){
		cin >> H[i];
	}
	if (N == K){
		cout << 0 << endl;
	} else {
		vector<vector<long long>> dp(N - K, vector<long long>(N, INF));
		for (int i = 0; i < N; i++){
			for (int j = N - K - 2; j >= 0; j--){
				for (int k = 0; k < i; k++){
					dp[j + 1][i] = min(dp[j + 1][i], dp[j][k] + abs(H[i] - H[k]));
				}
			}
			dp[0][i] = H[i];
		}
		long long ans = INF;
		for (int i = 0; i < N; i++){
			ans = min(ans, (dp[N - K - 1][i] + H[i]) / 2);
		}
		cout << ans << endl;
	}
}

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

long long N;
map<long long, long long> memo;

int main(){
	cin >> N;
	long long ans = 0;
	for(long long i = 0; i < N; i++) {
		long long a;
		cin >> a;
		memo[a]++;
		ans += a;
	}

	long long Q;
	cin >> Q;
	for(long long i = 0; i < Q; i++) {
		long long b, c;
		cin >> b >> c;
		ans -= memo[b] * b;
		ans += memo[b] * c;
		memo[c] += memo[b];
		memo[b] = 0;
		cout << ans << endl;
	}
}


Measured memory_bytes: 9508
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  int n,m,x;cin>>n>>m>>x;
  vector<int>a(m);
  rep(i,m)cin>>a[i];
  int l=0,r=0;
  rep(i,m){
    if(a[i]<x)l++;
    else r++;
  }
  int ans=min(l,r);
  cout<<ans<<endl;
}

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

ko = 0

for i in range(N):
  if A[i] + A[i+1] > B[i]:
    ko += B[i]
    if A[i] < B[i]:
      A[i+1] -= (B[i] - A[i])
  else:
    ko += A[i] + A[i+1]
    A[i+1] = 0
    
print(ko)

Measured memory_bytes: 82020
#include<bits/stdc++.h>
# define rep(i,n)for(i=0; i<n; i++)
using namespace std;
int main()
{
    string s1,s2,s3;
    cin>>s1>>s2;
    s3 = s2.substr(0,s2.size());
     s3 = s2.substr(0,s1.size());
    if(s1==s3){cout<<"Yes"<<endl;return 0;}
    else {cout<<"No"<<endl;return 0;}
}


Measured memory_bytes: 3588
#include <stdio.h>

int main(void){
  long long a[1000009],k;
  scanf("%lld",&k);
  a[1]=7%k;
  for(int i=1;i<=k;i++){
    a[i+1]=(10*a[i]+7)%k;
  }
  for(int i=1;i<=k;i++){
  if(a[i]==0){
    printf("%d\n",i);
    return 0;
  }
  }
  printf("-1");


  return 0;
}

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

int main(){
    int N, M, P;
    int X[102];
    int sumX;

    while(true){
        cin >> N >> M >> P;
        if(N==0 && M==0 && P==0) break;
        sumX = 0;
        for(int n=0;n<N;n++){
            cin >> X[n];
            sumX += X[n];
        }
        if(X[M-1] == 0){
            cout << 0 << "\n";
        }
        else{
            cout << sumX*(100-P) / X[M-1] << "\n";
        }
    }
    return 0;
}


Measured memory_bytes: 3052
N=int(input())
A = list(map(int, input().split()))
def nidewareru(x):
  ans=0
  while (1):
    if x%2==0:
      x/=2
      ans+=1
    else:
      break
  return ans
    
mina=10000000
for a in A:
  mina=min(mina, nidewareru(a))
print(mina)  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define min(...) minn(__VA_ARGS__)
#define max(...) maxx(__VA_ARGS__)
#define stringio() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
char _;
typedef long long ll;
typedef pair<int,int> pii;
#define getchar_unlocked getchar
template<typename t>constexpr const t minn(const t x,const t y){return x<y?x:y;}
template<typename t,typename ...r>constexpr const t minn(const t x,const r ...xs){return minn(x,minn(xs...));}
template<typename t>constexpr const t maxx(const t x,const t y){return x>y?x:y;}
template<typename t,typename ...r>constexpr const t maxx(const t x,const r ...xs){return maxx(x,maxx(xs...));}
template <typename t> void scan (t& x) {do{while((x=getchar_unlocked())<'0'); for(x-='0'; '0'<=(_=getchar_unlocked()); x=(x<<3)+(x<<1)+_-'0');}while(0);}
template <typename t, typename ...r> void scan (t& x, r&... xs) {scan(x); scan(xs...);}
const int MAXN = 100005;
int main() {
	int n,cnt = 0;
  	scan(n);
  	vector<int> arr(n);
  	for (auto &a : arr) scan(a);
  	for (int i = 1; i < n - 1; i++) if ((arr[i] < arr[i-1] && arr[i] >= arr[i+1]) || (arr[i] >= arr[i-1] && arr[i] < arr[i+1])) cnt++;
  	printf ("%d\n",cnt);
    return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


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

int main2() {
  int N = nextInt();
  int H = nextInt();
  int W = nextInt();
  int ans = (N-H+1)*(N-W+1);
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


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

int main (void) {
    int N, T;
    scanf("%d%d", &N, &T);

    int c, t, ans=INT_MAX;
    for ( int i=0; i<N; i++ ) {
        scanf("%d%d", &c, &t);
        if ( t <= T && c < ans )
            ans = c;
    }

    if ( ans != INT_MAX )
        printf("%d\n", ans);
    else
        printf("TLE\n");
    return EXIT_SUCCESS;
}


Measured memory_bytes: 128
# 「移動されるものとされないもの」という区分け
# 最も長く数字が並ぶものを探すというのはできていたんだけどな...
N = int(input())
P = [int(input()) for i in range(N)]

Q = [-1 for i in range(N)]
for i in range(N):
    Q[P[i]-1]=i

k = 1
i = 1
while i < N:
    cnt = 0
    while(i < N and Q[i-1] < Q[i]):
        cnt += 1
        i += 1
    k = max(k, cnt+1)
    i += 1

print(N - k)


Measured memory_bytes: 18892
module Main where

import           Data.List

main :: IO ()
main = do
    n    <- readLn :: IO Int
    list <- (sequence . take n . repeat) getLine
    putStr
        $ if (length . nub) list
             == length list
             && (siritori ((head . head) list) list)
          then
              "Yes"
          else
              "No"
    return ()

siritori :: Char -> [String] -> Bool
siritori _    []       = True
siritori next (x : xs) = head x == next && siritori (last x) xs


Measured memory_bytes: 636
N, K = map(int, input().split())

sum_prob = 0
for i in range(1, N+1):
    tmp = i
    count = 0
    while tmp < K:
        tmp *= 2
        count += 1
    prob = (1/N) * (0.5 ** count)
    sum_prob += prob

print(sum_prob)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N, X, T;
    cin >> N >> X >> T;
    cout << (N + X - 1) / X * T << endl;
}

Measured memory_bytes: 3648
def ascan; gets.strip.split.map(&:to_i);end
n = gets.to_i
data = n.times.map{ ascan }

def is_reachable(current, next_data)
    tc, xc, yc = current
    tn, xn, yn = next_data
    dist = (xc - xn).abs + (yc - yn).abs
    return false if dist > tn - tc
    (dist-(tn - tc)).even?
end

current = [0, 0, 0]
data.each do |d|
    unless is_reachable(current,d)
        puts 'No'
        exit 0
    end
    current = d
end

puts 'Yes'


Measured memory_bytes: 9596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  if (m2 > m1) {
    h2--;
    m2 += 60;
  }
  int ans = (h2 - h1) * 60 + (m2 - m1) - k;
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 3644
#include<iostream>
#include<string>
using namespace std;
int main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin >> s;
    for(int i=0;i<s.size();i++)
    {
        if(i%2==0 && s[i]=='L')
        {
            cout << "No";
            return 0;
        }
        if(i%2==1 && s[i]=='R')
        {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}

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

while True:
    if len(v) == 1:
        print(v[0])
        break
    tmp = (v[0] + v[1]) / 2
    v.pop(0)
    v.pop(0)
    v.insert(0, tmp)

Measured memory_bytes: 3060
#Contest 159
x = input()
N = int(x[:x.index(" ")])
M = int(x[x.index(" ")+1:])
def factorial(number):
	if number>2:
		return number*factorial(number-1)
	elif not number==0:
		return number
	else:
		return 1
def choose2(number):
	if number>=2:
		return factorial(number)/(2*factorial(number-2))
	else:
		return 0

print(int(choose2(N)+choose2(M)))


Measured memory_bytes: 3060
N = gets.to_i; A,B = gets.split.map(&:to_i); C = gets.to_i
sum_karory = C; sum_money = A
d = []
N.times{|i|d.push(gets.to_i)}
d.sort!{|a,b| b <=> a}
d.each{|a|
    sum_karory2 = sum_karory + a
    sum_money2 = sum_money + B
    if sum_karory * sum_money2 < sum_karory2 * sum_money then
        sum_karory = sum_karory2
        sum_money = sum_money2
    else
        break
    end
}
puts sum_karory / sum_money

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

int main(){

    int N; cin>>N;
    vector<int> P(N), Q(N);
    for (int n=0; n<N; n++) cin>>P[n];
    for (int n=0; n<N; n++) cin>>Q[n];
    vector<int> ptn(N);
    for (int n=0; n<N; n++) ptn[n]=n+1;

    int cnt=1;
    int a=0, b=0;
    do{
        if(ptn==P) a=cnt;
        if(ptn==Q) b=cnt;
        cnt++;
    }while(next_permutation(ptn.begin(), ptn.end()));

    cout << abs(a-b) << endl;

}

Measured memory_bytes: 3620
#include "stdio.h"
#include <iostream>
using namespace std;

int main() {
    int input, hour, min, sec;
    scanf("%d", &input);
    hour = input / 3600;
    input = input - hour*3600;
    min = input / 60;
    sec = input - min*60;
    cout << hour << ":" << min << ":" << sec << endl;
    return 0;
}

Measured memory_bytes: 1208
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    for i in 1..10 {
        for j in 1..10 {
            if i * j == n {
                println!("Yes");
                return;
            }
        }
    }
    println!("No");
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

const ll maxn_bellmanford=2505;
vector<vll> G(maxn_bellmanford);
bool reachableFrom1[maxn_bellmanford];
void dfs(ll v){
  if(reachableFrom1[v]) return;
  reachableFrom1[v]=true;
  for(auto nv: G[v]){
    dfs(nv);
  }
}

vector<vll> rG(maxn_bellmanford);
bool reachableToN[maxn_bellmanford];
void rdfs(ll v){
  if(reachableToN[v]) return;
  reachableToN[v]=true;
  for(auto nv: rG[v]){
    rdfs(nv);
  }
}

ll n,m;
vector<tuple<ll,ll,ll>> es;
ll dist[maxn_bellmanford];
bool ok[maxn_bellmanford];

bool bellmanford(ll s){
  fill(dist,dist+n,INF);
  dist[s]=0;
  bool update=true;
  ll cnt=0;
  while(update){
    update=false;
    for(auto e: es){
      ll a,b,c;
      tie(a,b,c)=e;
      if(!ok[a]||!ok[b]) continue;
      if(chmin(dist[b],dist[a]+c)) update=true;
    }
    if(cnt>=n){
      return true; // has negative loop
    }
    cnt++;
  }
  return false;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll m,p; cin>>n>>m>>p;
  rep(i,m){
    ll a,b,c; cin>>a>>b>>c;
    a--,b--; c=-(c-p);
    es.emplace_back(a,b,c);
    G[a].push_back(b);
    rG[b].push_back(a);
  }
  dfs(0);
  rdfs(n-1);
  rep(i,n) ok[i]=reachableFrom1[i]&&reachableToN[i];
  if(bellmanford(0)){
    cout<<-1<<endl;
  }else{
    ll ans=-dist[n-1];
    if(ans<0) ans=0;
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 768
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef pair<int, bool> PIB;

int N;
PIB A[100000];
int cache[100000][32];

int f(int i, int j) {
  if(i >= N) return 0;
  int &ret = cache[i][j];
  if(ret < 0) {
    if(A[i].second) {
      // complete
      ret = max(A[i].first - j, 0) + f(i + 1, A[i].first);
    } else {
      // incomplete
      ret = min(
          max(A[i].first - j, 0) + f(i + 1, A[i].first - 1),
          max(A[i].first - 1 - j, 0) + 1 + f(i + 1, A[i].first));
    }
  }
  return ret;
}

int main() {
  memset(cache, 0xFF, sizeof(cache));
  scanf("%d", &N);
  for(int i = 0; i < N; i++) {
    int m;
    scanf("%d", &m);
    for(int j = 0; ; j++) {
      if(m <= (1 << j)) {
        if(m == (1 << j)) {
          A[i] = PIB(j, true);
        } else {
          A[i] = PIB(j, false);
        }
        break;
      }
    }
  }
  printf("%d\n", f(0, 0));
  return 0;
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
constexpr ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }

int n;
void solve() {
    cin >> n;

    int s = iinf, b = -iinf;
    int sp = 0, bp = 0;
    rep(i, n) {
        int a; cin >> a;
        if (s > a) {
            s = a; sp = i;
        }
        if (b < a) {
            b = a; bp = i;
        }
    }

    cout << 2 * (n - 1) << endn;
    if (abs(b) >= abs(s)) {
        rep(i, n) {
            if (i != bp) cout << bp + 1 << " " << i + 1 << endn;
        }
        reps(i, n - 1) cout << i << " " << i + 1 << endn;
    }
    else {
        rep(i, n) {
            if (i != sp) cout << sp + 1 << " " << i + 1 << endn;
        }
        repds(i, n - 1) cout << i + 1 << " " << i << endn;
    }


}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


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

int main(void){
	int n,k,v;
	long long num=0;
	vector<int> h;

	cin>>n>>k;

	for(int i=0;i<n;i++){
		cin>>v;
		h.push_back(v);
	}

	sort(h.begin(),h.end());

	for(int i=0;i<n-k;i++){
		num+=h[i];
	}

	cout<<num<<endl;

	return 0;
}

Measured memory_bytes: 1400
#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()
{
    unordered_map<ll, ll> hashmap;
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
        hashmap[a[i]]++;
    }

    ll total = 0;
    for (auto p : hashmap) {
        ll m = p.second;
        total += m * (m - 1) / 2;
    }

    rep(i, n) {
        ll m = hashmap[a[i]];
        ll ans = total - m * (m - 1) / 2 + (m - 1) * (m - 2) / 2;
        cout << ans << endl;
    }

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  int sum = 0;
  int n = 1;
  
  while( N/n > 0) {
    int d = n * 10;
    sum += (N%d)/n;
    n *= 10 ;
  }
  
  
  if ( N%sum == 0 ) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
//abc163A
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
 
int main(void) {
  float n, k, i, cou=0, tmp;
  scanf("%f", &n);
  printf("%f", n * 2*M_PI);
  return 0;
}
 

Measured memory_bytes: 1740
import sys

array = []
for line in sys.stdin:
    array.append(int(line))

max_val = max(array)
prime_list = [1] * max_val
prime_list[0] = 0
prime_list[1] = 0

i = 2
while i < max_val:
    for j in range(i * 2, max_val, i):
        prime_list[j] = 0
    i = i + 1
    while i < max_val and prime_list[i] == 0:
        i = i + 1

for val in array:
    count = sum(prime_list[:val + 1])
    print(count)


Measured memory_bytes: 21936
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();

        int result = t.length();
        for (int i = 0; i < s.length() - t.length() + 1; i++) {
            int diff = 0;
            for (int j = 0; j < t.length(); j++) {
                if (s.charAt(i + j) != t.charAt(j)) {
                    diff++;
                }
            }
            result = Math.min(result, diff);
        }
        System.out.println(result);
    }

}


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

#define 	mod 			1000000007
#define 	ll  			long long int
#define 	rep(i, a, b) 	for(ll i = a ; i < b ; i++)
#define     repn(i, a, b)   for(ll i = a ; i > b ; i--)
#define 	mod1 			1000003
#define     mod2            998244353
#define     inf             2e18
#define 	hi   			"hello"
#define 	nl 				"\n"
#define 	ws 				" "
#define     ff 				first
#define 	ss 				second
#define 	pb 				push_back
#define 	MP				make_pair
#define 	B 				begin()
#define     RB              rbegin()
#define 	E 				end()
#define     UB              upper_bound
#define     LB              lower_bound
#define     present(k, m)   (m.find(k)!=m.end())?1:0
#define 	all(v) 			v.begin(), v.end()
#define 	reset(a, val) 	memset(a, val, sizeof(a))
#define     pll             pair<ll, ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vvll            vector<vll>
#define     vpll            vector<pll>
#define 	vs 				vector<string>
#define     vc              vector<char>
#define     sqr(a)          ((a)*(a))
#define 	print1(a) 		for(auto i : a)cout<<i<<" ";cout<<"\n"
#define 	print2(a) 		for(auto i : a)cout<<i;cout<<"\n"
#define 	print3(a) 		for(auto i : a)cout<<i<<nl;
#define 	boost 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

// ostringstream str1;
// str1 << n;
// string tmp = str1.str();
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }

bool compare(const pair<string, int>&a, const pair<string, int>&b){ return a.second<b.second; }

double logn(double n, double r) { return (n > r - 1) ? 1 + logn(n / r, r) : 0; }

// vll pwx(32);
// void cal(ll x){ pwx[0] = 1; rep(i, 1, 32)pwx[i] =  x*pwx[i-1]; }

/* ################################################################ */

#define space 100005

void solve() {
    int n, a, b, c;
    int ans = 0;
    cin >> n;

    rep(i, 1, n) {
        ans += (n-1)/i;
    }

    cout << ans << nl;
}

int main(){
    // boost;
    // cal(2);
    int t = 1, k = 1;
    // cin>>t;
    while(t--){
        // cout<<"Case #"<<k<<": ";
        solve();
        k++;
    }
}

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

using namespace std;

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


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

#define pb push_back
#define F first
#define S second
#define fo(i,a,b)  for(int i = a; i < b; i++)

using ll = long long;
using ld = long double;
using ul = unsigned long long;
using ii = pair<int, int>;
#define Mosta     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ReadFile            freopen("input.in","r",stdin)
#define WriteFile           freopen("output.txt","w",stdout)
const ll mod7 = 1000000007,mod = 1000000000,OO = 0x3f3f3f3f;
const ld EPS = 1e-7;
double Pi=acos(-1);
const ld rad=Pi/180.0;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll nCr (ll n,ll m)
{
        return(m == 0)?1:n*nCr(n-1,m-1)/m;
}
/*****************************************************/

const int N = 16;
vector<int> x[N] , y[N];
int n , a[N] , ans;

bool _check(int bit){
    for(int i = 0; i < n; ++i){
        if(((bit>>i)&1) == 1){
            for(int j = 0; j < a[i]; j++){
                if(((bit>>x[i][j])&1) != y[i][j]){
                    return false;
                }
            }
        }
    }
    return true;
}

int main()
{
    cin >> n;

    for(int i = 0; i < n; ++i){
        cin >> a[i];
        for(int j = 0; j < a[i]; ++j){
            int s , ss;
            cin >> s >> ss;
            s--;
            x[i].pb(s);
            y[i].pb(ss);
        }
    }

    for(int i = 0; i < (1<<n); ++i){
        if(_check(i)){
            int cnt = 0;
            for(int j = 0; j < n; ++j){
                if(((i>>j)&1) == 1){
                    cnt++;
                }
            }
            ans = max(cnt , ans);
        }
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)
t = ('A','G','C','T')
ans = 0
flag = 0
for i in range(n):
	for j in range(i,n):
		#print(s[i:j+1])
		flag = 0
		for c in s[i:j+1]:
			if c not in t:
				flag = 1
				break
		if flag == 0:
			ans = max(ans,j-i+1)
print(ans)	


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

using namespace std;

typedef long long LL;

const int N = 400010, mod = 1e9 + 7;
LL n, k;

int fact[N], infact[N];


int qmi(int a, int k, int p)
{
    int res = 1;
    while (k)
    {
        if (k & 1) res = (LL)res * a % p;
        a = (LL)a * a % p;
        k >>= 1;
    }
    return res;
}


int main()
{
    fact[0] = infact[0] = 1;
    for (int i = 1; i < N; i ++ )
    {
        fact[i] = (LL)fact[i - 1] * i % mod;
        infact[i] = (LL)infact[i - 1] * qmi(i, mod - 2, mod) % mod;
    }
    cin >> n >> k;
    if(k >= n){
        cout << (LL)fact[2*n-1] * infact[n-1] % mod * infact[n] % mod <<endl;
    }
    else {
        LL res = 0;
        for(int i = 0; i <= k; i ++){
            LL temp1 = (LL)fact[n-1] * infact[n-i-1] % mod * infact[i] % mod;
            LL temp2 = (LL)fact[n] * infact[i] % mod * infact[n- i] % mod;
            res += temp1*temp2 % mod;
            res %= mod;
        }
        cout << res << endl;
    }
    return 0;
}

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

class Program
{
    //static int[] dp;
    //static decimal[,,] dp;
    //static decimal N;
    static void Main(string[] args)
    {
        // 入力
        int[] input = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
        int H = input[0];
        int W = input[1];
        int A = input[2];
        int B = input[3];

        int small = A;
        int big = W - A;
        string str1 = new string('1', small);
        string str2 = new string('0', small);
        string str3 = new string('1', big);
        string str4 = new string('0', big);

        string ret1 = str1 + str4; // 111100000
        string ret2 = str2 + str3; // 000011111
        for (int i=0; i<H; i++)
        {
            if(i<B)
            {
                Console.WriteLine(ret1);
            }
            else
            {
                Console.WriteLine(ret2);
            }
        }
    }

}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef int64_t ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;
const ll MOD = 1e9 + 7;

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

  ll ret = 0LL;
  REP(i,N) {
    int cnt1 = 0;
    int cnt2 = 0;
    REP(j,i) if (A[j] < A[i]) cnt1++;
    for (int j = i + 1; j < N; ++j) if (A[j] < A[i]) cnt2++;
    ll tmp = (K * (K - 1) / 2) % MOD;
    ret += cnt2 * K % MOD + (cnt1 + cnt2) * tmp % MOD;
    ret %= MOD;
  }

  cout << ret << endl;
  return 0;
}



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

typedef long long ll;
using namespace std;

int main() {
    // s = "SCR" expected
    // t = "CRR" actual
    string s, t;
    cin >> s >> t;

    int res = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == t[i]) ++res;
    }

    cout << res << endl;
}


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

using namespace std;

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 (a>b) { a=b; return 1; } return 0; }

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

	int n, m;
	cin >> n >> m;

	vector<int> a(m);
	rep(i, m) cin >> a[i];

	vector<int> b{0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

	vector<int> dp(n+1, -1);
	dp[0] = 0;
	for(int i = 0; i <= n; i++){
		if(dp[i] == -1) continue;
		rep(j, m){
			int x = b[a[j]];
			if(i + x <= n) chmax(dp[i + x], dp[i] + 1);
		}
	}

	sort(a.begin(), a.end(), greater<int>());

	int p = n;
	string ans;
	while(p > 0){
		rep(j, m){
			int x = b[a[j]];
			if(p - x >= 0 && dp[p - x] == dp[p] - 1){
				p -= x;
				ans.push_back('0' + a[j]);
				break;
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 3612
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        // 出力
        if(s.equals("Sunny")) System.out.println("Cloudy");
        if(s.equals("Cloudy")) System.out.println("Rainy");
        if(s.equals("Rainy")) System.out.println("Sunny");
    }
}

Measured memory_bytes: 22100
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;

typedef long long ll;
typedef vector<ll> VL;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999

vector<ll> G[101000];
typedef pair<ll,ll> P;
ll ord[101000],low[100010];
bool used_v[100100];
set<ll> ans;
ll V,E;


//深さ優先探索 count=0,v=0として始める。
//lowlink配列とord配列を求め、 ord[v]≦low[u]となる親vと子uを求める。
void dfs(ll v,ll p,ll count){
  ll ct=0;
  bool flag =false;
  used_v[v]=true;
  ord[v]=low[v]=count++;
  REP(i,G[v].size()){
    if(!used_v[G[v][i]]){
      ct++;
      dfs(G[v][i],v,count);
      low[v]=min(low[v],low[G[v][i]]);
      if(~p && ord[v]<=low[G[v][i]])flag=true;
    }
    else if(G[v][i]!=p){
      low[v]=min(low[v],ord[G[v][i]]);
    }
  }
  if(p==-1 && ct>1)flag=true;
  if(flag)ans.insert(v);
}

int main(){
  cin >> V>>E;
  ll s,t;
  REP(i,E){
    scanf("%lld %lld",&s,&t);
    G[s].push_back(t);
    G[t].push_back(s);
  }

  REP(i,V)used_v[i]=false;

  dfs(0,-1,0);

  for(auto itr = ans.begin(); itr !=ans.end();++itr){
    cout << *itr<<endl;
  }
}



Measured memory_bytes: 7604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, i,ab=0;
  cin >> N;
  vector<int> a(N);
  
  for(i=0; i<N; i++)
    cin >> a.at(i);
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  for(i=0; i<N; i++)
    if(i%2==0)
      ab += a.at(i);
    else
      ab -= a.at(i);
  
  cout << ab << endl;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll h1,m1,h2,m2,k;
    cin >>h1>>m1>>h2>>m2>>k;
    ll s=h1*60+m1;
    ll g=h2*60+m2;
    ll ans=g-s-k;
    cout <<ans <<endl;
    return 0;
}


Measured memory_bytes: 3636
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<list>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;






int main(){
    ll n;
    cin>>n;
    vector<ll> a,b;
    ll mi=E;
    ll sum=0;
    for(int i=0;i<n;i++){
        ll A,B;
        cin>>A>>B;
        a.push_back(A);
        b.push_back(B);
        sum+=A;
        if(A>B){mi=min(mi,B);}
    }
    if(a==b){cout<<0<<endl; return 0;}
    cout<<sum-mi<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <map>
#include <functional>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <set>

using namespace std;

int main()
{
    string S, T;

    cin >> S;
    cin >> T;

    int cnt = 0;
    for (size_t i = 0; i < 3; i++)
    {
        if (S[i] == T[i])
            cnt++;
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#define pi 3.14159265358979323846
#define max max_element
#define min min_element
using namespace std;
 
template<typename T> 
	T gcd(T a, T b) {
		return b ? gcd(b, a % b) : a;
	}
template<typename T>
	T lcm(T a, T b) {
		return a * b / gcd(a, b);
	}
 
int main() {
  int n,k,ans=0;
    cin>>n>>k;
  vector<int> h(n);
  for(int i=0;i<n;i++) {
    cin>>h[i];
    if(k<=h[i]) ans++;
  }
  cout<<ans<<endl;
}
  

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

using namespace std;

const int M = 3e3 + 3;
string a, b;
int dp[M][M];
char l[M];

int solve (int i, int j) {
	if (i > a.size() || j > b.size()) return 0;
  int &ret = dp[i][j];
  if (ret != -1) return ret;
  if (a[i-1] == b[j-1])
    return ret = solve (i+1, j+1) + 1;
  return ret = max (solve (i+1, j), solve (i, j+1));
}

int main () {
    cin >> a >> b;
    memset (dp, -1, sizeof dp);
    int k = solve (1, 1);
    int x = k;
    k = 1;
    int i = 1;
    int j = 1;
    while (i <= a.size() && j <= b.size()) {
        if (a[i-1] == b[j-1]){
            l[k-1] = a[i-1];
            i++; j++; k++;
        }
        else if (dp[i+1][j] > dp[i][j+1]) i++;
        else j++;
    }
    for (int i = 0; i < x; i++) cout << l[i];

}


Measured memory_bytes: 35840
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

int n,w,h;
pii X[100100], Y[100100];

int main(){
  scanf("%d%d%d",&n,&w,&h);
  
  for(int i=0;i<n;i++){
    int x,y,d;
    scanf("%d%d%d",&x,&y,&d);
    X[i] = pii(x-d,x+d); Y[i] = pii(y-d,y+d);
  }
  sort(X,X+n); sort(Y,Y+n);

  bool f1 = true, f2 = true;
  int R = 0, U = 0;
  for(int i=0;i<n;i++){
    if(R<X[i].first)f1 = false;
    R = max(R,X[i].second);
    if(U<Y[i].first)f2 = false;
    U = max(U,Y[i].second);
    if(!f1 && !f2)break;
  }
  if( (f1 && w<=R) || (f2 && h<=U) )cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 2772
n,a,b=map(int,input().split())
mod=10**9+7
def comb(n,k,mod):
  if k>n-k:
    k=n-k
  c=1
  for i in range(n-k+1,n+1):
    c*=i
    c%=mod
  d=1  
  for i in range(1,k+1):
    d*=i
    d%=mod
  return (c*pow(d,mod-2,mod))%mod

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


Measured memory_bytes: 9100
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int main()
{
	string s,ans = "No";
	cin >> s;

	if (s.size() >= 4) {
		if (s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I')
			ans = "Yes";
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N; cin >> N;
	int ans[4] = { 0 };
	REP(i, N) {
		string S; cin >> S;
		if (S == "AC")ans[0]++;
		if (S == "WA")ans[1]++;
		if (S == "TLE")ans[2]++;
		if (S == "RE")ans[3]++;
	}
	cout << "AC x " << ans[0] << endl;
	cout << "WA x " << ans[1] << endl;
	cout << "TLE x " << ans[2] << endl;
	cout << "RE x " << ans[3] << endl;
	return 0;
}



Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk make_pair
#define pb push_back
#define eb emplace_back
#define ins insert
#define fi first
#define se second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=1e5+5;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int n,m,f[MAXN],fa[MAXN],a[MAXN],rt=1,b[MAXN],re,tot;vector<int>G[MAXN];
void dfs(int x,int f,int d){fa[x]=f,a[x]=d&1?1:-1;for(auto y:G[x])if(y!=f)dfs(y,x,d+1),a[x]+=a[y];}
int gf(int x){return f[x]==x?x:f[x]=gf(f[x]);}
inline bool Merge(int x,int y){return gf(x)==gf(y)?0:f[gf(x)]=gf(y);}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),m=read();
	Rep(i,1,n)f[i]=i;
	Rep(i,1,m){int x=read(),y=read();Merge(x,y)?G[x].pb(y),G[y].pb(x),0:(rt=x,re=y);}
	dfs(rt,0,0);
	if(n==m){
		for(int t=re;t;t=fa[t])b[++tot]=a[t];
		if(tot&1){
			if(a[rt]&1)return puts("-1"),0;
			for(int t=re;t;t=fa[t])a[t]-=a[rt]>>1;
		}else{
			if(a[rt])return puts("-1"),0;
			sort(b+1,b+tot+1);
			for(int t=re;t;t=fa[t])a[t]-=b[tot>>1];
		}
	}else if(a[rt])return puts("-1"),0;
	int ans=0;Rep(i,1,n)ans+=abs(a[i]);cout<<ans<<"\n";
	return 0;
}




Measured memory_bytes: 18304