akhauriyash/Code-Regression huggingface dataset:
//#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <climits>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << x << "\n"
using namespace std;
using point = pair< int,int >;
using ll = long long;

const int mod = 1e9 + 7;
int dp[100001];
int A[100001];

int solve(int n) {
    if (A[n]) {
        return 0;
    } else if (n <= 1) {
        return 1;
    } else if (dp[n] != -1) {
        return dp[n];
    } else {
        return dp[n] = (solve(n - 1) + solve(n - 2)) % mod;
    }
}

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

    int a;
    REP (i, m) {
        scanf("%d", &a);
        A[a] = 1;
    }

    fill(dp, dp + 100001, -1);

    OUT(solve(n));
    return 0;
}



Measured memory_bytes: 4096
#include <bits/stdc++.h>
#include <list> 
#include <unordered_map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9

using namespace std;
typedef long long ll;

// class to represent a disjoint set
class DisjointSet{
	unordered_map<int, int> parent;
    

public:
    unordered_map<int, int> size;

	// perform MakeSet operation
	void makeSet(vector<int> const &universe){
		// create n disjoint sets (one for each item)
		for (int i : universe){
            parent[i] = i;
            size[i] = 1;
        }	
	}

	// Find the root of the set in which element k belongs
	int Find(int k){
		if (parent[k] == k) return k; // if k is root
		return parent[k] = Find(parent[k]); // recur for parent until we find root
	}

	// Perform Union of two subsets
	void Union(int a, int b){
		// find root of the sets in which elements x and y belongs
		int x = Find(a);
		int y = Find(b);
		parent[x] = y;
        // increment size when union happens 
        if (x != y) size[y] += size[x];
	}

    // Get number of elements in the set which a belongs to
    int getSize(int a){
        int x = Find(a);
        return size[x];
    }
};

int main(){
    int n, m, k, a, b, c, d;
    cin >> n >> m >> k;

    DisjointSet ds;
    vector<int> recs;
    REP(i, n) recs.push_back(i+1);
    ds.makeSet(recs);

    vector<int> f(n, 0);
    map<int, vector<int>> bl;
    
    REP(j, m){
        cin >> c >> d;
        ds.Union(c, d);
        // fb[c].push_back(d);
        // fb[d].push_back(c);
        f[c-1]++;
        f[d-1]++;
    }

    REP(i, k){
        cin >> a >> b;
        bl[a].push_back(b);
        bl[b].push_back(a);
    }

    // vector<int> sizee(n, 0);
    // REP(i, n) sizee[i] = ds.getSize(i+1);

    int ans;
    REP(i, n){
        ans = ds.size[ds.Find(i+1)] - 1;
        ans -= f[i];
        for(auto x : bl[i+1]){
            if (ds.Find(x) == ds.Find(i+1)){
                ans--;
            }
        }
        cout << ans << " ";
    }
    cout << endl;
}

Measured memory_bytes: 21160
def dist(arr)
    brr = arr.sort
    cnt = 0
    arr.each_with_index do |x, idx|
        cnt += 1 unless arr[idx] == brr[idx]
    end
    return cnt
end


def bb
    n = gets.chomp.to_i#.map{|x| x.to_i}
    nn = gets.chomp.split(/\s/).map{|x| x.to_i}

    if dist(nn) <= 2
        puts 'YES'
    else
        puts 'NO'
    end
end

bb


Measured memory_bytes: 1916
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    queue<pair<string, int> > que;
    rep(i, n) {
        string s;
        int x;
        cin >> s >> x;
        que.emplace(s, x);
    }

    int time = 0;
    while(!que.empty()) {
        pair<string, int> now = que.front();
        que.pop();
        if(now.second > q) {
            time += q;
            que.emplace(now.first, now.second-q);
        } else {
            time += now.second;
            cout << now.first << ' ' << time << '\n';
        }
    }
}


Measured memory_bytes: 6364
import sys

def main():
    N, M = list(map(int, input().split()))
    X = list(map(int, input().split()))

    if N >= M:
        print('0')
        exit()

    X = sorted(X)

    kukan = []
    for i in range(1, M):
        kukan.append(X[i]-X[i-1])

    kukan = sorted(kukan, reverse=True)

    jogai = 0
    for j in range(N-1):
        jogai += kukan[j]

    print(X[M-1] - X[0] - jogai)

main()

Measured memory_bytes: 13968
# coding: utf-8

# In[5]:

import sys
input = sys.stdin.readline
#N, K = map(int, input().split())
S = input()


# In[6]:

f = int(S[:2])
b = int(S[2:])
if f >= 1 and f <=12 and b >= 1 and b <=12:
    print('AMBIGUOUS')
elif f>=1 and f<=12:
    print('MMYY')
elif b>=1 and b<=12:
    print('YYMM')
else:
    print('NA')


# In[ ]:





