akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <list>
#include <vector>
 
typedef long long i64;
 
i64 n;
 
std::list<int> a;
std::vector<int> b;
 
int main() 
{
  scanf("%lld", &n);
  ++n;
  int tot = 1;
  a.push_back(1);
  b.push_back(1);
  for (int i = 62 - __builtin_clzll(n); i >= 0; --i) {
    if (n >> i & 1) {
      ++tot;
      a.push_front(tot);
      b.push_back(tot);
    }
    if (i)
{
      ++tot;
      a.push_back(tot);
      b.push_back(tot);
    }
  }
  std::vector<int> ans(a.begin(), a.end());
  for (int i = 0; i < b.size(); ++i) ans.push_back(b[i]);
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); ++i) printf("%d ", ans[i]);
  return 0;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
from collections import deque
import sys
sys.setrecursionlimit(200000)


if __name__ == '__main__':

    n, m = [int(s) for s in input().split(" ")]
    M = [set() for j in range(n)]
    for _ in range(m):
        u, v = [int(s) for s in input().split(" ")]
        M[u].add(v)
        M[v].add(u)
        
    color = [0] * n
    def dfs(u, c):  # depth-first search
        color[u] = c
        for v in M[u]:
            if color[v] == 0:
                dfs(v, c)
    
    c = 1
    for u in range(n):
        if color[u] == 0:
            dfs(u, c)
            c += 1
    
    l = int(input())
    for _ in range(l):
        p, q = [int(s) for s in input().split(" ")]
        if color[p] == color[q]:
            print("yes")
        else:
            print("no")



Measured memory_bytes: 141736
/**
    BISMILLAH
    @Author : Arham
*/
#include <bits/stdc++.h>

using namespace std;

#define f first
#define s  second

void solve() {
    int n;
    cin >> n;
    vector<pair<int, int>> v;
    int count = false;
    for(int i = 0; i < n; ++i) {
         int a, b;
         cin >> a >> b;
         v.push_back({a, b});
    }
    vector<int> fin;
    for(int i = 0; i < n; i++) {
        int val = abs(v[i].f - v[i].s);
        fin.push_back(val);
    }
    for(int i = 0; i < n - 2; i++) {
        if(!fin[i] && !fin[i + 1] && !fin[i + 2]) {
            count = true;
            break;
        }
    }

    if(count)
        cout << "Yes" << endl;
    else cout << "No" << endl;

    return;
}

