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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  ll n, m;
  cin >> n >> m;

  vector<ll> dp(n + 2);
  int ng;
  for (int i = 0; i < m; i++) {
    cin >> ng;
    dp[ng] = -1;
  }

  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    if (dp[i] == -1) continue;
    if (dp[i + 1] != -1) dp[i + 1] = (dp[i + 1] + dp[i]) % MOD;
    if (dp[i + 2] != -1) dp[i + 2] = (dp[i + 2] + dp[i]) % MOD;
  }

  if (dp[n] == -1 || dp[n] == 0)
    cout << 0 << endl;
  else
    cout << dp[n] << endl;
}


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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  vector<ll> ans(n);
  for (int i = 0; i < n; ++i) {
    ans[0] += (i % 2 == 0 ? a[i] : -a[i]);
  }
  for (int i = 0; i + 1 < n; ++i) {
    ans[i + 1] = a[i] * 2 - ans[i];
  }
  for (int i = 0; i < n; ++i) {
    cout << ans[i] << " ";
  }
  cout << "\n";
  return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int, int >
#define F first
#define S second
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;
/// khodaya komak kon
/// ya navid navid
/// ye tec khaphan ke yadam bemone : age jayi didi soale masir hamiltoni mikhad rasasho bokon yal oilery;
/// age ye ja mikhasti to dp az ozv i k ta entekhab koni bejash ye log bezan (nominal) hamoon 2**k va o 1 ent kon

///\\\///\\\///\\\\\\\\\\\\\\\\\///\\\///\\\///

const int N=5100,mod=1e9+7;
ll dp[N][N];

ll power(ll n, ll k)
{
    if (k==0)
    {
        return 1;
    }
    else
    {
        if (k%2==0)
        {
            ll x=power(n,k/2);
            return x*x%mod;
        }
        else
        {
            ll x=power(n,k/2);
            x=x*x%mod;
            return x*n%mod;
        }
    }
}
int32_t main()
{
    sync;
    ll n;
    cin >> n;
    string s;
    cin >> s;
    dp[0][0]=1;
    for (int i=0; i<N-2; i++)
    {
        for (int j=0; j<N-2; j++)
        {
            // cout << i << " " << j << endl;
            if (j==0)
            {
                dp[i+1][j]+=dp[i][j];
                dp[i+1][1]+=dp[i][j]*2;
                dp[i+1][j]%=mod;
                dp[i+1][j+1]%=mod;
            }
            else
            {
                dp[i+1][j-1]+=dp[i][j];
                dp[i+1][j+1]+=dp[i][j]*2;
                dp[i+1][j-1]%=mod;
                dp[i+1][j+1]%=mod;
            }

        }
    }
    ll z=power(2,s.size());

    cout << dp[n][s.size()]*power(z,mod-2)%mod;


}


















Measured memory_bytes: 203520
N = int(input())
T, A = [int(a) for a in input().split()]
H = [int(a) for a in input().split()]


diff = [abs(A - (T-h*0.006)) for h in H]

min_pos = 0
min = 1e5

for i, d in enumerate(diff):
    if min > d:
        min = d
        min_pos = i+1

print(min_pos)


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


int main() {
int n; cin >>n;
vector<ll> a(n);
rep(i,n) cin >> a[i];
ll ans = 10000000000;
vector<ll> s(n);
s[0] = a[0];
for(int i = 1;i<n;++i){
    s[i] = s[i-1]+a[i];
} 
rep(i,n-1){
    ll sun = s[i];
    ll ara = s[n-1]-s[i];
    ans = min (ans,abs(ara-sun));
}
cout << ans << endl;
}


Measured memory_bytes: 3328
#include<iostream>
using namespace std ;
int main( void )
{
	short n ;
	short i ,j ;
	short team[ 4 ] ;
	short cnt ;
	cin >> n ;
	short point[ n + 1 ] = { 0 } ;
	for( i = 0 ; i < n * ( n - 1 ) / 2 ; i++ )
	{
		cin >> team[ 0 ] >> team[ 2 ] >> team[ 1 ] >> team[ 3 ] ;
		if( team [ 1 ] == team[ 3 ] )
		{
			point[ team[ 0 ] ]++ ;
			point[ team[ 2 ] ]++ ;
		}
		else
		{
			point[ team[ 1 ] > team[ 3 ] ? team[ 0 ] : team[ 2 ] ] += 3 ;
		}
	}
	for( i = 1 ; i <= n ; i++ )
	{
		cnt = 1 ;
		for( j = 1 ; j <= n ; j++ )
		{
			if( i == j )
			{
				continue ;
			}
			if( point[ i ] < point[ j ] )
			{
				cnt++ ;
			}
		}
		cout << cnt << endl ;
	}
	return 0 ;
}

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

using namespace std;

const int MAX_N = 105;

int check [10];
vector<int> pos [MAX_N];

