akhauriyash/Code-Regression huggingface dataset:
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template<typename T> T lcm(const T a, const T b) {
    return a / gcd(a, b) * b;
}

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

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

// End of template.

int main() {
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cin.read(buf, sizeof buf); // 注意: ./a.out < in か pbp | ./a.out で入力すること

    string s;
    cin >> s;

    bool ans = true;
    if (s.size() % 2 == 0) {
        rep(i, s.size() / 2) ans &= s[2*i] == 'h' && s[2*i + 1] == 'i';
    } else {
        ans = false;
    }

    if (ans) print("Yes"); else print("No");

    return 0;
}



Measured memory_bytes: 256
N, M, X = map(int, input().split())
A = [int(i) for i in input().split()]

cost0 = 0
costN = 0

for i in range(1, N):
    if i in A:
        if i < X:
            cost0 += 1
        else:
            costN += 1

print(min(cost0, costN))


Measured memory_bytes: 2940
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,H;
	while(cin>>H>>N) {
		VI A(N), B(N);
		REP(i, N) cin>>A[i]>>B[i];
		VI dp(H+1, INF);
		dp[0] = 0; //H
		REP(h, H+1) {
			REP(i, N) {
				ll nh = min(h+A[i], H);
				minUpdate(dp[nh], dp[h]+B[i]);
			}
//			DD(dp);
		}
		
		cout<<dp[H]<<endl;
//		break;
	}
	
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1ll;while(b){if(b&1)ans=ans*a%MOD;a=a*a%MOD;b>>=1;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/

int main()
{
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\in.txt.txt","r",stdin);
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\out.txt.txt","w",stdout);
	int sx,sy;
	int tx,ty;
	cin>>sx>>sy>>tx>>ty;
	int sc=ty-sy;
	int yc=tx-sx;
	repd(i,1,sc)
	{
		cout<<"U";
	}
	repd(i,1,yc)
	{
		cout<<"R";
	}
	repd(i,1,sc)
	{
		cout<<"D";
	}
	repd(i,1,yc)
	{
		cout<<"L";
	}

	cout<<"L";
	repd(i,0,sc)
	{
		cout<<"U";
	}
	repd(i,0,yc)
	{
		cout<<"R";
	}
	cout<<"D";
	cout<<"R";
	repd(i,0,sc)
	{
		cout<<"D";
	}
	repd(i,0,yc)
	{
		cout<<"L";
	}
	cout<<"U";
    return 0;

}

inline void getInt(int* p) {char ch;do {ch = getchar();} 
while (ch == ' ' || ch == '\n');if (ch == '-') {*p = -(getchar() - '0');
while ((ch = getchar()) >= '0' && ch <= '9') {*p = *p * 10 - ch + '0';}}
else {*p = ch - '0';while ((ch = getchar()) >= '0' && ch <= '9') 
{*p = *p * 10 + ch - '0';}}}

Measured memory_bytes: 888
n, k = map(int, input().split())
L = list(map(int, input().split()))
d = {}
for a in L:
    if a not in d:
        d[a] = 1
    else:
        d[a] += 1
l = []
for v in d.values():
    l.append(v)
l.sort(reverse=True)
print(n - sum(l[:k]))


Measured memory_bytes: 32184
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
using namespace std;

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	int a[n+1] = {};
	rep(i,0,n)cin >> a[i];
	ll ans = 0;
	rep(i,0,n){
		ans += a[i]/2;	
		a[i] -= a[i]/2 * 2;
		if(a[i] == 1 && a[i+1] != 0){
			--a[i+1];
			--a[i];
			++ans;
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

int main(){

    int n, m;
    cin >> n >> m;

    vector<int> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];

    int ans = 0;
    for(int i = 0; i < n; i++){
        if( v[i] * 4 * m >= accumulate( all(v), 0  ) ) ans++;
    }
    
    if(ans >= m) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

ll dp[101][10][1001];

// i以下の数字をk個使って総和をtにする場合の数
ll dfs(int i,int k,int t){
	if(t<0 || k<0) return 0;
	if(i<0){
		if(!k && !t) return 1;
		return 0;
	}
	if(dp[i][k][t]>=0) return dp[i][k][t];

	dp[i][k][t] = dfs(i-1,k,t)+dfs(i-1,k-1,t-i);
	return dp[i][k][t];
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	while(true){
		int K=in(),N=in();
		if(!K && !N) break;
		
		for(auto& x:dp){
			for(auto& y:x){
				for(auto& z:y) z=-1;
			}
		}
		out(dfs(100,K,N));
	}

	return 0;
}


Measured memory_bytes: 11108
# Middle-Square Method

def middle_square(s, n)
  ss=(s**2).to_s
  ss='0'*(n*2-ss.length)+ss
  ss[n/2..n+1].to_i
end

i=0
while (n=gets.to_i)!=0
  n.times {
    puts "Case #{i+=1}:"
    s=gets.to_i
    10.times {
      s=middle_square(s, 4)
      puts s
    }
  }
end

Measured memory_bytes: 6100
#include <stdio.h>

int		main()
{
	int		H, N;
	int		sum, move;

	sum = 0;
	scanf("%d %d\n", &H, &N);
	while (N)
	{
		if (N != 1)
			scanf("%d ", &move);
		else
			scanf("%d\n", &move);
		sum += move;
		if (sum >= H)
		{
			printf("Yes\n");
			return (0);
		}
		N--;
	}
	printf("No\n");
	return (0);
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
int main() {
	int n, k;
	cin >> n >> k;
	n -= k *( n / k);
	if (n != 0) {
		cout << "1" << endl;
	}
	else {
		cout << "0" << endl;
	}
}

Measured memory_bytes: 256
def solve(N, x, A):
    A = sorted(A)
    count = 0
    for i, a in enumerate(A):
        x -= a
        if i == len(A) - 1:
            if x == 0:
                count += 1
        elif x >= 0:
            count += 1
        else:
            break
    return count

if __name__ == "__main__":
    l = input()
    N, x = int(l.split()[0]),int(l.split()[1])
    A = [int(c) for c in input().split()]
    print(solve(N, x, A))


Measured memory_bytes: 3064
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] count = new int[M];
		
		for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			for (int j = 0; j < K; j++) {
				count[sc.nextInt()-1]++;
			}
		}
		
		int result = 0;
		for (int i = 0; i < M; i++) {
			if (count[i] == N) {
				result++;
			}
		}
		
		System.out.println(result);
	}
  
}


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

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> h(N);
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }

    // c[i] = 足場 i にたどり着くまでのコストの最小値
    vector<int> c(N, 0); // DP 配列の全要素を 0 で初期化

    // i = 1 からループ
    for (int i = 1; i < N; i++) {
        if (i == 1) {
            // i == 1 のときは i-1 からしか来られない
            c[i] = c[i - 1] + abs(h[i - 1] - h[i]);
        } else {
            c[i] = min(c[i - 2] + abs(h[i - 2] - h[i]),
                       c[i - 1] + abs(h[i - 1] - h[i]));
        }
    }

    cout << c[N - 1] << endl;

    return 0;
}

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

