akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007

int main(){
  int N;
  cin>>N;
  vector<ll> a(N),b(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  for(int i=0;i<N;i++){
    cin>>b.at(i);
  }

  ll a_count=0,b_count=0;
  for(int i=0;i<N;i++){
    if(a.at(i)>b.at(i)){
      b_count+=a.at(i)-b.at(i);
    }else{
      if((b.at(i)-a.at(i))%2==0){
        a_count+=(b.at(i)-a.at(i))/2;
      }else{
        a_count+=(b.at(i)-a.at(i)-1)/2+1;
        b_count++;
      }
    }
  }

  if(a_count>=b_count){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 384
/*
luogu AT4826
*/
#include <bits/stdc++.h>
using namespace std;

#define int long long

const int M = 1e9+7ll;

int n;
int siz[200005],f[200005];
int ee,h[200005],nex[200005<<1],to[200005<<1];

int ksm(int x,int w)
{
	int s=1;
	while(w)
	{
		if(w&1)
			s = s*x%M;
		x = x*x%M;
		w >>= 1;
	}
	return s%M;
}

void addedge(int x,int y)
{
	nex[++ee] = h[x];
	to[ee] = y;
	h[x] = ee;
}

void getsiz(int x,int pre)
{
	siz[x] = 1;
	for(int i=h[x];i;i=nex[i])
		if(to[i]!=pre)
		{
			getsiz(to[i],x);
			siz[x] += siz[to[i]];
		}
	f[1] = f[1]*siz[x]%M;
}

void dfs(int x,int pre)
{
	for(int i=h[x];i;i=nex[i])
		if(to[i]!=pre)
		{
			f[to[i]] = f[x]*(n-siz[to[i]])%M*ksm(siz[to[i]],M-2)%M;
			dfs(to[i],x);
		}
}

signed main()
{
	cin>>n;
	for(int i=1,x,y;i<n&&cin>>x>>y;i++)
		addedge(x,y), addedge(y,x);
	f[1] = 1;
	getsiz(1,0);
	dfs(1,0);
	int s=1;
	for(int i=1;i<=n;i++)
		s = s*i%M;
	for(int i=1;i<=n;i++)
		cout<<s*ksm(f[i],M-2)%M<<endl;
	
	return 0;
}

Measured memory_bytes: 13184
Sd = input()
T = input()

No = 'UNRESTORABLE'

if len(T)>len(Sd):
    print(No)
    exit()

ofs = []
for i in range(len(Sd)-len(T)+1):
    for j in range(len(T)):
        if Sd[i+j] != T[j] and Sd[i+j] != '?':
            break
    else:
        ofs.append(i)

if not ofs:
    print(No)
    exit()

ans = ''
offset = ofs[-1]
for i in range(len(Sd)):
    if offset <= i < offset+len(T):
        ans += T[i-offset]
    else:
        if Sd[i] == '?': ans += 'a'
        else: ans += Sd[i]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#include <map>
#include <sstream>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
using namespace std;

int main(){
    int n;
    while (cin >> n){
    	int i;
    	for(i=1; i <= 512; i *= 2){
    		if ((i&n) != 0) {
    			cout << i;
    			break;
    		}
    	}
    	for(i = i*2; i <= 512; i *= 2){
    		if ((i&n) != 0) cout << ' ' << i;
    	}
    	cout << endl;
    }
}


Measured memory_bytes: 2964
N, W = map(int, input().split())

import numpy as np

dp = np.zeros(W + 1, dtype=np.longlong)

for i in range(N):
    w, v = map(int, input().split())
    np.maximum(dp[:-w] + v, dp[w:], out=dp[w:])

print(dp[-1])

Measured memory_bytes: 28884
//#include"cpp_kyopro.h"
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include<stdio.h>

using namespace std;

int main() {
	int n; cin >> n;
	vector<int > v(n);
	for (int i = 0; i < n; ++i) cin >> v[i];
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	int a=0, b=0;
	for (int i = 0; i < n; ++i) {
		if (i % 2 == 0)a += v[i];
		else b += v[i];
	}
	cout << a - b;
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
// #include <cassert>
#include <vector>
#include <algorithm>
#include <climits>

// #include <stack>
// #include <queue>
// #include <deque>
// #include <set>
// #include <map>
// #include <string>
// #include <unordered_set>
// #include <unordered_map>

// #include <tuple>
// #include <cmath>
// #include <numeric>

using namespace std;
typedef long long ll;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef pair<int,long> pil;
typedef pair<long,int> pli;
typedef vector<vector<long long>> vvll;
typedef vector<vector<long>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<long long> vll;

#define emplace_back pb
const char el = '\n';

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

    long long h,w; cin>>h>>w;

    if (h==1 || w==1) {
        cout<<1<<el;
    }   else { 
        if ((h*w)%2==1) {
                cout<<(h*w)/2+1<<el;
        } else {
            cout<<(h*w)/2<<el;
        }
    }

}

Measured memory_bytes: 256
/*C*/
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MOD 1000000007
typedef long long  ll;

using namespace std;

int ans;

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

	int H, W, K;
	cin >> H >> W >> K;

	vector<string> S(H);
	rep(i, H) {
		cin >> S[i];
	}

	for (int bit = 0; bit < (1 << (H + W)); ++bit) {
		vector<vector<bool>> flag(H, vector<bool>(W, true));
		for (int i = 0; i < H + W; ++i) { // bit(2:0b001)のどこに1があるか確認
			if (i < H) {
				if (bit & (1 << i)) { // bitのi番目にフラグが立っているか
					rep(k, W) {
						flag[i][k] = false;
					}
				}
			}
			else {
				if (bit & (1 << i)) { // bitのi番目にフラグが立っているか
					rep(k, H) {
						flag[k][i-H] = false;
					}
				}
			}
		}

		int cnt = 0;
		rep(a, H) {
			rep(b, W) {
				if (flag[a][b] == true && S[a][b] == '#') {
					cnt++;
				}
			}
		}

		if (cnt == K) {
			ans++;
		}
	}
	

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <map>
#include <numeric>
#define bogo_sort std::sort
#define bozo_sort std::stable_sort
#define alles(obj) obj.begin(), obj.end()
#define elif else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo std::cout <<
#define read std::cin >>
#define endl std::endl
#define fin << '\n'
#define bash push_back
#define makePair std::make_pair
#define _ << ' ' <<
// type-define
#define Stack std::stack
#define Queue std::queue
#define Set std::set
#define PQueue std::priority_queue
#define Vector std::vector
#define Pair std::pair
#define Map std::map
#define Greater std::greater
using String = std::string;
using llong = long long;
using boolean = bool;
using Pii = Pair<int, int>;
using Vi = Vector<int>;
using Vii = Vector<Pii>;
// utils
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    llong power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    llong power ( llong x, llong n ) { return power( x, n, 1000000007 ); }
    llong gcd ( llong x, llong y ) { return x % y ? gcd( y, x % y ) : y; }
    llong lcm ( llong x, llong y ) { return ( x / gcd(x, y) * y ); }
    llong abs ( llong n ) { return ( n < 0 ) ? -n : n; }
    boolean isMovable ( int x, int y, int w, int h ) { 
        return ( x >= 0 && y >= 0 && x < w && y < h ); }
}

namespace Rlyeh {

    Vi vi[100100];
    int dp[100100];

    int dfs ( int pos ) {
        if ( ~dp[pos] ) return dp[pos];

        int rec = 0;
        for ( int i = 0; i < vi[pos].size(); i++ ) {
            rec = std::max ( dfs(vi[pos][i]), rec );
        }
        if ( vi[pos].size() ) {
            rec++;
        }

        return dp[pos] = rec;
    }

    signed call_of_Cthulhu( signed datum ) {

        int n, m;
        read n >> m;

        for ( int i = 0; i < m; i++ ) {
            int from, to;
            read from >> to;
            vi[from].bash(to);
        }

        memset(dp, -1, sizeof(dp));

        for ( int i = 1; i <= n; i++ ) {
            dfs(i);
        }

        int max = 0;
        for ( int i = 1; i <= n; i++ ) {
            max = std::max ( max, dp[i] );
        }

        echo max fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 8192
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		S = S.replaceAll("eraser","");
        S = S.replaceAll("erase","");
        S = S.replaceAll("dreamer","");
        S = S.replaceAll("dream","");

		if(S.length() == 0) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 29196
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    vector<bool> a(n+1);
    vector<int>w(n+1,0);
    int acnt=0,wcnt=0;
    for(int i=0;i<m;i++){
        string s;
        int tmp;
        cin>>tmp>>s;
        if(s=="AC"){
            if(!a[tmp]){
                acnt++;
                wcnt+=w[tmp];
                a[tmp]=true;
            }
        }else{
            w[tmp]++;
        }
    }
    cout<<acnt<<" "<<wcnt<<endl;
    return 0;
}

Measured memory_bytes: 3760
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
constexpr int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int cnt = 0;
	string s; cin >> s;
	REP(i, s.size())if (s[i] == 'o')cnt++;
	if (cnt + 15 - s.size() >= 8)cout << "YES" << endl;
	else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    int A,B;
    cin >>A>>B;
    cout <<max(A+B,max(A-B,A*B))<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <set>

using namespace std;

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

	string S;
	cin >> S;

	set<char> char_set;

	for (int i = 0; i < S.size(); i++)
	{
		char_set.insert(S[i]);
	}

	int we_value = 0;
	int ns_value = 0;

	for (char e : char_set)
	{
		if (e == 'N') ns_value--;
		else if (e == 'S') ns_value++;
		else if (e == 'W') we_value--;
		else if (e == 'E') we_value++;
	}

	if (we_value == 0 && ns_value == 0)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}

	return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque

N, K = map(int, sys.stdin.readline().split())
P = list(map(int, sys.stdin.readline().split()))
C = list(map(int, sys.stdin.readline().split()))

# 重み付き有向グラフ
# edges = [[] for _ in range(N)]
# for i in range(N):
#     edges[i].append((P[i]-1, C[i]))

# DFSで閉路と経路の最大取得スコアを調査
ans = -float("inf")
for i in range(N):
    q = deque([(i, 0, 0)])
    cycle_score = -1
    cycle_count = -1
    cycle_start = None
    scores = {} # (score, count)
    while q:
        node1, score, count = q.popleft()
        # print(node1, score, count)
        if K < count:
            break
        if 0 < count: 
            ans = max(ans, score)
        if node1 in scores:
            # 閉路
            if score > 0:
                # print("plus cycle detected")
                # cycle.add((score, count, i))
                cycle_score = score
                cycle_count = count
                cycle_start = node1
            break
        scores[node1] = (score, count)
        # for で回しているが、実際は一択
        # for node2, weight in edges[node1]:
        #     q.appendleft((node2, score + weight, count + 1))
        node2 = P[node1] - 1
        weight = C[node2]
        q.append((node2, score + weight, count + 1))

    # cycleを回れる限界の-1から始めて、最大のスコアを算出
    if cycle_start is not None:
        cycle_len = cycle_count - scores[cycle_start][1]
        # print("cycle_len", cycle_len, "cycle_score", cycle_score - scores[cycle_start][0])
        loop = (K - scores[cycle_start][1]) // cycle_len - 1

        count = loop * cycle_len + scores[cycle_start][1]
        score = scores[cycle_start][0] + loop * (cycle_score - scores[cycle_start][0])
        # print(count, score, loop)
        q = deque([(cycle_start, score, count)])
        while q:
            node1, score, count = q.popleft()
            # print(node1, score, count)
            if count > K:
                break

            ans = max(ans, score)
            # for node2, weight in edges[node1]:
            #     q.appendleft((node2, score + weight, count + 1))
            node2 = P[node1] - 1
            weight = C[node2]
            q.append((node2, score + weight, count + 1))

print(ans)

Measured memory_bytes: 220324
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    int n;
    cin >> n;
    int sm = 0;
    int mx = 0;
    for (int i = 0; i < n; i++) {
        int p;
        cin >> p;
        sm += p;
        mx = max(mx, p);
    }

    cout << sm - mx/2 << "\n";
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> number(N);
  
  for(int i = 0; i < N; i++){
    cin >> number.at(i);
  }
  
  int sum = 0;
  
  for(int i = 0; i < N; i++){
    for(int j = i + 1; j < N; j++){
      
      sum += number.at(i) * number.at(j);
    }
    }
  
  cout << sum << endl;

}

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

using namespace std;

#define ll long long
ll input(){
	ll x=0,f=0;char ch=getchar();
	while(ch<'0'||ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return f? -x:x;
}

const int N=1e5+7;

ll dp[N],v[N],w[N];

int main(){
	ll n=input(),W=input();

	int V=0;

	for(int i=1;i<=n;i++){
		w[i]=input(),v[i]=input();
		V+=v[i];
	}

	fill(dp+1,dp+1+V,0x3f3f3f3f);

	int Ans=0;
	dp[0]=0;

	for(int i=1;i<=n;i++){
		for(int j=V;j>=0;j--){
			if(j+v[i]>V) continue;
			dp[j+v[i]]=min(dp[j]+w[i],dp[j+v[i]]);
		}
	}
	for(int i=1;i<=V;i++){
		if(dp[i]<=W) Ans=i;
	}
	
	cout<<Ans<<endl;
}

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    lli A, B, C, K;
    cin >> A >> B >> C >> K;
    cout << (B - A) * (2 * (K % 2) - 1) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
#define _GLIBCXX_DEBUG
using namespace std;

int main(){
  int64_t n,q;
  string s;
  cin >> n;
  cin.ignore();
  cin >> s;
  cin >> q;
  int64_t DIV = 700;
  ////////////
  vector<vector<int64_t>> bottom_a(26,vector<int64_t>(500000));
  vector<vector<int64_t>> upper_a(26,vector<int64_t>(750));
  rep(i,n){
    bottom_a[s[i]-'a'][i]++;
    upper_a[s[i]-'a'][i/DIV]++;
  }
  rep(iq,q){
    /*rep(i,(n+DIV-1)/DIV){
      rep(j,26){
        cout << upper_a[j][i];
      }
    }
    cout << endl;*/
    int querytype;
    cin >> querytype;
    if(querytype == 1){
      int64_t k;
      char qc;
      cin >> k >> qc;
      //cout << k <<" " <<  qc << endl;
      k--;
      char notqc = s[k];
      s[k] = qc;
      //cout << qc << notqc << endl;
      bottom_a[notqc-'a'][k]--;
      bottom_a[qc-'a'][k]++;
      upper_a[notqc-'a'][k/DIV]--;
      upper_a[qc-'a'][k/DIV]++;
    }else{
      int64_t ql,qr;
      cin >> ql >> qr;
      ql--;
      qr--;
      vector<bool> exalp(26);
      if(ql/DIV != qr/DIV){
        int64_t bigql = (ql+DIV-1)/DIV,bigqr = (qr/DIV)-1;
        //printf("%ld,%ld\n",bigql,bigqr);
        for(int64_t i=ql;i < bigql*DIV;i++){
          rep(j,26){
            exalp[j] = exalp[j] || (bottom_a[j][i] > 0);
          }
        }
        for(int64_t i=bigql;i <= bigqr;i++){
          rep(j,26){
            exalp[j] = exalp[j] || (upper_a[j][i] > 0);
          }
        }
        for(int64_t i=(bigqr+1)*DIV;i <= qr;i++){
          rep(j,26){
            exalp[j] = exalp[j] || (bottom_a[j][i] > 0);
          }
        } 
      }else{
        for(int64_t i=ql;i <= qr;i++){
          rep(j,26){
            exalp[j] = exalp[j] || (bottom_a[j][i] > 0);
          }
        }
      }
        
      int64_t cnt=0;
      rep(i,26){
        if(exalp[i]){
          cnt++;
        }
      }
      cout << cnt << endl;
      
    }
    ////
    /*rep(i,n){
      rep(j,26){
        cout << bottom_a[j][i];
      }
      cout << endl;
    }*/
    ////
  }
}
      
    

Measured memory_bytes: 106500
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 2e2+5;

int n , d;

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


int main(){
    cin >> n >> d;
    long long gd = 0;
    for(int i = 1; i <= n; i++){
        int x;
        cin >> x;
        gd = gcd(gd , abs(x - d));
    }
    cout << gd << endl;
}





Measured memory_bytes: 764
#include <iostream>

using namespace std;

int main()
{
    int l=0,i;
    char c;
    cin>>c;
    string s="aeiou";
    for(i=0;i<5;i++){
        if(c==s[i])
           l=9;
    }
    if(l==9)
       cout<<"vowel";
    else
        cout<<"consonant";
}


Measured memory_bytes: 256
#include<cstdio>

typedef long long int lli;

lli a[1000000];

int main(void) {
    lli n,x;
    scanf("%lld%lld",&n,&x);
    for(lli i=0; i<n; i++)
        scanf("%lld",&a[i]);

    lli res=0;
    // a[i] -y + a[i-1] <= x
    // y >= a[i] + a[i-1] - x
    if(a[0] > x) res+= a[0]-x, a[0]=x;

    for(lli i=1; i<n; i++) {
        if(a[i] + a[i-1] > x) {
            res += a[i] + a[i-1] - x;
            a[i] -= a[i] + a[i-1] - x;
        }
    }
    printf("%lld\n",res);



}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main() {
	int x, n, p, min, min_n;
	cin >> x >> n;
	vector<bool> exst(101, true);
	for (int i = 0; i < n; i++) {
		cin >> p;
		exst.at(p) = false;
	}
	min = x;
	min_n = 0;
	for (int i = 1; i < 101; i++) {
		if (exst.at(i)) {
			if (abs(i - x) < min) {
				min = abs(i - x);
				min_n = i;
			}
		}
	}
	for (int i = 101; i < 201; i++) {
		if (abs(i - x) < min) {
			min = abs(i - x);
			min_n = i;
		}
	}
	cout << min_n << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define INPUTSTRING 150
#define RINGSTRING 250

void copy_string(char * source, char * destination)
{
    int length = strlen(source) - 1;
    
    strncpy(destination, source, length);
    strcat(destination, source);
}

int find(char * ringed, char * search)
{
    char * buffer = (char*)malloc(sizeof(char) * strlen(search));
    //char * EOL = malloc(1);   //デバッグ用
    //*EOL = '\0';  //デバッグ用
    int length = strlen(ringed);
    int bufferlength = strlen(search);
    int i;
    //int cmp;  //デバッグ用
    //printf("debugging point 2\n");    //デバッグ用
    for(i = 0; i < length - bufferlength; i++){
        strncpy(buffer, ringed + i, bufferlength - 1);
        //strncat(buffer, EOL, 1);  //デバッグ用
        //cmp = strcmp(buffer, search); //デバッグ用
        //printf("%s and %s :  %d %d %d %d %d\n", buffer, search, cmp, strlen(search), sizeof(search), strlen(buffer), sizeof(buffer)); //デバッグ用
        if(strncmp(buffer, search, strlen(buffer)) == 0){ //strlen(search)とstrlen(buffer)が違う理由がわからないからてあきらめてstrcmpじゃなくてstrncmp使用した
            free(buffer); 
            return 1;
        }
    }
    free(buffer);
    //free(EOL);    //デバッグ用
    return 0;
}


int main(void)
{
    char * ring = (char*) malloc(sizeof(char) * INPUTSTRING);
    char * search = (char*) malloc(sizeof(char) * INPUTSTRING);
    char * ringed = (char*)malloc(sizeof(char) * RINGSTRING);
    int found;
    
    fgets(ring, sizeof(char) * INPUTSTRING, stdin);
    fgets(search, sizeof(char) * INPUTSTRING, stdin);
    
    copy_string(ring, ringed);

    //printf("%s", search); //デバッグ用
    //printf("%s", ringed); //デバッグ用

    found = find(ringed, search);

    if(found == 1) printf("Yes\n");
    else if(found == 0) printf("No\n");
    else printf("Error\n");

    free(ring);
    free(search);
    free(ringed);

    return 0;
}


Measured memory_bytes: 2100
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef multiset<int> MS;
typedef queue<int> Q;
typedef priority_queue<int> PQ;
typedef deque<int> DQ;

int main(){
    int n,k; cin>>n>>k;
    DQ deq;
    for(int i=0; i<n; i++) {
        int tmp; cin>>tmp;
        deq.push_back(tmp);
    }
    int min_nk = min(n,k);
    int ans = 0;
    for(int a=0; a<=min_nk; a++){
        for(int b=0; b<=min_nk; b++){
            if(a+b <= min_nk){
                int cnt = 0, tmp;
                DQ v = deq;
                PQ minus;
                for(int i=0; i<a; i++){
                    if(v.empty()) break;
                    tmp = v.front();
                    v.pop_front();
                    cnt += tmp;
                    if(tmp<0) minus.push(tmp*(-1));
                }
                for(int j=0; j<b; j++){
                    if(v.empty()) break;
                    tmp = v.back();
                    v.pop_back();
                    cnt += tmp;
                    if(tmp<0) minus.push(tmp*(-1));
                }
                for(int l=0; l<(k-a-b); l++){
                    if(minus.empty()) break;
                    cnt += minus.top();
                    minus.pop();
                }
                ans = max(ans,cnt);
            }
        }
    }
    OUT(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 100007
#define INF 1e9 + 7

using namespace std;
typedef long long ll;

ll dp[MAX], n, arr[MAX];
ll solve(int i){
    if(i == n-1) return 0LL;

    if(i >= n) return INF;
    if(dp[i] != -1) return dp[i];

    ll ans = solve(i+2) + abs(arr[i+2]-arr[i]);
    ans = min(ans, solve(i+1) + abs(arr[i+1]-arr[i]));
    return dp[i] = ans;
}
int main(){
    scanf("%d", &n);
    for(int i = 0; i < MAX; i++) arr[i] = INF;
    for(int i = 0; i < n; i++) scanf("%d", &arr[i]);
    memset(dp, -1, sizeof dp);
    printf("%lld\n", solve(0));
    return 0;
}

Measured memory_bytes: 3328
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N,M,Q;
int64_t S[100100];
int64_t T[100100];
int64_t X[100100];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N>>M>>Q;
	for (size_t i = 1; i <= N; i++)
	{
		in >> S[i];
	}
	N += 2;
	S[0] = -100000000001000000;
	S[N-1] = 100000000001000000;
	for (size_t i = 1; i <= M; i++)
	{
		in >> T[i];
	}
	M += 2;
	T[0] = -100000000001000000;
	T[M - 1] = 100000000001000000;
	for (size_t i = 0; i < Q; i++)
	{
		in >> X[i];
	}



	for (size_t i = 0; i < Q; i++)
	{
		auto iter1 = std::lower_bound(S, S + N, X[i]);
		auto iter2 = std::lower_bound(T, T + M, X[i]);
		out << std::min({
			std::max(*iter1 - X[i],*iter2 - X[i]),
			std::max(X[i] - *(iter1 - 1),X[i] - *(iter2 - 1)),
			(*iter1 - X[i]) * 2 + X[i] - *(iter2 - 1),
			(*iter2 - X[i]) * 2 + X[i] - *(iter1 - 1),
			(*iter1 - X[i]) + (X[i] - *(iter2 - 1)) * 2,
			(*iter2 - X[i]) + (X[i] - *(iter1 - 1)) * 2,
			}) << endl;
	}

	return 0;
}
#endif


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

int main () {
    int N, A, B;
    int total = 0;
    cin >> N >> A >> B;

    for (int i = 1; i <= N; i++) {
        int sum = 0;
        for (int j = i; j != 0; j /= 10) {
            sum += j % 10;
        }
        if (sum >= A) {
            if (sum <= B) total = total + i;
        }
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 256
h,w=map(int, input().split())
a=['']*h
for i in range(h):
    a[i]=input()

row=[False]*h
col=[False]*w
for i in range(h):
    for j in range(w):
        if a[i][j]=='#':
            row[i]=True
            col[j]=True

for i in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j],end='')
        print()

Measured memory_bytes: 4468
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
count = Counter(A) #not dict!!
temp_sum = sum(A)
for _ in range(Q):
    before, after = map(int, input().split())
    temp_sum += (after - before) * count[before]
    count[after] += count[before]
    count[before] = 0
    print(temp_sum)

Measured memory_bytes: 24324
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
vector<int64_t> vec1;
vector<int64_t> vec2;
int64_t N, M, K;


int main() {
    cin >> N >> M >> K;
    vec1.resize(N+1);
    vec2.resize(M+1);
    int64_t n_sum = 0;
    for (int64_t i=0; i<N; i++) {
        int64_t n;
        cin >> n;
        vec1[i] = n_sum;
        n_sum += n;
    }

    vec1[N] = n_sum;
    int64_t m_sum = 0;
    for (int64_t i=0; i<M; i++) {
        int64_t m;
        cin >> m;
        vec2[i] = m_sum;
        m_sum += m;
    }

    vec2[M] = m_sum;

    int64_t ans = 0;
    int64_t j = M;
    for (int i=0; i<=N; i++) {
        if (vec1[i] > K) {
            break;
        }

        while (vec2[j] > (K - vec1[i])) {
            j--;
        }

        ans = max(ans, i+j);
    }

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

Measured memory_bytes: 6340
// ctrl+shift+b
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll X; cin >> X;
    if (X == 3 || X == 5 || X == 7){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3604
using System;
using System.Linq;
using System.Collections.Generic;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var h = int.Parse(_[0]);
            var w = int.Parse(_[1]);

            var s = new string[h];
            for(var i = 0; i < h; i++){
                s[i] = Console.ReadLine().Trim();
            }

            Console.WriteLine(new string('#', w + 2));
            for(var i = 0; i < h; i++){
                Console.WriteLine("#" + s[i] + "#");
            }
            Console.WriteLine(new string('#', w + 2));
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
using namespace std;

typedef long long ll;

int dx[4] = { 0, -1, 1, 0 };
int dy[4] = { -1, 0, 0, 1 };

int m[1010];

int main() {
  int a, b;
  cin >> a >> b;
  int res = 0;
  for (int i = a; i <= b; ++i) {
    if (i % 10 == i / 10000 && i / 10 % 10 == i / 1000 % 10) {
      ++res;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=100010;
int a[MAXN],n,cnt;
int read(){
    int f=1,x=0;
    char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();}
    return f*x;
}
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++){
        if(i==1) cnt=a[i];
        else cnt=gcd(cnt,a[i]);
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

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

int main(){
    int n, m; cin>>n>>m;
    vector<int> indeg(n+10, 0);
    vector<vector<int>> g(n+10);
    for(int i=0; i<m; i++){
        int x, y; cin>>x>>y;
        x--, y--;
        g[x].eb(y);
        indeg[y]++;
    }

    queue<int> que;
    for(int i=0; i<n; i++){
        if(indeg[i]==0){
            que.push(i);
        }
    }

    vector<int> dp(n+10, 0);
    while(que.size()){
        int cv=que.front(); que.pop();

        for(auto nv:g[cv]){
            indeg[nv]--;

            dp[nv]=max(dp[nv], dp[cv]+1);

            if(indeg[nv]==0){
                que.push(nv);
            }
        }
    }
    
    int ans=0;
    for(int i=0; i<n; i++){
        chmax(ans, dp[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6528
#!/usr/bin/env python3

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N = int(input())
A = list(map(int, input().split()))

Amax = max(A)
dp = [True] * Amax
seen = set()

for a in A:
    if a in seen:
        dp[a-1] = False
        continue
    i = 2
    while i * a <= Amax:
        dp[i*a-1] = False
        i += 1
    seen.add(a)


B = [dp[a-1] for a in A]
print(sum(B))




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

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repp(i, s, e) for (int i = (s); i < (e); i++)
#define all(x) x.begin(), x.end()

#define INF 2123456789
#define IINF 9123456789123456789

void use_cio() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}

//--------------------------------------------------//
int main() {
    use_cio();
    int n, k;
    cin >> n >> k;
    if (k % 2 == 0) {
        int m = k / 2;
        ll ans = 1LL * (n / k) * (n / k) * (n / k);
        if (n % k >= m) {
            cout << ans + 1LL * (n / k + 1) * (n / k + 1) * (n / k + 1) << "\n";
        } else {
            cout << ans * 2 << "\n";
        }
    } else {
        cout << 1LL * (n / k) * (n / k) * (n / k) << "\n";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream> 
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;

#define assert_range(x,a,b) assert((a) <= (x) and (x) <= (b))
using ll = long long;
const int INF = 1e9;

const int N = 1e5;
vector<int> g[N];
bool visited[N];

void dfs(int v, vector<int>& order) {
    visited[v] = true;
    for (auto u : g[v]) {
        if (visited[u]) continue;
        dfs(u, order);
    }
    order.push_back(v);
}
int main() {
    ios_base::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int v, u;
        cin >> v >> u;
        --v, --u;
        g[v].push_back(u);
    }
    vector<int> order;
    for (int i = 0; i < n; ++i) {
        if (visited[i]) continue;
        dfs(i, order);
    }
    vector<int> dp(n);
    for (auto v : order) {
        for (auto u : g[v]) {
            dp[v] = max(dp[v], dp[u]+1);
        }
    }
    int res = 0;
    for (int i = 0; i < n; ++i) {
        res = max(res, dp[i]);
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 8824
class imosOneDimension:
    def __init__(self, size):
        self.table = [0 for i in range(size)]

    def setTable(self):
        for i in range(len(self.table)-1):
            if is_prime(i) and is_prime(int((i + 1) / 2)):
                self.table[i] = 1
                # self.table[i] += self.table[i - 1]

    def cumulativeSum(self):
        for i in range(1, len(self.table)):
            self.table[i] += self.table[i - 1]


def is_prime(n):
    if n == 1:
        return False
    if n == 2:
        return True
    if n % 2 == 0:
        return False
    i = 3
    while i ** 2 <= n:
        if n % i == 0:
            return False
        i += 2
    return True

imos = imosOneDimension(size=10 ** 5 + 1)
imos.setTable()
imos.cumulativeSum()
q = int(input())
for i in range(q):
    l, r = [int(i) for i in input().split()]
    print(imos.table[r] - imos.table[l - 1])


Measured memory_bytes: 6424
import sys
def input(): return sys.stdin.readline().rstrip()
 
def main():
    n=int(input())
    A=list(map(int, input().split()))
    ans = 0
    mod = 10**9 + 7
    for i in range(60):
        q = sum(map(lambda x:((x >> i) & 0b1),A))
        ans += q*(n-q)*pow(2, i, mod)
        ans = ans % mod
    print(ans)
 
if __name__=='__main__':
    main()

Measured memory_bytes: 124476
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N, A, B;
  cin >> N >> A >> B;
  cout << max((N - 2) * (B - A) + 1, 0LL) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
#define INFLL 1ull<<60u
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;


void print_map(const vector<vector<char>> &vv) {
    for(const auto &str: vv) {
        for(const auto &c: str) cout << c;
        cout << endl;
    }
}

int vh[4] = { 0,0,-1,1 };
int vw[4] = { 1,-1,0,0 };

int magic[5] = {-2 ,-1 ,0,1,2};

vector<vector<int>> cost_map;
void solve() {
    int H,W; cin >> H >> W;
    vector<vector<char>> vv(H+4,vector<char>(W+4,'#'));

    pair<int,int> start,dest;
    int sh,sw,dh,dw;

    cin >> sh >> sw; sh++; sw++;
    start = make_pair(sh,sw);

    cin >> dh >> dw; dh++; dw++;
    dest = make_pair(dh,dw);

    REP(i,H) {
        string s; cin >> s;
        REP(j,W) vv[i+2][j+2] = s[j];
    }

    cost_map.resize(H+4,vector<int>(W+4,INF));

    cost_map[sh][sw] = 0;



    auto bfs = [&]() {

        deque<pair<int,int>> qp;
        qp.push_front(start);

        while(!qp.empty()) {
            auto [h,w] = qp.front(); qp.pop_front();
            int cnt = 0;

            // 上下左右移動
            REP(i,4) if(vv[h+vh[i]][w+vw[i]] == '.') {
                cnt++;
                if(chmin(cost_map[h+vh[i]][w+vw[i]],cost_map[h][w])) {
                    qp.push_front(make_pair(h+vh[i],w+vw[i]));
                }
            }

            // 上下左右に道があった場合はべつにそこから25マス見る必要はないから。
            if(cnt == 4) continue;

            // 25マス移動
            REP(i,5)REP(j,5) {
                if(vv[h+magic[i]][w+magic[j]] == '.') {
                    if(chmin(cost_map[h+magic[i]][w+magic[j]],cost_map[h][w]+1)) qp.push_back(make_pair(h+magic[i],w+magic[j]));
                }
            }
        }
    };
    bfs();

    if (cost_map[dh][dw] != INF) cout << cost_map[dh][dw] << endl;
    else cout << -1 << endl;

}

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

Measured memory_bytes: 8648
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();
		Arrays.sort(s);
		Arrays.sort(t);
		for (int i = 0; i < Math.min(s.length, t.length); i++) {
			if (s[i] == t[t.length - 1 - i]) {

			} else if (s[i] > t[t.length - 1 - i]) {
				System.out.println("No");
				return;
			} else if (s[i] < t[t.length - 1 - i]) {
				System.out.println("Yes");
				return;
			}
		}
		if (s.length < t.length) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 24148
import collections

N = int(input())
a = list(map(int, input().split()))

c = collections.Counter(a)
k = list(c.keys())
v = list(c.values())

count = 0
for i in range(len(k)):
    if k[i] < v[i]:
        count += v[i] - k[i]
    elif k[i] > v[i]:
        count += v[i]

print(count)


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

#define debug(var)  do{std::cerr << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cerr << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cerr << e << " "; } std::cerr << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> v1;
typedef vector<v1> v2;
typedef vector<v2> v3;

typedef unordered_map<ll, unordered_map<ll, ll>> graph;

const ll INF = 1ll << 50;
const ll mod = 1000000007;

ll n;
graph g;
ll a;
ll b;

int main(){
    cin >> n;
    for(ll i = 1;i < n;i++){
        ll u,v;
        cin >> u >> v;
        if(u > v) swap(u,v);
        g[u][v] = 0;
    }
    for(ll i = 1, j = n;i <= n;i++,j--){
        a += i*j;
    }
    // debug(a);
    for(ll i = 1;i <= n;i++){
        for(auto p : g[i]){
            ll j = p.first;
            b += i*(n-j+1);
        }
    }
    cout << a-b << endl;
}


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

int main()
{
    int X, Y;
    cin >> X >> Y;
    if( (Y%2==0) && (2 * X <= Y && Y <= 4 * X)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
S = input()
listS = []
for i in range(len(S)):
  listS.append(S[i])
  

def check_ACGT(array):
  cnt = 0
  for i, elm in enumerate(array):
    if elm not in ["A", "C", "G", "T"]:
      cnt += 1
  return True if cnt == 0 else False

ans = 0
for i in range(len(listS)):
  for j in range(len(listS)):
    if i<j+1:
      sublistS = listS[i:(j+1)]
      if check_ACGT(sublistS) and ans < len(sublistS):
        ans = len(sublistS)

print(ans)

Measured memory_bytes: 3064
use std::io::stdin;

fn main() {
  let mut a = String::with_capacity(4); // 1000\nの5文字
  stdin().read_line(&mut a)
  	.expect("Too long! Please input 4 characters or less.");
  let a: i32 = a.trim().parse().expect("Please input number");
  if a >= 30 {
    println!("Yes");
  } else {
  	println!("No");
  }
}

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

int main(){
	int x, y, a, b, c;
  	cin >> x >> y >> a >> b >> c;
  	vector<int> red(a), green(b), less(c);
  	rep(i, a) cin >> red[i];
   	rep(i, b) cin >> green[i];
  	rep(i, c) cin >> less[i];

  	sort(red.rbegin(), red.rend());
   	sort(green.rbegin(), green.rend());

	vector<int> d;
  	rep(i, x) d.push_back(red[i]);
    rep(i, y) d.push_back(green[i]);
    rep(i, c) d.push_back(less[i]);
	sort(d.rbegin(), d.rend());
  
  	ll ans = 0;
  	rep(i, x + y) ans += d[i];
  	cout << ans << endl;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define eps 0.000000001
using namespace std;
typedef long double ld;
typedef pair<int,int> p;
typedef pair<ld,p> P;

int n;
ld px[200],py[200],pz[200],vx[200],vy[200],vz[200],r[200],vr[200];

ld getlen(ld x1,ld x2,ld y1,ld y2,ld z1,ld z2,ld r1,ld r2){
  ld dx=x2-x1,dy=y2-y1,dz=z2-z1;
  return sqrt(dx*dx+dy*dy+dz*dz)-(r1+r2);
}

ld check(int a,int b){
  ld mt=min(r[a]/vr[a],r[b]/vr[b]);
  ld L=0,R=mt,M;
  int s=0;
  while(s++<50){
    M=(L+R)/2;
    ld ax=px[a]+vx[a]*M,ay=py[a]+vy[a]*M,az=pz[a]+vz[a]*M,ar=r[a]-vr[a]*M;
    ld bx=px[b]+vx[b]*M,by=py[b]+vy[b]*M,bz=pz[b]+vz[b]*M,br=r[b]-vr[b]*M;
    ld M1=M+eps;
    ld ax1=px[a]+vx[a]*M1,ay1=py[a]+vy[a]*M1,az1=pz[a]+vz[a]*M1,ar1=r[a]-vr[a]*M1;
    ld bx1=px[b]+vx[b]*M1,by1=py[b]+vy[b]*M1,bz1=pz[b]+vz[b]*M1,br1=r[b]-vr[b]*M1;
    ld len=getlen(ax,bx,ay,by,az,bz,ar,br),len1=getlen(ax1,bx1,ay1,by1,az1,bz1,ar1,br1);
    if(len<len1||len<=0)R=M;
    else L=M;
  }
  ld ax=px[a]+vx[a]*R,ay=py[a]+vy[a]*R,az=pz[a]+vz[a]*R,ar=r[a]-vr[a]*R;
  ld bx=px[b]+vx[b]*R,by=py[b]+vy[b]*R,bz=pz[b]+vz[b]*R,br=r[b]-vr[b]*R;
  if(R==mt||L==0||getlen(ax,bx,ay,by,az,bz,ar,br)>0)return 1000;
  return R;
}

int main(){
  while(cin>>n,n){
    for(int i=0;i<n;i++)
      cin>>px[i]>>py[i]>>pz[i]>>vx[i]>>vy[i]>>vz[i]>>r[i]>>vr[i];
    priority_queue<P,vector<P>,greater<P> > q;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++)
	q.push(P(check(i,j),p(i,j)));
      q.push(P(r[i]/vr[i],p(i,i)));
    }
    ld used[200]={};
    while(!q.empty()){
      ld t=q.top().first;
      int a=q.top().second.first,b=q.top().second.second;
      q.pop();
      if(used[a]||used[b])continue;
      used[a]=used[b]=t;
    }
    for(int i=0;i<n;i++)printf("%.10Lf\n",used[i]);
  }
  return 0;
}

Measured memory_bytes: 4496
#include <bits/stdc++.h>
#define int long long
#define sz(x) (int)(x.size())
using namespace std;

const int N = 1e5 + 5, inf = 1e8, mod = 1e9 + 7;

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);	
  
    int a, b, c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

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

int main() {
  int p, q, r; cin >> p >> q >> r;

  cout << (p + q + r) - max(p, max(q, r)) << endl;
  return 0;
}


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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    if (n <= k) {
      cout << x * n << endl;
    } else {
      cout << k * x + (n - k) * y << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
int N=0;
int ans=0;

int main(){
  	cin >>N;
  	int p[N+1]={};
  	for(int i=0;i<N;i++) cin >>p[i];
  	
  	sort(p,p+N);
  	for(int x:p){
    	ans+=x;
    }
  	ans-=p[N-1]/2;
  
  	cout <<ans <<endl;
}

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

int a[110];

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

    int n;cin>>n;
    int sum=0;
    for(int i=0;i<n;i++){cin>>a[i];sum+=a[i];}

    int avg=sum/n+((sum%n)*2)/n;

    int ans=0;
    for(int i=0;i<n;i++)ans+=(a[i]-avg)*(a[i]-avg);

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 3616