int main () {
  ios::sync_with_stdio(false);

  for (int i = 0; i < 9; i++) {
    int x;
    cin >> x;

    pos[x].push_back(i);
  }

  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;

    for (int u : pos[x]) {
      check[u] = 1;
    }
  }

  if ((check[0] && check[1] && check[2]) ||
      (check[3] && check[4] && check[5]) ||
      (check[6] && check[7] && check[8]) ||
      (check[0] && check[3] && check[6]) ||
      (check[1] && check[4] && check[7]) ||
      (check[2] && check[5] && check[8]) ||
      (check[0] && check[4] && check[8]) ||
      (check[2] && check[4] && check[6])) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    int n;
    cin >> n;
    int cnt, maxc = 0, ans = 1, t;
    for (int i = 1; i <= n; i++) {
        cnt = 0;
        t = i;
        while (t % 2 == 0) {
            t /= 2;
            cnt++;
        }
        if (maxc < cnt) {
            maxc = cnt;
            ans = i;
        }
    }
    cout << ans << endl;
}

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


int main() {
    double N,M;
    cin >> N >> M;

    vector<int> A(M);
    vector<int> B(M);

    for(int i = 0; i < M; i++){
        cin >> A.at(i) >> B.at(i);
        A.at(i)--;
        B.at(i)--;
    }

    vector<vector<int>> G(N,vector<int>(0));

    for(int i = 0; i < M; i++){
        G.at(A[i]).push_back(B[i]);
        G.at(B[i]).push_back(A[i]);
    }

    vector<int> Ans(N,-1);
    vector<bool> seen(N,false);
    queue<int> Stack;

    seen[0] = true;
    Stack.push(0);
    while(!Stack.empty()){
        int pos = Stack.front();
        Stack.pop();
        for(int i = 0; i < G[pos].size(); i++){
            if(Ans.at(G[pos].at(i))==-1){
                Ans.at(G[pos].at(i)) = pos;
            }
        }

        for(int i = 0; i < G[pos].size(); i++){
            if(!seen[G[pos][i]]){
                seen[G[pos][i]] = true;
                Stack.push(G[pos][i]);
            }
        }
    }

    cout << "Yes" << endl;


    for(int i = 1; i < N; i++){
        cout << Ans[i] + 1 << endl;
    }




}

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

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

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

vector<ll> G[100100];
ll ans;
ll D[100100];
ll D2[100100];

void dfs(int v, ll d){
    if(D[v] != -1) return;
    D[v] = d;
    for(auto&& n : G[v]){
        dfs(n, d+1);
    }
}

void dfs2(int v, ll d, int p){
    if(D2[v] != -1) return;
    D2[v] = d;

    if(p != -1)
        chmax(ans, min(D[v], D[p]));

    for(auto&& n : G[v]){
        if(D[n] < d+1) continue;
        dfs2(n, d+1, v);
    }
}

int main(){
    ll N, U, V;
    cin >> N >> U >> V;
    U--, V--;
    REP(i,N-1){
        ll a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    MEMS(D, -1);
    dfs(V, 0);

    MEMS(D2, -1);
    ans = 0;
    dfs2(U, 0, -1);

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


Measured memory_bytes: 10496
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var nextString func() string

func init() {
	nextString = newReadString(os.Stdin)
}

func main() {
	n := nextInt()
	l := []int{2, 1}

	for i := 2; i <= n; i++ {
		l[i%2] = l[0] + l[1]
	}
	fmt.Println(l[n%2])
}

func nextInt() (result int) {
	result, _ = strconv.Atoi(nextString())
	return
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
		}
		return r.Text()
	}
}


Measured memory_bytes: 640
h, w = map(int, input().split(" "))
a = [list(map(lambda x: int(x) % 2 == 1, input().split(" "))) for _i in range(h)]
move = []
for i in range(h):
    for j in range(w):
        if not a[i][j]:
            continue
        if j < w - 1:
            a[i][j + 1] ^= True
            move.append("{} {} {} {}".format(i + 1, j + 1, i + 1, j + 2))
        elif i < h - 1:
            a[i + 1][j] ^= True
            move.append("{} {} {} {}".format(i + 1, j + 1, i + 2, j + 1))
move.insert(0, str(len(move)))
print("\n".join(move))


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

int main() {
    ll x;
    cin >> x;
    ll ans;
    ll p=x/11;
    ll q=x-p*11;
    if(q==0) ans = p*2;
    else if(q<7) ans = p*2+1;
    else ans = p*2+2;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int x,y;
    vector<pair<int,int> > v;
    while(cin >> x >> y && (x != 0 || y != 0))
    {
        if(x > y)
        {
            swap(x,y);
        }
        v.push_back(make_pair(x,y));
    }
    for(int i = 0;i < v.size();i++)
    {
        cout << v[i].first << " " << v[i].second << "\n";
    }

    return 0;
}


Measured memory_bytes: 3124
from queue import Queue
H, W = map(int,input().split())
MAP = []
for _ in range(H):
    MAP.append(list(input()))