int main() {
    int t = 1;
    //cin >> t;
    while(t--)
        solve();

    return 0;
}


Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {

    private static Scanner sc;

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

    private void solve() {
        try {
            int N = sc.nextInt();
            int[] A = new int[N+1];

            A[0] = A[1] = 0;

            int[] buka = new int[N+1];

            for(int i=2; i<N+1; i++) {
                A[i] = sc.nextInt();
            }

            for(int i=2; i<N+1; i++) {
                buka[A[i]]++;
            }

            for(int i=1; i<N+1; i++) {
                System.out.println(buka[i]);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 68280
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vll;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvl;
const int mod = 1000000007;
const int N = 3e5;
vi g[N];
int a[N];
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);
ll f(ll n, ll d){
	ll ans = n/d;
	if(n%d) ans++;
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int i,n,k,j;
	cin>>n;
	ll a, b;
	cin>>a>>b;
	n--;
	ll M = 1e18;
	while(n--){
		ll x, y;
		cin>>x>>y;
		ll k = max(f(a,x), f(b,y));
		a = k*x, b = k*y;
		// cout<<k<<" "<<a<<" "<<b<<endl;
	}
	cout<<a+b<<endl;
	return 0;
} 

int mpow(int base, int exp) {
	base %= mod;
	int result = 1;
	while (exp > 0) {
	if (exp & 1) result = ((ll)result * base) % mod;
	base = ((ll)base * base) % mod;
	exp >>= 1;
	}
	return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
for(int v:g[u]){
	if (v == par) continue;
	dfs(v, u);
}
}

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

typedef long long ll;

int main(){
    string S;
    ll k;
    int i;
    
    cin >> S;
    cin >> k;

    for(i=0; i<S.size() && i<k; i++){
        if(S[i] == '1'){
            if(i == S.size()-1 || i == k-1){
                cout << 1 << endl;
            }
        }
        else{
            cout << S[i] << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int N, M, X[100]={}, A[100]={}, i, j;
    
    cin >> N;
    for(i=1; i<=N; i++){
        cin >> X[i];
    }
    cin >> M;
    for(j=1; j<=M; j++){
        cin >> A[j];
    }
    
    for(j=1; j<=M; j++){
        if((X[A[j]]!=2019) && (X[A[j]]+1)!=X[A[j]+1]){
            X[A[j]]++;
        }
    }
    
    for(i=1; i<=N; i++){
        cout << X[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b == c || a + c == b || b + c == a) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
def gcd(a, b):
    # `a >= b` is sopposed
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


def main():
    K = int(input())
    gcd_memo = [[0 for _ in range(K + 1)] for _ in range(K + 1)]
    for a in range(1, K + 1):
        for b in range(a, K + 1):
            left, right = max([a, b]), min([a, b])
            gcd_ab = gcd(left, right)
            gcd_memo[a][b] = gcd_ab
            gcd_memo[b][a] = gcd_ab
    answer = 0
    for a in range(1, K + 1):
        for b in range(1, K + 1):
            gcd_ab = gcd_memo[a][b]
            answer += sum(gcd_memo[gcd_ab])
    print(answer)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9512
#include<stdio.h>

int main(){
  	int arr[]= {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
   	scanf("%d",&k);
    printf("%d",arr[k-1]);
    return 0;
  
 return 0 ;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string n; cin>>n;
	if (n.back()=='2'||n.back()=='4'||n.back()=='5'||n.back()=='7'||n.back()=='9') cout<<"hon"<<endl;
	else if (n.back()=='0'||n.back()=='1'||n.back()=='6'||n.back()=='8') cout<<"pon"<<endl;
	else if (n.back()=='3') cout<<"bon"<<endl;
	else cout<<endl;
	return 0;
}


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

typedef long long ll;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<int> A(N),F(N);
    for (int i=0;i<N;i++) cin >> A[i];
    for (int i=0;i<N;i++) cin >> F[i];
    sort(A.rbegin(),A.rend()); //消化コストは降順
    sort(F.begin(),F.end()); //食べにくさは昇順
    //最小値Xが実現できるかを２分探索で求めるのを
    ll upper = 1e12;
    ll lower = -1;
    ll mid;
    while (upper - lower > 1){
        ll mid = (upper + lower)/2;
        ll m =0;
        for (int i=0;i<N;i++){
            m += max(0LL, A[i] - mid/F[i]);
        }
        if (m > K) {
            lower = mid;
        } else {
            upper = mid;
        }
    }
    cout << upper << endl;
    

    return 0;
}

Measured memory_bytes: 1792
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

double fact(double n){
  double ans = 1;
  FOR(i,1,n+1){
    ans *= i;
  }
  return ans;
}

signed main() {
  RAPID;
  // デフォルト変数定義
  double n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(n);
  Vd X(n);
  Vd Y(n);
  REP(i,n) IN2(X[i],Y[i]);
  double sum = 0;
  REP(i,n){
    FOR(j,i,n){
      sum += pow(pow(X[i]-X[j],2)+pow(Y[i]-Y[j],2),0.5) * 2 / n;
    }
  }
  FIX;
  OUT(sum);
}

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) const {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  combination c(n);
  mint ans;
  rep(i, n) { ans += c(i, k - 1) * a[i]; }
  reverse(a.begin(), a.end());
  rep(i, n) { ans -= c(i, k - 1) * a[i]; }
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1000000007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

vector<vector<long long>> G;
map<pair<long long, long long>, long long> mp;
vector<long long> edge_masks;

long long calc_mask(long long u, long long v){
    queue<vector<pair<long long, long long>>> que;
    que.push(vector<pair<long long, long long>>({make_pair(-1, u)}));

    vector<pair<long long, long long>> nodes;
    while(!que.empty()){
        auto q = que.front();
        long long prv = q.back().first;
        long long cur = q.back().second;
        que.pop();
        if(cur == v){
            nodes = q;
            break;
        }
        for(long long nxt : G[cur]){
            if(nxt == prv) continue;
            auto qq = q;
            qq.push_back(make_pair(cur, nxt));
            que.push(qq);
        }
    }
    long long mask = 0;
    for(long long i=1; i<nodes.size(); i++){
        long long from = nodes[i].first;
        long long to = nodes[i].second;
        mask |= (1LL<<mp[make_pair(from, to)]);
    }
    return mask;
}

int main(){
    long long N;
    cin >> N;
    G.resize(N);
    REP(i, N-1){
        long long a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
        mp[make_pair(a, b)] = mp[make_pair(b, a)] = mp.size()/2;
    }

    long long M;
    cin >> M;
    vector<pair<long long, long long>> uvs(M);
    REP(i, M){
        long long u, v;
        cin >> u >> v;
        u--; v--;
        uvs[i] = make_pair(u, v);
    }

    edge_masks.resize(M);
    REP(i, M){
        edge_masks[i] = calc_mask(uvs[i].first, uvs[i].second);
    }
    long long ans = 0;
    for(long long i=0; i<(1LL<<M); i++){
        long long mask = 0;
        for(long long j=0; j<M; j++){
            if(i&(1LL<<j)) mask |= edge_masks[j];
        }
        long long cnt = __builtin_popcountl(mask);
        long long rem = N-1-cnt;
        long long parity = (__builtin_popcountl(i)) % 2;
        parity = 1 - 2 * parity;
        ans += parity * (1LL<<rem);
    }
    cout << ans << endl;
    return 0;
}

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

#ifndef LOCAL
#define cerr dolor_sit_amet
#endif

#define mp make_pair
#define sz(x) ((int)((x).size()))
#define X first
#define Y second
#define all(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int , int > ipair;
typedef pair < ll , ll > lpair;
const int IINF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = numeric_limits<double>::infinity();
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int DX[] = { 1,  0, -1,  0,  1, -1,  1, -1};
const int DY[] = { 0,  1,  0, -1,  1, -1, -1,  1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll sqr(ll x) { return x*x; } ll sqr(int x) { return (ll)x*x; }
double sqr(double x) { return x*x; } ld sqr(ld x) { return x*x; }
mt19937 mmtw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }

template<typename T> T& updMin(T& a, T const& b) { if (b < a) a = b; return a; }
template<typename T> T& updMax(T& a, T const& b) { if (a < b) a = b; return a; }

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

const int N = 200179;

int n;
int a[N];

bool check(int k) {
    vector<ipair> s;
    s.push_back({a[0], 0});
    for (int i = 1; i < n; ++i) {
        int plen = a[i - 1];
        int clen = a[i];
        if (plen < clen) {
            if (s.back().Y == 0)
                s.back().X += clen - plen;
            else
                s.push_back({clen - plen, 0});
            continue;
        }
        while (plen > clen) {
            int r = min(plen - clen, s.back().X);
            s.back().X -= r;
            plen -= r;
            if (s.back().X == 0)
                s.pop_back();
        }
        if (s.back().Y == k - 1) {
            if (sz(s) == 1)
                return false;
            int cnt0 = s.back().X;
            s.pop_back();
            int ny = s.back().Y + 1;
            if (!--s.back().X)
                s.pop_back();
            if (sz(s) && s.back().Y == ny)
                ++s.back().X;
            else
                s.push_back({1, ny});
            if (sz(s) && s.back().Y == 0)
                s.back().X += cnt0;
            else
                s.push_back({cnt0, 0});
        } else {
            int ny = s.back().Y + 1;
            if (!--s.back().X)
                s.pop_back();
            if (sz(s) && s.back().Y == ny)
                ++s.back().X;
            else
                s.push_back({1, ny});
        }
    }
    return true;
}

int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    int l = 0, r = n;
    while (r - l > 1) {
        int mid = (l + r) / 2;
        if (check(mid))
            r = mid;
        else
            l = mid;
    }
    cout << r << "\n";

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    
    char c;
    cin>>c;
    string ans="consonant";
    char set[]={'a','i','u','e','o'};
    for(int i=0;i<sizeof(set)/sizeof(set[0]);i++){if(c==set[i])ans="vowel";}
    cout<<ans<<endl;
    
    return 0;
}

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

#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
const ll inf = 100100100100100;
const int mod = 1e9+7;

ll mod_pow(ll x, ll n, ll m){
    if(n== 0) return 1;
    ll res = mod_pow(x*x%m,n/2,m);
    if(n&1) res = res*x%m;
    return res;
}

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

    int m,n;
    cin >> m >> n;
    cout << mod_pow(m,n,mod) << endl;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const ll INF = 1e14;
const int MOD = 1000000007;

 
int main() {
  int n,k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) cin >> a.at(i);
  ll ans = INF;
  
  rep(i,pow(2,n)){
    int cnt = 0;
    rep(j,n){
      if(i >> j &1 ) cnt ++;
    }
    if(cnt < k) continue;
    ll now = 0;
    ll mx = 0;
    rep(j,n){
      if(i >> j &1 ){
        if(a.at(j) <= mx ){
          now += mx-a.at(j)+1;
          mx += 1;
        }
      }
      mx = max(a.at(j),mx);
    }
    ans = min(ans,now);
  }
  cout << ans << endl;
        
  return 0;
}




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

int main() {
	int N;
	cin >> N;
	vector<int> vec (N);
	for(int i = 0;i < N;i++){
		cin >> vec.at(i);
	}
	int M;
	cin >> M;
	for(int im = 0;im < M;im++){
		vector<int> dummy (N);
		for(int i = 0;i < N;i++){
		dummy.at(i) = vec.at(i);
		}
		int pos, change;
		cin >> pos >> change;
		dummy.at(pos - 1) = change;
		int all = 0;
		for(int i = 0;i < N;i++){
			all += dummy.at(i);
		}
		cout << all << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
int main() {
	int n, c;
	cin >> n >> c;
	ll tra[31][31] = {};
	rep(i, c) {
		rep(j, c) {
			cin >> tra[i][j];
		}
	}
	int x;
	vector<int>s, t, u;
	rep(i, n) {
		rep(j, n) {
			cin >> x; x--;
			if ((i + j) % 3 == 1)s.push_back(x);
			else if ((i + j) % 3 == 2)t.push_back(x);
			else u.push_back(x);
		}
	}
	ll mi = INF;
	ll sum[3][30] = {};
	rep(i, c) {
		rep(j, (int)s.size()) {
			sum[0][i] += tra[s[j]][i];
		}
		rep(j, (int)t.size()) {
			sum[1][i] += tra[t[j]][i];
		}
		rep(j, (int)u.size()) {
			sum[2][i] += tra[u[j]][i];
		}
	}
	rep(i, c) {
		rep(j, c) {
			rep(k, c) {
				if (i == j || j == k || k == i)continue;
				mi = min(mi, sum[0][i] + sum[1][j] + sum[2][k]);
			}
		}
	}
	cout << mi << endl;
	return 0;
}

Measured memory_bytes: 1520
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using static System.Console;
using static System.Math;


namespace CS_Contest
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            string str1 = Console.ReadLine();
            string[] str1s = str1.Split(' ');
            int a = int.Parse(str1s[0]);
            int b = int.Parse(str1s[1]);

            if (a > 8 || b > 8)
            {
                Console.WriteLine(":(");
            }
            else
            {
                Console.WriteLine("Yay!");
            }
        }

     
    }
}


Measured memory_bytes: 11092
#include "bits/stdc++.h"
using namespace std;
#define ASC(vec) vec.begin(), vec.end()			// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
const long long INF = 1LL << 60;
typedef long long ll;

int N, A, B, C;
int _min = 1000000000;
vector<int> l;

// 再帰
int dfs(int n, int a, int b, int c, int d) {
	if (n == N)
	{
		if (a == 0 || b == 0 || c == 0)
		{
			return 0;
		}
		int cost = abs(a - A) + abs(b - B) + abs(c - C);
		cost += d - 30;
		_min = min(_min, cost);
		return 0;
	}
	dfs(n + 1, a, b, c, d);
	dfs(n + 1, a + l[n], b, c, d + 10);
	dfs(n + 1, a, b + l[n], c, d + 10);
	dfs(n + 1, a, b, c + l[n], d + 10);
}

int main() {
	cin >> N >> A >> B >> C;
	l.resize(N);
	for (int i = 0; i < N; ++i) cin >> l[i];

	// 再帰する
	dfs(0, 0, 0, 0, 0);
	cout << _min << endl;
}

Measured memory_bytes: 256
n=int(input())
ab=[list(map(int,input().split())) for i in range(n)]
ab.sort(key=lambda x: x[1])
t,s=0,0
for a,b in ab:
  t=b
  s+=a
  if s<=t:
    pass
  else:
    print("No")
    exit(0)
print("Yes")



Measured memory_bytes: 53600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) stable_sort(a.begin(), a.end())
#define rsort(a) stable_sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define join(a, d) accumulate(a.begin() + 1, a.end(), a[0], [](string s, string t) {return s + d + t;})
#define all(a) a.begin(), a.end()
// #define __lcm(a, b) std::__detail::__lcm(a, b)
typedef long long ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int N;
  cin >> N;
  vector<vector<int>> T(N + 1, vector<int>(3, 0));
  rep(i, 1, N + 1) cin >> T[i][0] >> T[i][1] >> T[i][2];

  int t, x, y;
  rep(i, 1, N + 1) {
    t = T[i][0] - T[i-1][0];
    x = abs(T[i][1] - T[i-1][1]);
    y = abs(T[i][2] - T[i-1][2]);
    if ((t - x - y) % 2 || t < (x + y)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

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

int main(void){
    int a[3];
    rep(i, 3){
        cin >> a[i];
    }
    cout << a[2] << " " << a[0] << " " << a[1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  if(s[0] == s[1] && s[1] == s[2]){
    cout << "Yes" << endl;
  }else if(s[3] == s[1] && s[1] == s[2]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}  

Measured memory_bytes: 256
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<utility>
#include<algorithm>
using namespace std;

int main(void)
{
	int N, C;
	cin >> N >> C;

	typedef pair<int, int> State;
	vector<vector<State>> task(C, vector<State>());
	for(int i=0; i<N; i++){
		int s, t, c;
		cin >> s >> t >> c;

		task[c-1].push_back(make_pair(2*s-1, 2*t));
	}

	for(int i=0; i<C; i++){
		if(task[i].size() == 0)
			continue;

		sort(task[i].begin(), task[i].end());

		vector<State> v;
		v.push_back(task[i][0]);
		for(int j=1; j<task[i].size(); j++){
			if(task[i][j].first < v.back().second)
				v.back().second = task[i][j].second;
			else
				v.push_back(task[i][j]);
		}
		task[i] = v;
	}

	vector<int> table(2E5+5, 0);
	for(int i=0; i<C; i++){
		for(auto it=task[i].begin(); it!=task[i].end(); it++){
			table[it->first]++;
			table[it->second]--;
		}
	}
	
	int ret = 0;
	int sum = 0;
	for(auto it=table.begin(); it!=table.end(); it++){
		sum += *it;
		ret = max(ret, sum);
	}

	cout << ret << endl;

	return 0;
}


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

using namespace std;

typedef long long ll;

int main(){
	int n;
	cin >> n;
	ll sol = 0;
	for(int i = 0; i < n; i++){
		sol += (i + 1) * 1LL * (n - i);
	}
	for(int i = 0; i < n - 1; i++){
		int l, r;
		cin >> l >> r;
		int mini = min(l, r);
		int maxi = max(l, r);
		sol -= mini * 1LL * (n - maxi + 1);
	}
	cout << sol <<'\n';
}


Measured memory_bytes: 3600
n=int(input())
a=list(map(int,input().split()))
g=[0]*60
mod=10**9+7
for i in range(n):
    for j in range(60):
        if (a[i]>>j)&1==1:
            g[j]+=1

cnt=0
for i in range(60):
    now=g[i]
    cnt+=now*(n-now)*(2**i)
    cnt%=mod

print(cnt)

Measured memory_bytes: 122936
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<functional>
using namespace std;

#define INF 1<<21
#define MOD 1000000007

struct edge {
  int p, q;
};

int main(void) {
  int n, m, a;
  while (1) {
	vector <edge> V[1003];
	cin >> n >> m >> a;
	for (int i = 0; i < m; i++) {
	  V[i].clear();
	}
	if (n == 0 && m == 0 && a == 0) {
	  return 0;
	}
	int h, pp, qq;
	int maxh = 0;
	for (int i = 0; i < m; i++) {
	  cin >> h >> pp >> qq;
	  maxh = max(h, maxh);
	  struct edge e;
	  e.p = pp;
	  e.q = qq;
	  V[h].push_back(e);
	}

	for (int i = maxh; i >= 0; i--) {
	  for (auto x : V[i]) {
		if (x.p == a) {
		  a = x.q;
		}
		else if (x.q == a) {
		  a = x.p;
		}
	  }
	}
	cout << a << endl;
  }
}

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

int main() {
	int n;

	while (cin >> n) {
		int sum = n;
		int count = 0;
		for (int a = 9; a >= 0; a--, sum = n) {
			sum -= a;
			for (int b = 9; b >= 0; b--, sum = n-a) {
				sum -= b;
				for (int c = 9; c >= 0; c--, sum = n-a-b) {
					sum -= c;
					for (int d = 9; d >= 0; d--, sum = n-a-b-c) {
						sum -= d;
						if (sum == 0) {
							count++;
						}
					}
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 2988
import sys
N = int(input())
b = [int(i) for i in input().split()]

result = []

for j in range(0, N):
    b_length = len(b)
    for i in range(0, b_length):
        if b[b_length - 1 - i] == b_length - i:
            result.append(str(b[b_length - 1 - i]))
            b.pop(b_length - 1 - i)
            break

if len(result) < N:
    print(-1)
else:
    result.reverse()
    for r in result:
        print(r)


Measured memory_bytes: 3064
def p_b():
    x = [int(input()) for _ in range(5)]
    m = 10
    idx = -1
    for i, e in enumerate(x):
        tmp = int(str(e)[-1])
        if tmp == 0:
            continue
        if m > tmp:
            m = tmp
            idx = i
    ans = 0
    for i, e in enumerate(x):
        if i == idx:
            ans += e
        else:
            ans += (e + 9) // 10 * 10

    print(ans)
p_b()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

bool dp[100005];

int main() {
  int n,k; cin >> n >> k;
  vi a(n,0);
  rep(i,n) cin >> a.at(i);

  dp[0] = false;
  orep(i,k) {
    rep(j,n) if(i - a.at(j) >= 0 and !dp[i-a.at(j)]) dp[i] = true;
  }

  if(dp[k]) cout << "First" << endl;
  else cout << "Second" << endl;

  return 0;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n, a, b;
    cin >> n >> a >> b;
    if (a%2 == b%2) cout << abs(a-b)/2 << endl;
    else cout << min((a+b-1)/2, (2*n-a-b+1)/2) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <iterator>
#include <algorithm>
#include <map>
#include <string.h>
#include <vector>
#include <cmath>
#include <deque>
#include <iomanip>
#include <numeric>

using namespace std;
#define range(a) a.begin(), a.end()
#define rep(i, c) for(int i = 0; i < (int)c; i++)
typedef long long ll;

const string YES = "Yes";
const string NO = "No";
ll a, b, c;
ll ans;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);

  int n; cin >> n;
  string s; cin >> s;
  rep(i, n){
    if(s[i] == 'R') a++;
    else if(s[i] == 'G') b++;
    else c++;
  }

  ll ans = a*b*c;
  for (int i = 0; i < n; ++i) {
    for (int l = 1; i + l * 2 < n; ++l) {
      int j = i + l * 1,
          k = i + l * 2;
      if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) {
          --ans;
        }
      }
    }
    cout << ans << endl;



  return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 250000
ll MOD=1e9+7;



main(){
    int n=in();
    int a[N];
    rep(i,n)cin>>a[i+1];
    int b[N]={};
    rep3(i,n,1){
        int tmp=0;
        rep3(j,n/i,2){
            tmp+=b[j*i];
            //cout<<i<<" "<<tmp<<endl;
        }
        b[i]=(tmp+a[i])%2;
    }
    int m=0;
    rep2(i,1,n)m+=b[i];
    cout<<m<<endl;
    rep2(i,1,n)if(b[i])cout<<i<<endl;
}



Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

bool can(vi v, int x){
	//dbg(v, x);
	vi dp(20000);
	dp[10000] = 1;
	rep(i, v.size()){
		vi next(20000);
		rep(j, 20000) if(dp[j]){
			if(j + v[i] < 20000) next[j + v[i]] = 1;
			if(j - v[i] >= 0) next[j - v[i]] = 1;
		}
		dp = next;
	}
	return dp[10000 + x];
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	string in; cin >> in;
	int x, y; cin >> x >> y;
	int cnt = 0;
	for(int i = 0; i < in.size() && in[i] == 'F'; i++) cnt++;
	x -= cnt;
	in = in.substr(cnt);
	
	cnt = 0;
	bool toX = 1;
	vi a, b;
	rep(i, in.size()){
		if(in[i] == 'T'){
			if(cnt){
				if(toX) a.pb(cnt);
				else b.pb(cnt);
				cnt = 0;
			}
			toX ^= 1;
		}
 		else cnt++;
	}
	if(cnt){
		if(toX) a.pb(cnt);
		else b.pb(cnt);
		cnt = 0;
	}
	
	cout << (can(a, x) && can(b, y) ? "Yes" : "No") << endl;
	
	return 0;
}

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

int L[_MAX/2+2], R[_MAX/2+2];

void merge(int A[], int n, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    rep(i,n1) L[i] = A[left+i];
    rep(i,n2) R[i] = A[mid + i];
    L[n1] = R[n2] = SENTINEL;
    int i = 0, j = 0;
    for (int k = left; k < right; k++) {
        //Lの方がRより小さかったらAにはLを入れる
        if (L[i] <= R[j]) {
            A[k] = L[i++];
        //Rの方がLより小さかったらAにはRを入れる
        }else{
            A[k] = R[j++];
        }
    }
}

void mergeSort(int A[], int n, int left, int right) {
    if (left+1 < right) {
        int mid = (left + right)/2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

int main() {
    int n; cin >> n;
    int A[n];
    int arg_max = 0;
    int MAX = 0;
    rep(i,n) cin >> A[i];
    rep(i,n) {
        if (A[i] > MAX) {
            MAX = A[i];
            arg_max = i;
        }
    }
    mergeSort(A, n, 0, n);
    if (A[-1] == A[-2]) {
        rep(i,n) cout << MAX << endl;
    }else{
        rep(i,n) {
            if (i == arg_max) cout << A[n-2] << endl;
            else cout << MAX << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<algorithm>
#include<ctime>
using namespace std;
const int mod=1e9+7;
inline int read()
{
	int kkk=0,x=1;
	char c=getchar();
	while((c<'0' || c>'9') && c!='-')
		c=getchar();
	if(c=='-')
		c=getchar(),x=-1;
	while(c>='0' && c<='9')
		kkk=(kkk<<3)+(kkk<<1)+(c-'0'),c=getchar();
	return kkk*x;
}
int n,m,dp[3001][3001],a[3001],mem[3001][4];
inline int ksm(int A,int B)
{
	A%=mod;
	int C=1;
	while(B)
	{
		if(B%2)
			C=1ll*C*A%mod;
		A=1ll*A*A%mod;
		B/=2;
	}
	return C;
}
int main()
{
	n=read(),m=read();
	for(register int i=1;i<=n;++i)
		a[i]=read();
	int half=ksm(2,mod-2);
	for(register int i=1;i<=n;++i)
		for(register int j=1;j<=n;++j)
			dp[i][j]=(a[i]>a[j]);
	for(register int i=1;i<=m;++i)
	{
		int x=read(),y=read();
		if(x>y)
			swap(x,y);
		for(register int j=1;j<=n;++j)
		{
			mem[j][0]=dp[j][x];
			mem[j][1]=dp[x][j];
			mem[j][2]=dp[j][y];
			mem[j][3]=dp[y][j];
		}
		dp[x][y]=dp[y][x]=1ll*(mem[x][2]+mem[x][3])%mod*half%mod;
		for(register int j=1;j<=n;++j)
		{
			if(j==x || j==y)
				continue;
			dp[j][x]=dp[j][y]=1ll*(mem[j][0]+mem[j][2])%mod*half%mod;
			dp[x][j]=dp[y][j]=1ll*(mem[j][1]+mem[j][3])%mod*half%mod;
		}
	}
	int ans=0;
	for(register int i=1;i<=n;++i)
		for(register int j=i+1;j<=n;++j)
			ans=(ans+dp[i][j])%mod;
	printf("%lld\n",1ll*ans*ksm(2,m)%mod);
	return 0;
}

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

int main() {
    string stra;
    int x,y,z;
    cin >> x >> y;
    cin >> stra;
    y=y-1;
    z = (int)stra[y];
    z=z+32;
    stra[y]= (char)z;
    for(int i=0;i<x;i++){
        cout << stra[i];
    }
    cout << endl;
}

Measured memory_bytes: 3472
#include<bits/stdc++.h>
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;

typedef long long       ll;
typedef long double     ld;

typedef vector<int>     vi;
typedef vector<bool>    vb;
typedef vector<ll>      vll;
typedef vector<vi>      vvi;
typedef vector<vll>     vvll;
typedef vector<string>  vs;

typedef pair<int, int>  pii;
typedef pair<ll, int>   pli;
typedef pair<ll, ll>    pll;
typedef vector< pii >   vpi;
typedef vector< pll >   vpll;

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

#define pb           push_back
#define mod          1000000007
#define INF          1e17
#define mini         INT_MIN
#define maxo         INT_MAX
#define eb           emplace_back
#define ff           first
#define ss           second
#define re           return 
#define endl         "\n" 

#define all(c)       c.begin(),c.end()
#define be           begin()
#define en           end()
#define sz(x)        (ll)x.size()
#define mem(a,val)   memset(a,val,sizeof(a))
#define mk(x,y)      make_pair(x,y)
#define mid(s,e)     ((s)+((e)-(s))/2) 

#define fo(i,a,b)     for(ll i = (ll)(a); i <= (ll)(b); i++)
#define rf(i,a,b)    for(ll i = (ll)(a); i >= (ll)(b); i--)
#define read(a,n)    for(int i=0;i<n;i++)cin>>a[i];
#define show(a,n)    for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl;
#define p2(n)        (1LL << (n))
#define deb(x) cout <<#x << " = " << x << " | " << "LINE: "<<__LINE__<< endl;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void add(ll &x, ll y){ x += y; if(x>=mod) x %= mod; if(x<0) x = x%mod + mod; }

//============== *** START OF CODE ***




void solve()
{
    ll h,n;
    rd(h,n);
    ll a[n]; read(a,n);
    ll s = 0;
    fo(i,0,n-1)s+=a[i];
    if(s>=h)pp("Yes");
    else pp("No");   
    
}


void prep(){}

//=============== *** END OF CODE ***

int main(){
    speedio; cout<<fixed<<setprecision(12);

// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif

    prep();
    int t = 1;
    // cin >> t;
    while(t--)
        solve();

    cout<<"\n";
    return 0;
}

Measured memory_bytes: 4324
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <iomanip>
#include <stdlib.h>

using namespace std;

#define LL long long
#define FOR(i,l,r) for(int i = l; i <= r; ++i)
#define REP(i,l,r) for(int i = l; i < r; ++i)
#define pi pair<int,int>
#define mp make_pair

const int maxN = 1e5 + 11;
const LL oo = 1e17 + 11;

int N;
int A[maxN];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie();
    cout.tie();
    //
    //freopen("A.INP","r",stdin);
    //freopen("A.OUT","w",stdout);

    cin >> N;
    double x = N;
    double y = N/2 + N % 2;

    cout << setprecision(7) << fixed << y/x;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int n, m;
int main() {
	while (scanf("%d %d", &n, &m) != EOF) {
		int ans = 0;
		ans = (n-1) * (m-1);
		cout << ans << endl;
	}
	return 0;
} 

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

int main() {
    ll n;
    cin >> n;
    vector<int> a(n);
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        ll p;
        cin >> p;
        sum += p;
        a[i] = p;
    }
    ll ans = 9009009009009009009;
    ll now = 0;
    for (int j = 0; j < n - 1; ++j) {
        now += a[j];
        ans = min(ans, abs(2 * now - sum));
    }
    cout << ans << endl;
}


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

int main() {
  int H,W,N,a;
  cin >> H >> W >> N;
  a=max(H,W);
  if(N%a==0){
  cout << N/a << endl;
  }
  else{
  cout << N/a+1 << endl;
  }
}


Measured memory_bytes: 256
// ABC136B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;
int main()
{
	int N;
	cin >> N;

	int ans = 0;
	if (N<10)
	{
		ans = N;
	}
	else if (N<=99)
	{
		ans = 9;
	}
	else if (N<=999)
	{
		ans = N - 90;
	}
	else if (N<=9999)
	{
		ans = 909;
	}
	else if (N<100000)
	{
		ans = N - 9090;
	}
	else if (N==100000)
	{
		ans = 90909;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
N, M = list(map(int, input().split()))

product = [int(i) for i in input().split()]

# 投票数
votes = 1 / (4 * M)


# 総投票数
Total_votes = sum(product)

for p in product:
    if p / Total_votes >= votes:
        M -= 1
    if M == 0:
        break

if M <= 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 61832
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
constexpr int INF = 2e9 + 1;
int main() {
  int n, l, q;
  cin >> n;
  vector<int> x(n);
  rep(i,n) cin >> x[i];
  cin >> l >> q;
  vector<vector<int>> to(32, vector<int>(n, 0));
  x.emplace_back(INF);
  rep(i, n) {
    auto itr = lower_bound(x.begin(), x.end(), x[i] + l);
    if (*itr > x[i] + l) itr--;
    to[0][i] = itr - x.begin();
  }
  for (int i = 0; i < 31; i++) {
    for (int j = 0; j < n; j++) to[i + 1][j] = to[i][to[i][j]];
  }

  while (q--) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    if (a > b) swap(a, b);
    int res = 0;
    for (int i = 31; i >= 0; i--) {
      if (to[i][a] < b) {
        res += 1 << i;
        a = to[i][a];
      }
    }
    cout << res + 1 << endl;
  }
  return 0;
} 

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


//defines...
#define ll long long
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define in insert
#define pi 2*acos(0.0)1
#define srt(s) sort(s.begin(),s.end())
#define all(x) x.begin(),x.end()

const ll mod=1e9+7;
const ll MX=2e5+5;

//code goes from here...



int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);
#endif

    boost
    //---------------------------------
    int a,b;
    cin >> a >> b;
    int nd=log10(b)+1;
    
    while(nd--) a*=10;
    a+=b;
    int t=sqrt(a);
    if(t*t==a) cout << "Yes\n";
    else cout << "No\n";
    //---------------------------------
    
    return 0;
}


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

using namespace std;

int main()
{
	int n;cin >> n;
	vector<int> b(n);
	for(int i=0;i<n;i++)
	{
		cin >> b[i];
		if(b[i]>i+1)
		{
			cout<<-1<<endl;
			return 0;
		}
	}
	
	vector<int> ans(n);
	vector<int> bit(n,1);
	vector<bool> used(n,false);

	for(int i=0;i<n;i++)
	{
		int id=-1;
		for(int j=0;j<n;j++)
		{
			if(bit[j]==b[j] and used[j]!=true)
				id=j;
		}
//		cout << "ID : " << id << endl;
		if(id==-1)
		{
			cout<<-1<<endl;
			return 0;
		}
		ans[i]=b[id];
		used[id]=true;
		for(int j=id;j<n;j++)
			bit[j]++;

	}

	for(int i=0;i<n;i++)
		cout << ans[i] << endl;

}



	

Measured memory_bytes: 256