Measured memory_bytes: 3060
#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 rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    sort(whole(p));
    int ans = 0;
    rep(i, k) {
        ans += p[i];
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    vector<int> a(n),b;
    rep(i,n)cin >> a[i];
    b = a;
    sort(ALL(b));
    // これで最終的な場所はbになることがわかる
    ll ans = 0;
    for(int i=0;i<n;i++){
        // a[i] について i%2==0 && a[i]がbの偶数番目にあったら0
        int p = lower_bound(ALL(b),a[i]) - b.begin();
        if(i%2==0 && p%2==0)continue;
        if(i%2==1 && p%2==1)continue;
        ans++;
    }
    cout << ans/2LL << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
	int n;
	scanf("%d",&n);
	int s[13]={0},h[13]={0},c[13]={0},d[13]={0};
	int i,a;
	char m;
	for(i=0;i<n;i++){
		scanf("%c",&m);
		scanf("%c%d",&m,&a);
		if(m=='S') s[a-1]=1;
		else if(m=='H') h[a-1]=1;
		else if(m=='C') c[a-1]=1;
		else if(m=='D') d[a-1]=1;
	}
	for(i=0;i<13;i++){
		if(s[i]==0) printf("S %d\n",i+1);
	}
	for(i=0;i<13;i++){
		if(h[i]==0) printf("H %d\n",i+1);
	}
	for(i=0;i<13;i++){
		if(c[i]==0) printf("C %d\n",i+1);
	}
	for(i=0;i<13;i++){
		if(d[i]==0) printf("D %d\n",i+1);
	}
	return 0;
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#define testing 0
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << endl
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<endl
#define dbv(v) cerr << #v << ":"; for (auto i : v) cerr << i << ' '; cerr << endl
#define dbvp(v) cerr << #v << ":"; for (auto i : v) cerr << "{"  << i.f << ',' << i.s << "} "; cerr << endl
#define dba(a,ss,ee) cerr << #a << ":"; FOR(i,ss,ee) cerr << a[i] << ' '; cerr << endl
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define inf (int)1e9
#define oo (ll)1e18
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "hi\n";
typedef pair <int, int> pi;
typedef pair <ll,ll> pl;
typedef pair <pi, int> pii;
typedef tuple<int,int,int> ti3;
string lts(ll x) {stringstream s; s << x; return s.str(); }
ll stl(string x) {stringstream s(x); ll temp; s >> temp; return temp; }
string cts(char x) {string s(1,x); return s;}
const int MOD = 1e9 + 7;
template <typename T> void maxself(T& a, T b) {
	a = max(a, b);
}
template <typename T> void minself(T& a, T b) {
	a = min(a, b);
}
#define MAXN 305
#if !testing
	#define cerr if(0)cout
#endif

ll fuel[MAXN][MAXN], dist[MAXN][MAXN];

int32_t main() {
	IAMSPEED
	// set testing to 0 when submitting to judge
	int n,m,l; cin >> n >> m >> l;
	FOR(i,0,MAXN-1) {
		FOR(j,0,MAXN-1) {
			dist[i][j] = oo; fuel[i][j] = oo;
		}
		dist[i][i] = 0;
		fuel[i][i] = 0;
	}
	FOR(i,1,m) {
		ll a,b,c; cin >> a >> b >> c;
		minself(dist[a][b],c);
		minself(dist[b][a],c);
	}
	FOR(k,1,n) {
		FOR(i,1,n) {
			FOR(j,1,n) {
				minself(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}
	FOR(i,1,n) {
		FOR(j,1,n) {
			if (dist[i][j]<=l)minself(fuel[i][j], 1ll);
		}
	}
	FOR(k,1,n) {
		FOR(i,1,n) {
			FOR(j,1,n) {
				minself(fuel[i][j], fuel[i][k] + fuel[k][j]);
			}
		}
	}
	int Q; cin >> Q;
	while (Q--) {
		int a,b; cin >> a >> b;
		if (fuel[a][b] < inf) cout << max(fuel[a][b]-1,0ll) << '\n';
		else cout << -1 << '\n';
	}
	
}


Measured memory_bytes: 2048
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 110


int main(){
  char s[SIZE][SIZE];

  int h,w;

  scanf("%d%d",&h,&w);

  for(int i=0;i<w+2;i++){
    printf("#");
  }
  puts("");
  
  for(int i=0;i<h;i++){
    scanf("%s",s[i]);
    printf("#%s#\n",s[i]);
  }

  for(int i=0;i<w+2;i++){
    printf("#");
  }
  puts("");
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int hour;
		int priceA;
		int priceB;
		
		Scanner sn = new Scanner(System.in);
		hour = sn.nextInt();
		priceA = sn.nextInt();
		priceB = sn.nextInt();
		sn.close();
		
		int result;
		result = hour * priceA;
		
		if(result > priceB){
			System.out.println(priceB);
		}else {
			System.out.println(result);
		}
	}
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DBG(...)                \
  cerr << #__VA_ARGS__ << ": "; \
  debug(__VA_ARGS__);           \
  cerr << " (L" << __LINE__ << ")" << endl
#else
#define DBG(...)
#endif

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

using namespace std;

int main() {
  string S;
  cin >> S;
  DBG(S);
  cout << ((S.find("A") != string::npos) && (S.find("B") != string::npos) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int samecnt(string s, string t){
    int cnt = 0;
    rep(i, s.size()){
        if(s[i]==t[i])cnt++;
    }
    return cnt;
}

int main(){ 
    string s, t; cin >> s >> t;
    int res = INF, ss = s.size(), ts = t.size();
    rep(i, ss){
        string u = s.substr(i, ts);
        if(u.size()!=ts)break;
        chmin(res, ts - samecnt(t, u));
    }
    cout << res << ln;
}



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


int main()
{
	int N,K;
	cin>>N>>K;
	ll R,S,P;
	cin>>R>>S>>P;
	string T;
	cin>>T;
	string prev="";
	ll ans=0;
	rep(i,K)
	{
		switch(T[i])
		{
			case 'r':
				prev+='p';
				ans+=P;
				break;
			case 's':
				prev+='r';
				ans+=R;
				break;
			case 'p':
				prev+='s';
				ans+=S;
				break;
			default:
				break;
		}
	}
	for(int i=K;i<N;i+=K)
	{
		for(int k=i;k<min(i+K,N);k++)
		{		
			switch(T[k])
			{
				case 'r':
					if(prev[(k%K)]=='p')
					{
						prev[(k%K)]='o';
					}
					else
					{
						prev[(k%K)]='p';
						ans+=P;
					}
					break;
				case 's':
					if(prev[(k%K)]=='r')
					{
						prev[(k%K)]='o';
					}
					else
					{
						prev[(k%K)]='r';
						ans+=R;
					}
					break;
				case 'p':
					if(prev[(k%K)]=='s')
					{
						prev[(k%K)]='o';
					}
					else
					{
						prev[(k%K)]='s';
						ans+=S;
					}
					break;
				default:
					break;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3732
#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==5&&b==5&&c==7)cout<<"YES"<<endl;
	else if(a==5&&b==7&&c==5)cout<<"YES"<<endl;
	else if(a==7&&b==5&&c==5)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}


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

using namespace std;

#define LL long long
#define u64 unsigned long long
#define u32 unsigned int
#define reg register
#define Raed Read
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define rep(a,b,c) for(reg int a=(b),a##_end_=(c); a<=a##_end_; ++a)
#define ret(a,b,c) for(reg int a=(b),a##_end_=(c); a<a##_end_; ++a)
#define drep(a,b,c) for(reg int a=(b),a##_end_=(c); a>=a##_end_; --a)
#define erep(i,x) for(reg int i=Head[x]; i; i=Nxt[i])

inline int Read() {
	int res = 0, f = 1;
	char c;
	while (c = getchar(), c < 48 || c > 57)if (c == '-')f = 0;
	do res = (res << 3) + (res << 1) + (c ^ 48);
	while (c = getchar(), c >= 48 && c <= 57);
	return f ? res : -res;
}

template<class T>inline bool Min(T &a, T const&b) {
	return a > b ? a = b, 1 : 0;
}
template<class T>inline bool Max(T &a, T const&b) {
	return a < b ? a = b, 1 : 0;
}

const int N=2e5+5,M=1e5+5,mod=998244353;

bool MOP1;

inline void Add(LL &x,int y) {
	x+=y;
	if(x<0)x+=mod;
	if(x>=mod)x-=mod;
}

struct point {
	int x,y;
} S[N];

struct cmpy {
	bool operator()(point _,point __)const {
		return _.y<__.y;
	}
};

int X[N];

struct BIT {
	int c[N];
	inline void clear(void) {
		memset(c,0,sizeof c);
	}
	inline void Add(int x) {
		for(; x<N; x+=x&-x)c[x]++;
	}
	inline int Sum(int x) {
		int res=0;
		for(; x; x^=x&-x)res+=c[x];
		return res;
	}
} tr;

int F2[N];

bool MOP2;

inline void _main(void) {
	int n =Read();
	F2[0]=1;
	rep(i,1,n)F2[i]=(1ll*F2[i-1]*2)%mod;
	rep(i,1,n) S[i].x=X[i]=Read(),S[i].y=Read();
	sort(X+1,X+n+1);
	rep(i,1,n)S[i].x=lower_bound(X+1,X+n+1,S[i].x)-X;
	LL Ans=1ll*n*(F2[n]-1)%mod;
	rep(i,1,n) {
		Add(Ans,-(F2[i-1]-1));
		Add(Ans,-(F2[i-1]-1));
		Add(Ans,-(F2[n-i]-1));
		Add(Ans,-(F2[n-i]-1));
	}
	sort(S+1,S+n+1,cmpy());
	rep(i,1,n) {
		Add(Ans,(F2[tr.Sum(S[i].x)]-1));
		Add(Ans,(F2[i-1-tr.Sum(S[i].x)]-1));
		tr.Add(S[i].x);
	}
	tr.clear();
	drep(i,n,1) {
		Add(Ans,(F2[tr.Sum(S[i].x)]-1));
		Add(Ans,(F2[n-i-tr.Sum(S[i].x)]-1));
		tr.Add(S[i].x);
	}
	printf("%lld\n",Ans);
}

signed main() {
#define offline1
#ifdef offline
	freopen("chessboard.in", "r", stdin);
	freopen("chessboard.out", "w", stdout);
	_main();
	fclose(stdin);
	fclose(stdout);
#else
	_main();
#endif
	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <vector>
using namespace std;
typedef struct Node{
  vector<int> to;
  int d;
  int f;
}Node;

int n;
Node G[110];
int t = 0;

void dfs(int v){
  if(G[v].d > 0) return;
  G[v].d = ++t;
  for(int i=0; i<G[v].to.size(); i++){
    dfs(G[v].to[i]);
  }
  if(G[v].f < 0) G[v].f = ++t;
  return;
}

int main(){
  cin >> n;
  for(int i=0; i<n; i++){
    int u, k; cin >> u >> k;
    Node v;
    v.d = -1;
    v.f = -1;
    for(int j=0; j<k; j++){
      int c; cin >> c;
      v.to.push_back(c-1);
    }
    G[u-1] = v;
  }
  for(int i=0; i<n; i++){
    dfs(i);
  }
  for(int i=0; i<n; i++){
    cout << i+1 << " " << G[i].d << " " << G[i].f << endl;
  }
}


Measured memory_bytes: 3140
package main

import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
  "sort"
)

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

func Sum(A *[]int) int {
  s := 0
  for _, a := range (*A) {
    s += a
  }
  return s
}

func Max(A *[]int) int {
  m := 0
  for _, a := range (*A) {
    if m < a { m = a }
  }
  return m
}

func Solvable(A, F *[]int, K, X int) bool {
  k := 0
  for i, f := range (*F) {
    a := X / f
    if a < (*A)[i] { k += (*A)[i] - a }
  }
  return k <= K
}

func main() {
  NK := NextIntVec()
  N, K := NK[0], NK[1]
  A := NextIntVec()
  F := NextIntVec()
  sort.Ints(A)
  sort.Sort(sort.Reverse(sort.IntSlice(F)))
  if Sum(&A) <= K {
    Write(0)
  } else {
    FA := make([]int, N)
    for i := range FA {
      FA[i] = A[i] * F[i]
    }
    low := 0
    high := Max(&FA)
    for high - low > 1 {
      med := (high + low) / 2
      if Solvable(&A, &F, K, med) {
        high = med
      } else {
        low = med
      }
    }
    Write(high)
  }
  Output()
}

Measured memory_bytes: 13184
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>

using namespace std;

int main() {
   
   int N;
   string S;
   cin >> N >> S;
   int E[N], W[N];
   E[0] = 0;
   W[N-1] = 0;
   for (int i = 1; i < N; i++) {
      if (S[i-1] == 'E') E[i] = E[i-1] + 1;
      else E[i] = E[i-1];
      if (S[N-i] == 'W') W[N-1-i] = W[N-i] + 1;
      else W[N-1-i] = W[N-i];
   }
   
   int ans = N;
   for (int i = 0; i < N; i++) {
      int count = 0;
      int Etrue = i;
      int Wtrue = N-1-i;
      count += Etrue - E[i];
      count += Wtrue - W[i];
      if (ans > count) ans = count;
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define rep(x, to) for (int x = 0; x < (to); x++)
#define REP(x, a, to) for (int x = (a); x < (to); x++)
#define EPS (1e-14)
#define _PA(x,N) rep(i,N){cout<<x[i]<<" ";}cout<<endl;
#define _PA2(x,H,W) rep(i,(H)){rep(j,(W)){cout<<x[i][j]<<" ";}cout<<endl;}

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef complex<double> Complex;
typedef vector< vector<int> > Mat;

int N;
int A[100005];
int freq[100005];

int cnt;
int ans;

void solve() {
	for (int i = 0; i < N; i++) {
		freq[A[i]]++;
	}
	for (int i = 0; i < 100005; i++) {
		if (freq[i] == 0) continue;
		if (freq[i] % 2 == 0) {
			cnt++;
		} else {
			ans++;
		}
	}
	if (cnt % 2 == 1) {
		ans += cnt - 1;
	} else {
		ans += cnt;
	}
	cout << ans << endl;
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	solve();
	return 0;
}




Measured memory_bytes: 1024
#include <iostream>
#include <unordered_map>
#include <map>
#include <vector>
#include <stack>
#include <algorithm>
#include <list>
#include <set>
#include <climits>
#include <cmath>
#define lli long long int
using namespace std ;

int eval(string &s, string &t, int i, int j, vector<vector<int> > &dp)
{
	if(i < 0 || j < 0) return 0 ;
	if(dp[i][j] != -1) return dp[i][j] ;

	if(s[i] == t[j]) return dp[i][j] = 1 + eval(s,t,i-1,j-1,dp) ;

	return dp[i][j] = max(eval(s,t,i-1,j,dp), eval(s,t,i,j-1,dp)) ;
}

void construct(string &s, string &t, int i, int j, vector<vector<int> > &dp, string &ans)
{
	if(i < 0 || j < 0) return ;
	if(s[i] == t[j])
	{
		ans.push_back(s[i]) ;
		construct(s,t,i-1,j-1,dp,ans) ;
		return ;
	}

	if(i-1 >= 0 && dp[i][j] == dp[i-1][j])
	{
		construct(s,t,i-1,j,dp,ans) ;
		return ;
	}

	if(j-1 >= 0 && dp[i][j] == dp[i][j-1])
	{
		construct(s,t,i,j-1,dp,ans); 
	}

}

int main(int argc, char const *argv[])
{
	string s,t ;
	cin>>s>>t ;

	vector<vector<int> > dp(s.size(), vector<int> (t.size(),-1)) ;
	eval(s,t,s.size()-1,t.size()-1,dp) ;
	string ans ;
	construct(s,t,s.size()-1,t.size()-1,dp,ans) ;
	reverse(ans.begin(),ans.end()) ;
	cout<<ans<<endl ;
	return 0;
}

Measured memory_bytes: 35968
#include <stdio.h>

int main(void){
	int i,j,r,c,k,l;

	int gyouretu[100][100];
	int sum_c[100]={0};
	int sum_r[100]={0};
	int sum_t;

	scanf("%d %d",&r,&c);
	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			scanf("%d",&gyouretu[i][j]);
		}
	}
	for(i=0;i<=r;i++){
		for(j=0;j<=c;j++){
			if(j==c){	
				if(i==r){
					for(k=0;k<c;k++){
						for(l=0;l<r;l++){
							sum_r[k]=gyouretu[l][k]+sum_r[k];
						}
						printf("%d ",sum_r[k]);						
					}
					sum_t=0;
					for(k=0;k<c;k++){
						sum_t=sum_r[k]+sum_t;
					}
					printf("%d\n",sum_t);

				}else{
					for(k=0;k<c;k++){
						sum_c[i]=gyouretu[i][k]+sum_c[i];
					}
					printf("%d\n",sum_c[i]);
				}
			}else{
				

				if(i==r){	

				}else{
					printf("%d ",gyouretu[i][j]);
				}



			}
		}

	}

	return 0;
}

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

int main(){
    //入力変数宣言
    int n,m; ll l; 
    cin >> n >> m >> l;
    vector<vector<ll>> d(n,vector<ll>(n,INF)); //d[i][j]:iとjの最短距離
    int a,b; ll c;
    
    //入力
    rep(i,m){
        cin >> a >> b >> c;
        --a; --b;
        d[a][b] = d[b][a] = c;
    }

    rep(i,n) d[i][i] = 0LL;

    //warshal-floyd
    //最短距離を求める
    rep(k,n) rep(i,n) rep(j,n) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    
    //最小補給回数を求める
    vector<vector<int>> charge(n,vector<int>(n,10000000)); //charge[i][j]:iからjに行く時の最小補給回数(+1)
    rep(i,n) rep(j,n) if(d[i][j] <= l && i != j) charge[i][j] = 1; //最小距離がl以下なら辺を張る
    rep(i,n) charge[i][i] = 0;
    //warshal-floyd
    rep(k,n) rep(i,n) rep(j,n) charge[i][j] = min(charge[i][j], charge[i][k] + charge[k][j]);

    //クエリ処理
    int q; cin >> q;
    int s,t;
    rep(i,q){
        cin >> s >> t;
        --s; --t;
        if(charge[s][t] < 10000000) cout << charge[s][t]-1 << "\n";
        else cout << -1 << "\n";
    }
}

Measured memory_bytes: 1664
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    string s; cin >> s;

    int ans = 0;
    for (int i = 0; i < s.size() / 2; i++) {
        if (s[i] != s[s.size() - 1 - i]) ans++;
    }
    cout << ans << endl;
}


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

int main() {
  int N;
  cin >> N;
  for (int a = 0; a < N; ++a) {
    vector<int> A(10);
    for (int i = 0; i < 10; ++i)
      cin >> A[i];

    bool flag = false;
    for (int bit = 0; bit < 1 << 10; ++bit) {
      vector<int> B1(10), B2(10);
      int B1_size = 0, B2_size = 0;
      for (int i = 0; i < 10; ++i)
        if (bit & 1 << i)
          B1[B1_size] = A[i], ++B1_size;
        else
          B2[B2_size] = A[i], ++B2_size;

      vector<int> B1_s = B1, B2_s = B2;
      sort(B1_s.begin(), B1_s.begin() + B1_size),
          sort(B2_s.begin(), B2_s.begin() + B2_size);

      if (B1 == B1_s && B2 == B2_s)
        flag = true;
    }

    if (flag)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
#define M 1000000007
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  char arr[n][m];
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<m;j++)
      cin>>arr[i][j];
  }
  vector<vector<int> >dp(n,vector<int>(m,0));
  dp[0][0]=1;
  for(int i=1;i<m;i++)
  {
    if(arr[0][i]=='.')
      dp[0][i]=dp[0][i-1];
    else
      dp[0][i]=0;
  }
  for(int i=1;i<n;i++)
  {
    if(arr[i][0]=='.')
      dp[i][0]=dp[i-1][0];
    else
      dp[i][0]=0;
  }
  for(int i=1;i<n;i++)
  {
    for(int j=1;j<m;j++)
    {
      if(arr[i][j]=='.')
        dp[i][j]=(dp[i-1][j]+dp[i][j-1])%M;
      else
        dp[i][j]=0;
    }
  }
  cout<<dp[n-1][m-1]<<"\n";
}

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

using namespace std;

using ll = long long;

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

    int h, w;
    cin >> h >> w;
    vector<string> a(h + 2, string(w + 2, '#'));
    for (int i = 0; i < h; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < w; ++j)
            a[i + 1][j + 1] = s[j];
    }

    for (int i = 0; i < h + 2; ++i)
        cout << a[i] << '\n';

    return 0;
}


Measured memory_bytes: 256
H, W = list(map(int, input().split()))
rows = [input() for i in range(H)]
grid = [list(row) for row in rows]


'''generating a grid expanded by '&'. For example,

            &&&&&
#.#         &#.#&
###    ->   &###&
##.         &##.& 
            &&&&&

'''

expanded_grid = [list('&' * (W + 2))]
for row in rows:
    expanded_grid.append(list('&' + row + '&'))
expanded_grid.append(list('&' * (W + 2)))

for i in range(H):
    for j in range(W):
        if (grid[i])[j] == '.':
            EightPiece = [
                (expanded_grid[i])[j],
                (expanded_grid[i])[j+1],
                (expanded_grid[i])[j + 2],

                (expanded_grid[i+1])[j],
                (expanded_grid[i+1])[j+2],

                (expanded_grid[i+2])[j],
                (expanded_grid[i+2])[j+1],
                (expanded_grid[i+2])[j+2],
            ]

            (grid[i])[j] = str(EightPiece.count('#'))

for row_in_the_form_of_list in grid:
    print(''.join(row_in_the_form_of_list))


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

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

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

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

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

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

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

int main() {
    LL h, w;
    cin >> h >> w;
    if (h % 3 == 0 || w % 3 == 0) {
        cout << 0 << endl;
        return 0;
    }
    if (h < w) swap(h,w);
    LL ans = w;
    REP(i,0,h) {
        LL a = (LL)i * (w / 2);
        LL b = (LL)i * ((w + 1) / 2);
        LL c = (h - (LL)i) * w;
        ans = min(ans, max({b - a, abs(c - a), abs(c - b)}));
    }
    swap(h,w);
    REP(i,0,h) {
        LL a = (LL)i * (w / 2);
        LL b = (LL)i * ((w + 1) / 2);
        LL c = (h - (LL)i) * w;
        ans = min(ans, max({b - a, abs(c - a), abs(c - b)}));
    }
    cout << ans << endl;

    return 0;
}

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

int main(){
	int n; 
	cin >> n;
	int a[n],b[n],c[n-1];
	
	rep(i,n) cin >> a[i];
	rep(i,n) cin >> b[i];
	rep(i,n-1) cin >> c[i];


	int ans = 0;
	rep(i,n) {
		ans += b[i];
		if (a[i] == a[i+1] - 1) {
			ans += c[a[i]-1];
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 100000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    int n,m;
    cin>>n>>m;
    ll ans=0;
    pair<ll,ll>a[n];
    for(int i=0;i<n;i++){
        cin>>a[i].first>>a[i].second;
    }
    sort(a,a+n);
    int id=0;
    while(m){
        if(a[id].second>m){
            ans+=a[id].first*m;
            m=0;
        }else{
            ans+=a[id].first*a[id].second;
            m-=a[id].second;
        }
        id++;
    }
    cout<<ans<<endl;
   return 0;

}

Measured memory_bytes: 1792
#include <stdio.h>          // printf(), scanf()
#define MAX_N 500000

typedef struct node_tbl
{
	int key;
	int parent;
	int left;
	int right;
} node;

const int nil = -1;
node t[MAX_N + 1];
int root;
int room;
int ix;

int
tree_minimum(int u)
{
	while (t[u].left != nil)
		u = t[u].left;

	return u;
}

int
find(int u, int k)
{
	while (u != nil && k != t[u].key)
	{
		if (k < t[u].key)
			u = t[u].left;
		else
			u = t[u].right;
	}

	return u;
}

int
tree_successor(int u)
{
	if (t[u].right != nil)
		return tree_minimum(t[u].right);

	int y = t[u].parent;
	while (y != nil && u == t[y].right)
	{
		u = y;
		y = t[y].parent;
	}

	return y;
}

void
delete(int z)
{
	int y; /* ????????????????±? */
	int x; /* y?????? */

	/* ??????????????????????±??????? */
	if (t[z].left == nil || t[z].right == nil)
		y = z;
	else
		y = tree_successor(z);

	/* y??????x????±??????? */
	if (t[y].left != nil)
		x = t[y].left;
	else
		x = t[y].right;

	if (x != nil)
		t[x].parent = t[y].parent;

	if (t[y].parent == nil)
		root = x;
	else
	{
		if (y == t[t[y].parent].left)
			t[t[y].parent].left = x;
		else
			t[t[y].parent].right = x;
	}

	if (y != z)
		t[z].key = t[y].key;

	t[y].right = room;
	room = y;
}

void
insert(int k)
{
	int z;

	int y = nil;
	int x = root;
	if (room == nil)
		z = ix++;
	else
	{
		z = room;
		room = t[room].right;
	}

	t[z].key = k;
	t[z].left = nil;
	t[z].right = nil;

	while (x != nil)
	{
		y = x;
		if (t[z].key < t[x].key)
			x = t[x].left;
		else
			x = t[x].right;
	}

	t[z].parent = y;
	if (y == nil)
		root = z;
	else
	{
		if (t[z].key < t[y].key)
			t[y].left = z;
		else
			t[y].right = z;
	}
}

void
inorder(int u)
{
	if (u == nil)
		return;

	inorder(t[u].left);
	printf(" %d", t[u].key);
	inorder(t[u].right);
}

void
preorder(int u)
{
	if (u == nil)
		return;

	printf(" %d", t[u].key);
	preorder(t[u].left);
	preorder(t[u].right);
}

int
main(int argc, char** argv)
{
	char command[8];
	int n;
	int x;
	int i;

	root = nil;
	room = -1;
	ix = 0;
	scanf("%d", &n);
	for (i = 0; i < n; ++i)
	{
		scanf("%s", command);
		switch (command[0])
		{
		case 'd':
			scanf("%d", &x);
			delete(find(root, x));
			break;

		case 'f':
			scanf("%d", &x);
			printf("%s\n", find(root, x) != nil ? "yes" : "no");
			break;

		case 'i':
			scanf("%d", &x);
			insert(x);
			break;

		case 'p':
		default:
			inorder(root);
			printf("\n");

			preorder(root);
			printf("\n");
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 6868
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
 
int main(){
	int a, b;
	scanf(" %d %d", &a, &b);
	if(a + b >=10){
            printf("error");
}
    else{
           printf("%d", a+b);
    }
        return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int cnt = 0, res = 0;
    for(int i = 1; i <= n; i += 2)
    {
        cnt = 0;
        for(int j = 1; j <= i; j++)
        {
            if(i % j == 0)
                cnt++;
        }
        //cout << cnt <<endl;
        if(cnt == 8) res++;
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define uLL unsigned long long
#define db double

using namespace std;
const int N=2000+10,M=2e5+10,mod=1e9+7;
int rd()
{
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9') {if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') {x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
    return x*w;
}
void ad(int &x,int y){x+=y,x-=x>=mod?mod:0;}
int fpow(int a,LL b,int mod){int an=1;while(b){if(b&1) an=1ll*an*a%mod;a=1ll*a*a%mod,b>>=1;}return an;}
int ginv(int a,int mod){return fpow(a,mod-2,mod);}
int n,ans,z[M][2],f[N<<1][N<<1],fac[N<<2],iac[N<<2];
int C(int a,int b){return 1ll*fac[a]*iac[b]%mod*iac[a-b]%mod;}

int main()
{
	fac[0]=1;
	for(int i=1;i<=8000;++i) fac[i]=1ll*fac[i-1]*i%mod;
	iac[8000]=ginv(fac[8000],mod);
	for(int i=8000;i;--i) iac[i-1]=1ll*iac[i]*i%mod;
	n=rd();
	for(int i=1;i<=n;++i)
	{
		z[i][0]=rd(),z[i][1]=rd();
		ad(ans,mod-C(z[i][0]+z[i][0]+z[i][1]+z[i][1],z[i][0]+z[i][0]));
		ad(f[2000-z[i][0]][2000-z[i][1]],1);
	}
	for(int i=0;i<=4000;++i)
		for(int j=0;j<=4000;++j)
		{
			if(i) ad(f[i][j],f[i-1][j]);
			if(j) ad(f[i][j],f[i][j-1]);
		}
	for(int i=1;i<=n;++i)
		ad(ans,f[2000+z[i][0]][2000+z[i][1]]);
	ans=1ll*ans*ginv(2,mod)%mod;
	printf("%d\n",ans);
    return 0;
}


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

int main(){
    int num;
    int n[1000];
    cin >> num;

    for (int i = 0; i<num; i++){
        cin >> n[i];
    }
    for (int i = 1; i<num; i++){ // 確かめる配列の番号
        for (int p = 0; p < num; p++){
            cout << n[p];
            if (p < num -1) cout << " ";
        }
        for (int j=0; j<i; j++){    //
            if (n[i] < n[j]){ //小さければ
                int tmp = n[j];
                n[j] = n[i];
                n[i] = tmp;
            }
        }
        cout << endl;
    }
    for (int p = 0; p < num; p++){
        cout << n[p];
        if (p < num -1) cout << " ";
    }
    cout << endl;
}


Measured memory_bytes: 3104
#include <iostream>

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    int ma = a, mi = a;
    if (b > ma) {
        ma = b;
    }
    if (b < mi) {
        mi = b;
    }
    if (c > ma) {
        ma = c;
    }
    if (c < mi) {
        mi = c;
    }

    cout << ma - mi << endl;

    return 0;
}

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

int main(){
  string s,ans;
  cin>>s;
  int K;
  cin>>K;
  for(int i=0;i<s.size();i++){
    if(s[i]!='1'||i==K-1){ans=s[i];break;}
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {

    int n;
    double x, max_slope = 0.0, xi, hi;;
    cin >> n >> x;

    for ( int i=0; i<n; ++i ) {
	cin >> xi >> hi;
	double slope = hi/xi;
	if ( slope > max_slope ) max_slope = slope;
    }

    cout.setf(ios_base::fixed, ios_base::floatfield);
    cout << x*max_slope << endl;
    return 0;
}



Measured memory_bytes: 3272
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		String s = sc.next();
		int res = 0;
		
		if (n < 3) {
			System.out.println(res);
			return;
		}
		
		for (int i = 2; i < n; i++) {
			if (s.charAt(i) == 'C' && s.charAt(i-1) == 'B' && s.charAt(i-2) == 'A') {
				res++;
			}
		}
		
		System.out.println(res);
	}
	
	static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 23124
#include<iostream>
#include<memory.h>
using namespace std;
int main(){
	int a,b,c,d;
	while(cin>>a>>b>>c>>d){
	int dp[101];
	memset(dp,0,sizeof(dp));
	for(int i=a;i<b;i++){
		dp[i]++;
	}
	for(int i=c;i<d;i++){
		dp[i]++;
	}
	int cnt=0;
	for(int i=0;i<100;i++){
		if(dp[i]==2) cnt++;
		
	}
	cout<<cnt<<endl;
	}
	
}

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

int main(){
	ll n;cin>>n;
	priority_queue<ll> a;

	ll MIN=INF;
	for(ll i=0;i<n;i++){//n体のmonsterの体力
		ll num;
		cin>>num;
		a.push(num);
		MIN=min(MIN,num);
	}

	while(a.size()!=1){//1対以外が倒されるまで以下の操作

		//最小のmonsterが他の全てのmonsterの体力をできるだけ削る->余りをqueueに入れる
		//最小値を更新
		ll now=a.top();
		a.pop();
		if(now%MIN!=0){
			a.push(now%MIN);
			MIN=min(MIN,now%MIN);
		}
	}

	ll ans;
	ans=a.top();//残った1体

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

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

#define HAS_TEST_CASE 0  // Do you forget to complete this?

namespace registerGen
{
typedef long long ll;

const int N=5e5;

int n,m,a[N+10];
char str[N+10];

inline void main()
{
	int x;
	scanf("%d",&x);
	if(x>=30)puts("Yes");
	else puts("No");
}
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("tmp.out","w",stdout);
#endif
	int T=1;
#if HAS_TEST_CASE
	scanf("%d",&T);
#endif
	while(T--)registerGen::main();
	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <numeric>
#include <ctype.h>
#include <cstdlib>
#include <string.h>
#include <cmath>
#include <cstdio>





using namespace std;


int main()
{
	for (int i = 1; i < 10; i++)
	{
		for (int j = 1; j < 10; j++)
		{
			cout << i << "x" << j << "=" << i * j << endl;
		}
	}
}

Measured memory_bytes: 3012
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/*
 * ref. http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_C
 */

#define TABLE_SIZE 10000

struct dictionary_entry {
    char *val;
    struct dictionary_entry *next;
};

typedef struct dictionary_entry DictionaryEntry;
typedef DictionaryEntry *Dictionary[TABLE_SIZE];

// A = 0, C = 1, G = 2, T = 3

static int convert_char(char c) {
    if (c == 'A') {
        return 0;
    } else if (c == 'C') {
        return 1;
    } else if (c == 'G') {
        return 2;
    } else if (c == 'T') {
        return 3;
    } else {
        return -1;
    }
}

static int hash(char *str, int len) {
    int res = 0;
    for (int i = 0; i < len; i++) {
        res = res * 4 + convert_char(str[i]);
    }
    return res;
}

void insert(Dictionary dict, char *str, int len) {
    int h = hash(str, len);
    int ind = h % TABLE_SIZE;

    DictionaryEntry *entry = (DictionaryEntry *) malloc(sizeof (DictionaryEntry));
    entry->val = str;
    entry->next = dict[ind];
    dict[ind] = entry;
}

bool find(Dictionary dict, char *str, int len) {
    int h = hash(str, len);
    int ind = h % TABLE_SIZE;

    for (DictionaryEntry *entry = dict[ind]; entry != NULL; entry = entry->next) {
        if (strcmp(entry->val, str) == 0) {
            return true;
        }
    }

    return false;
}



#define MAX_N 1000000
#define MAX_STR_LEN 12

Dictionary dict;
char strings[MAX_N][MAX_STR_LEN + 2];

int main(void) {
    int n, str_len, strings_ind = 0;
    char buf[8];

    scanf("%d\n", &n);

    for (int i = 0; i < n; i++) {
        fgets(buf, 6, stdin);
        if (buf[0] == 'i') {
            // insert
            fgets(buf, 3, stdin);
            fgets(strings[strings_ind], MAX_STR_LEN + 2, stdin);
            str_len = strlen(strings[strings_ind]);
            strings[strings_ind][str_len - 1] = '\0';
            str_len--;

            insert(dict, strings[strings_ind], str_len); 
            strings_ind++;
        } else if (buf[0] == 'f') {
            // find
            fgets(strings[strings_ind], MAX_STR_LEN + 2, stdin);
            str_len = strlen(strings[strings_ind]);
            strings[strings_ind][str_len - 1] = '\0';
            str_len--;

            if (find(dict, strings[strings_ind], str_len)) {
                fprintf(stdout, "yes\n");
            } else {
                fprintf(stdout, "no\n");
            }
        } else {
            fprintf(stderr, "invalid command\n");
            return 1;
        }
    }

    return 0;
}



Measured memory_bytes: 27420
N = int(input())
T = list(map(int, input().split()))
H = list(map(int, input().split()))

H_to_T = []
for i in range(N):
    H_to_T.append(abs(T[1] - (T[0]-H[i]*0.006)))


print(H_to_T.index(min(H_to_T))+1)


Measured memory_bytes: 3060
#include<iostream>
#define MAX 100
using namespace std;
int main(){
	bool data[MAX][MAX*MAX+1];
	int n=0;
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<MAX*MAX+1;j++){
			data[i][j]=false;
		}
	}
	data[0][0]=true;
	int b=0;
	cin>>b;
	data[0][b]=true;
	int max=b;
	for(int i=1;i<n;i++){
		int a=0;
		cin>>a;
		for(int j=0;j<=max;j++){
			if(data[i-1][j]){
				data[i][j]=data[i-1][j];
				data[i][j+a]=true;
			}
		}
		max+=a;
	}
	int high=0;
	for(int i=0;i<=max;i++){
		if(data[n-1][i]){
			if((i%10)!=0){
				high=i;
			}
		}
	}
	cout<<high<<endl;
	return 0;
}

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

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }


int main(){
    ll N ,M, K;
    cin >> N >> M >> K;
    ll diff = N * M - K;
    bool flag = false;

    for(int i = 0; i <= M; i++){
        for(int j = 0; j <= N; j++){
            if(i * (N - j) + (M - i) * j == K){
                flag = true;
            }
        }
    }
    
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;

}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
	"sort"
)

func abs(x int) int { return int(math.Abs(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return abs(a[i]) > abs(a[j]) }

func main() {
	var N, ans int
	fmt.Scan(&N)

	A := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&A[i])
	}
	sort.Sort(SortBy(A))
	for i := 0; i < N-1; i++ {
		if A[i] < 0 {
			A[i] *= (-1)
			A[i+1] *= (-1)
		}
		ans += A[i]
	}
	fmt.Println(ans + A[N-1])
}


Measured memory_bytes: 5504
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>
// 追加１
#include <fstream>



using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()


int main()
{
	ll N, K;
	cin >> N >> K;
	
	cout << min(N % K, abs(N % K - K));

	return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <stdlib.h>
#include <stdio.h>

using namespace std;

int my_abs_A(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

int my_abs_B(long long num,long long numb) {
    if (num - numb >= 0)
        return num - numb;
    else
        return -1 * (num - numb);
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    long long N, K;
    cin >> N >> K;
    vector<long long> retu(N);
    for (long long i = 0; i < N; i++) {
        cin >> retu.at(i);
    }
    sort(retu.begin(), retu.end());
    reverse(retu.begin(), retu.end());
    if (N <= K) {
        for (long long j = 0; j < N; j++) {
            retu.at(j) = 0;
        }
    }
    else {
        for (long long j = 0; j < K; j++) {
            retu.at(j) = 0;
        }
    }
    
    long long ans = 0;
    for (long long k = 0; k < N; k++) {
        ans = ans + retu.at(k);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
const int N = 2e5 + 100;
 
int n, m, fa[N], Size[N], ans = 1;
inline int Find(int x) {return x == fa[x] ? x : fa[x] = Find(fa[x]);}
inline void Union(int x, int y) {
	x = Find(x); y = Find(y);
	if(x == y) return;
	fa[x] = y; Size[y] += Size[x];
	ans = max(ans, Size[y]);
}
 
int main() {
	scanf("%d%d", &n, &m);
	for(int i = 1;i <= n; ++i)
		fa[i] = i, Size[i] = 1;
	for(int i = 1;i <= m; ++i) {
		int u, v; scanf("%d%d", &u, &v);
		Union(u, v);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5176
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
//	"time"
)
var ( 
	N int
	A []int
)



var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
    buf := make([]byte, 0, 1000000)
    for {
        l, p, e := rdr.ReadLine()
        if e != nil {
            panic(e)
        }
        buf = append(buf, l...)
        if !p {
            break
        }
    }
    return string(buf)
}  

func stringToArr(str string )[]string{
   return strings.Split( str," ")	
}

func atoi(str string)int{
	 ret,_ := strconv.Atoi(str)
	 return ret
}
func atoi2(str []string)[]int{

	ret:= make([]int,len(str))

	for i,v := range(str){
		ret[i] = atoi(v)
	}
	return ret
}


func calc (a []int)int64{
	current:= a[0]
	var cnt int64
	cnt = int64(0)
	for i:=1; i< len(a); i++{
		if current > a[i]{
			cnt= cnt + int64(current - a[i])
		}else{
			current = a[i]
		}
	
	}
	return cnt

}


func main (){
//	start := time.Now()
N= atoi( readLine())
A= atoi2 ( stringToArr(readLine()))

re:= calc(A)



//s:= atoi2 (stringToArr( readLine()))
 
//N:=s[0]
//X:=s[1]
//T:=s[2]
/*
cnt:=0
for i:=0; i< len(N); i++ {
	n :=  N[i] - '0'
	cnt += int( n)
}
r:="No"

if  cnt % 9 == 0{
	r="Yes"
}*/



fmt.Println(re)
    
   //n,_ := strconv.Atoi( readLine());
   //l:= strings.Split( readLine(), " ");

   /*
   for i:=0; i<n ;i++ {

   }
	
   for i:=1; i<n ;i++ {
	 
   }
 
   for i:=0; i<n ;i++ {
fmt.Println ( person[i].childrenNumber)
   }*/

 //  end := time.Now()
 //  fmt.Printf("%fç§’\n", (end.Sub(start)).Seconds())

}

Measured memory_bytes: 12800