tx = [1,0,-1,0]
ty = [0,1,0,-1]
cnt = 0
INF = 10 ** 8
for i in range(H):
    for j in range(W):
        if MAP[i][j] == '#':
            cnt += 1
d = [[INF for i in range(W)] for j in range(H)]
q = Queue()
q.put([0,0])
d[0][0] = 1
flag = 1
while not q.empty():
    x, y = q.get()
    if x == H - 1 and y == W - 1:
        flag = 0
        break
    for i in range(4):
        nx = x + tx[i]
        ny = y + ty[i]
        if 0 <= nx <= H-1 and 0 <= ny <= W-1 and MAP[nx][ny] == '.' and d[nx][ny] == INF:
            d[nx][ny] = d[x][y] + 1
            q.put([nx,ny])
if flag:
    print(-1)
else:
    ans = H * W - d[H-1][W-1] - cnt
    print(ans)

Measured memory_bytes: 45416
from collections import Counter


def main():
    H, W = map(int, input().split())
    A = [input() for _ in range(H)]
    space = {}
    space[1] = (H % 2) * (W % 2)
    space[2] = (H % 2) * (W//2*2) + (W % 2) * (H//2*2)
    space[4] = (H//2*2) * (W//2*2)
    cnt = Counter("".join(A))
    for alpha in cnt:
        c = cnt[alpha]
        for k in (4, 2, 1):
            while c//k >= 1 and space[k]:
                y = min(c//k*k, space[k])
                space[k] -= y
                c -= y
        if c:
            print("No")
            return
    print("Yes")


if __name__ == "__main__":
    main()


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef long long ll;
typedef long long ll;
//typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e15;
const ll MINF = -10e10;
//const int INF = INT_MAX / 100;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("~/Downloads/02.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
const double PI = 3.14159265358979323846;

typedef pair<ll, ll> P;

struct Machine {
    ll begin, end;
};

class Conv {
    ll cursor = 0;
    map<ll, ll> to_short; // <original, small >
    map<ll, ll> to_long; // <small, original>

    std::set<ll> _prepare;

public:
    void set(ll original) {
        if (to_short.find(original) != to_short.end()) {
            return;
        }
        to_long[cursor] = original;
        to_short[original] = cursor;
        cursor++;
    }

    ll revert(ll after) {
        assert(to_long.find(after) != to_long.end());
        return to_long[after];
    }

    ll convert(ll original) {
        assert(to_short.find(original) != to_short.end());
        return to_short[original];
    }

    ll next() {
        return cursor;
    }

    void prepare(ll l) {
        _prepare.insert(l);
    }

    void build() {
        for (ll a : _prepare) {
            set(a);
        }
    }

};


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


    vector<Machine> machines;
    rep(i, n) {
        Machine m;
        ll x, l;
        cin >> x >> l;

        m.begin = x - l + 1;
        m.end = x + l;
        machines.push_back(m);

    }

//    Conv conv;
//    for (Machine &m : machines) {
//        conv.prepare(m.begin);
//        conv.prepare(m.end);
//    }
//    conv.build();
//
//
//    rep(i, n) {
//        machines[i].begin = conv.convert(machines[i].begin);
//        machines[i].end = conv.convert(machines[i].end);
//    }

    sort(machines.begin(), machines.end(), [](Machine &m, Machine &n) {
        if (m.end != n.end) return m.end < n.end;
        return m.begin > n.end;
    });

    ll start = LONG_LONG_MIN;
    int count = 0;
    for (Machine &m: machines) {
        if (m.begin > start) {
            count++;
            start = m.end;
        }
    }

    cout << count << endl;

}



Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

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

typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<pii> vpii;
typedef vector<vint> det1;
typedef vector<vpii> det2;

const ll MAXT = 5;
ll T[MAXT];

ll N;

int main()
{
    cin >> N;
    rep(i, MAXT) { cin >> T[i]; }

    ll t = T[0];
    rep(i, MAXT) { t = std::min<ll>(t, T[i]); }

    const ll t1 = N / t;
    const ll t2 = (N % t) == 0 ? 0 : 1;

    cout << 4 + (t1 + t2) << endl;

    return 0;
}


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

#define pb push_back
#define f first
#define s second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
int const mod = 1e9+7;
int power(int x, int y, int mod = 2e18){ int ans = 1;x %= mod;while(y){if(y&1)ans = (x * ans) % mod;x = (x * x) % mod;y >>= 1;}return ans;}
int gcd(int a , int b){if(a==0)return b;return gcd(b%a,a);}
bool ok(int a){
  return a<=12 && a>=1;
}
signed main() {
  IOS;
  string s;
  cin>>s;
  // cout <<s <<endl;
  int A = stoi(s.substr(0,2));
  int B = stoi(s.substr(2));

  if(ok(A)&& ok(B)){
     cout << "AMBIGUOUS\n"; 
  }
  if(ok(A)&&!ok(B)){
    cout << "MMYY";
  }
  if(!ok(A)&&ok(B)){
    cout <<"YYMM";
  }
  if(!ok(A)&&!ok(B)){
    cout <<"NA";}
  
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;

VI adj[112345];


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    REP(i,M){
        int a,b; cin >> a >> b;
        a--; b--;
        adj[a].eb(b);
        adj[b].eb(a);
    }
    int sa,sb;
    sa = 0;
    sb = adj[sa][0];

    VI ans1,ans2;
    ans1.eb(sa);
    ans2.eb(sb);
    int contain[112345] = {};
    contain[sa] = 1;
    contain[sb] = 1;
    int ta = sa;

    while(1){
        bool flag = 0;
        for(auto i : adj[ta]){
            if(contain[i] == 0){
                contain[i] = 1;
                ta = i;
                flag = 1;
                ans1.eb(i);
                break;
            }
        }
        if(!flag){
            break;
        }
    }
    ta = sb;

    while(1){
        bool flag = 0;
        for(auto i : adj[ta]){
            if(contain[i] == 0){
                contain[i] = 1;
                ta = i;
                flag = 1;
                ans2.eb(i);
                break;
            }
        }
        if(!flag){
            break;
        }
    }
    cout << ans1.size() + ans2.size() << endl;
    reverse(ans1.begin(),ans1.end());
    for(int i : ans1){
        cout << i+1 << " ";
    }
    for(int i : ans2){
        cout << i+1 << " ";
    }
    cout << endl;



}


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

int main()
{
	int no[26] = { 0 };
	while (true)
	{
		char c;
		c = cin.get();
		if (cin.eof()) break;
		int c2 = c;
		if ('A' <= c2 && 'Z' >= c2)
		{
			c2 = c + 32;
		}
		no[c2 - 97] ++;
	}
	for (int i = 0; i < 26; i++)
	{
		char a = 97 + i;
		//cout << "a";
		cout << a << " : " << no[i] << endl;
	}
}


Measured memory_bytes: 3116
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val N = sc.nextInt()
    val D = sc.nextLong()
    val A = sc.nextLong()
    val X = mutableListOf<Long>()
    val H = mutableListOf<Long>()
    (1..N)
            .map { Pair(sc.nextLong(), sc.nextLong()) }
            .sortedWith(Comparator { a, b -> if (a.first < b.first) -1 else 1 })
            .forEach { p -> X.add(p.first); H.add(p.second) }
    var ans = 0L
    var count = 0L
    val minus = Array(N + 1) { 0L }
    repeat(N) {
        count -= minus[it]
        val rem = (H[it] - count * A + A - 1) / A
        if (rem > 0) {
            var idx = X.binarySearch(X[it] + D * 2 + 1, it)
            if (idx < 0) {
                idx = idx.inv()
            }
            minus[idx] += rem
            count += rem
            ans += rem
        }
    }
    println(ans)
}


Measured memory_bytes: 130320
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> a(n),b(n),c(m),d(m);
    for(int i=0;i<n;i++)cin>>a[i]>>b[i];
    for(int i=0;i<m;i++)cin>>c[i]>>d[i];
    
    for(int i=0;i<n;i++){
        int p;
        long long md=1<<30;
        for(int j=0;j<m;j++){
            if(md>abs(a[i]-c[j])+abs(b[i]-d[j])){
                p=j+1;
                md=abs(a[i]-c[j])+abs(b[i]-d[j]);
            }
        }
        cout<<p<<endl;
    }
    
}

