akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys

def solve(N: int, A: "List[int]"):
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)

if __name__ == '__main__':
    
    N = int(input())
    A = [0]*N
    max_a1 = 0
    max_a2 = 0
    for i in range(N):
        a = int(input())
        if a > max_a1:
            max_a1 ,max_a2 = a, max_a1
        elif a > max_a2:
            max_a2 = a
        A[i] = a

    for i in range(N):
        print(max_a1) if A[i] < max_a1 else print(max_a2)

Measured memory_bytes: 12508
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin>>
using namespace std;
const int INF = 1001001001;

int main()
{
    string s,ans="";
    in s;
    for(int i=0;i<s.size();i++)
    {
        if(i%2==0)ans+=s[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const unsigned int m = 1000000007; 

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

	int n; cin >> n;
	// int arr[n];
	unordered_map<int, int> m;
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		int ele; cin >> ele;
		m[ele]++;
		sum += ele;
	}

	int q; cin >> q;
	while (q--) {
		int a, b;
		cin >> a >> b;

		int count = m[a];
	
		m[a] = 0;
		m[b] += count;
		ll new_sum = sum + (b-a)*count;
		cout << new_sum << endl;
		sum = new_sum;

	}


}




Measured memory_bytes: 7116
#include <stdio.h>

int main(void){
  
  while(1){
    int month,day,week,sum,i;
    int data[]={0,31,29,31,30,31,30,31,31,30,31,30};
    char week_tmp[7][20]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};

    scanf("%d %d",&month,&day);
    if(month==0)break;

    sum=0;
    for(i=0;i<month;i++){
      sum+=data[i];
    }
   
    week=(sum+day)%7;

    printf("%s\n",week_tmp[week]);
  }
  return(0);
}

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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;


int main() {
    int n, k; cin >> n >> k;
    int dislike = 0;
    rp(i, 0, k){
        int d; cin >> d;
        dislike += (1<<d);
    }
    
    rp(i, n, 100000){
        int c = i;
        int flag = true;
        while(c > 0){
            int m = c%10;
            if(dislike & (1<<m)) flag = false;
            c/=10;
        }
        if(flag) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;
const ll mod = 1e9+7;

ll powmod(ll x,ll n){
    if(!n)return 1;
    if(n%2)return x *powmod(x*x%mod,n/2)%mod;
    return powmod(x*x%mod,n/2)%mod;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,a,b; cin >> n >> a >> b;
    ll nCa = 1,nCb = 1;
    rep(i,a)nCa = (nCa*(n-i)%mod)*powmod(i+1,mod-2)%mod;
    rep(i,b)nCb = (nCb*(n-i)%mod)*powmod(i+1,mod-2)%mod;
    cout << (powmod(2,n) - nCa - nCb + 2*mod -1)%mod << endl;
}

Measured memory_bytes: 256
S=input()
if "AA" in S:
    print("NO")
elif "KIH" not in S:
    print("NO")
else:
    s=""
    for i in range(len(S)):
        if S[i]=="A":
            s+=""
        else:
            s+=S[i]
    if s=="KIHBR":
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 3060
fn main() {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();

    let input: i32 = input.trim().parse().unwrap();

    let answer = if input < 1200 {
        "ABC"
    } else if input < 2800 {
        "ARC"
    } else {
        "AGC"
    };

    println!("{}", answer);
}


Measured memory_bytes: 4352
nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1]

A, B = map(int, input().split())

if nums.index(A) > nums.index(B):
    print("Alice")
elif nums.index(A) < nums.index(B):
    print("Bob")
else:
    print("Draw")

Measured memory_bytes: 3060
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var [n,a,b,c] = nexts(4);
  var s = nexts(n,1);
  var ans = [];
  var NN = "No";
  for(var i = 0; i < n-1; i++){
    if(s[i] === "AB"){
      a--,b--;
      if(a < 0 && b < 0)return NN;
      if(a > b || (s[i+1] !== "AC" && a >= 0)){
        b += 2;
        ans.push("B");
      }else{
        a += 2;
        ans.push("A");
      }
    }
    if(s[i] === "AC"){
      a--,c--;
      if(a < 0 && c < 0)return NN;
      if(a > c || (s[i+1] !== "AB" && a >= 0)){
        c += 2;
        ans.push("C");
      }else{
        a += 2;
        ans.push("A");
      }
    }
    if(s[i] === "BC"){
      c--,b--;
      if(c < 0 && b < 0)return NN;
      if(c > b || (s[i+1] !== "AC" && c >= 0)){
        b += 2;
        ans.push("B");
      }else{
        c += 2;
        ans.push("C");
      }
    }
  }
  if(s[n-1] === "AB"){
    a--,b--;
    if(a < 0 && b < 0)return NN;
    if(a > b)ans.push("B");
    else ans.push("A");
  }else if(s[n-1] === "AC"){
    a--,c--;
    if(a < 0 && c < 0)return NN;
    if(a > c)ans.push("C");
    else ans.push("A");
  }else{
    b--,c--;
    if(b < 0 && c < 0)return NN;
    if(b > c)ans.push("C");
    else ans.push("B");
  }
  console.log("Yes");
  return ans.join("\n");
}

Measured memory_bytes: 44424
# -*- coding: utf-8 -*-