int a[3][3];
int b[3][3];

int main() {
    bool ans = false;
    rep(i,3) rep(j,3) cin >> a[i][j];
    int n;
    cin >> n;
    rep(i,n){
        int x;
        cin >> x;
        rep(ia,3) rep(ib,n){
            if (a[ia][ib] == x)b[ia][ib] = 1;
        }
    }
    //たて
    rep(j,3){
        int count = 0;
        rep(i,3) count += b[i][j];
        if(count == 3) ans = true;
    }
    //横
    rep(i,3){
        int count = 0;
        rep(j,3) count += b[i][j];
        if(count == 3) ans = true;
    }

    {
        int count = 0;
        rep(i,3) count += b[i][i];
        if (count == 3) ans = true;
    }
    {
        int count = 0;
        rep(i,3) count += b[i][2-i];
        if (count == 3) ans = true;
    }

    puts(ans ? "Yes" : "No");
    return 0;
}


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

int main() {
    int H,N;
    cin >> H;
    cin >> N;

    int a[N][2];
    int b[H+1];
    for(int i=1; i<=H; i++){
        b[i] = 100000000;
    }
    b[0] = 0;
    for(int i=0; i<N; i++){
        cin >> a[i][0];
        cin >> a[i][1];
    }

    for(int i=0; i<=H; i++){
        for(int j=0; j<N; j++){
            int c,need;
            c = a[j][0];
            if (i>c) {
                need = b[i-c];
            }
            else {
                need = 0;
            }
            need += a[j][1];
            if (b[i] > need) {
                b[i] = need;
            }
        }
    }

    cout << b[H] << endl;
}

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

int a, b, c, d;

int main () {
    cin >> a >> b >> c;
    if (a>b) {
        d = a;
        a = b;
        b = d;
    }
    if (a>c) {
        d = a;
        a = c;
        c = d;
    }
    if (b>c) {
        d = b;
        b = c;
        c = d;
    }
    cout << c-a << endl;
    return 0;
}


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

const int
	MAX = 5005,
	MOD = 1e9 + 7;
int n, m, dp[MAX][2 * MAX];
char a[MAX];

int exp(int a, int b) {
	if(b == 0)
		return 1;

	if(b & 1)
		return 1LL * a * exp(a, b - 1) % MOD;

	int sq = exp(a, b / 2);
	return 1LL * sq * sq % MOD;
}