Measured memory_bytes: 256
def examA():
    N, M = LI()
    if N==M:
        print("Yes")
    else:
        print("No")
    return

def examB():
    A, B = LI()
    if A>B:
        ans = str(B)*A
    else:
        ans = str(A)*B
    print(ans)
    return

def examC():
    N = I()
    P = LI()
    minP = N+1
    ans = 0
    for i in range(N):
        if minP>P[i]:
            minP=P[i]
            ans +=1
    print(ans)
    return

def examD():
    N = I()
    ans = 0
    keep = [[0]*10 for _ in range(10)]
    for i in range(1,N+1):
        l = int(str(i)[0]); r = int(str(i)[-1])
        keep[l][r]+=1

    for i in range(1,N+1):
        l = int(str(i)[0])
        r = int(str(i)[-1])
        ans += keep[r][l]

    print(ans)
    return

def examE():
    def factorization(n):
        arr = []
        temp = n
        for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
            if temp % i == 0:
                cnt = 0
                while temp % i == 0:
                    cnt += 1
                    temp //= i
                arr.append([i, cnt])

        if temp != 1:
            arr.append([temp, 1])

        if arr == []:
            arr.append([n, 1])

        return arr
    N = I()
    A = LI()
    CA = 1
    d = defaultdict(int)
    for i in range(N):
        now = factorization(A[i])
        for key,j in now:
            d[key] = max(d[key],j)
    for key,i in d.items():
        CA *=key**i
        CA %=mod
    ans = 0
#    print(CA,d)
    for i in range(N):
        now = CA *pow(A[i],mod-2,mod)
        ans += now
        ans %=mod
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examE()

"""

"""