import sys
import math
from decimal import Decimal, ROUND_DOWN


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (x, n) = [int(e) for e in lines[0].split(' ')]
    if n >= 1:
        p = [int(e) for e in lines[1].split(' ')]
    else:
        p = []

    return (x, n, p)


def solve(x, n, p):
    
    pp = set(p)
    result = None
    for i in range(0, 99):
        xa = x - i
        xb = x + i

        if xa in pp:
            pass
        else:
            result = xa
            break

        if xb in pp:
            pass
        else:
            result = xb
            break


    return result
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

int main(){
    lint a,v,b,w,t;
    cin>>a>>v>>b>>w>>t;
    if(v <= w){
        out("NO"); return 0;
    }
    lint s = (abs(a-b)+(v-w)-1)/(v-w);
    if(s <= t) out("YES");
    else out("NO");
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cerr<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> inline bool chmax(t&a,u b){if(a<b){a=b;return true;}return false;}
template<class t,class u> inline bool chmin(t&a,u b){if(b<a){a=b;return true;}return false;}

int main(){
    int k;cin >> k;
    string s;cin >> s;
    if(s.size() <= k){
        cout << s << endl;
    }else{
        cout << s.substr(0,k) << "...\n";
    }
}

Measured memory_bytes: 3632
N = int(input())
a = input().split()

a = [float(i) for i in a]#リストの型変換

i = 0
sum = 0
for a_f in a:
    a[i] = 1 / a_f
    sum = sum + a[i]
    i += 1

sum = 1 / sum

print(sum)

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

int cmpfunc (const void * a, const void * b) {
   return ( *(int*)a - *(int*)b );
}

int main(void){
     int n,i,c=0,k=0,j,m[100100]={0};
    long long int a[100090];

   scanf("%ld",&n);

    for(i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }

    qsort(a, n, sizeof(long long int), cmpfunc);

    a[n]=-5;

    for(i=0;i<n;i++){
        if(a[i]==a[i+1]){
            m[k]++;
        }
        else{
            k++;
        }
    }

    for(i=0;i<k;i++){
        if(m[i]%2==0){c++;}
        else if(k==n){c=k;break;}
    }

    printf("%ld",c);

    return 0;
}
/*for(j=0;j<i;j++){
            if(a[j]==a[i]){
                n--;
                k=k-2;
                if(i<n){
                    scanf("%lld",&a[j]);
                    n--;
                }
                i--;
            }
       }*/


Measured memory_bytes: 3360
//c++ テンプレ
#include<bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
#define sort(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)



priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

vector<llint>f;

void solve(){
    int n;
    cin >> n;
    f.resize(n+1);
    f[0]=1;
    f[1]=1;
    rep(i,2,n+1)f[i]=f[i-1]+f[i-2];
    cout << f[n] << endl;
}

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






Measured memory_bytes: 3096
#include <iostream>
using namespace std;
const int maxn = 3e5 + 10;
const int mod = 1e9 + 7;

unsigned long long a [ maxn ] , b [ maxn ] , n , sum;
/*
inline long long read ( )
{
	int s = 0 , t = 1; char ch = getchar ( );
	while ( ch < '0' || ch > '9' ) { if ( ch == '-' ) t = -1; ch = getchar ( ); }
	while ( ch >= '0' && ch <= '9' ) { s = s * 10 + ch - '0'; ch = getchar ( ); }
	return s * t;
}*/

int main ( void )
{
	ios::sync_with_stdio ( false );
	cin.tie ( 0 );
	cin >> n;
	for ( int i = 1 ; i <= n ; i++ ) cin >> a [ i ];
	for ( int i = 1 ; i <= n ; i++ ) {
		for ( int j = 0 ; j < 60 ; j++ ) {
			if ( a [ i ] >> j & 1 ) {
				b [ j ]++;
			}
		}
	}
	for ( int i = 1 ; i <= n ; i++ ) {
		for ( int j = 0 ; j < 60 ; j++ ) {
			if ( a [ i ] >> j & 1 ) { 
				b [ j ]--;
			}
		}
		for ( int j = 0 ; j < 60 ; j++ ) {
			if ( a [ i ] >> j & 1 ) {
				sum = ( sum + ( 1LL << j ) % mod * ( n - b [ j ] - i ) % mod ) % mod; // 1遇到0，0遇到1，自己不能遇自己，cao，我是脑瘫吧
			} else {
				sum = ( sum + ( 1LL << j ) % mod * b [ j ] % mod ) % mod;
			}
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 2944
x = int(input())
y = [int(i) for i in input().split()]

cnt = 0
tmp = 0
ans = []

for i in range(x):
  if i != 0 and i != x-1:
    if tmp >= y[i]:
      cnt += 1
    else:
      ans.append(cnt)
      cnt = 0
  if i == x-1:
    if tmp >= y[i]:
      cnt += 1
      ans.append(cnt)
    else:
      ans.append(cnt)
  tmp = y[i]

print(max(ans))

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

int main(){
    long N;
    long A[110];
    cin >> N;

    for(int i = 0; i < N; ++i) cin >> A[i];
    long min = A[0];
    long max = A[0];

    for(int i = 1; i < N; ++i){

        if(A[i] > max) max = A[i];
        if(A[i] < min) min = A[i];
    }
    cout << max - min << endl;
}

Measured memory_bytes: 256
#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;

const int mod = 1e9 + 7;
map<vi, int> dp, dp2;

int pw2(int x){
	int res = 1;
	for(ll m = 2; x; x /= 2){
		if(x & 1) res = res * m % mod;
		m = m * m % mod;
	}
	return res;
}
vector<vi> children(const vi &h){
	int mn = *min_element(all(h)), n = h.size();
	vector<vi> cs;
	vi tmp;
	rep(i, n){
		if(h[i] > mn) tmp.pb(h[i] - mn);
		if(h[i] == mn || i == n-1){
			if(tmp.size()) cs.pb(tmp);
			tmp.clear();
		}
	}
	return cs;
}
int rec2(const vi &h){
	if(dp2.count(h)) return dp2[h];
	int &res2 = dp2[h], mn = *min_element(all(h));
	res2 = pw2(mn);
	for(vi &c : children(h)) res2 = (ll)res2 * rec2(c) % mod;
	return res2;
}
int rec(const vi &h){
	if(dp.count(h)) return dp[h];
	int &res = dp[h];
	int mn = *min_element(all(h)), rem = count(all(h), mn);
	
	//パターン1 i列目とi+1列目が反転でも同じでもいい
	//パターン2 i列目とi+1列目が反転
	int res1 = pw2(rem);
	int res2 = (pw2(mn) + mod - 2) % mod;
	for(vi &c : children(h)){
		res1 = res1 * (ll)(rec(c) + rec2(c)) % mod;
		res2 = res2 * (ll)rec2(c) % mod;
	}
	return res = (res1 + res2) % mod;
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n;
	vi h(n); rep(i, n) cin >> h[i];
	cout << rec(h) << endl;
	
	return 0;
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  
  int A[N];
  for(int i = 0; i < N; i++){
    cin >> A[i];
      if(A[i] % 2 == 0){
        if(A[i] % 3 != 0 && A[i] % 5 != 0){
        cout << "DENIED" << endl;
        return 0;
        }
      }
  }
  
  cout << "APPROVED" << endl;
  return 0;
}
  






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

using namespace std;



string s;

int n;

bool pal(int st, int dr)
{
    for(int i = st, j = dr; i < j; i ++, j --)
    {
        if(s[i] != s[j])
            return 0;
    }

    return 1;
}

int main()
{
    long double x;
    cin >> x;
    x = x / 3;
    x = x * x * x;

    cout << fixed << setprecision(10) << x << "\n";

    return 0;
}


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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    ll res = 0;
    REP(i, s.length())
    {
        if (s[i] == '+')
        {
            res++;
        }
        else
        {
            res--;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (ll (i) = (s); (i) < (e); ++(i))
#define per(i, s, e) for (ll (i) = (s); (i) >= (e); --(i))
#define all(x) x.begin(),x.end()
 
int main(void) {
    ll n, m; cin >> n >> m;
    if (n <= m) cout << "Yes" << endl;
    else cout << "No" << endl;

}


Measured memory_bytes: 256
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	m := nextInt(sc)

	C := make([]int, m+1)
	T := make([]int, n+1)
	for i := 1; i <= m; i++ {
		C[i] = nextInt(sc)
	}

	INF := math.MaxInt32
	for i := 0; i <= n; i++ {
		T[i] = INF
	}

	T[0] = 0
	for i := 1; i <= m; i++ {
		for j := 0; j+C[i] <= n; j++ {
			T[j+C[i]] = min(T[j+C[i]], T[j]+1)
		}
	}

	fmt.Println(T[n])
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}



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

int main()
{
	int k;
	cin>>k;
	if(k%7==0)
		k/=7;
	if(k%2==0 || k%5==0)
	{
		cout<<-1<<endl;
		return 0;
	}
	int ans=1;
	int v=1%k;
	while(v!=0)
	{
		ans++;
		v=(v*10+ 1)%k;
//		cout<<ans<<"  "<<v<<endl;
	}
	cout<<ans<<endl;
	return 0;
}


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

int main(){
    vector<int> v(3);
    for(int i = 0; i < 3; i++)  cin >> v[i];
    sort(v.begin(),v.end());
    cout << v[0]+v[1] << endl;
    return 0;
}

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

bool LinearSearch(int vect[], int num, int key)
{
    int i;
    vect[num] = key;

    i = 0;
    while (vect[i] != key) {
        ++i;
    }

    return (i != num);
}

int main(void)
{
    int i;
    int vect[10000+1];
    int num, num2;
    int target;
    int cnt = 0;

    scanf("%d", &num);
    for (i = 0; i < num; i++) {
        scanf("%d", &vect[i]);
    }
    scanf("%d", &num2);
    for (; num2 > 0; num2--) {
        scanf("%d", &target);
        if (LinearSearch(vect, num, target)) {
            ++cnt;
        }
    }

    printf("%d\n", cnt);
}

Measured memory_bytes: 1228
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

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

    ll res=0;
    if (N == 1 && M == 1) res = 1;
    else if (N == 1 && M >= 2) res = M-2;
    else if (N >= 2 && M == 1) res = N-2;
    else res = (N-2) * (M-2);

    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <stack>
#include <queue>
#include <list>
#include <stdio.h>
#include <algorithm>
#define MAX 100000
using namespace std;
typedef long long ll;
vector<int> G;
int a[1000001],ans;
void insertsort(int a[],int n,int g)
{
	int i,j;
	for(i=g;i<n;i++)
	{
		int tmp=a[i];
		j=i-g;
		while(j>=0&&a[j]>tmp){
			a[j+g]=a[j];
			j-=g;
			ans++;
		}
		a[j+g]=tmp;//复位 
	}
}//其实只有g和插入排序不同 
void shellsort(int a[],int n)
{
	for(int h=1;;){
		if(h>n) break;
		G.push_back(h);
		h=3*h+1;	
	}
	for(vector<int>::reverse_iterator it=G.rbegin();it!=G.rend();it++){
		insertsort(a,n,*it);
	}
}
int main(int argc, char *argv[]) {
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	shellsort(a,n);
	printf("%d\n",G.size());
	for(int i=G.size()-1;i>=0;i--)
	{
		if(i==0) printf("%d\n",G[i]);
		else printf("%d ",G[i]);
	}
	printf("%d\n",ans);
	for(int i=0;i<n;i++)
	{
		printf("%d\n",a[i]);
	}
}


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

b=[0]*N
for a in A:
    b[a-1]+=1
    
c=[0]*N
tmp=b
for i in range(N):
    c[i]+=tmp[i]*(tmp[i]-1)//2
sum_c=sum(c)

for a in A:
    b[a-1]-=1
    print(sum_c-c[a-1]+b[a-1]*(b[a-1]-1)//2)
    b[a-1]+=1
    

Measured memory_bytes: 26140
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INF = 999999999;
const int MOD = (int)1e9 + 7;
const int EPS = 1e-9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, a;
  vector<int> vec;
  int alice = 0;
  int bob = 0;
  cin >> n;
  REP(i,n){
      cin >> a;
      vec.push_back(a);
  }
  SORT(vec);
  REV(vec);
  REP(i,n){
      if (i%2==0){
          alice+=vec[i];
      }else{
          bob+=vec[i];
      }
    
  }
  cout << alice - bob << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int
main(int argc, char *argv[])
{
        char s[100], p[100];
        char ring[200];
        int i = 0;
        
        scanf("%s\n%s", s, p);
        strcpy(ring, s);
        strcpy((char *)(ring + strlen(s)), s);
        while (i < strlen(s)) {
                if (!strncmp((char *)(ring + i++), p, strlen(p))) {
                        printf("Yes\n");
                        return 0;
                }
        }
        printf("No\n");
        return 0;
}

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

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

int main(){
    int n,k; cin>>n>>k;
    if(k==1){
        cout<<0<<endl;
        return 0;
    }
    cout<<n-k<<endl;
}


Measured memory_bytes: 3664
# -*- coding: utf-8 -*-
# 標準入力を取得
N = int(input())
c = input()

# 求解処理
w = 0
r = c.count("R")
ans = max(w, r)
for n in range(N):
    c_n = c[n]
    if c_n == "W":
        w += 1
    else:
        r -= 1
    ans = min(ans, max(w, r))

# 結果出力
print(ans)


Measured memory_bytes: 9316
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int m = scan.nextInt();
    ArrayList<ArrayList<Integer>> a = new ArrayList<ArrayList<Integer>>();
    for (int i=0;i<n;i++){
      ArrayList<Integer> aa = new ArrayList<Integer>();
      a.add(aa);
    }
    for (int i=0;i<m;i++){
      int k = scan.nextInt();
      for (int j=0;j<k;j++){
        int tt = scan.nextInt();
        ArrayList<Integer> b = a.get(tt-1);
        b.add(i+1);
      }
    }

    int [] p = new int[m];
    for (int l=0;l<m;l++){
      p[l] = scan.nextInt();
    }

    int sum = 0;
    int combination = (int) Math.pow(2,n);
    for (int i=0;i<combination;i++){
      int [] c = per(i,n);
      int[] ch = new int[m];
      for (int j=0;j<n;j++){
        if ((a.get(j).size() == 0) || (c[j] == 0)){
          continue;
        }
        ArrayList<Integer> d = a.get(j);
        for (int t : d){
          ch[t-1] += 1;
        }
      }
      sum += check(ch,p);
    }

    System.out.println(sum);
  }

  static int check(int[] a, int[] b){
    for (int i=0;i<a.length;i++){
      if ((a[i]%2) != b[i]){
        return 0;
      }
    }
    return 1;
  }

  static int[] per(int a, int n){
    int[] b  = new int[n];
    int start = n-1;
    while(a>0){
      if ((a & 1) == 1){
        b[start] = 1;
      }
      start -= 1;
      a >>= 1;
    }
    return b;
  }
}


Measured memory_bytes: 36544
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll INF=1e18;
#define PI 3.14159265358979323846

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

    int N, M;
    cin >> N >> M;

    ll day = N;
    for (int i=0; i<M; i++) {
        ll num = 0;
        cin >> num;
        day -= num;
        if (day < 0) {
            break;
        }
    }

    if (day < 0) {
        cout << -1 << '\n';
    } else {
        cout << day << '\n';
    }


    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
 
#define test        int tc;cin>>tc;while(tc--)

bool check(string str){

    for(int i=1;str[i];i++){
        if(str[i]!=str[0]){
            for(int j=i+1;str[j];j++){
                if(str[j]==str[0])
                    return 1;
            }
        }
    }
    return 0;
}

int32_t main(){
        
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b && a!=c){
        cout<<"Yes"<<endl;
    }
    else if(a==c && a!=b){
        cout<<"Yes"<<endl;
    }
    else if(b==c && b!=a)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
        
}


Measured memory_bytes: 256
c = [list(map(int, input().split())) for _ in range(3)]
for a1 in range(100 + 1):
    b1 = c[0][0] - a1
    b2 = c[0][1] - a1
    b3 = c[0][2] - a1
    a2 = c[1][0] - b1
    a3 = c[2][0] - b1

    if a2 + b2 == c[1][1] and a2 + b3 == c[1][2] and a3 + b2 == c[2][1] and a3 + b3 == c[2][2]:
        print('Yes')
        exit()

print('No')


Measured memory_bytes: 3064
import sys
input = lambda: sys.stdin.readline().rstrip()

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

#最小の値 0+1+2+...+K-1
#最大の値 N-K+1 + N-K+2 + ...+ N
#ans = (2N-K+1)*K/2 - ((K-1)*K/2 - 1)

ans = 0

for i in range(K, N+2):
    ans += ((2*N- i+1)*i//2 - ((i-1)*i//2-1)) % (10**9 + 7)
    ans %= 10**9+7

print(ans)

Measured memory_bytes: 63652
#include <iostream>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#define fup(i,a,b) for(int i=a;i<=b;i++)
#define fdw(i,a,b) for(int i=a;i>=b;i--)
#define sync ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define cl(a) memset(a,0,sizeof(a))
using namespace std;
typedef long long ll;
const int N=1e6+10;
char s[N],s1[N];
int p[N],sum[N],val[30];
bool pre[N],suf[N];
int len;
void manachar()
{
    cl(pre);
    cl(suf);
    int i,j=0;
    s1[j++]='@';s1[j++]='#';
    for(i=0;s[i];i++)
    {
        s1[j++]=s[i];
        s1[j++]='#';
    }
    s1[j]='\0';
    int id=0,mx=0;
    fup(i,1,j-1)
    {
        if(i<mx) p[i]=min(mx-i,p[2*id-i]);
        else p[i]=1;
        while (s1[i+p[i]]==s1[i-p[i]])p[i] ++;
        if (i+p[i]>mx){
            id=i;
            mx=id+p[i];
        }
        if(i-p[i]==0)
        {
            pre[p[i]-2]=true;
        }
        if((i+p[i])==j)
        {
            suf[len+1-p[i]]=true;
        }
    }

}
int a[100010];
int main ()
{
    int n,m;
    cin>>n>>m;
    fup(i,1,m)
    {
        cin>>a[i];
        n-=a[i];
        if(n<=0)
        {
            cout<<"Yes"<<endl;
            break;
        }
    }
    if(n>0)
        cout<<"No"<<endl;

    return 0;
}



Measured memory_bytes: 640
s=input()

l_1=[0 if i%2==0 else 1 for i in range(len(s))]
l_2=[1 if j%2==0 else 0 for j in range(len(s))]

ans_1=0
ans_2=0
for k in range(len(s)):
    if int(s[k])!=l_1[k]:
        ans_1+=1
    if int(s[k])!=l_2[k]:
        ans_2+=1

print(min(ans_1,ans_2))

Measured memory_bytes: 4724
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
using namespace std;
typedef long long ll;
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
 
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;
}
 
ll digitsum(ll a){
	ll x=0;
	while(a>0){
		x+=a%10;
		a/=10;
	}
	return x;
}
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	ll x=abs(a-b);
	ll y=abs(a-c);
	ll z=abs(b-c);
	ll s=min(x+y,y+z);
	ll t=min(s,z+x);
	cout<<t<<endl;
	
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.TreeMap;

public class Main {
    public void solve(BufferedReader stdin, PrintWriter stdout) throws NumberFormatException, IOException {
        int n = Integer.parseInt(stdin.readLine());
        TreeMap<Integer, Integer> d = new TreeMap<>();
        for (int i = 0; i < n; i++) {
            Integer a = Integer.valueOf(stdin.readLine());
            Integer b = d.lowerKey(a);
            if (b != null) {
                if (d.get(b) == 1) {
                    d.remove(b);
                } else {
                    d.put(b, d.get(b) - 1);
                }
            }
            d.put(a, d.getOrDefault(a, 0) + 1);
        }

        int ans = d.values().stream().mapToInt(Integer::intValue).sum();
        stdout.println(ans);
    }

    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter stdout = new PrintWriter(System.out, false);
        new Main().solve(stdin, stdout);
        stdout.flush();
    }
}


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

int compare(const void *x, const void *y) {
	if (*(long*)x < *(long*)y) return 1;
	if (*(long*)x > *(long*)y) return -1;
	return 0;
}

void calc(long A, long *ans, int *tmp, int *i) {
	if (*tmp == 0) *ans = A;
	else *ans *= A;
	++*tmp;
	++*i;
}

int main() {
	int N, tmp = 0;
	long A[100000], ans;
	cin >> N;
	for (int i = 0; i < N; ++i) cin >> A[i];
	qsort(A, N, sizeof(long), compare);
	for (int i = 0; i < N - 1 && tmp != 2; ++i) {
		if (A[i] == A[i + 1]) calc(A[i], &ans, &tmp, &i);
	}
	if (tmp == 2) cout << ans;
	else cout << 0;
}

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

#include <iostream>


#define MOD 1000000007

typedef unsigned long long ull;

using namespace std;
auto f=[]()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
};


ull power(ull base, ull p)
{
	if(p==0)return 1;

	ull local=(power(base,p>>1))%MOD;
	local=(local*local)%MOD;

	return !(p&1)?local:(base*local)%MOD;
}

ull nCk(ull n, ull k)
{
	ull prod=1;
	ull i=n;
	while(i>n-k)
	{
		prod*=i;
		prod%=MOD;
		i--;
	}

	ull X=prod;
	
	i=1;
	ull Y=1;
	while(i<=k)
	{
		Y*=i;
		Y%=MOD;
		i++;
	}

	ull mmi=power(Y,MOD-2);
	
	return (X*mmi)%MOD;

}

int main()
{
	f();
	ull n,a,b;
	cin>>n>>a>>b;
	ull total_possibility=(power(2,n)-1);

	cout<<((total_possibility-nCk(n,a)-nCk(n,b) +2*MOD)%MOD)<<"\n";

	return 0;
}

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

int main() {
    int a,b;
 
 cin >> a >> b;
 string s[a];
    for(int i = 0; i < a; i++){
        cin >> s[i];
 }
 
 for(int i = 0; i < b + 2; i++){
     cout << "#";
 }
 cout << endl;
 for(int i = 0; i < a; i++){
     cout << "#" << s[i] << "#" << endl;
     
 }

 for(int i = 0; i < b + 2; i++){
     cout << "#";
 }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt(); 
		int X = sc.nextInt();
		
		int count = 1;
		int D = 0;
        for (int i = 0; i < N; i++) {
            D +=sc.nextInt();
            if(D > X){
                break;
            }
            count++;
        }
		System.out.println(count);
	}
	
}


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