int F(int i, int c) {
	if(c < 0)
		return 0;

	if(i == n)
		return c == m;

	int &ans = dp[i][c];

	if(ans != -1)
		return ans;

	ans = 2LL * F(i + 1, c + 1) % MOD;

	if(c == 0)
		ans = (ans + F(i + 1, 0)) % MOD;

	else ans = (ans + F(i + 1, c - 1)) % MOD;

	return ans;
}

int main() {
	scanf("%d", &n);
	scanf("%s", a + 1);

	m = strlen(a + 1);

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

	int inv = exp(2, MOD - 2);
	int ans = 1LL * F(0, 0) * exp(inv, m) % MOD;

	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 196224
#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#define  ll long long
using namespace std;

int main()
{
int n,x;
char com[20];
list < int >  v;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
	memset(com,0,sizeof(com));
	scanf("%s",com);
	if(com[0]=='i')
	{
	scanf("%d",&x);
	v.push_front(x);
}
else if(com[6]=='L')
v.pop_back();
else if(com[6]=='F')
v.pop_front();
else if(com[0]=='d')
{
	scanf("%d",&x);
	for(list<int>::iterator it=v.begin();it!=v.end();it++)
	{
		if(*it ==x )
	{
		v.erase(it);
		break;
	}
}
 }
}
int i=0;
	for(list<int>::iterator it=v.begin();it!=v.end();it++)
	{
		if(i++)
		printf(" ");
		printf("%d",*it);
	}
	printf("\n");


return 0;
}


Measured memory_bytes: 34384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int N = sc.nextInt();
			char[] S = sc.next().toCharArray();
			int c = 0;
			char prev = 'A';
			for(int i = 0; i < N; i++) {
				if(S[i] != prev) {
					c++;
					prev = S[i];
				}
			}
			System.out.println(c);
		}
	}
}


Measured memory_bytes: 26240
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long n = (long)Math.Sqrt((double)N);
            if((long)Math.Pow((double)n,2.0) == N )
            {
                Console.WriteLine((long)(n*2)-2);
                return;
            }
            for (long i = n; i > 1;i--)
            {
                if(N % i == 0)
                {
                    long j = N / i;
                    Console.WriteLine(j + i - 2);
                    return;
                }
            }
            Console.WriteLine(N-1);
        }
    }
}


Measured memory_bytes: 27580
#include<iostream>
#include<vector>
using namespace std;
int main(void){
  int n;
  cin >> n;
  long ans = 0L;
  for(int i=0; i<n; ++i){
    int a;
    cin >> a;
    while(a%2==0){
      ans++;
      a/=2;
    }
  }
  cout << ans << endl;
  return 0;
}
  

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

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    ll n,k;cin>>n>>k;
    ll x[n];
    for(ll i=0;i<n;i++){
        cin>>x[i];
    }
    ll ans=inf;
    for(ll i=0;i+k-1<=n-1;i++){
        if(x[i]<=0 && x[i+k-1]<=0){
            ans=min(ans,abs(x[i]));
        }else if(x[i]<=0 && x[i+k-1]>=0){
            ans=min(ans,2*min(-x[i],x[i+k-1])+max(-x[i],x[i+k-1]));
        }else if(x[i]>=0 && x[i+k-1]>=0){
            ans=min(ans,x[i+k-1]);
        }
    }
    cout<<ans<<endl;
    return 0;
}



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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ull unsigned long long
#define ld long double

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

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