Measured memory_bytes: 47324
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#include<queue>
#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 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using vvii = vector<vector<int> >;
using vvll =  vector<vector<ll> >;

const ll inf = 1LL << 60;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    ll N;cin>>N;
    vector<ll> A(N);
    REP(i,N){
        cin >> A[i];
    }
    sort(ALL(A),greater<ll>());
    queue<ll> que;
    ll ans = 0;
    que.push(A[0]);
    //int itr = 1;
    for(int i = 1; i < N;i++){
        ll a = que.front(); que.pop();
        ans += a;
        REP(k,2){
            que.push(A[i]);
        }
    }
    cout<<ans<<endl;
}

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

int a[100][100];
int k[100][100];
signed main() {
	int b;
	while (cin >> b, b) {
		memset(k, 0, sizeof(k));
		for (int c = 0; c < b; c++) {
			for (int d = 0; d < b; d++) {
				cin >> a[c][d];
			}
		}
		for (int c = 0; c < b; c++) {
			int MAX = 0;
			for (int d = 0; d < b; d++) {
				MAX = max(MAX, a[d][c]);
			}
			for (int d = 0; d < b; d++) {
				if (a[d][c] == MAX)k[d][c]++;
			}
		}
		for (int c = 0; c < b; c++) {
			int MIN = 1 << 29;
			for (int d = 0; d < b; d++) {
				MIN = min(MIN, a[c][d]);
			}
			for (int d = 0; d < b; d++) {
				if (a[c][d] == MIN)k[c][d]++;
			}
		}
		for (int i = 0; i < b; i++) {
			for (int j = 0; j < b; j++) {
				if (k[i][j] == 2) {
					cout << a[i][j] << endl;
					goto l;
				}
			}
		}
		puts("0");
	l:;
	}
}

Measured memory_bytes: 3124
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N, L = rl()

aji = [0]*N

minaji = float('inf')
for i in range(N):
	aji[i] = L+i
	if abs(minaji) > abs(aji[i]):
		minaji = aji[i]
print(sum(aji)-minaji)


Measured memory_bytes: 68612
#include <iostream>

using namespace std;

int main()
{
	int a, b, c, d, area;
	cin >> a >> b >> c >> d;
	if (a * b > c * d)
	{
		area = a * b;
	}
	else
	{
		area = c * d;
	}
	cout << area; 
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(input()) for i in range(n)]
dict = {}
count = 0
for i in a:
  if i not in dict:
    dict[i] = 1
  elif i in dict:
    dict[i]+= 1

for i in set(a):
  if dict[i]%2!=0:
    count += 1
    
    
print(count)
    

Measured memory_bytes: 19852
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int G = 1000001;
int a, hv[1000001], m[200000];
vec<int> divz[1000001];

int main() {
    fast;
    memset(hv, 0, sizeof(hv));
    cin>>a;
    for(int q=0; q<a; q++){
        cin>>m[q];
        hv[m[q]]++;
    }
    for(int q=1; q<G; q++){
        for(int w=q; w<G; w+=q) if(hv[w]) divz[w].pb(q);
    }
    ll o = 0;
    for(int q=0; q<a; q++){
        int c = m[q], fl = 1;
        for(int d : divz[c]){
            if(d==c) fl &= hv[d]==1;
            else fl &= !hv[d];
        }
        o += fl;
    }
    cout<<o;
}

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

using namespace std;

int main (){
	long double x, y;

	cin >> x >> y;

	int n = ceil(log2l(y) - log2l(x)) + 1;

	long long int pot = 1;

	for(int i = 1 ; i < n ; i++){
		pot = pot * 2;
	}

	while(x * pot > y){
		pot = pot / 2;
		n--;
	}

	cout << n << '\n';

	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#define ll long long

int main(){
    ll a,b,k;
    scanf("%lld%lld%lld",&a,&b,&k);

    if(a>=k){
        a-=k;  
    }else{
        k-=a;
        a=0;
        b-=k; 
        if(b<0){
            b=0;
        }
    }

    printf("%lld %lld\n",a,b);

    return 0;
}

Measured memory_bytes: 128
import sys
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
tmp=1
while 1:
    if 2*n==(tmp+1)*tmp:
        break
    if 2*n<(tmp+1)*tmp:
        print("No")
        exit()
    tmp+=1
print("Yes")
print(tmp+1)
ans=[[] for i in range(tmp)]
a=1
for i in range(tmp):
    for j in range(i+1):
        ans[i].append(a)
        a+=1
# print(ans)
for i in range(tmp):
    b=str(tmp)
    flag=-1
    for j in range(tmp):
        if flag==-1:
            b+=" "+str(ans[i][j])
        else:
            b+=" "+str(ans[i+j-flag][i])
        if j+1==len(ans[i]):
            flag=j
    print(b)
b=str(tmp)
for i in range(tmp):
    b+=" "+str(ans[i][-1])
print(b)

Measured memory_bytes: 46684
import math

n,m = map(int,input().split())

nCount = 0
mCount = 0

def comb(a):
  return math.factorial(a) // (math.factorial(a - 2) * math.factorial(2))

if n >=2:
  nCount = comb(n)

if m >=2:
  mCount = comb(m)
  
print(nCount + mCount)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll h,w,n;cin >> h >> w >> n;
    vl ans(10,0);
    ans[0]=(h-2)*(w-2);
    map<pl,bool> mp;
    rep(i,n){
        ll y,x;cin >> y >> x;y--;x--;
        rep(j,9){
            ll ny=y+dy[j],nx=x+dx[j];
            if(ny<1||nx<1||ny>=h-1||nx>=w-1)continue;
            ll cnt=0;
            rep(k,9){
                ll nny=ny+dy[k],nnx=nx+dx[k];
                if(mp[{nny,nnx}])cnt++;
            }
            ans[cnt]--;ans[cnt+1]++;
        }
        mp[{y,x}]=true;
    }
    rep(i,10)cout << ans[i] <<endl;
}

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