#define NIL -1
struct Node { int parent, left, right; };
struct Node T[100001];

int D[100001];

void Depth(int u, int p)
{
	D[u] = p;
	if (T[u].right != NIL) Depth(T[u].right, p);
	if (T[u].left != NIL) Depth(T[u].left, p + 1);
}

void print(int u)
{
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].parent << ", ";
	cout << "depth = " << D[u] << ", ";

	if (T[u].parent == NIL) cout << "root, ";
	else if (T[u].left == NIL) cout << "leaf, ";
	else cout << "internal node, ";

	cout << "[";
	for (int i = 0, c = T[u].left; c != NIL; i++, c = T[c].right) 
	{
		if (i > 0) cout << ", ";
		cout << c;
	}
	cout << "]" << endl;
}

int main()
{
	int n, k, id, c, l, r;
	cin >> n;
	for (int i = 0; i < n; i++) T[i].parent = T[i].left = T[i].right = NIL;

	for (int i = 0; i < n; i++) 
	{
		cin >> id >> k;
		for (int j = 0; j < k; j++)
		{
			cin >> c;
			if (j == 0) T[id].left = c;
			else T[l].right = c;
			l = c;
			T[c].parent = id;
		}
	}

	for (int i = 0; i < n; i++)
	{
		if (T[i].parent == NIL) r = i;
	}

	Depth(r, 0);

	for (int i = 0; i < n; i++) print(i);

	return 0;
}