// #define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
// #define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()  //

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(15);
    //    cout << std::setfill('0') << std::setw(2);

    long long D;
    std::cin >> D;
    long long G;
    std::cin >> G;
    G /= 100;
    std::vector<long long> p(D);
    std::vector<long long> c(D);
    for (int i = 0; i < D; i++) {
        std::cin >> p[i];
        std::cin >> c[i];
        c[i] /= 100;
    }
    int ans = 1e9;
    rep(i, 1 << D) {
        ll score = 0;
        int num = 0;
        rep(j, D) {
            if (i >> j & 1) {
                score += p[j] * (j + 1) + c[j];
                num += p[j];
            }
        }
        for (int j = D - 1; j >= 0; --j) {  // if文をforに組み込む
            if (!(i >> j & 1)) {
                for (int k = 0; k < p[j] && score < G; ++k) {
                    score += j + 1;
                    num++;
                }
            }
        }
        if (score >= G) ans = min(ans, num);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
const int maxn = 1000;
char a[maxn];
int main()
{
	scanf("%s",&a);
	int flag = 0;
	int k = strlen(a);
//	printf("%d\n",k);
	for(int i = 0; i < k/2; i++)
		for(int j = k-1; j >= k/2 + 1; j--){
//			printf("%c %c\n",a[i],a[j]);
			if(a[i] != a[j]){
				flag = 1;
				break;
			}
		}
			if(flag == 1) printf("No\n");
			else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}

int N,M;
double h[500];
double dp[510][510];

int main(){
	cin>>N>>M;
	rep(i,N) cin>>h[i];
	rep(i,N+1) rep(j,M+1) dp[i][j] = -1e50;
	dp[0][0] = 0;
	rep(i,N){
		rep(j,M) if(dp[i][j]>=0){
			double acc = 0;
			for(int k=i+1;k<=N;k++){
				acc += h[k-1];
				chmax(dp[k][j+1],dp[i][j] + acc/(k-i));
			}
		}
	}
	double ans = 0;
	rep1(j,M) chmax(ans,dp[N][j]);
	printf("%.12f\n",ans);
}



Measured memory_bytes: 5260
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
using namespace std;

int main() {
	int A,B,C;
	cin >> A >> B >> C;	
	 if (A*10+B+C >= A+10*B+C&&A*10+B+C>=A+B+10*C) {
		cout << A*10+B+C << endl;
	}
	 else if (A * 10 + B + C <= A + 10 * B + C && A+B*10+C >= A+B+C*10) {
		 cout << A+10*B+C << endl;
	 }
	 else if (A * 10 + B + C <= A + B + 10*C && A + 10 * B + C <= A + B + 10 * C) {
		 cout << A + B + 10*C << 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++)
typedef long long int ll;
typedef pair<int, int> P;

#define int long long

int n, p, val[10101];
string s;

signed main()
{
    cin >> n >> p >> s;
    if(p == 2 || p == 5)
    {
        ll res = 0;
        rep(i, n)
        {
            if((s[i] - '0') % p == 0)
            {
                res += (long)(i + 1);
            }
        }
        cout << res << endl;
        return 0;
    }

    int sum = 0, cur = 1;
    for (int i = n - 1; i >= 0; i--)
    {
        sum += (cur * (s[i] - '0'));
        sum %= p;
        val[sum]++;
        cur *= 10;
        cur %= p;
    }

    int res = val[0];
    rep(i, p)
    {
        res += (val[i] * (val[i] - 1)) / 2;
    }
    cout << res << endl;

    
    return 0;
}

Measured memory_bytes: 644
//Together

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) int n;cin>>n;vector<int>a(n);rep(i,0,n)cin>>a[i]
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
#define cout15(a) printf("%.15f\n",a)
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<int,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    int n;cin>>n;
    map<int,int>m{};
    rep(i,0,n){
        int t;cin>>t;
        m[t]++;
    }
    int ans=0;
    rep(i,1,99999){
        int c = 0;
        c = m[i-1]+m[i]+m[i+1];
        ans=max(ans,c);
    }
    cout << ans << nnn;
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <tuple>
#include <vector>
#include <set>

using namespace std;

int main()
{
        int n, q;
        std::set<tuple<int,int,int>> events;
        std::vector<int> start_times;

        cin >> n >> q;

        for (int i = 0; i < n; i++)
        {
                int s, t, x;

                cin >> s >> t >> x; 
                events.insert(make_tuple(s - x, 1, x));
                events.insert(make_tuple(t - x, -1, x));
        }

        for (int i = 0; i < q; i++)
        {
                int d;
                cin >> d;
                start_times.push_back(d);
        }

        std::set<int> set;
        auto it = events.begin();
        for (int i = 0; i < start_times.size(); i++)
        {
                int d = start_times[i];

                while (it != events.end())
                {
                        int t, meth, x;
                        tie(t, meth, x) = *it;

                        if (t <= d)
                        {
                                if (meth == -1)
                                        set.erase(x);
                                else if (meth == 1)
                                        set.insert(x);
                        } else
                                break;

                        it++;
                }

                if (set.begin() == set.end())
                        cout << -1 << endl;
                else
                        cout << *set.begin() << endl;
        }
}


Measured memory_bytes: 36344
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> x(m);
    REP(i,m){
        cin >> x[i];
    }
    SORT(x);
    vector<int> d(m-1);
    REP(i,m-1){
        d[i] = x[i+1]-x[i];
    }
    SORT(d);
    int res = 0;
    REP(i,max(m-n,0)){
        res += d[i];
    }
    put(res);
    return 0;
}


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

using namespace std;

const int N = (int) 1e5;
const int S = (int) 5e1;

bool dp[N][S + 1];