int main() {
	int n;
	while(cin >> n, n) {
		int y;
		double mx = -1;
		int mxb;
		cin >> y;
		for(int i = 0; i < n; i++) {
			int b, r, t;
			cin >> b >> r >> t;
			double g;
			if(t == 1) {
				g = (1 + y * r / 100.0);
			}
			else {
				g = pow(1 + r / 100.0, y);
			}
			if(g > mx) {
				mx = g;
				mxb = b;
			}
		}
		cout << mxb << endl;
	}
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>

using namespace std;

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  string s1;
  int i;
  int count ;
  int min = N;

  s1 = S.substr(1);
  for(i = 0;i < s1.size();i++){
    if(s1[i] != 'W') count++;
  }
  min = count;
  for(i = 1;i < N;i++){
    if(S[i] == 'E') count--;
    if(S[i-1] != 'E') count++;
    if(min > count) min = count;
  }

  cout << min << endl;
}


Measured memory_bytes: 1028
def counting_sort(A, B, k):
    C = [0 for _ in xrange(k+1)]
    for a in A:
        C[a] += 1

    for i in xrange(1, k+1):
        C[i] = C[i] + C[i-1]

    for i in xrange(n-1, -1, -1):
        B[C[A[i]]-1] = A[i]
        C[A[i]] -= 1


n = int(raw_input())
A = map(int, raw_input().split())
B = [0 for _ in xrange(n)]

counting_sort(A, B, 10000)

print " ".join(map(str, B))

Measured memory_bytes: 202524
N = int(input())
S = input()
count = 0
for i in range(10):
    ind_i = S.find(str(i))
    if ind_i == -1 or ind_i >= N - 2:
        continue
    for j in range(10):
        ind_j = S.find(str(j), ind_i+1)
        if ind_j == -1 or ind_j == N - 1:
            continue
        for k in range(10):
            ind_k = S.find(str(k), ind_j+1)
            if ind_k != -1:
                count += 1
print(count)


Measured memory_bytes: 3060
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
n = int(input())
if n == 1:
    print(1)
    exit()
if n == 2:
    print(9)
    exit()
ans = 0
for i in range(1,n - 1):
    for j in range(i + 1, n ):
        for k in range(j + 1, n + 1):
            ans += gcd(i, j, k) * 6
for i in range(1, n):
    for j in range(i + 1, n + 1):
        ans +=math.gcd(i, j) * 6

for i in range(1, n + 1):
    ans += i
print(ans)

Measured memory_bytes: 69496
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
#define fin(ans) cout << (ans) << endl
const int INF = 1<<30;
const ll MOD = 1000000007;

int main() {
  string s,u;
  int N,M;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
        int a; cin >> a;
        N-=a;
  } 
  if(N>=0) cout << N << endl;
  else  cout << -1 << endl;
  
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <string>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

int main()
{
    int N,num;
	int so[10000]={};
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>num;
		so[num]++;
	}
	for(int j=0,i=0;j<N;i++){
		if(so[i]){
			if(j){
				for(int k=0;k<so[i];k++){
					cout<<' '<<i;
					j++;
				}
			}else{
				cout<<i;
				j++;
				for(int k=1;k<so[i];k++){
					cout<<' '<<i;
					j++;
				}
			}
		}
	}
	cout<<endl;
}

Measured memory_bytes: 1208
def examA():
    X, Y, Z = LI()
    X, Y = Y,X
    X,Z = Z, X
    print(X,Y,Z)
    return

def examB():
    N, M = LI()
    A = LI()
    need = (sum(A)-1)//(4*M) + 1
    ans = 0
    #print(need)
    for a in A:
        if a>=need:
            ans += 1
    if ans>=M:
        print("Yes")
    else:
        print("No")
    return

def examC():
    N, K = LI()
    ans = N%K
    if K-ans<ans:
        ans = K-ans
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examC()

