akhauriyash/Code-Regression huggingface dataset:
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10

    D = II()
    C = LMIIS()
    S = []
    for i in range(D):
        S.append(LMIIS())
    
    T = [0]*D
    last_helds = []
    for _ in range(26):
        last_helds.append([-1])
    sat = 0
    for i in range(D):
        max_sat = -INF
        max_type = -1
        L = S[i]
        reduction = 0
        for j in range(26):
            reduction += C[j] * (i-last_helds[j][-1])
        for j in range(26):
            tmp = -reduction + C[j]* (i-last_helds[j][-1])
            tmp += S[i][j]
            if max_sat < tmp:
                max_sat = tmp
                max_type = j
            

            
        T[i] = max_type
        last_helds[max_type].append(i)
        sat += max_sat
    
    for t in T:
        print(t+1)
    dbg(sat)

    
main()

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    string a,b;
    cin >>a>>b;
    if((a=="H"&&b=="H")||(a=="D"&&b=="D"))
    {
        cout <<"H"<<endl;
    }
    else cout<<"D"<<endl;
    return 0;
}

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

int main() {
	u32 N;
	cin >> N;
	
	string S;
	cin >> S;
	
	u32 Q;
	cin >> Q;
	
	map<char, set<u32>> cm;
	for(u32 i=0; i<N; i++) cm[S[i]].insert(i);

	for(u32 q=0; q<Q; q++) {
		u32 t;
		cin >> t;
		
		if(t & 1) {
			u32 i;
			char c;
			cin >> i >> c;
	
			if(S[i-1] == c) continue;
			
			cm[c].insert(i-1);
			cm[S[i-1]].erase(i-1);
			
			if(cm[S[i-1]].empty()) cm.erase(S[i-1]);
			
			S[i-1] = c;
			
		} else {
			u32 l, r;
			cin >> l >> r;
			
			u32 ans = 0;
			
			for(auto ci=begin(cm); ci!=end(cm); ci++) {
				auto pi = (*ci).second.lower_bound(l - 1);
				if(pi != (*ci).second.end() && *pi <= r - 1) ans++;
			}
			
			cout << ans << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 24196
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    VI a(n);
    REP(i,0,n) cin >> a[i];
    LL ans = 0;
    VVI cnt(n+1, VI(32));
    REP(i,0,n) {
        REP(j,0,32) {
            cnt[i+1][j] = ((a[i] & (1<<j)) != 0 ? 1 : 0) + (cnt[i][j]);
        }
    }

    REP(i,0,n) {
        int ok = i - 1, ng = n;
        int c = 0;
        //dump(i);
        while (ng - ok > 1 && c++ < 30) {
            //dump(ok);
            //dump(ng);
            int m = (ng + ok) / 2;
            //dump(m);
            bool b = true;
            REP(j,0,32) if (cnt[m+1][j] - cnt[i][j] > 1) {
                b = false;
                break;
            }
            if (b) ok = m;
            else ng = m;
        }

        ans += ok - i + 1;
    }
    cout << ans << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 33792
#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;

int main(){
	int n,a,b,c,d;
	int m=0;
	scanf("%d",&n);
	if(n>=1000&&n<=9999){
		a=n/1000;
		b=n/100%10;
		c=n/10%10;
		d=n%10;
		if(a==b&&b==c) m=1;
		if(b==c&&c==d) m=1;
	}
	if(m==1) printf("Yes\n");
	if(m==0) printf("No\n");
}

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

#define ll long long
#define pb push_back
#define eb emplace_back
//#define st first
#define sc second

using namespace std;

const ll mod = 1e9 + 7;
const int e = 2*1e5 + 69;
const int base = 311;

// dung inverse module de tinh nCk
// beginer 78
// mbeginer
// cach tao hoan vi tu n so : n*(n+1)/2;

//vector<pair<ll,ll>>adj[e];
//vector<ll>adj[e];

/*ll Pow(ll n, ll dem)
{
    if(dem == 0) return 1;
    if(dem == 1) return n ;
    ll t = Pow(n, dem/2);
    if(dem % 2 == 0) return (t*t);
    else return ((t * t) * n);
}*/

/*ll C(ll k, ll n)
{
    if(k == 0) return 1;
    if(n < k) return 0;
    return (gt[n]%mod * (igt[k]%mod * igt[n-k]%mod)%mod)%mod;
}*/

ll n, m, k;
ll h[e];

int main()
{
    cin >> n;
    map<ll,ll>kt;
    map<ll,ll>kt1;
    for(int i=1; i<=n; i++)
    {
        cin >> h[i];
        kt[h[i] + i] ++;
        kt1[i - h[i]] ++;
    }
    ll ans = 0;
    for(int i=1; i<=n; i++)
    {
        ans += kt1[h[i] + i];
        //ans += kt[i - h[i]];
    }
    cout << ans;

}
/*

*/


Measured memory_bytes: 39456
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args)throws Exception {
    	InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);

       String[] input = br.readLine().split(" ");
       int a = Integer.parseInt(input[0]);
       int b = Integer.parseInt(input[1]);
       int d = a / b;
       int r = a % b;
       double f = (double)a / b;
       System.out.printf("%d %d %.5f" ,d , r , f);
    }
}