Measured memory_bytes: 7748
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cstring>
using namespace std;
#define INF 0x3f3f3f3f3f3f3f3f;
typedef long long LL;
const int maxn=100005;
LL p1[maxn], p2[maxn];
int n,res[maxn*3];
LL c1, c2, ans;

priority_queue<int, vector<int>, greater<int> > Q1;
priority_queue<int> Q2;

int main()
{
    scanf("%d", &n);
    c1=c2=0;
    for(int i=1;i<=3*n;i++){
        scanf("%lld", &res[i]);
        if(i<=n){
            Q1.push(res[i]);
            c1+=res[i];
        }
        else if(i>2*n){
            Q2.push(res[i]);
            c2+=res[i];
        }
    }
    p1[0]=c1;
    p2[0]=c2;
    for(int i=1;i<=n;i++){
        c1+=res[n+i];
        Q1.push(res[n+i]);
        c1-=Q1.top();
        Q1.pop();
        p1[i]=c1;
        c2+=res[2*n+1-i];
        Q2.push(res[2*n+1-i]);
        c2-=Q2.top();
        Q2.pop();
        p2[i]=c2;
    }
    ans=-INF;
    for(int i=0;i<=n;i++){
        ans=max(ans, p1[i]-p2[n-i]);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3960
#include<iostream>
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>

using namespace std;

string s;
int n;

bool f(string ss) {
	int len = 0;
	bool ans;
	len = ss.size();
	map<int, int> mp;
	for (int i = 0; i < len; i++) {
		mp[ss[i]]++;
	}
	for (auto it = mp.begin(); it != mp.end(); it++) {
		ans = it->second * 2 > len;
		if (ans)
			break;
	}
	return ans;
}

int main() {
	cin >> s;
	n = s.size();
	bool bl = false;
	int a = -1, b = -1;
	for (int i = 2; i <= min(n, 3); i++) {
		for (int j = 0; j < n - i + 1; j++) {
			string s0;
			for (int k = 0; k < i; k++) {
				s0 += s[j + k];
			}
			bl = f(s0);
			if (bl) {
				a = j + 1;
				b = j + i;
				cout << a << " " << b << endl;
				//cout << s0;
				//cin >> a;
				return 0;
			}
		}
	}

	cout << a << " " << b << endl;
	//cin >> a;
	return 0;
}

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

int main() {
  char b;
  cin >> b;

  cout << (b == 'A' ? 'T' : (b == 'T' ? 'A' : (b == 'G' ? 'C' : 'G'))) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>


using namespace std;

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


int main() {
	int N;
	cin >> N;
	bool is_ok = true;
	rep(i, N) {
		int a;
		cin >> a;
		if (a % 2 == 0) {
			if (a % 3 == 0) continue;
			if (a % 5 == 0) continue;
			cout << "DENIED" << endl;
			return 0;
		}
	}
	cout << "APPROVED" << endl;



	
	return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n, q; cin >> n >> q;
    vector<vector<int>> g(n);
    rep(i,n-1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> ans(n);
    rep(i,q) {
        int p, x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }

    auto rec = [&](auto &&rec, int now, int before) -> void {
        rep(i,g[now].size()) {
            if (g[now][i] == before) continue;
            ans[g[now][i]] += ans[now];
            rec(rec, g[now][i], now);
        }
    };

    rec(rec, 0, -1);
    rep(i,n) {
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}

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

int main(){
	int n;	cin>>n;
	vector<int> b(n);	for(int i=1;i<n;i++) cin>>b[i];

	b[0]=b[1];

	for(int i=0; i+1<n; i++){
		if(b[i]>b[i+1])b[i]=b[i+1];
	}

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

	return 0;
}


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

#define vl vector<ll>
#define vi vector<int>

#define ff first
#define ss second

#define pb push_back
#define MOD 1e9+7 
const int nax = 1e6+5;
#define display(v) for(int i =0;i<v.size();++i)cout << v[i] << " "

inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }

int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int h,n;  cin>>h>>n;
    int sum = 0;
    for(int i =0;i<n;++i){
        int val; cin>>val;
        sum += val;
    } 
    if(sum >= h)cout << "Yes";
    else cout << "No";
    
    return 0;
 }

Measured memory_bytes: 256
# D - equeue
def main():
    N, K, *V = map(int, open(0).read().split())
    lim = min(N, K)
    available_choices = set()

    for l in range(lim + 1):
        for r in range(lim + 1):
            if l + r > lim:
                break

            choice = V[:l] + V[-r:] if r else V[:l]
            choice.sort()
            cnt_negatives, cnt_rest = sum(i < 0 for i in choice), K - (l + r)

            if cnt_negatives > cnt_rest:
                available_choices.add(sum(choice[cnt_rest:]))
            else:
                available_choices.add(sum(choice[cnt_negatives:]))

    print(max(available_choices))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>

int main(void) {
  float a = 0,b = 0,c = 0,d = 0,e = 0,f = 0;
  while(scanf("%f %f %f %f %f %f", &a,&b,&c,&d,&e,&f) != EOF) {
    float x = 0,y = 0;
    y = (c*d - a*f)/(b*d - a*e);
    x = c/a - (b/a)*y;
    x = roundf(1000*x)/1000;
    y = roundf(1000*y)/1000;
    printf("%.3f %.3f\n", x,y);
  }
  return 0;
}

Measured memory_bytes: 656
N = int(input())
W = list(map(int,input().split()))
s1 = 0;s2 = 0
min = 1001001001
for T in range(1,N):
  for i in range(T):
    s1 += W[i]
  for i in range(T,N):
    s2 += W[i]
  if abs(s1-s2) < min:
    min = abs(s1-s2)
  s1 = 0;s2 = 0
print(min)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    int k, x;
    cin >> k >> x;
    for(int i = x - k + 1; i < k + x; ++i){
        cout << i << " ";
    }
    cout << endl;
	return 0;
}

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

public class Main {
	public static boolean enoughTwos(int r, int amount) {
		return (r <= amount) && ((r % 2) == (amount % 2));
	}
	public static void main(String[] args) throws IOException {
		BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(f.readLine());
		int h = Integer.parseInt(st.nextToken());
		int w = Integer.parseInt(st.nextToken());
		int counts[] = new int[26];
		for(int i = 0; i < h; i++) {
			String s = f.readLine();
			for(int j = 0; j < w; j++) {
				counts[s.charAt(j) - 'a']++;
			}
		}
		int residues[] = new int[4];
		for(int i = 0; i < 26; i++) {
			residues[counts[i] % 4]++;
		}
		boolean good = true;
		int oddCount = 0;
		if(h % 2 == 1) {
			oddCount++;
		}
		if(w % 2 == 1) {
			oddCount++;
		}
		if(oddCount == 0) {
			good = (residues[1] == 0) && (residues[2] == 0) && (residues[3] == 0);
		} else if(oddCount == 1) {
			if(h % 2 == 1) {
				good = (residues[1] == 0) && enoughTwos(residues[2], w/2) && (residues[3] == 0);
			} else {
				good = (residues[1] == 0) && enoughTwos(residues[2], h/2) && (residues[3] == 0);
			}
		} else if(oddCount == 2) {
			if(residues[1] == 1) {
				good = enoughTwos(residues[2], (h - 1 + w - 1)/2) && (residues[3] == 0);
			} else if(residues[3] == 1) {
				good = enoughTwos(residues[2] + 1, (h - 1 + w - 1)/2) && (residues[1] == 0);
			} else {
				good = false;
			}
		}
		if(good) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


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

using namespace std;

int main()
{
	long long n,w;
	cin>>n>>w;
	long long qty[n],val[n];
	for(int i=0;i<n;i++)
		cin>>qty[i]>>val[i];
	long long dp[n+1][w+1];

	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=w;j++)
		{
			if(i==0||j==0)
				dp[i][j]=0;
			else
			{
				long long inc=0,exc=0;
				exc=dp[i-1][j];
				if(qty[i-1]<=j)
				{
				    inc=val[i-1]+dp[i-1][j-qty[i-1]];
				}
				
				
				dp[i][j]=max(inc,exc);
            
			}

		}
        
	}
	cout<<dp[n][w];
}

Measured memory_bytes: 79104
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long int lli;

int main() {
	int N;
	cin >> N;
	vector<string> S(100001);
	for (int i = 0;i<N;i++) cin >> S[i];

	//頭文字がMARCHのものを検索
	lli M = 0, A = 0, R = 0, C = 0, H = 0;
	for (int i = 0;i<N;i++) {
		char x = S[i].front();
		if (x == 'M') M+=1;
		if (x == 'A') A+=1;
		if (x == 'R') R+=1;
		if (x == 'C') C+=1;
		if (x == 'H') H+=1;
	}
	//組合せを計算
	lli ans = M * A*R + M * A*C + M * A*H + M * R*C + M * R*H + M * C*H + A * R*C + A * R*H + A * C*H + R * C*H;
	cout << ans;
}

Measured memory_bytes: 6144
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int N;

int main()
{
    cin >> N;
    double x[N];
    string u[N];
    double answer = 0;
    double value = 380000;

    for (int i = 0; i < N; i++)
    {
        cin >> x[i] >> u[i];
    }

    for (int i = 0; i < N; i++)
    {
        if (u[i] == "JPY")
        {
            answer += x[i];
        }
        else
        {
            answer += x[i] * value;
        }
    }

    cout << answer << endl;

    return 0;
}

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

int main(){
    i64 n,ans=0;
    string s;
    cin>>n>>s;
    for(i64 i=0;i<n-2;i++){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

int max(int a, int b){
  return a >= b ? a : b;
}
int min(int a, int b){
  return b >= a ? a : b;
}
int factorial(int n) {
    if (n > 0) return n*factorial(n - 1);
		else return 1;
}
int compare_up_int(const void *a, const void *b){
   return *(int*)a - *(int*)b;
}
int compare_down_int(const void *a, const void *b){
   return *(int*)b - *(int*)a;
}
int euclid(int a, int b){
  if(a < b){int tmp = a;a = b;b = tmp;}
  int r = a % b;
  if(r < 0) r += b;
  while(r != 0){
    a = b;b = r;r = a % b;
    if(r < 0) r += b;
  }
  return b;
}

int main(){
  int N,K;
  scanf("%d %d",&N,&K);
  if(N%2 == 0){
    if(N/2 >= K){
      printf("YES");
      return 0;
    }
    else printf("NO");
  }
  if(N%2 == 1){
    if(N/2+1 >= K){
      printf("YES");
      return 0;
    }
    else printf("NO");
  }
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if((a + b) % 2 == 0) {
			System.out.println((a + b) / 2);
		} else {
			System.out.println((a + b) / 2 + 1);
		}
	}
}


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

using namespace std;

#define inf 1<<30
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> P;
struct UnionFind{
	int par[100001];

	UnionFind(){};
	UnionFind(int n){
		for(int i = 0; i <= n; i++)
			par[i] = i;
	};
	int find(int n){
		if(par[n] == n) return n;
		return par[n] = find(par[n]);
	};
	bool isSame(int a, int b){
		return find(a) == find(b);
	};
	void marge(int a, int b){
		a = find(a);
		b = find(b);
		if(a == b) return;
		else if(a < b)
			par[b] = a;
		else
			par[a] = b;
		return;
	};
};

int N, M;
int id[100001] = {};
UnionFind uf(100001);

int main(){
	cin >> N >> M;
	int in;
	for(int i = 1; i <= N; i++){
		cin >> in;
		id[in] = i;
	}
	int a, b;
	for(int i = 0; i < M; i++){
		cin >> a >> b;
		uf.marge(a,b);
	}
	int cnt = 0;
	for(int i = 1; i <= N; i++)
		if(uf.isSame(i, id[i]))
			cnt++;

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 1024