int main() {
	int k; cin >> k;
	int s = 0;
	for (int t = k; t > 0; t /= 10) {
		s += t % 10;
	}
	int ans = s;
	for (int d = 1; d <= 9; d++) {
		int r = d % k;
		if (r == 0) {
			ans = min(ans, d);
		}
  	}
  	queue<int> qr;
	queue<int> qs;	
	for (int d = 1; d <= 9; d++) {
		if (d < ans) {
			dp[d % k][d] = 1;
			qr.push(d % k);
			qs.push(d);
		}
	}
	while (!qr.empty()) {
		int r = qr.front(); qr.pop();
		int s = qs.front(); qs.pop();		
		for (int d = 0; d <= 9; d++) {
			int nr = (r * 10 + d) % k;
			int ns = s + d;
			if (ns < ans && dp[nr][ns] == 0) {
				if (nr == 0) {
					ans = ns;
				}
				dp[nr][ns] = 1;
				qr.push(nr);
				qs.push(ns);
			}			
		} 
	}
	cout << ans;	
	return 0;
}

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

typedef long long ll;

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

	int a, b;
	cin >> a >> b;

	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}

	cout << "NG" << endl;

	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
  string g;
  cin>>g;
  int x,y,z,w,h,u,v,b;
  x=g.at(0)-'0';
  y=g.at(1)-'0';
  z=g.at(2)-'0';
  w=g.at(3)-'0';
  for(h=0;h<2;h++){
    for(u=0;u<2;u++){
      for(v=0;v<2;v++){
        b=x;
        if(h==0) b-=y; else b+=y;
        if(u==0) b-=z; else b+=z;
        if(v==0) b-=w; else b+=w;
        if(b==7){
          cout<<x;
          if(h==0) cout<<'-'; else cout<<'+';
          cout<<y;
          if(u==0) cout<<'-'; else cout<<'+';
          cout<<z;
          if(v==0) cout<<'-'; else cout<<'+';
          cout<<w<<"=7"<<endl;
          return 0;
        }
      }
    }
  }
}

Measured memory_bytes: 3612
#include<iostream>
using namespace std;
int main()
{
    string s;
    int n,AC_count=0,WA_count=0,TLE_count=0,RE_count=0;
    cin >> n ;
    for(int i=0;i<n;i++){
        cin >> s;
        if(s == "AC"){
           AC_count++;
        }
        else if(s == "WA"){
            WA_count++;
        }
        else if(s == "TLE"){
            TLE_count++;
        }
        else if(s == "RE"){
            RE_count++;
        }
    }
    cout<<"AC x "<<AC_count<<endl;
    cout<<"WA x "<<WA_count<<endl;
    cout<<"TLE x "<<TLE_count<<endl;
    cout<<"RE x "<<RE_count<<endl;
    return 0;
}


Measured memory_bytes: 3228
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

int n;

int a[100005];
int b[100005];
int c[100005];

int memo[100005][4];

int dp(int pos, int l) {
	if (pos==n) return 0;
	if (memo[pos][l]!=-1) return memo[pos][l];
	if (l==1) 
		return memo[pos][l]=max(dp(pos+1, 2)+b[pos], dp(pos+1, 3)+c[pos]);
	if (l==2) 
		return memo[pos][l]=max(dp(pos+1, 1)+a[pos], dp(pos+1, 3)+c[pos]);
	return memo[pos][l]=max(dp(pos+1, 1)+a[pos], dp(pos+1, 2)+b[pos]);
}

int main() {
	memset(memo, -1, sizeof memo);
	cin >>n;
	for (int i=0 ; i<n ; i++) {
		cin >>a[i]>>b[i]>>c[i];
	}
	cout <<max(dp(0, 1), dp(0, 2))<<endl;
	return 0;
}

Measured memory_bytes: 7680
#include <iostream>
using namespace std;
int main()
{
    long long int q=0,i,j,k,l,m,n,s=0;
    cin>>n;
    if(n%2!=0)
    {
        cout<<0;
    }
    else
    {k=5;

    while((n/(2*k))!=0)
    {
        q+=(n/(2*k));
        k*=5;
    }
    cout<<q;
    }

}


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

using namespace std;

const int N = 100010;
const long long mod = 1e9 + 7;

int done[N];
vector < pair < int, int > > g[N];

bool minimize(long long &u, long long v){
	if(u > v){
		u = v;
		return true;
	}
	return false;
}

int n, m, s, t;
long long a[2][N];
long long c[2][N];

void dijkstra(int start, long long *path, long long *cnt){
	fill(done + 1, done + n + 1, 0);
	fill(cnt + 1, cnt + n + 1, 0);
	fill(path + 1, path + n + 1, 1e18);

	cnt[start] = 1;
	path[start] = 0;

	set < pair < long long, int > > que;
	que.insert(make_pair(0, start));

	while(!que.empty()){
		int v = que.begin() -> second;
		que.erase(*que.begin());

		if(done[v]) continue;
		done[v] = 1;


		for(auto p : g[v]){
			int u = p.first, w = p.second;
			if(minimize(path[u], path[v] + w)){
				cnt[u] = cnt[v];
				que.emplace(path[u], u);

			}
			else if(path[u] == path[v] + w) {
				cnt[u] += cnt[v];
				cnt[u] %= mod;
			}
		}
	}
}