"""

"""

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a;
  vector<int> l(k);
  vector<int> r(k);
  for(int i=0;i<k;i++){
    cin >> l[i] >> r[i];
  }
  vector<long long> ans(n,0);
  ans[0]=1;
  bool f=false;
  for(int i=0;i<k;i++){
    if(l[i]==1) f=true;
  }
  if(f) ans[1]=1;
  else ans[1]=0;
  for(int i=2;i<n;i++){
    ans[i]=ans[i-1];
    for(int j=0;j<k;j++){
      if(l[j]<=i) ans[i]=ans[i]+ans[i-l[j]];
      if(r[j]+1<=i) ans[i]=ans[i]+(998244353-ans[i-r[j]-1]);
      ans[i]=ans[i]%998244353;
    }
  }
  cout << ans[n-1] << endl;
  return 0;
}

Measured memory_bytes: 4844
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007



n, m = LI()
G = [[] for _ in range(n)]
for a, b, c in LIR(m):
    G[a - 1] += [(b - 1, c)]

# 負の閉路がなかったら高々n-1回で更新は終わるはずn回目に更新が起こったとしたら負の閉路がある。
def bellman_ford(G, s=0):
    n = len(G)
    dist = [-INF] * n
    dist[s] = 0
    v_nows = {s}
    for _ in range(n):
        v_changeds = set()
        for u in v_nows:
            for v, c in G[u]:
                if dist[u] + c > dist[v]:
                    dist[v] = dist[u] + c
                    v_changeds.add(v)
        v_nows = v_changeds
    dq = deque(v_nows)
    while dq:
        u = dq.popleft()
        if u == n - 1:
            return "inf"
        for v, c in G[u]:
            if dist[v] != INF:
                dist[v] = INF
                dq += [v]
    return dist[n - 1]



print(bellman_ford(G))



Measured memory_bytes: 84168
N, Ma, Mb = map(int, input().split())

items = []
mas = []
mbs = []
costs = []
for i in range(N):
  ma, mb, c = map(int, input().split())
  mas.append(ma)
  mbs.append(mb)
  costs.append(c)

max_cost = 5000
dp = [[[max_cost for k in range((N+1)*10)] for j in range((N+1)*10)] for i in range(N+1)]
dp[0][0][0] = 0

for i in range(N):
  for j in range(N*10):
    for k in range(N*10):
      if dp[i][j][k] == max_cost:
        continue
      if dp[i+1][j][k] > dp[i][j][k]:
        dp[i+1][j][k] = dp[i][j][k]
      if dp[i+1][j+mas[i]][k+mbs[i]] > dp[i][j][k] + costs[i]:
        dp[i+1][j+mas[i]][k+mbs[i]] = dp[i][j][k] + costs[i]
        
min_cost = max_cost
for wa in range(1, N*10):
  for wb in range(1, N*10):
    if (wa * Mb != wb * Ma):
      continue;
    if min_cost > dp[N][wa][wb]:
      min_cost = dp[N][wa][wb]

  
if min_cost == max_cost:
  print("-1")
else:
  print(min_cost)


Measured memory_bytes: 105564
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        String board = scanner.next();
        int stop = 0;
        char last = board.charAt(0);
        for (int i = 0; i < board.length(); i++) {
            if (last != board.charAt(i)){
                stop ++;
                last = board.charAt(i);
            }
        }

        System.out.println(stop);
    }
}


Measured memory_bytes: 13716
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
typedef unsigned long long ull;
typedef std::pair<ll, ll>P;

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool fl = true;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
std::string abc = "abcdefghijklmnopqrstuvwxyz";
struct edge { ll to, cost; };
double pai = 3.141592653589793;
std::vector<P>v[100010];
int d[100010];
bool flag[100010];

void dfs(int node, int t) {
	if (flag[node]) {
		if (d[node] != t) {
			std::cout << "No" << std::endl;
			exit(0);
		}
		return;
	}
	flag[node] = true;
	d[node] = t;
	for (int i = 0;i < v[node].size();i++)dfs(v[node][i].first, t + v[node][i].second);
}

int main() {
	int n, m;
	std::cin >> n >> m;
	for (int i = 0;i < m;i++) {
		ll l, r, c;
		std::cin >> l >> r >> c;
		v[l].push_back(P(r,c));
		v[r].push_back(P(l,-c));
	}
	for (int i = 1;i <= n;i++) {
		if (!flag[i])dfs(i, 0);
	}
	std::cout << "Yes" << std::endl;
}

Measured memory_bytes: 16128
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

S = s()
T = s()
cnt = 0
for i in range(len(S)-len(T)+1):
    cnty = 0
    for j in range(len(T)):
        if S[i+j] == T[j]:
            cnty += 1
    cnt = max(cnt,cnty)
print(len(T)-cnt)

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

pll X[100005];

