akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<128>>;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << (x) << '\n'
typedef long long lint;
const int INF = 2e9;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const lint LINF = 1e18;
typedef vector<int> vint;
typedef pair<int, int> pint;
template <class T = int> T in() {
    T x;
    cin >> x;
    return (x);
}
void print() { cout << endl; }
template <class T, class... A> void print(const T &first, const A &... rest) {
    cout << first;
    print(rest...);
}
template <class... A> void print(const A &... rest) { print(rest...); }
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 modulo(int a, int b, int n) {
    long long x = 1, y = a;
    while(b > 0) {
        if(b % 2 == 1) {
            x = (x * y) % n; // multiplying with base
        }
        y = (y * y) % n; // squaring the base
        b /= 2;
    }
    return x % n;
}
/* templates */ /* templates */ /* templates */ /* templates */ /* templates */

const int MAXN = 300;
vector<vector<vector<bool>>>
    flag(MAXN + 10,
         vector<vector<bool>>(MAXN + 10, vector<bool>(MAXN + 10, false)));
vector<vector<vector<double>>>
    dp(MAXN + 10,
       vector<vector<double>>(MAXN + 10, vector<double>(MAXN + 10, 0.0)));
int N;

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

    int N, K;
    cin >> N >> K;
    vector<int> a(N + 1, 0);
    rep(i, 1, N + 1) { cin >> a[i]; }
    vector<bool> dp(K + 1);
    dp[0] = false;

    rep(i, 1, K + 1) {
        rep(j, 1, N + 1) {
            if(i - a[j] >= 0 && !dp[i - a[j]]) {
                dp[i] = true;
            }
        }
    }

    if(dp[K]) {
        cout << "First" << endl;
    } else {
        cout << "Second" << endl;
    }
}

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

#define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = (int)(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

inline int read() {
	int x(0), sgn(1); char ch(getchar());
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
	for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
	return x * sgn;
}

void File() {
#ifdef zjp_shadow
	freopen ("C.in", "r", stdin);
	freopen ("C.out", "w", stdout);
#endif
}

inline int Solve(int n, int m) {
	long long res = (n % 3 ? 1 : 0) * m;
	For (i, 1, n) For (j, max(1, m / 2 - 1), min(m, m / 2 + 1)) {
		chkmin(res, max(max(
						abs(1ll * i * m - 1ll * j * (n - i)), 
						abs(1ll * i * m - 1ll * (m - j) * (n - i))),
					abs(1ll * (n - i) * (m - 2 * j))));
	}
	return res;
}

int main () {

	File();

	int h = read(), w = read();

	printf ("%d\n", min(Solve(h, w), Solve(w, h)));

	return 0;

}

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

def solver():
    # mr.zehnpaard
    n, y = map(int, input().split())

    all1000s = y // 1000
    x = all1000s - n

    for a in range(0, x+1, 4):
        nines = (x - a) // 9
        fours = a // 4
        ones = n - nines - fours
        if (x - a) % 9 == 0 and all(x >= 0 for x in (nines, fours, ones)):
            print("{} {} {}".format(nines, fours, ones))
            break
    else:
        print("-1 -1 -1")


def main():
    # 9 45000
    N, Y = list(map(int, input().split()))

    # implements
    for x in range(N+1):
        for y in range(N+1):
            z = N - (x + y)
            if z < 0:
                break
            if (10000*x + 5000*y + 1000*z) == Y:
                print("{} {} {}".format(x, y, z))
                exit()
    print("-1 -1 -1")


if __name__ == "__main__":
    main()


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

int main()
{
  int a;
  char s[11];
  scanf("%d",&a);
  scanf("%s",s);
    if (a<3200)
    {
      printf("red");
    }
    else
    {
      printf("%s",s);
    }
return 0;
}


Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int[] a = new int[10];
		for(int i = 0; i < 10; i++) {
			a[i] = stdIn.nextInt();
		}
		
		Arrays.sort(a);
		
		for(int i = 0; i < 3; i++) {
			System.out.println(a[9-i]);
		}
		
		
		
	
	}
}

Measured memory_bytes: 17184
x,y=map(int,input().split())
a=[4, 6, 9, 11]
if x==2 and y==2:
    print('Yes')
else:
    if (x==2 and y!=2) or (x!=2 and y==2):
        print('No')
    elif x in a and y in a:
        print('Yes')
    elif not x in a and not y in a:
        print('Yes')
    else:
        print('No')

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long