struct edge{
	int u;
	int v;
	int w;

	void read(){
		scanf("%d%d%d", &u, &v, &w);
		g[u].emplace_back(v, w);
		g[v].emplace_back(u, w);
	}
}lst[N + N];


int main(){

	scanf("%d%d%d%d", &n, &m, &s, &t);
	for(int i = 1; i <= m; ++i){
		lst[i].read();
	}

	dijkstra(s, a[0], c[0]);
	dijkstra(t, a[1], c[1]);


	long long tot = c[0][t] * c[1][s] % mod;


	for(int i = 1; i <= n; ++i){
		if(a[0][i] + a[1][i] != a[0][t]) continue;
		if(a[0][i] == a[1][i]){
			long long calc = c[0][i] * c[1][i] % mod;
			tot -= calc * calc;
			tot += mod * mod;
			tot %= mod;
		}
	}


	for(int u = 1; u <= n; ++u){
		for(auto e : g[u]){
			int v = e.first;
			int w = e.second;

			if(a[0][u] + a[1][v] + w != a[0][t]) continue;
			if(a[0][u] + w <= a[1][v] || a[1][v] + w <= a[0][u]) continue;


			long long calc = c[0][u] * c[1][v] % mod;
			tot -= calc * calc - mod * mod;
			tot %= mod;
		}
	}

	cout << tot;
	return 0;
}

Measured memory_bytes: 20468
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN = 50;
const int MOD = 1000000007;

int n;
int dp[MAXN + 1][2 * MAXN + 1]; // dp[i][MAXN+j] = # ways to choose first i items such we next need to chose items of value +-2^x and the sum so far is 1+j*2^x

int inv[MAXN + 1];
int fac[MAXN + 1];
int ifac[MAXN + 1];
int C(int n, int k) { if (k<0 || k>n) return 0; return (ll)fac[n] * ifac[k] % MOD*ifac[n - k] % MOD; }