Measured memory_bytes: 24800
/*

    author : s@if

*/

#include<bits/stdc++.h>
using namespace std;

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			99999999
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)


bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hr[]={-2,-2,-1,+1,+2,+2,-1,+1};
int hc[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)1e5+9;

int ara[MAXN];

int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    int i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    cin>>n;

    For(i,1,n)
    {
        cin>>ara[i];
    }
    sort(ara+1,ara+n+1);

    m = n/2;

    int ans = ara[m+1]-ara[m];

    cout<<ans<<endl;

    return 0;
}


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

signed main(){
    int n,m;
    cin >> n >> m;
    priority_queue<int> que;
    vector<int> jobs[m];
    rep(i,n){
        int a,b;
        cin >> a >> b;
        //que.push(make_pair(b,a));
        if(m-a<0) continue;
        jobs[m-a].push_back(b);
    }
    int ans=0;
    for(int i=m-1;i>=0;i--){
        for(auto x:jobs[i]){
            que.push(x);
        }
        if(!que.empty()){
            int v=que.top();
            ans+=v;
            que.pop();
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
int main()
{
    double d,n,k;
    cin >> d>>n >> k;
    if(d/k<=n)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
}


Measured memory_bytes: 3720
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math") 
///#pragma GCC target("avx2")
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <functional>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <climits>
#include <numeric>

using namespace std;
#define open_streams ifstream fin("olympiad.in");ofstream fout("olympiad.out")
#define close_streams fin.close();fout.close()
#define speed cout.tie(0);cin.tie(0);ios_base::sync_with_stdio(0)
#define ll long long
#define ull unsigned long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define UNIQ(a) a.resize(unique(all(a)) - a.begin())
#define eps 1e-6
//const double PI = M_PI;
const int INF = INT_MAX;
const ll limit = 1LL * 4e18;
const int MOD = 1e9 + 711;
const int MOD2 = 1e9 + 933;
//---------------------------------------------------------------------------
const int mod = 1e9 + 7;
const int maxn = 1e5 + 100;



signed main() {
	speed;
	int n;
	map<string, int> mp;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		mp[s]++;
	}
	vector<string> a;
	int mx = 0;
	for (auto &i : mp) {
		mx = max(mx, i.second);
	}
	for (auto &i : mp) {
		if (i.second == mx) {
			a.pb(i.first);
		}
	}
	sort(all(a));
	for (auto &i : a) {
		cout << i << '\n';
	}
	return 0;
}

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

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  string ans(n, 'z');
  while (m--) {
    int s;
    char c;
    cin >> s >> c;
    s--;
    if (s == 0 && c == '0') {
      if (n == 1) {
        cout << 0 << '\n';
      } else {
        cout << -1 << '\n';
      }
      return 0;
    }
    if (ans[s] == 'z') {
      ans[s] = c;
    } else if (ans[s] != c) {
      cout << -1 << '\n';
      return 0;
    }
  }
  for (int i = 0; i < n; i++) {
    if (ans[i] == 'z') {
      if (n > 1 && i == 0) {
        ans[0] = '1';
      } else {
        ans[i] = '0';
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3656
{-# LANGUAGE TypeApplications #-}
import qualified Data.ByteString.Char8 as BS

check :: Int -> Int -> Int -> Int -> String
check a b c d =
  if x > y
  then "No"
  else "Yes"
  where
    a2 = fromIntegral a
    b2 = fromIntegral b
    c2 = fromIntegral c
    d2 = fromIntegral d
    x = ceiling $ c2 / b2
    y = ceiling $ a2 / d2

main :: IO()
main = do  
  [a,b,c,d] <- map (read @Int . BS.unpack) . BS.words <$> BS.getLine
  putStrLn $ check a b c d


Measured memory_bytes: 3936
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<stack>
using namespace std;

#define len 1e5+1
#define maxwt 1e15

int main(){
    int n,k; cin>>n>>k;
    vector<int> p(20); p[0]=1; vector<long double> pr(20); pr[0]=1;
    for(int i=1; i<20; i++){ p[i]=p[i-1]*2; pr[i]=pr[i-1]/2; }

    long double ans=0;
    for(int i=1; i<=n; i++){
        for(int j=0; j<20; j++){
            if(i*p[j]>=k){
                ans+=pr[j]/n; break;
            }
        }
    }
     std::cout << std::fixed;
  std::cout << std::setprecision(14) << ans << '\n';
}








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

using namespace std;


int main() {
    int x,y,s;
    while(cin>>x>>y>>s && x) {
        int ans = -1;
        for(int a=1; a<s; a++) {
            for(int b=1; ; b++) {
                int p = a * (100+x) / 100 + b * (100+x) / 100; // zeikomi
                if(p > s) break;
                if(p == s) {
                    ans = max(ans, a*(100+y)/100 + b*(100+y)/100);
                }
            }
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int main()
{
  int a,b,c,d;
  double f;
  scanf("%d%d",&a,&b);
  c=a/b;
  d= a%b;
  f=(double)a/(double)b;
  printf("%d %d %f\n",c,d,f);
  return 0;
}

Measured memory_bytes: 636
import re
# and
def and_def(a, b):
    return str(min(int(a), int(b)))

# or
def or_def(a, b):
    return str(max(int(a), int(b)))

# not
def not_def(a):
    return str(2 - int(a))

def match(struct):
    if re.fullmatch(r'\-[0,1,2]', struct):
        return not_def(struct[-1])
    if re.fullmatch(r'[0,1,2]\+[0,1,2]', struct):
        return or_def(struct[0], struct[-1])
    if re.fullmatch(r'[0,1,2]\*[0,1,2]', struct):
        return and_def(struct[0], struct[-1])
    if re.fullmatch(r'[0,1,2]', struct):
        return struct
    if re.fullmatch(r'\([0,1,2]\)', struct):
        return struct[1]
    return struct

def parse(struct):
    tmpstruct = ''
    check, minas = False, False
    if len(struct) == 1:
        return struct

    for i in range(len(struct)):
        if not check:
            if struct[i] == '(':
                check = [')', '(']
                tmp = 1
                num = i
            elif struct[i] == '-':
                check = ['0', '1', '2', '(']
                minas = True
                num = i
            else:
                tmpstruct += struct[i]

        else:
            if struct[i] in check:
                if struct[i] == ')':
                    tmp -= 1
                    if not tmp:
                        if not minas:
                            tmpstruct += parse(struct[num+1: i])
                        else:
                            tmpstruct += not_def(parse(struct[num + 1: i + 1]))
                            minas = False
                        check = False
                elif struct[i] == '(' and check == ['0', '1', '2', '(']:
                    check = [')', '(']
                    tmp = 1
                elif struct[i] == '(':
                    tmp += 1
                else:
                    tmpstruct += not_def(parse(struct[num + 1: i + 1]))
                    check = False
                    minas = False
        tmpstruct = match(tmpstruct)
    return tmpstruct


def change_PQR(string, P, Q, R):
    ret = ''
    for i in string:
        if i == 'P':
            ret += str(P)
        elif i == 'Q':
            ret += str(Q)
        elif i == 'R':
            ret += str(R)
        else:
            ret += i
    return ret


while True:
    struct = input()
    if struct == '.':
        break

    ans = 0
    for i in (0, 1, 2):
        for j in (0, 1, 2):
            for k in (0, 1, 2):
                tmpstr = struct
                if parse(change_PQR(tmpstr, i, j, k)) == '2':
                    ans += 1
    print(ans)



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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll A, B;
    cin >> A >> B;
    if(1 <= A && A <= 9 && 1 <= B && B <= 9) cout << A * B;
    else cout << -1;
    cout << endl;
    return 0;
}


Measured memory_bytes: 3600
import collections

n=int(input())
a=list(map(int,input().split()))
a_s=sorted(a)
a_s_p=[]
a_s_m=[]
for i in range(n):
    a_s_p.append(a_s[i]+1)
    a_s_m.append(a_s[i]-1)

all_a=a_s+a_s_p+a_s_m

mode=collections.Counter(all_a).most_common()[0][1]
print(mode)

Measured memory_bytes: 34108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T> ostream& operator << (ostream& os, const set<T>& s) { for (auto e : s) os << e; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { (a += b % mod) %= mod; if (a < 0) a += mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12); // debuged
  int T;
  T = 1;
  while (T--) solve();
}

// si<tiに注意!!
// https://kmjp.hatenablog.jp/entry/2019/10/28/0930
void solve() {
  int n, m;
  cin >> n >> m;
  vector<vector<int> > G(n), G2(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].eb(b);
    G2[b].eb(a);
  }

  vector<double> dp(n);
  for (int i = n - 2; i >= 0; --i) {
    for (int nv : G[i]) {
      dp[i] += dp[nv];
    }
    dp[i] /= sz(G[i]);
    ++dp[i];
  }
  double ans = dp[0];

  rep(i, n) { // 始点iの辺を消す
    if (sz(G[i]) <= 1) continue;
    // dp[i] += dp[nv]において, dp[nv]最大の辺を消す
    vector<double> e;
    for (int nv : G[i]) e.eb(dp[nv]);
    sort(all(e));
    e.pop_back();

    vector<double> dp2(n);
    // 頂点iのdpの値は先に決める
    rep(j, sz(e)) dp2[i] += e[j];
    dp2[i] /= sz(e);
    ++dp2[i];

    for (int j = n - 2; j >= 0; --j) {
      if (j == i) continue;
      for (int nv : G[j]) dp2[j] += dp2[nv];
      dp2[j] /= sz(G[j]);
      ++dp2[j];
    }
    chmin(ans, dp2[0]);
  }
  cout << ans << endl;
}


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

const ll mod = 1e9 + 7;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(a*c, max(a*d, max(b*c, b*d))) << "\n";
	return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 2147483647;
int prime = 998244353;
void Debug(auto a);
double PI = 3.14159265358979;
void input(vector<auto>& a,int n);
int n;

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

    cin >> n;
    vec(a,n);
    input(a,n);
    a[0]--;
    bool ans = true;
    FOR(i,1,n){
        if(a[i-1] > a[i]){
            ans = false;
        }
        if(a[i-1]<a[i]){
            a[i]--;
        }
    }
    (ans)? print("Yes"):print("No");

    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


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

int main(){
    ll n, m;
    cin >> n >> m;
    if(2 * n >= m){
        cout << m / 2 << endl;
    } else {
        ll k = (m - 2*n) / 4;
        cout << n + k << endl;
    }
    return 0;
}

Measured memory_bytes: 3644
def resolve():
    # 整数 1 つ
    n = int(input())
    # 整数複数個
    # a, b, c = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    A = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    re = 0
    B = sorted(A, reverse=True)

    for i in range(len(B)):
        if i % 2 == 0:
            re += B[i]
        else:
            re -= B[i]
    print(re)
resolve()

Measured memory_bytes: 38384
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    ll n,w,w_1; cin>>n>>w;
    ll ans=0;
    vector<int> num(4,0);
    vector<vector<int>> g(4);
    ll wi,vi; cin>>wi>>vi; w_1=wi;
    num[0]++; g[0].push_back(vi);
    rep(i,n-1){
        cin>>wi>>vi;
        num[wi-w_1]++; g[wi-w_1].push_back(vi);
    }
    rep(i,4){
        sort(al(g[i])); reverse(al(g[i]));
    }
    rep(a,num[0]+1){
        rep(b,num[1]+1){
            rep(c,num[2]+1){
                rep(d,num[3]+1){
                    ll ws=a*(w_1)+b*(w_1+1)+c*(w_1+2)+d*(w_1+3);
                    if(ws>w) continue;
                    ll cnt=0;
                    rep(i,a) cnt+=g[0][i];
                    rep(i,b) cnt+=g[1][i];
                    rep(i,c) cnt+=g[2][i];
                    rep(i,d) cnt+=g[3][i];
                    ans=max(ans,cnt);
                }
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

//aのb乗
ll modpow(ll a, ll b) {
	ll res = 1;
	while(b > 0) {
		if(b & 1) res = res * a % MOD;
		if(res==0) res = MOD;
		a = a * a % MOD;
		if(a==0) a = MOD;
		b >>= 1;
	}
	return res;
}

signed main() {
	string S;
	cin >> S;
	int N = (int)S.size();
	ll ans = 0;
	// ABC AB? ?BC ?B? に分ける
	vector<ll>  a(N+1, 0), c(N+2, 0), l(N+1, 0), r(N+2, 0);
	for(int i=1;i<=N;i++) {
		if(S[i-1] == 'A') a[i]++;
		if(S[i-1] == '?') l[i]++;
	}
	for(int i=1;i<=N;i++) {
		a[i] += a[i-1];
		l[i] += l[i-1];
	}
	
	for(int i=N;i>=1;i--) {
		if(S[i-1] == 'C') c[i]++;
		if(S[i-1] == '?') r[i]++;
	}
	for(int i=N;i>=0;i--) {
		c[i] += c[i+1];
		r[i] += r[i+1];
	}

	for(int i=1;i<=N;i++) {
		if(S[i-1] == 'B' or S[i-1] == '?') {
			ll plus = 0;
			plus += (((modpow(3, l[i-1] + r[i+1]) * a[i-1]) % MOD) * c[i+1] % MOD);
			plus += (((modpow(3, l[i-1] + r[i+1] - 1) * a[i-1]) % MOD) * r[i+1] % MOD);
			plus += (((modpow(3, l[i-1] + r[i+1] - 1) * l[i-1]) % MOD) * c[i+1] % MOD);
			plus += (((modpow(3, l[i-1] + r[i+1] - 2) * l[i-1]) % MOD) * r[i+1] % MOD);
			ans += plus;
			ans %= MOD;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3584
# include <iostream>
# include <cstdio>
using namespace std;
char s[105][105];
int cmp(char a[],char b[],int l);
void swap(char a[],char b[],int l);
int main(){
    int N,L;
    while(scanf("%d%d",&N,&L)!=EOF){
        for(int i = 1;i <= N;++i)
            scanf("%s",s[i]);
        for(int i = 1;i <= N-1;++i)
            for(int j = 1;j <= N-i;++j)
                if(cmp(s[j],s[j+1],L)) swap(s[j],s[j+1],L);

        for(int i = 1;i <= N;++i)
            printf("%s",s[i]);
        printf("\n");
    }
    return 0;
}
 // a b 1    dxx   axx
int cmp(char a[],char b[],int l){
    if(l == 0) return 0;
    else if(a[0] > b[0]) return 1;
    else if(a[0] < b[0]) return 0;
    else return cmp(a+1,b+1,l-1);
}
void swap(char a[],char b[],int l){
    for(int i = 0;i < l;++i){
        char t = a[i];
        a[i] = b[i];
        b[i] = t;
    }
}


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 int ll;
typedef pair<int, int> P;
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 n, m;
	cin >> n >> m;
	cout << (n-1)*(m-1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int r0,w0,c,r;

  while(cin>>r0>>w0>>c>>r,r0){
    int nodo=r0/w0;
    int x=0;
    while(nodo<c){
      x++;
      nodo=(r0+x*r)/(w0);
    }
    cout<<x<<endl;
  }
}

Measured memory_bytes: 3020
import * as fs from 'fs';

namespace AtCoder.abc091 {
    export class Program {
        constructor(private readonly args: string[]) {
        }

        main(this: Program): void {
            const [a, b, c]: number[] = this.args[0].split(' ').map(Number);

            console.log((a + b >= c) ? 'Yes' : 'No');

        }
    }
}

const args: string[] = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n');
const prg: AtCoder.abc091.Program = new AtCoder.abc091.Program(args);
prg.main();

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define ff { ios_base::sync_with_stdio(false);cin.tie(NULL);}
using namespace std;

typedef long long ll;
 ll  pp=1e9+7; 
double pi=3.141592653589793238;
  
 int main() {
        ff;
        ll n;
        cin>>n;
        ll a[n];
        map<ll,ll> m;
        ll s=0;
        for(int i=0;i<n;i++){
            cin>>a[i];
            s+=a[i];
            m[a[i]]++;
        }
        ll q;
        cin>>q;
        while(q--){
            ll x,y;
            cin>>x>>y;
            ll z=m[x];
            s=s-z*x+z*y;
            m[x]=0;
            m[y]+=z;
            cout<<s<<endl;
            
        }
    return 0;
}

            
		
        
           
  

Measured memory_bytes: 10316
#%%
import collections

n = int(input())
x = [0] * n
y = [0] * n
for i in range(n):
    x[i], y[i] = map(int, input().split())

l = []
for i in range(n):
    for j in range(n):
        tmp = str(x[i]-x[j]) + ' ' + str(y[i]-y[j])
        l.append(tmp)

c = collections.Counter(l)
a = list(c.values())
#print(a)
a.sort(reverse=True)


if n == 1:
    print(1)
else:
    print(n-a[1])

Measured memory_bytes: 3700
import java.util.*;

public class Main{

    public static void main(String args[]){

        Scanner scan = new Scanner(System.in);
        Integer N = Integer.parseInt(scan.next());

        int counter = 0;

        for(int i=1;i<=N;i++){
            if(String.valueOf(i).length() % 2 == 1) counter++;
        }

        System.out.println(counter);

    }
}


Measured memory_bytes: 26196
#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;
const int INF = 1<<29;
struct elem {
    int node, cost;
};

bool operator >(const elem& x, const elem& y) {
    return tie(x.cost, x.node) > tie(y.cost, y.node);
}

int main()
{
    while (1) {
END:
        int n, m, l, k, a, h; cin >> n >> m >> l >> k >> a >> h;
        if (!n) break;
        vector<int> L;
        loop (l, i) {
            int v; cin >> v;
            L.push_back(v);
        }
        L.push_back(h);
        vector<vector<int>> d(n, vector<int>(n, INF));
        loop (k, i) {
            int x, y, t; cin >> x >> y >> t;
            d[x][y] = t;
            d[y][x] = t;
        }
        loop (n, j) loop (n, i) loop (n, k) {
            d[i][k] = min(d[i][k], d[i][j] + d[j][k]);
        }

        priority_queue<elem, vector<elem>, greater<elem>> Q;
        Q.push({ a, 0 });
        vector<int> vis(n);
        while (Q.size()) {
            elem crr = Q.top(); Q.pop();

            if (vis[crr.node]) continue;
            vis[crr.node] = 1;
            if (crr.node == h) {
                int ans = crr.cost;
                if (ans > m) ans += ans - m;
                cout << ans << endl;
                goto END;
            }
            for (int nxt_node : L) {
                int cost = d[crr.node][nxt_node];
                if (cost <= m) {
                    Q.push({ nxt_node, crr.cost + cost });
                }
            }
        }
        cout << "Help!" << endl;
    }
    return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

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

int dp[100010];

int main() {
	int n,m;
	cin >> n >> m;
	vector< vector<int> > e(n, vector<int>());
	vector<int> deg(n, 0);
	int x,y;
	rep(i,m) {
		cin >> x >> y;
		e[x-1].pb(y-1);
		deg[y-1]++;
	}
	vector<int> l;
	queue<int> s;
	rep(i,n) {dp[i] = -1e9;}
	rep(i,n) {
		if (deg[i] == 0) {
			s.push(i);
			dp[i] = 0;
		}
	}
	while(!s.empty()) {
		int n = s.front();
		s.pop();
		l.pb(n);
		for(auto k : e[n]) {
			deg[k]--;
			chmax(dp[k], dp[n]+1);
			if(deg[k] == 0) {
				s.push(k);
			}
		}
	}
	int ans = 0;
	rep(i,n) {
		chmax(ans, dp[i]);
	}
	cout << ans << endl;
	/*for(auto i : l) {
		cout << "v:" << i << endl;
		for(auto& j : e[i]) {
			cout << j;
		}
		cout << endl;
	}*/
  return 0;
}


Measured memory_bytes: 7164
import bisect
import sys
input = sys.stdin.readline


N = int(input())
A = list(map(int ,input().split()))
B = list(map(int ,input().split()))
C = list(map(int ,input().split()))
A.sort()
B.sort()
C.sort()
cnt = 0
for j in B:
    a_index = bisect.bisect_left(A, j)
    c_index = bisect.bisect_right(C, j)
    cnt += a_index*(N-c_index)
print(cnt)

Measured memory_bytes: 22720
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
class UnionFind{
public:
  vector<int> Parent;
  
  UnionFind(int N){
    Parent = vector<int>(N,-1);
  }
  
  int root(int A){
    if(Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }
  
  int size(int A){
    return -Parent[root(A)];
  }
  
  bool connect(int A, int B){
    A = root(A);
    B = root(B);
    if (A==B){
      return false;
    }
    
    if (size(A) < size(B)) swap(A,B);
    
    Parent[A] += Parent[B];
    Parent[B] = A;
    
    return true;
  }
};

int main(){
  int N, M; cin >> N >> M;
  vector<int> A(M), B(M);
  rep(i,M){
    cin >> A[i] >> B[i];
    A[i]--; B[i]--;
  }
  
  vector<ll> ans(M);
  ans[M-1] = (ll)N * (N-1) / 2;
  
  UnionFind Uni(N);
  
  for(int i = M-1; i >= 1; i--){
    ans[i-1] = ans[i];
    
    if(Uni.root(A[i]) != Uni.root(B[i])){
      ans[i-1] -= (ll)Uni.size(A[i])*Uni.size(B[i]);
      Uni.connect(A[i],B[i]);
    }
  }
  
  rep(i,M) cout << ans[i] << endl;
  
  return 0;
}

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

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

int main() {
    int n, k;
    cin >> n >> k;

    vector<long long int> x(n);
    rep(i, n) cin >> x[i];

    long long int dm = __LONG_LONG_MAX__;
    for (int i = 0; i < n - k + 1; i++) {
        dm = min(dm, abs(x[i]) + abs(x[i + k - 1] - x[i]));
        dm = min(dm, abs(x[i + k - 1]) + abs(x[i + k - 1] - x[i]));
    }

    cout << dm << endl;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main() {
  int n,l,maxl,all;
  int i;
  
  cin >> n;
  
  maxl=0;
  all=0;
  for(i=0;i<n;i++){
    cin >> l;
    
    if(maxl<l){
      all+=maxl;
      maxl=l;
    }else{
      all+=l;
    }
    
  }
  
  if(maxl<all){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int A, B, M;
    cin >> A >> B >> M;

    vector<int> vecA(A,0);
    vector<int> vecB(B,0);
    int ans=MOD;

    int min_=MOD;
    for(auto &a:vecA){
        cin >> a;
        min_=min(a,min_);
    }
    ans=min_;
    min_=MOD;
    for(auto &b:vecB){
        cin >> b;
        min_=min(b,min_);
    }
    ans+=min_;

    for(int i=0; i<M; i++){
        int x, y, c;
        cin >> x >> y >> c;
        x--;y--;

        ans=min(ans,vecA[x]+vecB[y]-c);
    }
    cout << ans << endl;

}

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

int main(){
    double w,h,x,y;
    cin >> w >> h >> x >> y;
    int ans;
    if(x == w/2 && y == h/2){
        ans = 1;
    }else{
        ans = 0;
    }
    double a = w*(h/2);
    cout << a << " " << ans << endl;
return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
long long k, a, b;
int main()
{
	std::ios::sync_with_stdio(false);
	cin >> k >> a >> b;
	if(a + 2 >= b)
	{
		cout << k + 1 << endl;
		return 0;
	}
	if(k <= a)
	{
		cout << k + 1 << endl;
		return 0;
	}
	long long x = k - a + 1;
	long long ans1 = a + x / 2 * (b - a) + x % 2;
	//cout << ans1 << endl;
	cout << max(ans1, k + 1) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    VI d(N); REP(i,N) cin >> d[i];
    sort(d.begin(), d.end());
    int ans = 0;

    REP(i,1e5+2){
    //REP(i,10){
        int lar = d.end()-lower_bound(d.begin(),d.end(),i);
        if(N/2 == lar) ans++;
    }
    cout << ans << endl;

}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

typedef long long s64;

inline int getint()
{
	static char c;
	while ((c = getchar()) < '0' || c > '9');

	int res = c - '0';
	while ((c = getchar()) >= '0' && c <= '9')
		res = res * 10 + c - '0';
	return res;
}

const int MaxN = 1000000;
const int MaxM = 1000000;

int n, m, a[MaxN + 1];

s64 f[MaxM + 3];

inline void add(int l, int r, int a, int b)
{
	int x = a + (r - l) * b;
	f[l + 0] += a, f[l + 1] -= a;
	f[l + 1] += b, f[r + 1] -= b;
	f[r + 1] -= x, f[r + 2] += x;
}

int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; ++i)
		a[i] = getint();

	for (int i = 2; i <= n; ++i)
	{
		int u = a[i - 0];
		int v = a[i - 1];

		if (u > v)
			add(v + 1, u, 0, 1);
		else if (v == m)
			add(1, u, 0, 1);
		else
		{
			int l = m - v;
			add(v + 1, m, 0, 1);
			add(1, u, l, 1);
		}
	}

	for (int i = 2; i <= m; ++i)
		f[i] += f[i - 1];
	for (int i = 2; i <= m; ++i)
		f[i] += f[i - 1];

	s64 res = -*max_element(f + 1, f + m + 1);
	for (int i = 2; i <= n; ++i)
		res += a[i] - a[i - 1] + (a[i] > a[i - 1] ? 0 : m);

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define ll long long
#define MAX_N 8
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;


int M[MAX_N][MAX_N];
int n,e;

int dfs_visit(int u,int color2[MAX_N]){
    bool all_visited = true;
    for(int i =0;i<n;i++){
        if(color2[i] == WHITE) {
            all_visited = false;
        }
    }
    if(all_visited) return 1;
    int res = 0;

    for(int v = 0; v < n; v++){
        if(M[u][v] == 0)continue;
        if(color2[v] == WHITE){
            color2[v] = GRAY;
            res += dfs_visit(v,color2);
            color2[v] = WHITE;
        }
    }
    color2[u] = BLACK;
    return res;
}

int dfs(){
    int color[MAX_N];
    for(int i=0; i < n ; i++) color[i] = WHITE;
    int u = 0;
    color[u] = GRAY;

    int ans = dfs_visit(u, color);
    return ans;
}

int main(){
    cin>>n>>e;
    for(int i =0;i<n;i++){
        for(int j=0;j<n;j++)M[i][j] = 0;
    }
    for(int i=0;i<e;i++){
        int u,v;
        cin>>u>>v;
        u--;
        v--;
        M[u][v] =M[v][u]= 1;
    }
    cout<< dfs() <<endl;
}


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

using namespace std;
using ll = long long;

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

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

  int sum = 0;
  rep(i, n) sum += w[i];

  int ans = 1001001001;
  for (int k = 1; k < n; ++k) {
    int l = 0;
    rep(i, k) l += w[i];
    int r = sum - l;
    ans = min(ans, abs(r - l));
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

class Solution {
public:
	void solve() {
		long long n;
		cin >> n;
		if (n == 2) {
			cout << 1 << endl;
			return;
		}
		long long ans = 2;
		for (long long i = 2; i * i <= n; i++) {
			if (n % i) continue;
			long long x = n;
			while (!(x % i)) x /= i;
			if ((x % i) == 1) ans++;
		}
		long long x = n - 1;
		for (long long i = 2; i * i <= x; i++) {
			if (x % i) continue;
			ans++;
			if (i != x / i) ans++;
		}
		cout << ans << "\n";

		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 #include<math.h>
 #include<iostream>
 using namespace std;
 
 int main()
 {
 	int a,b;
 	int kk;
 	while(cin>>a>>b)
 	{
 		if(b<10) kk=10;
		else if(b<100) kk=100;
		else kk=1000;
		long long int tot=a*kk+b;
		long long int s=(int)(sqrt(tot));
		if(s*s==tot) cout<<"Yes"<<endl;
		else cout<<"No"<<endl; 
	 }
 	return 0;
 }

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

using ll=long long;
ll N;
ll A,B,C;
using vll=vector<long long>;
vector<ll> v;
vector<ll> vA;
vector<ll> vB;
vector<ll> vC;
vector<ll> vD;
ll INF=1LL<<60;
ll ans=INF;



void dfs(vll &vA,vll &vB,vll &vC,vll &vD,vll v,ll &count,ll &ans,ll i){
  if (i==N){
    ll countA=10*(vA.size()-1);
    ll countB=10*(vB.size()-1);
    ll countC=10*(vC.size()-1);
    ll sumA=0; ll sumB=0; ll sumC=0; ll sumD=0;
    
    for (int i=0;i<vA.size();i++){
      sumA+=vA.at(i);
    }
    for (int i=0;i<vB.size();i++){
      sumB+=vB.at(i);
    }
    for (int i=0;i<vC.size();i++){
      sumC+=vC.at(i);
    }
    count=abs(sumA-A)+countA+abs(sumB-B)+countB+abs(sumC-C)+countC;
    if (count<ans && vA.size()>0 && vB.size()>0 && vC.size()>0)
      ans=count;
    return;
  }
  vA.push_back(v.at(i));
  dfs(vA,vB,vC,vD,v,count,ans,i+1);
  vA.pop_back();
  vB.push_back(v.at(i));
  dfs(vA,vB,vC,vD,v,count,ans,i+1);
  vB.pop_back();
  vC.push_back(v.at(i));
  dfs(vA,vB,vC,vD,v,count,ans,i+1);
  vC.pop_back();
  vD.push_back(v.at(i));
  dfs(vA,vB,vC,vD,v,count,ans,i+1);
  vD.pop_back();
  
  return;
}


int main(){
  cin >> N;
  cin >> A >> B >> C;
  v.resize(N);
  for (int i=0;i<N;i++){
    cin >> v.at(i);
  }
  ll count;
  dfs(vA,vB,vC,vD,v,count,ans,0);
  cout << ans << endl;
    
}

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


int main()
{
	long long int n, s, i, j, k, l, m, sum,N,a,b,ans,cc,cnt;
	sum = 0;
	cin >> a >> b;
	if (a + b == 15) {
		cout << "+" << endl;
	}
	else if (a*b == 15) {
		cout << "*" << endl;
	}
	else
		cout << "x" << endl;
	int flag = 0;
	




    return 0;
}



Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
#if DEBUG
            ReadLine();
#endif
        }

        void Solve(ConsoleInput cin)
        {
            int n = cin.ReadInt;
            long[] a = cin.ReadLongArray(n);
            long[] b = cin.ReadLongArray(n);
            List<long> cap = new List<long>();

            int ans = 0;
            long need = 0;
            for (int i = 0; i < n; i++)
            {
                long sub = b[i] - a[i];
                if (sub > 0)
                {
                    ans++;
                    need += sub;
                }
                else if (sub < 0)
                {
                    cap.Add(-sub);
                }

            }

            cap = cap.OrderByDescending(v => v).ToList<long>();


            foreach(long p in cap)
            {
                if (need <= 0)
                {
                    break;
                }

                need -= p;
                ans++;
            }

            if(need > 0)
                Console.WriteLine("-1");
            else
                Console.WriteLine(ans);
        }

        class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;

            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }

            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }

            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


Measured memory_bytes: 29280
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

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

	if (N % 2 == 0)
	{
		cout << N << endl;
	}
	else
	{
		cout << N * 2 << endl;
	}

	return 0;
}

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

int n;
int H[110];

int main(){
  cin >> n;
  rep(i, n) cin >> H[i];
  int max_h = H[0];
  int ans = 1;
  rep(i, n-1){
    if (H[i+1] >= max_h){
      max_h = H[i+1];
      ans ++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3592