int main()
{
    ll N;
    cin >> N;
    REP(i, N)
    {
        cin >> X[i].first;
    }
    REP(i, N)
    {
        cin >> X[i].second;
    }
    sort(X, X + N, [](pll a, pll b) { return a.second - a.first < b.second - b.first; });

    ll s = 0;
    REP(i, N)
    {
        ll t = X[i].second - X[i].first;
        if (t < 0)
        {
            s += abs(t);
            continue;
        }

        s -= t / 2;
        if (s <= 0)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 384
n = int(input())
b = [int(i) for i in input().split()]
dp = [0] * n
dp[0] = b[0]
for i in range(n):
    targets = []
    if i < n - 1:
        targets.append(b[i])
    if i - 1 >= 0:
        targets.append(b[i - 1])
    dp[i] = min(targets)
print(sum(dp))

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

int main() {
    int x, y;
    cin >> x >> y;
    for(int i = 0; i <= 100; i++) {
        for(int j = 0; j <= 100; j++) {
            if(i + j == x and 2 * i + 4 * j == y) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3588
#include<iostream>
 
using namespace std;
 
const int M = 1e9 + 7;
long long n;
long long k1, k2, k3;
 
int main()
{
    scanf("%lld", &n);
    k1 = k2 = k3 = 1;
    for(int i = 0; i < n; i ++ )
    {
        k1 *= 10;
        k1 %= M;
        k2 *= 9;
        k2 %= M;
        k3 *= 8;
        k3 %= M;
    }
    k1 = k1 - k2 - k2 + k3;
    k1 = k1 % M;
    k1 = (k1 + M) % M;
    printf("%d", k1);
    return 0;
}

Measured memory_bytes: 3860
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    long long n, a;
    cin >> n >> a;
    vector<long long> x(n);
    if (a == 0)
    {
        cout << 1 << endl;
        return 0;
    }
    for (int i = 0; i < n; ++i)
        cin >> x[i];
    long long ans = 0;
    vector< vector<long long> > dp;
    for (int i = 0; i <= n; ++i)
        dp.push_back(vector<long long>(a * n + 1, 0));
    dp[0][0] = 1;
    for (int i = 0; i < n; ++i)
    {
        for (int amount = n; amount > 0; --amount)
            for (int sum = 0; sum <= a * n; ++sum)
            {
                if (sum >= x[i])
                    dp[amount][sum] += dp[amount - 1][sum - x[i]];
            }
    }
    for (int i = 1; i <= n; ++i)
    {
        ans += dp[i][a * i];
    }
    cout << ans << endl;
    //system("pause");
    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

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

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    int n, m; cin >> n >> m;
    pair< int, vector<int> > d[110][110];
    rep(i,0,n) rep(j,0,n) d[i][j] = make_pair(INF, vector<int>{});
    int a, b, c;
    rep(i,0,m) {
        cin >> a >> b >> c; a--; b--;
        d[a][b] = make_pair(c, vector<int>{i});
        d[b][a] = make_pair(c, vector<int>{i});
    }

    int V = n;
    rep(k,0,V) rep(i,0,V) rep(j,0,V) {
        if(d[i][k].fr != INF && d[k][j].fr != INF) {
            if(d[i][j].fr > d[i][k].fr + d[k][j].fr) {
                vector<int> temp = d[i][k].sc;
                temp.insert(temp.begin(), d[k][j].sc.begin(), d[k][j].sc.end());
                d[i][j] = make_pair(d[i][k].fr + d[k][j].fr, temp);
            }
        }
    }
    set<int> s;
    rep(i,0,V) rep(j,0,V) {
        rep(k,0,d[i][j].sc.size()) {
            // cout << d[i][j].sc[k] << endl;
            s.insert(d[i][j].sc[k]);
        }
    }
    cout << m - s.size() << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
long mid;
int main(){
    int n,k; cin>>n>>k;
    vector<long> h(n);
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    sort(begin(h),end(h));
    vector<long> imos(n,0);
    for(int i=1;i<n;i++){
        imos[i-1]+=abs(h[i]-h[i-1]);
        if(i-2+k<n)
            imos[i-2+k]+=abs(h[i]-h[i-1])*-1;
    }
    for(int i=1;i<n;i++)
        imos[i]+=imos[i-1];
    //for(auto x:imos)
    //   cout<<x<<endl;
    unsigned long m=-1,mi;
    for(int i=k-2;i<n-1;i++){
        if(imos[i]>=0&&imos[i]<m){
            m=imos[i];
            mi=i;
        }
    }
    //cout<<mi<<endl;
    unsigned long max=0,min=-1;
    for(int i=mi+2-k;i<mi+2;i++){
        if(h[i]<min)
            min=h[i];
        if(h[i]>max)
            max=h[i];
    }
    cout<<max-min;
}

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

using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void debugF(ostream &os) {os << endl;}
template <typename Head, typename... Tail>
void debugF(ostream &os, Head H, Tail... T) { os << " " << H; debugF(os, T...); }
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debugF(cout, __VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); os << (i>0 ? " ":"") << v[i++]); return os;}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    vi v(5);
    cin >> v;
    int i;
    for(i=0;i<5;i++) if(v[i] == 0) break;
    cout << (i+1) << "\n";
    return 0;
}

Measured memory_bytes: 3608