void inc(int &a, int b) { if ((a += b) >= MOD) a -= MOD; }
void run() {
	inv[1] = 1; FORE(i, 2, MAXN) inv[i] = (ll)(MOD - MOD / i)*inv[MOD%i] % MOD;
	fac[0] = 1; FORE(i, 1, MAXN) fac[i] = (ll)fac[i - 1] * i%MOD;
	ifac[0] = 1; FORE(i, 1, MAXN) ifac[i] = (ll)ifac[i - 1] * inv[i] % MOD;

	scanf("%d", &n);
	memset(dp, 0, sizeof(dp)); dp[1][MAXN] = n; dp[1][MAXN - 1] = n;
	REP(i, n) FORE(j, -n, +n) if (dp[i][MAXN + j] != 0) {
		//printf("%d %d: %d\n", i, j, dp[i][MAXN + j]);
		FORE(k, max(1, abs(j)), n - i) if((j+k)%2==0) REPE(l, k) {
			int ni = i + k, nj = (j + k) / 2 - l; if (nj<-n || nj>+n) continue;
			int ways = (ll)dp[i][MAXN + j] * C(n - i, k) % MOD*C(k, l) % MOD;
			//printf("-> %d %d: %d\n", ni, nj, ways);
			inc(dp[ni][MAXN + nj], ways);
		}
	}
	printf("%d\n", dp[n][MAXN + 0]);
}

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    ll a, b, k;
    cin >> a >> b >> k;
    cout << max(a - k, 0ll) << ' ' << min(b, max(a + b - k, 0ll)) << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    int n, ans = 0;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int flag = 0;
    for (int i = 1; i <= n; i++)
    {
        if (a[i] > a[i - 1])
        {
            while (i < n)
            {
                i++;
                if (a[i] < a[i - 1])
                    break;
            }
            ans++;
        }
        else if (a[i] < a[i - 1])
        {
            while (i < n)
            {
                i++;
                if (a[i] > a[i - 1])
                    break;
            }
            ans++;
        }
        else
        {
            if (i == n)
                ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <math.h>
#include <string>

int main(void);
std::string rev_string(std::string str);


int main(){
	std::string str = "";
	//char str[20];
	std::cin >> str;
	std::cout << rev_string(str) << std::endl;

	//while (1);
	return 0;
}

//*
std::string rev_string(std::string str){
	int i;
	int len = str.length();
	for (i = 0; i < len / 2; i++) {
		char temp = str[i];
		str[i] = str[len - i - 1];
		str[len - i - 1] = temp;
	}

	return str;
}
//*/


Measured memory_bytes: 2976
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N, T, t, pt = 0;
	ll ans = 0, till = 0;

	cin >> N >> T;
	rep(i, N) {
		cin >> t;

		if (till < t) ans += T;
		else ans += (ll)t - (ll)pt;

		till = (ll)t + (ll)T;
		pt = t;
	}

	cout << ans + T << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  ll N;
  cin>>N;
  string S,T;
  cin>>S>>T;
  
  rep(i,N){
cout<<S[i]<<T[i];
  }
  
  cout<<endl;
}


Measured memory_bytes: 256
n = gets.to_i
l = gets.split(" ").map(&:to_i)
cnt = 0
if l.size < 3
  puts 0
  exit
end
l.combination(3) do |a,b,c|
  if a != b && b != c && a != c
    arr = [a,b,c].sort
    if arr[2] < arr[0] + arr[1]
      cnt += 1
    end
  end
end
puts cnt

Measured memory_bytes: 14284
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define dev 998244353 //tenka1
#define P pair<int,int>
#define F first
#define S second
int n;
int a[2][150];
int dfs(int h,int w,int sum){
    if(h>1||w>=n)return 0;
    if(h==1&&w==n-1)return sum+a[1][n-1];
    int x=dfs(h,w+1,sum+a[h][w]);
    int y=dfs(h+1,w,sum+a[h][w]);
    int r=max(x,y);
    return r;
}
signed main(){
    cin>>n;
    rep(i,n){
        cin>>a[0][i];
    }
    rep(i,n){
        cin>>a[1][i];
    }
    int ans=dfs(0,0,0);
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
n = int(input())

ans = []
for i in range(1, 99): # 99は適当
    if n <= 26**i:
        n -= 1
        for j in range(i):
            ans.append(chr(ord('a') + n % 26))
            n //= 26
        break
    else:
        n -= 26**i

print(''.join(ans[::-1]))

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


int main(){
  int A, B, C, D; cin >> A >> B >> C >> D;
  while(1){
    C -= B;
    if(C<=0){
      cout << "Yes" << endl;
      return 0;
    }
    A -= D;
    if(A<=0){
      cout << "No" << endl;
      return 0;
    }
  }
  return 0;
}



Measured memory_bytes: 3636
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("avx") 
#include<bits/stdc++.h>
using namespace std;

inline int read()
{
	int ret=0; char c=getchar();
	while(c<48||c>57)c=getchar();
	while(c>=48 && c<=57)ret=ret*10+c-48,c=getchar();
	return ret;
}
int n,m,u,ans;
struct node {
	int a, b;
	bool operator < (const node & d)const{
		return a>d.a;
	}
}o[113469];
multiset<int>S;
int main()
{
	n=read();
	m=read();
	for(int i=1;i<=n;++i){
		o[i].b=read(); o[i].a=read();
	}
//	auto a; 
//	a=1;
	sort(o+1,o+n+1);
	for(int i=0;i<m;++i)S.insert(i);
	for(int i=1;i<=n;++i){
		auto it=S.upper_bound(m-o[i].b);
		if(it==S.begin())continue;
		--it; S.erase(it);
		ans+=o[i].a;
	}
	cout<<ans;
}

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

using namespace std;



int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    long long cur=100,X,ans=0;
    cin>>X;
    while(cur<X)cur+=cur*0.01,ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3656
import math
t = input().split()
t = [int(i) for i in t]
r = math.sqrt(t[0]*t[0]+ t[1]*t[1])
h = t[2]
m = t[3]
if (h == 12):
    h = 0
if (m == 60):
    m = 0
hour_angle = 0.5 * (h * 60 + m) 
minute_angle = 6 * m 
angle = abs(hour_angle - minute_angle) 
angle = min(360 - angle, angle)
print(math.sqrt(r*r - 2*t[0]*t[1]*math.cos(angle*(2*math.pi/360))))   

Measured memory_bytes: 9540
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 100005
using namespace std;
using LL = long long;
int n,in[M];
int main()
{
    while (~scanf("%d", &n)) {
        REP(i,1,n) scanf("%d", &in[i]);
        sort(in+1, in+n+1);
        if (n==2) {
            printf("%d\n", in[2]-in[1]);
            printf("%d %d\n",in[2],in[1]);
            continue;
        }

        vector<pair<LL,LL>> ans;
        if ((in[n]>0&&in[1]>0) || (in[n]<0&&in[1]<0)) {
            if (in[1]<0) {
                ans.push_back(make_pair(in[n], in[1]));
                in[1] = in[n] - in[1];
            } else {
                ans.push_back(make_pair(in[1], in[n]));
                in[1] = in[1] - in[n];
            }
            n--;
            sort(in+1, in+n+1);
        }

        if (in[n]==0) {
            LL fr = in[n];
            REP(i,1,n-1) {
                ans.push_back(make_pair(fr, in[i]));
                fr -= in[i];
            }
            printf("%lld\n", fr);
            for (auto i:ans) printf("%lld %lld\n",i.first,i.second);
            continue;
        }

        int pos=-1;
        LL fr = in[1];
        REP(i,1,n) if(in[i]>0) {
            pos = i;
            break;
        }
        REP(i,pos,n-1) {
            ans.push_back( make_pair(fr, in[i]) );
            fr = fr - in[i];
        }
        ans.push_back(make_pair(in[n], fr));
        fr = in[n] - fr;
        REP(i,2,pos-1) {
            ans.push_back( make_pair(fr, in[i]) );
            fr = fr - in[i];
        }

        printf("%lld\n", fr);
        for (auto i:ans) printf("%lld %lld\n",i.first,i.second);
    }
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    for(int i = 0 ; i < n ; i += 1){
        int a;
        cin >> a;
        if(a % 2 == 0){
            if(a % 3 == 0 || a % 5 == 0){
                continue;
            }
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
}

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

using namespace std;

int match(int a){
    if(a == 1) return 2;
    else if(a == 2) return 5;
    else if(a == 3) return 5;
    else if(a == 4) return 4;
    else if(a == 5) return 5;
    else if(a == 6) return 6;
    else if(a == 7) return 3;
    else if(a == 8) return 7;
    else return 6;
}

int main(){
    int N, M;
    cin >> N >> M;
    int A[M];
    for(int i=0; i<M; i++) cin >> A[i];
    sort(A, A + M);
    string dp[N+10];
    fill(dp, dp + N + 10, "?");
    dp[0] = "";
    for(int i=0; i<N; i++){
        for(int a : A){
            if(dp[i] != "?") {
                if(dp[i + match(a)] == "?" || dp[i + match(a)].length() < dp[i].length() + 1 || (dp[i +match(a)].length() == dp[i].length() + 1 && dp[i + match(a)] < dp[i] + to_string(a))) dp[i + match(a)] = dp[i] + to_string(a);
            }
        }
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 33024
#include <stdio.h>

void selectionSort(int [] ,int);

int main(){
  int i,N,A[100];

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  selectionSort(A,N);

  return 0;
}

void selectionSort(int A[] ,int N){
  int i,j,k,minj,tmp,count=0;

  for(i=0;i<N;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(A[j]<A[minj])
       minj=j;


    }
    if(i!=minj){
    tmp=A[i];
    A[i]=A[minj];
    A[minj]=tmp;
    count++;
  }
  }

  for(k=0;k<N;k++){
    printf("%d",A[k]);
    if(k!=N-1) printf(" ");
  }
  printf("\n");
  printf("%d\n",count);
}



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

namespace ProgramingStudying2
{
    class Program
    {

        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            Console.WriteLine(n % 2 == 0 ? n : 2 * n);
        }
    }
}


Measured memory_bytes: 27408
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  char s;
  cin >> s;
  if(s=='A'){
    cout << 'T' << endl;
  }else if(s=='C'){
    cout << 'G' <<endl;
  }else if(s=='T'){
    cout << 'A' <<endl;
  }else if(s=='G')
    cout << 'C' <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int a,b,c;
cin>>a>>b>>c;
if(b-a==c-b)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
//system("pause");
return 0;
}

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

B = []
C = []
for _ in range(Q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)

d = [0] * (10**5 + 7)
for a in A:
    d[a] += 1
sum_a = sum(A)
for j in range(Q):
    before = d[C[j]]
    d[C[j]] += d[B[j]]
    sum_a -= d[B[j]] * B[j]

    sum_a += (d[C[j]] - before) * C[j]
    d[B[j]] = 0
    print(sum_a)


Measured memory_bytes: 88496
ans=0
a,b=map(int,input().split())
for i in range(10000):
    ans1=int(i*1.08)
    ans2=int(i*1.1)
    ans11=ans1-i
    ans22=ans2-i
    if ans11==a and ans22==b:
        print(i)
        exit(0)
print(-1)

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(),K = sc.nextInt();
		int[] n = new int[N];
		for(int i=0; i<N; i++) {
			n[i] = sc.nextInt();
		}

		Arrays.sort(n);
		int ans = 0;
		for(int i = 0; i < K; i++) {
			ans += n[N-(i+1)];
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<array>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<stack>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<stdexcept>
#include<climits>
#include<memory>
//#include<fstream>
#define int long long
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
signed main(){
	int n,dist,ans=0;
	cin>>n>>dist;
	dist*=dist;
	for(int i=1;i<=n;i++){
		int x,y;
		cin>>x>>y;
		int cdist=x*x+y*y;
		if(cdist<=dist)
			ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3608