int main(){
    string s;
    cin >> s;
    int ans = 0;

    REP(i, s.size()) {
        if(s[i] == '1') ans++;
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
// AOJ 2109 Ancient Expression
// 2018.3.5 bal4u

#include <stdio.h>
#include <string.h>
#include <ctype.h>

#define MAX 200

char buf[105], *p;

int G;
int rank[128], ass[12];	// ass 0:left 2 right

int top, end;
char q[MAX], s[MAX];
char gb[MAX][100], gw[MAX];
char sp[MAX][250]; int len[MAX];

int in()
{
	int n = 0;
	while (*p >= '0') n = 10*n + (*p++ & 0xf);
	p++;
	return n;
}

void pushback(int min)
{
	int i, g;
	char op;
	
	if (!top) return;
	while (top && s[top-1] != '(') {
		op = s[top-1];
		if ((g = rank[op]) > min) gb[g][gw[g]++] = op, top--;
		else break;
	}
	for (g = G-1; g > min; g--) {
		if (!gw[g]) continue;
		if (ass[g]) for (i = 0; i < gw[g]; i++)    q[end++] = gb[g][i];
		else        for (i = gw[g]-1; i >= 0; i--) q[end++] = gb[g][i];
		gw[g] = 0;
	}
}

void parse(char *p)
{
	int g;

	top = 0, end = 0; memset(gw, 0, G);
	while (1) {
		if (*p <= ' ') { pushback(0); break; }
		if (isalpha(*p)) q[end++] = *p;
		else if (*p == ')') pushback(0), top--;		// take '('
		else if (*p == '(') s[top++] = '(';
		else {
			g = rank[*p];
			if (ass[g]) pushback(g);
			else        pushback(g-1);
			s[top++] = *p;
		}
		p++;
	}
}

void cout()
{
	int s;
	char c, t[250];

	s = 0, top = 0;
	while (top < end) {
		if (isalpha(c=q[top])) sp[s][0] = c, sp[s][1] = 0, len[s] = 1;
		else {
			s -= 2; p = t;
			*p++ = '(', memcpy(p, sp[s  ], len[s  ]), p += len[s  ];
			*p++ = c,   memcpy(p, sp[s+1], len[s+1]), p += len[s+1];
			*p++ = ')', *p = 0;
			len[s] = p-t, memcpy(sp[s], t, p-t+1);
		}
		s++, top++;
	}
	puts(sp[0]);
}

int main()
{
	int M, N, g;
	int cno, cmax;

	fgets(p=buf, 10, stdin), cmax = in();
	for (cno = 0; cno < cmax; cno++) {
		if (cno) putchar('\n');

		fgets(p=buf, 10, stdin), G = in()+1;
		for (g = 1; g < G; g++) {
			fgets(p=buf, 100, stdin);
			ass[g] = (*p == 'R'), p+=2;
			M = in(); while (M--) rank[*p] = g, p+=2;
		}

		fgets(p=buf, 10, stdin), N = in();
		while (N--) {
			fgets(buf, sizeof(buf), stdin);
			parse(buf);
			cout();
		}
	}
	return 0;
}


Measured memory_bytes: 2028
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
   int c[3][3] ;
   for(int i=0;i<3;i++){
     for(int j=0;j<3;j++){
       cin >> c[i][j] ;
     }   
   }
  
  if(c[0][0]-c[0][1] == c[1][0]-c[1][1] && 
     c[0][1]-c[0][2] == c[1][1]-c[1][2] &&
     c[0][2]-c[0][0] == c[1][2]-c[1][0] && 
     c[1][0]-c[1][1] == c[2][0]-c[2][1] && 
     c[1][1]-c[1][2] == c[2][1]-c[2][2] && 
     c[1][2]-c[1][0] == c[2][2]-c[2][0]){  
     cout << "Yes" << endl ;
  }else{
         cout << "No" << endl ;
  }
    return 0;
}



Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 10;

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

	int ans = -1, t = 0;
	bool updated = true;
	while (updated) {
		updated = false;
		FOR(i, t, t + a) {
			if (i%60 == c) {
				ans = i;
				updated = false;
				break;
			}
			if (y[i%60] == 0) {
				updated = true;
				y[i%60] = 1;
			}
		}
		t += (a + b);
	}

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

Measured memory_bytes: 1200
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

ll mpow(ll x, ll n){ //x^n(mod M)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

char str[100005];

int main(int argc, char* argv[])
{
    scanf("%s", str);
    int len = strlen(str);

    ll ans=0;
    ll curr=1;
    int i;
    for(i=len-1; i>=0; i--) {
        if(str[len-1-i]=='1') {
            ans = (ans + curr * mpow(3, i))%MOD;
            curr = (curr * 2)%MOD;
        }
        else {
            
        }
        if(i==0) {
            ans = (ans + curr)%MOD;
        }
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
	int i;
	ll n, s, d, a, kn, ks;
	vector<ll> v;

	scanf("%lld%lld", &n, &s);

	if (n <= s) {
		if (n == s) {
			printf("%lld\n", n + 1);
		}
		else {
			printf("-1\n");
		}
		return 0;
	}

	kn = n;
	ks = 0ll;
	while (kn > 0) {
		ks += kn % 2;
		kn /= 2;
	}

	if (ks == s) {
		printf("2\n");
		return 0;
	}

	d = n - s;

	for (a = 2; a * a <= d; a++) {
		if (d % a == 0) {
			v.push_back(a);
			v.push_back(d / a);
		}
	}
	v.push_back(d);

	sort(v.begin(), v.end());

	for (i = 0; i < v.size(); i++) {
		kn = n;
		ks = 0ll;
		while (kn > 0) {
			ks += kn % (v[i] + 1);
			kn /= (v[i] + 1);
		}
		if (ks == s) {
			printf("%lld\n", v[i] + 1);
			return 0;
		}
	}

	printf("-1\n");

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

namespace mp = boost::multiprecision;
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;

ll nCr(ll n, ll r) {
  if (r > n) {
    return 0;
  }
  if (r == 0 || n == r) {
    return 1;
  }
  if (r * 2 > n) {
    r = n - r;
  }

  ll result = n;
  for (ll i = 2; i <= r; i++) {
    result *= (n - i + 1);
    result /= i;
  }
  return result;
}

ll N, A, B;
vector<ll> v;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> A >> B;
  v.resize(N);
  for (ll i = 0; i < N; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end(), greater<ll>());

  Real1024 ans_avg = 0;
  ll ans_cnt = 0;
  for (ll i = A; i <= B; i++) {
    map<ll, ll, greater<ll>> mp;
    ll cur = 0;
    ll last = 0;
    while (cur < i) {
      mp[v[cur]]++;
      last = v[cur];
      cur++;
    }
    while (cur < v.size() && v[cur] == last) {
      mp[v[cur]]++;
      cur++;
    }

    ll ll_avg = 0;
    cur = 0;
    for (auto &e : mp) {
      if (mp.rbegin()->first == e.first) {
        ll_avg += (e.first * (i - cur));
      } else {
        ll_avg += (e.first * e.second);
        cur += e.second;
      }
    }
    Real1024 avg = ll_avg;
    avg /= i;
    ll cnt = nCr(mp.rbegin()->second, i - cur);

    if (avg > ans_avg) {
      ans_avg = avg;
      ans_cnt = cnt;
    } else if (avg == ans_avg) {
      ans_cnt += cnt;
    }
  }

  cout << fixed << setprecision(6) << ans_avg << endl;
  cout << ans_cnt << endl;
  return 0;
}

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

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

    string p,q;
    for(int i=0;i<a;i++)p+=to_string(b);
    for(int i=0;i<b;i++)q+=to_string(a);

    vector<string>str;
    str.push_back(p);
    str.push_back(q);
    sort(str.begin(),str.end());
    cout<<str[0]<<"\n";

    
    return 0;
}

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

ll k,a,b,ans;
int main(){
    cin >> k >> a >> b;
    if(k<=a-1 || b<=a+2){
        ans=1+k;
    }
    else{
        k-=(a-1);
        ll p=1ll*k/2;
        ans =1ll*p*(b-a)+a+(k%2);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N,X,Y=map(int,input().split())

X-=1
Y-=1
A=[0]*(N-1)
for i in range(N-1):
    for j in range(i+1,N):
        a=min(j-i,abs(j-Y)+1+abs(X-i))
        A[a-1]+=1

for i in A:
    print(i)



Measured memory_bytes: 46044
#include <iostream>

using namespace std;

int main()
{
	int Ttotal,Ftotal,in;

	
	while(cin >> Ttotal && Ttotal){

		Ftotal = 0;
		for(int i = 0; i < 9; i++){
			cin >> in;
			Ftotal += in;
		}

		cout << Ttotal-Ftotal << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

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

int main() {
	while (true) {
		int n, ans = 0;
		cin >> n;
		if (n == 0) break;

		REP(i, n) {
			int x, y, h, w;
			scanf("%d %d %d %d", &x, &y, &h, &w);

			int s = x + y + h;
			int size1 = ceil((s - 60) / 20.0);
			if (size1 > 5) continue;
			if (size1 < 0) size1 = 0;

			int dw[] = {2, 5, 10, 15, 20, 25};
			int size2 = 0;
			REP(i, 6) if (w > dw[i]) size2++;
			if (size2 > 5) continue;

			ans += 600 + 200*max(size1, size2);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1248
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

vector<int> primes(int n) {
  vector<int> v(n);
  for (int i=2; i<n; i++) v[i] = i;
  for (int i=2; i*i<n; i++)
    if (v[i])
      for (int j=i*2; j<n; j+=i)
        v[j] = 0;
  // v.erase(remove(ALL(v),0),v.end()); // ツつアツつアツづーツづつつッツづェツづ篠素ツ青板δ環スツト
  return v;
}

int main() {
  vector<int> pr = primes(10001);
  vector<int> tw(10001);
  for(int i = 5; i<10001; ++i) {
    if (pr[i] && pr[i-2]) tw[i] = i;
    else tw[i] = tw[i-1];
  }
  int n;
  while(cin >> n,n) {
    cout << tw[n]-2 << " " << tw[n] << endl;
  }
}

Measured memory_bytes: 980
//
//	Created by shamim_nik
//

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

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

#define br printf("\n")
#define pi acos(-1)

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

//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	long long num , cnt = 0, sum = 100;
	cin >> num;
	while(sum < num) {
		cnt++;
		sum += sum / 100;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lp(i,a,n) for(int i=(a);i<=(int)(n);++i)
#define lpd(i,a,n) for(int i=(a);i>=(int)(n);--i)
#define mem(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define println(a) cout <<(a) <<endl
#define sz(x) ((int)(x).size())
#define readi(x) scanf("%d",&x)
#define read2i(x,y) scanf("%d%d",&x,&y)
#define read3i(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define mod 1000000007
#define eps 1e-8
#define infi 1000000000
#define infll 1000000000000000000ll
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef set<int> si;
typedef map<int,int> mii;

const int N = 302;
int n,m,a[N][N],f[N],ptr[N];
bool deleted[N];

bool check(int mid){
    mem(f, 0);
    mem(deleted, 0);
    lp(i,1,n) ++f[a[i][ptr[i] = 1]];
    while(true){
        if(f[max_element(f+1, f+1+m) - f] <= mid) return true;
        lp(i,1,m) if(f[i] > mid) deleted[i] = true;
        lp(i,1,n){
            while(ptr[i] <= m and deleted[a[i][ptr[i]]]){
                --f[a[i][ptr[i]]];
                ++ptr[i];
                ++f[a[i][ptr[i]]];
            }
            if(ptr[i] > m) return false;
        }
    }
}

int main(){
    read2i(n,m);
    lp(i,1,n) lp(j,1,m) readi(a[i][j]);

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

/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
*/


Measured memory_bytes: 640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class CCitySavers {
public:
    void solve(istream& cin, ostream& cout) {
      int n; cin >> n;
      vector<int> a(n+1);
      rep(i, n+1) cin >> a[i];
      vector<int> b(n);
      rep(i, n) cin >> b[i];
      ll ans = 0;
      rep(i, n) {
        if (b[i] <= a[i]) {
          ans += b[i];
        } else {
          ans += min(b[i], a[i]+a[i+1]);
          a[i+1] = max(0, a[i+1]+a[i]-b[i]);
        }
      }
      cout << ans << endl;
    }
};

signed main() {
  CCitySavers solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main()
{
  int H,k,i;
  int A[250];

  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }

  for(i=1;i<=H;i++){
    k = A[i];
    printf("node %d: key = %d, ",i,k);
    if(i/2 >= 1){
      printf("parent key = %d, ",A[i/2]);
    }
    if(i*2 <= H){
      printf("left key = %d, ",A[i*2]);
    }
    if((i*2+1) <= H){
      printf("right key = %d, ",A[i*2+1]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 600
h, w, d = map(int, raw_input().split())
a = [map(int, raw_input().split()) for _ in xrange(h)]
r = {a[x][y]: (x, y) for x in xrange(h) for y in xrange(w)}
b = [0] * (h * w + 1)
for _ in xrange(d + 1, h * w + 1):
    b[_] = b[_ - d] + sum([abs(r[_ - d][i] - r[_][i]) for i in [0, 1]])
for _ in xrange(input()):
    l, r = map(int, raw_input().split())
    print b[r] - b[l]


Measured memory_bytes: 21308
//ABC142B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	int count = 0;
	for(int i=0;i<n;i++){
		cin >> a.at(i);
		if(a.at(i) >= k){
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    string S;
    cin >> S;
    if(S == "AKIHABARA" || S == "AKIHABAR" || S == "AKIHABRA" ||
       S == "AKIHBARA" || S == "KIHABARA" || S == "AKIHABR" ||
       S == "AKIHBAR" || S == "KIHABAR" || S == "AKIHBRA" ||
       S == "KIHABRA" || S == "KIHBARA" || S == "KIHBRA" ||
       S == "KIHBAR" || S == "KIHABR" || S == "AKIHBR" ||
       S == "KIHBR") {
        puts("YES");
    }
    else {
        puts("NO");
    }
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
const int N=400002;
typedef long long ll;
int n,a[N*5],v[N],top,st[N],las[N],ne[N],i,sum,j;
bool vis[N];
ll k;
int main(){
	scanf("%d%lld",&n,&k);
	for (i=0;i<n;i++) scanf("%d",&a[i]);
	for (j=1;j<3;j++)
		for (i=0;i<n;i++) a[n*j+i]=a[i];
	for (i=2*n-1;i>=0;i--){
		if (i<n){
			ne[i]=las[a[i]]+1;
			v[i]=ne[i]/n,ne[i]%=n;
		}
		las[a[i]]=i;
	}
	for (i=ne[0],sum=v[0];i;sum+=v[i],i=ne[i]);
	k%=sum;
	for (i=0;k>=3;k-=v[i],i=ne[i]);
	for (;i<k*n;i++){
		if (vis[a[i]]){
			for (;top && st[top]!=a[i];vis[st[top]]=0,top--);
			top--,vis[a[i]]=0;
		}else vis[a[i]]=1,st[++top]=a[i];
	}
	for (i=1;i<=top;i++) printf("%d ",st[i]);
}

Measured memory_bytes: 10752
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)

	aa := make([]int, n)
	bb := make([]int, n)
	cc := make([]int, n-1)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner) - 1
	}
	for i := 0; i < n; i++ {
		bb[i] = getNextInt(scanner)
	}
	for i := 0; i < n-1; i++ {
		cc[i] = getNextInt(scanner)
	}

	var ans int
	for i := 0; i < n; i++ {
		ans += bb[i]
		if i == 0 {
			continue
		}
		if aa[i-1]+1 == aa[i] {
			ans += cc[aa[i-1]]
		}
	}
	fmt.Fprintln(writer, ans)
	writer.Flush()
}


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

using P = pair<int, int>;

struct edge {
    int to, weight;
};

constexpr int INF = 1e9;

int main() {
    int n, m;
    while(cin >> n >> m, n) {
        vector<vector<edge>> g(n);
        for(int i=0; i<m; ++i) {
            int a, b, cost;
            cin >> a >> b >> cost;
            g[a].push_back((edge){b, cost});
            g[b].push_back((edge){a, cost});
        }

        vector<int> d(n, INF);
        vector<bool> used(n);
        d[0] = 0;
        int res = 0;
        priority_queue<P, vector<P>, greater<P>> que;
        que.push(make_pair(0, 0));
        while(!que.empty()) {
            P p = que.top();
            que.pop();
            int v = p.second;
            if(d[v] < p.first) {
                continue;
            }
            used[v] = true;
            res += d[v];
            for(auto& e : g[v]) {
                if(!used[e.to] && e.weight < d[e.to]) {
                    d[e.to] = e.weight;
                    que.push(make_pair(d[e.to], e.to));
                }
            }
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 3012
// A. 

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstring>

using namespace std;

int main(int argc, char *argv[])
{
	int x, y;
	cin >> x >> y;
	int ans = 1 << 30;
	for (int a = -1; a <= 1; a += 2) {
		for (int b = -1; b <= 1; b += 2) {
			int cnt = (a < 0) + (b < 0);
			int p = x * a, q = y * b;
			if (p <= q) {
				ans = min(ans, cnt + q - p);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(){
	int N;
	scanf("%d", &N);
	
	for(int i = 1; i < 10; i++){
		if(N % i == 0 && N / i < 10){
			puts("Yes");
			break;
		}
		else if( i == 9){
			puts("No");
		}
	}
	
	return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;

int main() {
    int a, b; cin  >> a >> b;
    for (int i = 1; i <=3; ++i) {
        if (i != a && i != b) cout << i;
    }



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
long long weights[N],n,prices[N],dp[100][100002];
long long  solve(long long i,long long weight){
    if(weight<0){
        return -OO;
    }
    if(i==n||weight==0){
        return 0;
    }
    if(dp[i][weight]!=-1){
        return dp[i][weight];
    }
    return dp[i][weight]=max(prices[i]+solve(i+1,weight-weights[i]),solve(i+1,weight));
}
int main()
{
long long weight,i;
memset(dp,-1,sizeof(dp));
scanf("%lld %lld",&n,&weight);
for(i=0;i<n;++i){
    scanf("%lld %lld",&weights[i],&prices[i]);
}
cout<<solve(0,weight)<<endl;




    return 0;
}


Measured memory_bytes: 81876
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,x,y,z,i,j,sum,rem,res=0;
    cin>>n>>x>>y;
    for(i=1;i<=n;i++){
        sum=0;
        z=i;
        while(z!=0){
            rem=z%10;
            z=z/10;
            sum+=rem;
        }
        for(j=x;j<=y;j++){
            if(sum==j){
                res+=i;
                break;
            }
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int main()
{
	int n,i;
	char s[100],t[100];
	scanf("%d",&n);
	scanf("%s %s",s,t);
	for(i=0;i<n;i++){
		printf("%c%c",s[i],t[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 1724
import math
import fractions
import copy
import numpy as np
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def printrow(a):
    for i in a:
        print(i)

"""
#decomment when needed
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
"""
x,y = ips()

if x%3==0 or y%3 == 0:
    print(0)
    exit(0)
ans = min(x,y)
base = [y,y//2,y//2]
if y%2:base[2]+=1
total = [0,x*base[1],x*base[2]]
ans = min(ans,max(total)-min(total))
for i in range(x):
    total[0]+=y
    total[1]-=base[1]
    total[2]-=base[2]
    ans = min(ans,max(total)-min(total))

base = [x,x//2,x//2]
if x%2:base[2]+=1
total = [0,y*base[1],y*base[2]]
ans = min(ans,max(total)-min(total))
for i in range(y):
    total[0]+=x
    total[1]-=base[1]
    total[2]-=base[2]
    ans = min(ans,max(total)-min(total))
print(ans)





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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

void fastio(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	return;
}
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define size(a) int(a.size())

const ll mod = 1e9 + 7;
const ll inf = ll(1e18);
const double PI = acos(-1);

ll modexp(ll x, ll n, int md) {
	if (n == 0)return 1;
	if (n % 2 == 0)return modexp((x * x) % md, n / 2, md);
	return (x * modexp((x * x) % md, n / 2, md)) % md;
}


int main() {
	fastio();
	//clock_t tm = clock();
	ll a,b,n;
	cin>>a>>b>>n;
	ll x=min(b-1,n);
	cout<<(floor((a*x)/b)-a*floor(x/b))<<endl;
	//cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}


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

int main(void) {
    int a, b, c;
    int ans = 0;
    cin >> a >> b >> c;
    if (a == b && b == c) {
        if (a % 2)
            cout << 0 << endl;
        else
            cout << -1 << endl;
        return 0;
    }
    while (true) {
        if (!(a % 2) && !(b % 2) && !(c % 2)) {
            int ta = a / 2, tb = b / 2, tc = c / 2;
            a = tb + tc;
            b = tc + ta;
            c = ta + tb;
            ans++;
        }
        else
            break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int a,b,c[10000];
  scanf("%d%d\n",&a,&b);
  for(int i=0;i<b;i++){
    scanf("%d",&c[i]);
    a-=c[i];
  }
  if(a>=0)
    printf("%d",a);
  else printf("-1");    
  return 0;
}

Measured memory_bytes: 2160
from collections import *
d=defaultdict(list)
n,m=map(int,input().split())
 
for s in range(m):
    a,b,c=map(int,input().split())
    d[a].append([b,c])
#print(d)

def BELLMANFORD(point,d):
    cost       = {node:-float("inf")for node in range(1,n+1)}
    preference = {node:None         for node in range(1,n+1)}      #最適路のこと 
    cost[point]= 0
    for i in range(n-1):                                  #経路の長さは最大n-1であるため
        for now,lis in d.copy().items():
            for nex,c in lis:
                if cost[nex]<cost[now]+c:
                    cost[nex]=cost[now]+c
                    preference[nex]=now

    negative=[0]*n                                        #負閉路の長さは最大nであるため
    
    for i in range(n):                  #閉路判定
        for now,lis in d.copy().items():
            for nex,c in lis:
                if negative[now-1]==1:
                    negative[nex-1]=1
                if cost[nex]<cost[now]+c:
                    cost[nex]=cost[now]+c
                    preference[nex]=now
                    negative[now-1]=1

    return cost,negative

x,y=(BELLMANFORD(1,d))
#print(x,y)
if y[n-1]==1:
    print("inf")
else:
    print(x[n])

Measured memory_bytes: 4076
#include<iostream>
using namespace std;
int max(int,int);
int min(int,int);
static const int MAX=200000;
int main()
{
	int R[MAX],n,i;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>R[i];
	int maxv=-2000000000;
	int minv=R[0];
	for(i=1;i<n;i++)
	{
		maxv=max(maxv,R[i]-minv);
		minv=min(minv,R[i]);
	}
	 cout<<maxv<<endl;
	return 0;
}
int max(int a,int b)
{
	if(b>a)
		return b;
	else
		return a;
}
int min(int a,int b)
{
	if(b<a)
		return b;
	else
		return a;
}


Measured memory_bytes: 3872
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int A = sc.nextInt();
    int B = sc.nextInt();

    int ans = (B - 1) / (A - 1);
    if((A - 1) * ans != B - 1){
      ans++;
    }
    System.out.println(ans);
  }
}


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

int main(){
#ifndef ONLINE_JUDGE
//	freopen("in.txt","r",stdin);
#endif
	//read
	int n,x,t;
	cin>>n>>x>>t;
	int sum=0;
	while(n>0){
		n-=x;
		sum+=t;
	} 
	cout<<sum;
	return 0;
} 

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

int main(){
    int i,x;
    cin >> x;
    vector<int> ruiseki;
    ruiseki.push_back(0);
    for(i = 1;ruiseki[i - 1] <= 10000000;i++){
        ruiseki.push_back(ruiseki[i - 1] + i);
    }
    i = 0;
    while(x > ruiseki[i])i++;

    for(int k = i;x != 0;k--){
        if(x - k >= 0){
             cout << k << endl;
             x -= k;
        }
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
using VI = vector<int>;
using VB = vector<bool>;
VI h;
VB ok;
int n, m, x, y, res;
int main() {
    DAU
    cin >> n >> m;
    h = VI(n + 1);
    for (int i = 1; i <= n; ++i)
        cin >> h[i];
    ok = VB(n + 1, true);
    for (int i = 1; i <= m; ++i) {
        cin >> x >> y;
        if (h[x] >= h[y])
            ok[y] = false;
        if (h[y] >= h[x])
            ok[x] = false;
    }
    for (int i = 1; i <= n; ++i)
        res += ok[i];
    cout << res;
    PLEC
}


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

int n,x,ans;
map<int,int> m;
vector<int> v;

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		if(m[x]==0) v.push_back(x);
		m[x]++;
	}
	for(int i=0;i<=v.size();i++)
		if(v[i]>m[v[i]]) ans+=m[v[i]];
		else if(v[i]<m[v[i]]) ans+=m[v[i]]-v[i];
	
	cout << ans;
	return 0; 
}

Measured memory_bytes: 5112
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m,ans,a[500010],mn;
int pd(int mid){
	int i,j;
	for(i=mid*2+1,j=n*2;i<=n*2;i++,j--)if(a[i]+a[j]<m)return 0;
	return 1;
}
int main(){
	int i,j,l,r,mid;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n*2;i++)scanf("%d",&a[i]);
	sort(a+1,a+n*2+1);
	l=0;r=n;mn=n;
	while(l<=r){
		mid=(l+r)/2;
		if(pd(mid))mn=mid,r=mid-1;
		 else l=mid+1;
	}
	//printf("%d\n",mn);
	for(i=1;i<=mn;i++)ans=max(ans,a[i]+a[mn*2-i+1]);
	for(i=mn*2+1,j=n*2;i<=n*2;i++,j--)ans=max(ans,a[i]+a[j]-m);
	printf("%d",ans);
}

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

template <typename T> T load() { T r; cin >> r; return r; }
template <typename T> vector<T> loadMany(int n) { vector<T> rs(n); generate(rs.begin(), rs.end(), &load<T>); return rs; }

struct Graph {
	Graph(int n):edges(n){}
	void addEdge1(int a, int b) { edges[a].push_back(b); }
	void addEdge2(int a, int b) { addEdge1(a, b); addEdge1(b, a); }
	int size() const { return (int)edges.size(); }
    vector<int> toposort() const {
        auto deg = vector<int>(size(), 0);
        auto que = vector<int>();
        for (auto v=0; v<size(); ++v)
            for (auto u : edges[v])
                ++deg[u];
        for (auto v=0; v<size(); ++v)
            if (deg[v] == 0)
                que.push_back(v);
        for (auto i=0; i<(int)que.size(); ++i)
            for (auto u : edges[que[i]])
                if (--deg[u] == 0)
                    que.push_back(u);
        return que;
    }
	vector<vector<int>> edges;
};


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    auto n = load<int>();
    auto m = load<int>();
    auto graph = Graph(n);
    for (auto i=0; i<m; ++i) {
        auto v = load<int>()-1;
        auto u = load<int>()-1;
        graph.addEdge1(v, u);
    }
    auto topo = graph.toposort();
    auto dyn = vector<int>(n, 0);
    for (auto v : topo)
        for (auto u : graph.edges[v])
            dyn[u] = max(dyn[u], dyn[v]+1);
    cout << *max_element(dyn.begin(), dyn.end()) << '\n';
}


Measured memory_bytes: 6780
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define int long long
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")

using namespace std;

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

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000000000000000;
const ll LOG = 25;

vi G[N], Gin[N];
int n, m, col[N], M = 0;
ll cnt[3], ted;
bool mark[N];
bool f, f1;

void DFS(int v, int c){
	mark[v] = 1;
	ted ++;
	col[v] = c;
	cnt[c] ++;
	M += G[v].size();
	for (auto u:G[v]){
		if (!mark[u]){
			DFS(u, (c + 1) % 3);
		}else{
			if (u == v) f1 = 1;
			if (col[u] != (col[v] + 1) % 3) f = 1;
		}
	}
	for (auto u:Gin[v]){
		if (!mark[u]){
			DFS(u, (((c - 1) % 3) + 3) % 3);
		}else{
			if (col[u] != (((c - 1) % 3) + 3) % 3) f = 1;
		}
	}
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= m; i++){
		int v ,u;
		cin >> v >> u;
		G[v].pb(u);
		Gin[u].pb(v);
	}
	ll ans = 0;
	for (int i = 1; i <= n; i++){
		if (!mark[i]){
			f = f1 = 0;
			ted = 0;
			M = 0;
			memset(cnt, 0, sizeof cnt);
			DFS(i, 0);
			if (!f){
				if (cnt[0] == 0 || cnt[1] == 0 || cnt[2] == 0){
					ans += M;
				}
				else{
					for (int j = 0; j < 3; j++){
						ans += cnt[j] * cnt[(j + 1) % 3];
					}
				}
			}else{
				ans += ted * ted;
			}
			
		}
	}
	cout << ans;












	return 0;
}


Measured memory_bytes: 23040
#include<bits/stdc++.h>
using namespace std;
int main(){
    // 辞書順最小について
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  vector<string> s(2);
  cin >> s[0] >> s[1];

  sort(s[0].begin(),s[0].end());
  sort(s[1].begin(),s[1].end(),greater<int>());

  if(s[0].compare(s[1])>=0)cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <numeric>

using namespace std;

typedef pair<long long, long long> pl;

#define ll long long


long long A[100005] = {};

class UnionFind {
public:
	vector <ll> par; 
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i; 
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};


long long N, M, k, a, b, c, d, e, H, W;
long long B[2][100005] = {};
bool f;
bool ff;
string S;
set <long long>sll;
pl buf;
vector <long long>vl;

struct ST
{
	long long group;
	long long rank;
	long long tugi=-1;
	int siro;
};

vector <ST> vst;
ST st[100004];

double fl, fll;


int main() {

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

	a = 0;
	c = 0;
	for (int i = 1; i <= N; i++) {
		a += B[0][i];
		a -= B[1][i];

		if (a == M) {
			c++;
		}

	}

	cout << c << endl;

	return 0;

}


Measured memory_bytes: 4992
#include <complex>
#include <iomanip>
#include <iostream>

using namespace std;

typedef complex<double> Point;

Point reflection(Point a, Point b) {
  return conj(b / a) * a;
}

int main() {
  double x, y;
  cin >> x >> y;
  complex<double> p1(x, y);
  cin >> x >> y;
  complex<double> p2(x, y);
  int q;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    cin >> x >> y;
    complex<double> p(x, y);
    auto refl = reflection(p2 - p1, p - p1) + p1;
    cout << fixed << setprecision(10) << refl.real() << " " << refl.imag() << endl;
  }
}

Measured memory_bytes: 1304
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;

int N;
int h[100001];
int dp[100001];

int main(){
    cin>>N;
    repn(i,N) cin>>h[i];

    h[0]=1001001001;
    dp[0]=0;
    dp[1]=0;
    for(int i=2;i<=N;i++){
        int a=dp[i-1]+abs(h[i]-h[i-1]);
        int b=dp[i-2]+abs(h[i]-h[i-2]);
        dp[i]=min(a,b);
    }

    cout<<dp[N]<<endl;
}

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

int main(){
    int n;
    cin >> n;
    int a[n];
    
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n-1;i++){
        cout << a[i] << " ";
    }
    cout << a[n-1] << endl;
    
    for(int i=1;i<n;i++){
        int v = a[i];
        int j = i-1;
        
        while(j>=0&&a[j]>v){
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
        
        for(int k=0;k<n-1;k++){
            cout << a[k] << " ";
        }
        cout << a[n-1] << endl;
    }
    return 0;
}


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

int main(int argc, char* argv[]) {
  int ina, inb, n;
  cin >> n;
  while(n != 0){
    int a=0, b=0;
    for(int i=0;i<n;i++){
      cin >> ina >> inb;
      if(ina > inb){
        a += ina+inb;
      }else if(ina < inb){
        b += ina+inb;
      }else{
        a += ina;
        b += inb;
      }
    }
    cout << a << " " << b << endl;
    cin >> n;
  }

  return 0;
}

Measured memory_bytes: 1160
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fromIntegral . fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  [a, v] <- getIntList
  [b, w] <- getIntList
  t <- getInt
  let d = abs (a-b)
  if d <= (v-w) * t
    then putStrLn "YES"
    else putStrLn "NO"


Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
long long n,m,k,ans=1e9+7,cnt=0,tmp;
string s;
int main(){
  cin >> n >> k;
  long long a[n],b[n];
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
    if(b[i]<=k){
      ans=min(ans,a[i]);
    }
  }
  if(ans==1e9+7){
    cout << "TLE\n";
    return 0;
  }
  cout << ans << endl;
  return 0;
}

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

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

int main() {
    int a, b; cin >> a >> b;
    if(a + b == 15){
        cout << '+';
    }else if(a * b == 15){
        cout << '*';
    }else{
        cout << 'x';
    }
}

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

int main()
{
    string s;
    cin >> s;
    string t, p = "";
    int ans = 0;
    rep(i, s.size()) {
        t += s[i];
        if(t == p) continue;
        p = t;
        t = "";
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	
	p := make([]int,n)
	for i := range p {
		fmt.Scan(&p[i])
	}

	min := p[0]
	ans := 1
	for i := 1; i < n; i++ {
		if min > p[i] {
			ans++
			min = p[i]
		} 
	}
	fmt.Println(ans)
}

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

int main() {
  int a,b,c,count = 0;
  cin >> a >> b >> c;
  vector<int> cookie = {a,b,c};
  sort(cookie.begin(),cookie.end());
  while(cookie[0]%2==0 && cookie[1]%2==0 && cookie[2]%2==0) {
    vector<int> cp = {cookie[0],cookie[1],cookie[2]};
    cookie[0] = (cp[1]+cp[2])/2;
    cookie[1] = (cp[0]+cp[2])/2;
    cookie[2] = (cp[0]+cp[1])/2;
    count++;
    sort(cookie.begin(),cookie.end());
    sort(cp.begin(),cp.end());
    if(cookie == cp) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
# define ll long long
# define mo 1000000009
using namespace std;
int f1(int x)
{
	int ans;
	while(x!=0)
	{
		ans=x%10;
		x=x/10;
	}
	return ans;
}
int f2(int x)
{
	return x%10;
}
int main()
{
	ll n;
	cin>>n;
	map<pair<int,int>,int> m;
	//cout<<f1(n)<<" "<<f2(n);
	for(ll i=1;i<=n;i++)
	{
		m[{f1(i),f2(i)}]++;
	}
    ll ans=0;
    for(int i=1;i<=9;i++)
    {
    	ans+=1LL*m[{i,i}]*m[{i,i}];
    	for(int j=i+1;j<=9;j++)
    	{
    		ans+=2LL*m[{i,j}]*m[{j,i}];
		}
	}

cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef unordered_map<string, ll> mpsl;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll n = inl();
        vl a(n);
        rep(i, n) cin >> a[i];
        ll ans = ll_inf;
        for (int j = -100; j <= 100; j++) {
            ll tmp = 0;
            rep(i, n) {
                tmp += (a[i] - j) * (a[i] - j);
            }
            ans = min(tmp, ans);
        }
        cout << ans << endl;

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 764