akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll a, b; cin >> a >> b;

    ll v = 1;
    while(true){

        ll tax_a = v * 0.08;
        ll tax_b = v * 0.10;

        if(tax_a == a && tax_b == b){
            cout << v << endl;
            break;
        }

        if(tax_a > a && tax_b > b){
            cout << -1 << endl;
            break;
        }

        v++;
    }

    return 0;
}

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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int X;
    cin>>X;
    string ans = "No";
    if(X>=30) ans = "Yes";
    cout << ans << endl;
}

Measured memory_bytes: 3584
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxd = 1e5+10;
int a[maxd],n;
long long b[maxd];
int main()
{
    // freopen("a.in","r",stdin);
    // freopen("k.out","w",stdout);
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    b[1] = 0ll;
    for(int i=1;i<=n;i++)
    {
        if(i%2) b[1] += a[i];
        else b[1] -= a[i];
    }
    b[1] /=2; a[n] -= b[1];
    for(int i=1;i<n;i++)
        b[i+1] = a[i] - b[i];
    for(int i=1;i<=n;i++)
        printf("%lld ",b[i]*2);
    //printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 2560
import math

numbers = input().split(" ")
numbers = [int(x) for x in numbers]
N = numbers[0]
D = numbers[1]

return_value =0

for i in range(N):
    coordinates = input().split(" ")
    coordinates = [int(x) for x in coordinates]
    x_coor = coordinates[0]
    y_coor = coordinates[1]
    distance = math.sqrt((x_coor ** 2) + (y_coor ** 2))
    if distance <= D:
        return_value += 1

print(return_value)

Measured memory_bytes: 9216
from math import inf
A=26

D=int(input())

C=[0]+list(map(int,input().split())) #減る満足度のベース
#S=[0]*(D+1) #S[d][i] :(d+1)日目にコンテストiを開催した時の満足度

for i in range(1,D+1):
    S=list(map(int,input().split()))

    M=max(S)
    print(S.index(M)+1)


Measured memory_bytes: 67984
N,M=map(int, input().split())
H=list(map(int, input().split()))
L=[[] for _ in range(N)]
for i in range(M):
    a,b=map(int, input().split())
    L[a-1].append(H[b-1])
    L[b-1].append(H[a-1])

ans=0
for i in range(N):
    if len(L[i])==0:
        ans+=1
    elif H[i]>max(L[i]):
        ans+=1

print(ans)

Measured memory_bytes: 23120
n, m = map(int,input().split())
A = list(map(int,input().split()))
A = [x * -1 for x in A]
A.sort()
import heapq
import bisect
heapq.heapify(A)
for _ in range(m):
    min_ = heapq.heappop(A)
    tmp = min_ * -1 // 2 * -1
    index = bisect.bisect_left(A, tmp)
    heapq.heappush(A,tmp)
print(sum(A) * -1)


Measured memory_bytes: 15020
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime> 
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, x, t;
	cin >> n >> x >> t;
	cout << ((n + x - 1) / x) * t << endl;	
}

Measured memory_bytes: 3152
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::vector<std::string> W){
    set<string> st;
    bool f = true;
    for(int i = 1; i < N; ++i) {
        st.insert(W[i - 1]);
        f = f && W[i-1].back() == W[i][0] && st.find(W[i]) == st.end();
    }
    cout << (f ? YES : NO) << endl;
}

signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> W(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> W[i];
    }
    solve(N, std::move(W));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;
 
template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}
 
const double PI = acos(-1.0);
const int INF = 1e9 + 47;
const LL LINF = 1LL * INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string s;
	cin >> s;
	int ans = 0;
	FOR(i, 0, SZ(s))
	{
		FOR(j, i, SZ(s))
		{
			if(s[j] == 'S') break;
			setmax(ans, j - i + 1);
		}
	}
	cout << ans << endl;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}
 


Measured memory_bytes: 3848
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll dp[2][100010];
 
int main() {
    string s;
    cin >> s;
    ll m = s.size();

    dp[0][0] = 1;
    rep(i, m) {
        if(s[i] == '0') {
            dp[0][i+1] += dp[0][i];
            dp[1][i+1] += 3*dp[1][i];
        }
        else if(s[i] == '1') {
            dp[0][i+1] += 2*dp[0][i];
            dp[1][i+1] += 3*dp[1][i] + dp[0][i];
        }
        dp[0][i+1] %= mod;
        dp[1][i+1] %= mod;
    }

    ll ans = (dp[0][m] + dp[1][m])%mod;

    out(ans);
    re0;
}

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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;

int main() {
  char c;
  cin >> c;
  if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
  
  
}
      
       




Measured memory_bytes: 3512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())

//最大公約数
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;
}

int main(){
    int a,b;
    cin >> a >> b;
    if(a*b%2==0)    puts("Even");
    else
    {
        puts("Odd");
    }
    
    return 0;
}

Measured memory_bytes: 256
S = input()
N = len(S)
ans = [0] * N
r_cnt = 0 # Rcount
for i in range(N):
    if S[i] == 'R':
        r_cnt += 1
    else:
        even = r_cnt // 2
        odd = r_cnt - even
        ans[i] += even
        ans[i-1] += odd
        r_cnt = 0

l_cnt = 0
for i in range(N-1, -1, -1):
    if S[i] == 'L':
        l_cnt += 1
    else:
        even = l_cnt // 2
        odd = l_cnt - even
        ans[i] += even
        ans[i+1] += odd
        l_cnt = 0
print(*ans)

Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll k, x, key;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
		cin >> k >> x;
		key = x-k+1;
		for (ll i = key; i <= x+k-1; i++){
			cout << i << ' ';
			}

}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>

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

using namespace std;

const int V_MAX=100000;
const int M=1000000007;

int main(){
	for(int n,m;~scanf("%d%d",&n,&m);){
		if(n==0) break;

		static vector<int> G[V_MAX];
		rep(u,n) G[u].clear();

		rep(i,m){
			int a,b; scanf("%d%d",&a,&b); a--; b--;
			G[a].push_back(b);
			G[b].push_back(a);
		}

		// BFS
		int cc=0; // number of connected components of G
		static bool vis[V_MAX];
		rep(u,n) vis[u]=false;
		rep(u,n) if(!vis[u]) {
			cc++;
			vis[u]=true;

			int head=0,tail=0;
			static int Q[V_MAX];
			Q[tail++]=u;
			while(head<tail){
				int v=Q[head++];
				rep(i,G[v].size()){
					int w=G[v][i];
					if(!vis[w]){
						vis[w]=true;
						Q[tail++]=w;
					}
				}
			}
		}

		int ans=1;
		rep(i,cc) ans=2*ans%M;
		if(m>0) ans=(ans+1)%M;
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 7304
import sys
sys.setrecursionlimit(5010)

def solve(s): 
    if len(s) ==3:
        if s[0]=='A' and s[1]=='B' and s[2]=='C':
            return True
        else:
            return False
    i=0
    a = 0
    b = 0
    c = 0
    lis =[]
    while i < len(s):
        if i+2<len(s) and s[i] =='A' and s[i+1] == 'B' and s[i+2] == 'C':
            lis.append('X')
            i += 3
        else:
            lis.append(s[i])
            if s[i] == 'A':
                a = 1
            if s[i] == 'B':
                b = 1
            if s[i] == 'C':
                c = 1
            i += 1

    if not(a+b+c == 2):
        return False
    if a==0:
        for i in range(len(lis)):
            if lis[i] == 'X':
                lis[i]='A'
    if b==0:
        for i in range(len(lis)):
            if lis[i] == 'X':
                lis[i]='B'
    if c==0:
        for i in range(len(lis)):
            if lis[i] == 'X':
                lis[i]='C'
    if len(s) == len(lis):
        return False

    return solve(lis)


if solve(input()):
    print("Yes")
else:
    print("No")



Measured memory_bytes: 60096
#pragma GCC optimize("O3")
#pragma GCC target("avx")

#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    vector<double> x(n), y(n);
    vector<char> d(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i] >> d[i];
    }
    double uu = -INF, ud = -INF, um = -INF;
    double du = INF, dd = INF, dm = INF;
    double lle = INF, lr = INF, lm = INF;
    double rl = -INF, rr = -INF, rm = -INF;
    for (int i = 0; i < n; ++i) {
        if (d[i] == 'U') {
            chmax(uu, y[i]);
            chmin(du, y[i]);
            chmax(rm, x[i]);
            chmin(lm, x[i]);
        } else if (d[i] == 'D') {
            chmax(ud, y[i]);
            chmin(dd, y[i]);
            chmax(rm, x[i]);
            chmin(lm, x[i]);
        } else if (d[i] == 'L') {
            chmax(um, y[i]);
            chmin(dm, y[i]);
            chmax(rl, x[i]);
            chmin(lle, x[i]);
        } else if (d[i] == 'R') {
            chmax(um, y[i]);
            chmin(dm, y[i]);
            chmax(rr, x[i]);
            chmin(lr, x[i]);
        }
    }
    double lastx = 1e20, lasty = 1e20;
    double ret = 1e20;
    double time, u, dn, l, r, xx, yy;
    for (int i = 0; i <= 400000000; ++i) {
        time = 0.5 * i;
        u    = max({uu + time, ud - time, um});
        dn   = min({du + time, dd - time, dm});
        l    = min({lr + time, lle - time, lm});
        r    = max({rr + time, rl - time, rm});
        xx   = r - l;
        yy   = u - dn;
        chmin(ret, xx * yy);
        if (xx > lastx && yy > lasty)
            break;
        lastx = xx;
        lasty = yy;
    }
    cout << fixed << setprecision(15) << ret << "\n";
    return 0;
}

Measured memory_bytes: 1920
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

unsigned long long dp[301][301];
const int cm = 1 << 12;
char cn[cm], * ci = cn, ct;

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


	fread(cn, 1, cm, stdin);
	int N = 0, M = 0;
	while ((ct = *ci++) >= '0') N = N * 10 + ct - '0';
	while ((ct = *ci++) >= '0') M = M * 10 + ct - '0';

	int xm[301][4], xM[301][4];
	rep1(i, N) {
		xm[i][1] = N;
		xm[i][2] = N;
		xM[i][2] = -1;
		xM[i][3] = -1;
	}
	rep(i, M) {
		int l = 0, r = 0;
		while ((ct = *ci++) >= '0') l = l * 10 + ct - '0';
		while ((ct = *ci++) >= '0') r = r * 10 + ct - '0';
		int x = *ci++ - '0';
		+ci++;
		chmin(xm[r][x], l);
		chmax(xM[r][x], l);
	}

	const int mod = 1e9 + 7;
	dp[0][0] = 1;
	int mj = 0;
	int mk = 0;
	unsigned long long yabai = 1;
	rep1(i, N) {
		for (int j = i - 1; j >= mj; j--) {
			auto dpj = dp[j];
			for (int k = i - 1; k >= max(j, mk); k--) {
				dpj[i] += dpj[k];
				dp[k][i] += dpj[k];
			}
		}
		yabai *= i + 1;
		for (int j = i; j > xm[i][2]; j--) {
			for (int k = i; k >= max(j, mk); k--) dp[j][k] = 0;
		}
		for (int j = xm[i][2]; j > max(xM[i][3], mj - 1); j--) {
			for (int k = i; k > max(max(xm[i][1], mk - 1), j - 1); k--) dp[j][k] = 0;
			if (yabai > 18446744073709551615 / (i + 1)) {
				for (int k = xm[i][1]; k > max(max(xM[i][2], mk - 1), j - 1); k--) {
					dp[j][k] %= mod;
				}
			}
			for (int k = xM[i][2]; k >= max(j, mk); k--) dp[j][k] = 0;
		}
		for (int j = xM[i][3]; j >= mj; j--) {
			for (int k = i; k >= max(j, mk); k--) dp[j][k] = 0;
		}
		if (yabai > 18446744073709551615 / (i + 1)) {
			yabai = mod;
		}
		if (mj <= xM[i][3]) mj = xM[i][3] + 1;
		if (mk <= xM[i][2]) mk = xM[i][2] + 1;
	}

	ll kotae = 0;
	for (int j = mj; j <= N; j++) for (int k = max(mk, j); k <= N; k++) {
		kotae += dp[j][k] % mod;
	}
	printf("%lld", kotae% mod);

	Would you please return 0;
}

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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)

int main() {
  i32 n, m;
  cin >> n >> m;
  cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;

  return 0;
}


Measured memory_bytes: 3620
num = int(input())
num_list = [int(s) for s in input().split()]
count = 1
hantei = False
for i in range(0,num):
    if num_list[i] == count:
        count+=1
        hantei = True
if hantei == False:
    print("-1")
else:
    print(num-count+1)

Measured memory_bytes: 24744
#include<iostream>
#include<math.h>
void solve();
typedef long long ll;
using namespace std;
int main() {
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int cases;
    cases = 1;
    for (int i = 0 ; i < cases; i++) {
        solve();
        cout << '\n';
    }
    return 0;
}

void solve() {
    int n;
    cin >> n;
    int a[n];
    int count = 0;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) {
        //Skip parts where no change
        while (i + 1 < n && a[i] == a[i + 1]) i++; 
        //Skip decreasing parts
        if (i + 1 < n && a[i] > a[i + 1]) while(i + 1 < n && a[i] >= a[i + 1]) i++;
        //Skip increasing parts
        else if (i + 1 < n && a[i] < a[i +1]) while (i + 1 < n && a[i] <= a[i + 1]) i++;
        count++;
    }
    cout << count;
}

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

int main()
{
    long long n,l0 = 2,l1 = 1,l2;
    cin >> n;
    for(int i = 0; i < n; i++){
        l2 = l1 + l0;
        l0 = l1,l1 = l2;
    }

    cout << l0 << endl;
    
    return 0;
}

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	long long n, k, p;
	cin >> n >> k;
	p = n % k;
	cout << min(p, abs(p - k));
	return 0;
}



Measured memory_bytes: 256
from collections import Counter
n=int(input())
V=list(map(int,input().split()))
a=Counter(V[0::2]).most_common(2)
b=Counter(V[1::2]).most_common(2)
a.append((0,0))
b.append((0,0))
if a[0][0]!=b[0][0]:
    print(n-(a[0][1]+b[0][1]))
else:
    print(min(n-(a[1][1]+b[0][1]),n-(a[0][1]+b[1][1])))

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin>>n>>k;
    std::vector<int> v(n);
    for(int i = 0; i < n; i++)
        cin>>v[i];
    std::vector<int> dp(n);
    dp[n-1] = 0;
    dp[n-2] = abs(v[n-2] - v[n-1]);
    for(int i = n-3; i >= 0; i--)
    {
        dp[i] = abs(v[i] - v[i+1]) + dp[i+1];
        for(int j = i+2; j <= i+k && j < dp.size(); j++)
        {
            if(dp[i] > (abs(v[i] - v[j]) + dp[j]))
            {
                dp[i] = abs(v[i] - v[j]) + dp[j];
            }
        }
    }
    cout<<dp[0]<<"\n";
}

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

int main() {
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    int ans = 0;
    

    if (H2 - H1 >= 1)
    {
        ans = 60 - M1 + M2 + 60 * (H2 - H1 - 1);
    } else
    {
        if (M2 > M1)
        {
            ans = M2 - M1;
        } else {
        
            ans = 24 * 60 - (M1 - M2);
        }
    }
    cout << ans - K << endl;
    
    
  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;

int main()
{
    ll N,K;
    ll count=0;
    ll modcount=0;
    ll ans=0;
    cin>>N>>K;
    if(K%2==1)
    {
        ll num=0;
        while(1)
        {
            num+=K;
            if(num>N)break;
            count+=1;
        }
        ans=count*count*count;
    }
    else
    {
        ll num=0;
        while(num<N)
        {
            num++;
            if(num%K==0)
            {
                
                count+=1;
            }
            else if(num%K==K/2)
            {
                modcount++;
            }
        }
        ans=(count*count*count)+(modcount*modcount*modcount);
    }
    
    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
#define int long long
signed main(){
        char buf[256];
        while ( fgets(buf, 256, stdin) != NULL ) {
                string str(buf);
                transform(str.cbegin(), str.cend(), str.begin(), ::toupper);
                cout << str;
        }
        return 0;
}

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int hp,n;
int atk[1001];
int cost[1001];
int mem[10001];
//int temp[10000];
int templen=0;
int f(int hp){
  if (hp<0&&hp!=-99999) return 0;
  if (mem[hp]>=0) return mem[hp];
  
  int minn=199999999;
  for (int i=0;i<n;i++){
    if (hp>0){
      int x=f(hp-atk[i])+cost[i];
      //temp[templen]=i;
      //templen++;
      if (x<minn) minn=x;
      //if (hp-atk[i]<=0) cout<<minn<<endl;
    }//else cout<<minn<<endl;
  }

  mem[hp]=minn;
  return minn;
}
int main() {
  
  cin>>hp>>n;
  for (int i=0;i<n;i++){
    cin>>atk[i]>>cost[i];
  }
  mem[0]=0;
  for (int i=1;i<10001;i++){  
    mem[i]=-99999;  
  }  
  /*
  int maxn=0,ind;
  for(int i=0;i<n;i++){
    if(atk[i]/cost[i]>maxn) {
      maxn=atk[i]/cost[i];
      ind=i;
    }
  }
  */

  /*
  if (hp>=100){
    int y=hp*0.1;
    while(hp>=y){
      hp-=atk[ind];
      mp+=cost[ind];
      //cout<<"#";
    }
  }
  */
  //cout<<"ind "<<ind<<endl;
  //for (int i=0;i<=hp;i++){  
    //cout<<i<<"  "<<mem[i]<<endl;
  //}  
  cout<<f(hp)<<endl;
}

Measured memory_bytes: 4244
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a1 , a2 , a3 ;
		a1 = scan.nextInt();
		a2 = scan.nextInt();
		a3 = scan.nextInt();
		int diff1 = Math.abs(a1-a2);
		int diff2 = Math.abs(a2-a3);
		int diff3 = Math.abs(a3-a1);
		int sum1 = diff1+diff2;
		int sum2 = diff2+diff3;
		int sum3 = diff3+diff1;
		int min = sum1;
		if(sum2<min)
			min = sum2;
		if(sum3<min)
			min = sum3;
		System.out.println(min);
		scan.close();
	}

}


Measured memory_bytes: 20948
'use script';

{
function Main(input) {
 	const N = input;
	const b = BigInt(1000000000+7);

	function x(m){

		let d = BigInt(1);

		for(i=0; i<N; i++){
				d *= BigInt(m)%b;
				d %= b;
		}
		
	return(d)
	}

	let ans = (x(10)-x(9))+(x(10)-x(9))-(x(10)-x(8));
  	
  	for(i=0; i<3; i++){
     if(ans<BigInt(0)){
        ans += b;
      }
    }
  
  	ans %= b;     
  	console.log(ans.toString());
  
	}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

}

Measured memory_bytes: 35224
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Security.Cryptography;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        //return Pow(2, 61);
        checked { 
            var n = int.Parse(input.ReadLine());
            var aa = ToIntArray(input.ReadLine(), n+1);

            if (n == 0) {
                return aa[0] == 1 ? 1 : -1;
            }
            if(aa[0] != 0) return -1;

            long[] maxnode = new long[n+1];

            maxnode[n] = aa[n];
            for(int i = n - 1; i >= 0; i--) {
                maxnode[i] = maxnode[i+1] + aa[i];
            }

            long sum = 1;
            long nodecount = 1;

            for (int i=1; i <= n; i++) {
                if (nodecount - aa[i-1] <= 0)
                    return -1;

                var y = (nodecount - aa[i-1]) * 2;
                y = Math.Min(y, maxnode[i]);
                sum += y;

                nodecount = y;
            }
            if(nodecount != aa[n]) return -1;

            return sum;
        }
    }

    static long Pow(long x, long n) {
        long ans = 1;
        while (n > 0) {
            if (n % 2 == 1) {
                ans = ans * x;
            }
            n /= 2;
            if (n == 0) break;
            x = x * x;
        }
        return ans;
    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define forin(x,n) for(auto& (x) : n)
#define all(v) (v).begin(),(v).end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define mp make_pair
#define pb push_back
#define MOD 1000000007
#define inf 1000000000
#define llinf 1000000000000000
#define MAX 1000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;
typedef pair<int,pint> P;

int main(){
    int n;
    cin>>n;
    vint val(n),cost(n);
    rep(i,n)cin>>val[i];
    rep(i,n)cin>>cost[i];
    int ans=0;
    rep(i,n){
        if(val[i]-cost[i]>=0){
            ans+=val[i]-cost[i];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(2e5 + 5);
const double EPS = 1e-8;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    while(1){
        int n, w[15], s[15], mi=IINF;
        string f[15];
        vector<int> v, ans;
        cin >> n;
        if(n==0)break;
        REP(i,n){
            cin >> f[i] >> w[i] >> s[i];
            v.push_back(i);
        }
        while(1){
            int cum[15]{}, tmp=0;
            REP(i,n) cum[i+1] += cum[i] + w[v[i]];
            bool ok = true;
            REP(i,n) ok &= s[v[i]] >= cum[n]-cum[i+1];
            if(ok){
                REP(i,n){
                    tmp += w[v[i]]*(i+1);
                }
                if(tmp < mi){
                    mi = tmp;
                    ans = v;
                }
            }
            if(!next_permutation(ALL(v)))break;
        }
        for(auto i : ans){
            cout << f[i] << endl;
        }
    }
    return 0;
}   



Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

int main() {
	int h, w, a, b;
	scanf("%d%d%d%d", &h, &w, &a, &b);
	for(int i=0; i<b; i++) {
		for(int j=0; j<a; j++)
			putchar('1');
		for(int j=0; j<w-a; j++)
			putchar('0');
		putchar('\n');
	}
	for(int i=0; i<h-b; i++) {
		for(int j=0; j<a; j++)
			putchar('0');
		for(int j=0; j<w-a; j++)
			putchar('1');
		putchar('\n');
	}
	return 0;
}

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

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

        int count = 0;
        for (int i=0; i<=k; ++i) {
                for (int j=0; j<=k; ++j) {
                        int z = s-i-j;
                        if (z>=0 && z<=k) {
                                count++;
                        }
                }
        }
        cout << count << endl;
        return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int n;
	ll mod = 1e9 + 7;
	cin >> n;
	vector<ll>As(n+1,0),A(n);
	ll a;
	rep(i, n) {
		cin >> a;
		A[i] = a;
		As[i + 1] = As[i] + a;
	}
	ll ans = 0;
	rep(i, n - 1) {
		ans += (A[i] * ((As[n] - As[i+1]) % mod));
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 6412
import java.util.*;

public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int a = sc.nextInt();
        String s = sc.next();
      
      	if(a >= 3200){
        	System.out.println(s);
          
        }else{
        	System.out.println("red");
        }
    } 
}

Measured memory_bytes: 21712
// 154 B

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>
#include <iomanip>
#include <climits>
#include <string>

using namespace std;

int main(){
    int n, count=0;
    string tmp;
    cin >> n;
    vector<string> v;
    for(int i=0; i<n; i++){
        cin >> tmp;
        v.push_back(tmp);
    }

    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    cout << v.size() << endl;
    return 0;
}


Measured memory_bytes: 11660
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")

from collections import defaultdict
import math
n,m = map(int, input().split())
s = input()
t = input()
g = math.gcd(n,m)
d = defaultdict(list)
for i in range(n):
    ind = i*(m//g)
    d[ind].append(s[i])
for i in range(m):
    ind = i*(n//g)
    d[ind].append(t[i])
for k,v in d.items():
    if v and not all(item==v[0] for item in v):
        ans = -1
        break
else:
    ans = n*m//g
print(ans)


Measured memory_bytes: 116208
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <bitset>
#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000'000'007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;

int main(){
    int a,b;
    cin >> a >>b;
    if(a == 1){
        if(b == 1){
            cout << "Draw" << endl;
        }
        else{
            cout << "Alice" << endl;
        }
    }
    else{
        if(b == 1){
            cout << "Bob" << endl;
        }
        else if(a < b){
            cout << "Bob" << endl;
        }
        else if(a == b){
            cout << "Draw" << endl;
        }
        else{
            cout << "Alice" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import math, cmath

def koch(p1, p2, n):
    if n == 0:
        return [p1, p2]
    
    rad60 = math.pi/3
    v1 = (p2 - p1)/3
    v2 = cmath.rect(abs(v1), cmath.phase(v1)+rad60)
    q1 = p1 + v1
    q2 = q1 + v2
    q3 = q1 + v1
    if n == 1:
        return [p1,q1,q2,q3,p2]
    else:
        x1 = koch(p1,q1,n-1)[:-1]
        x2 = koch(q1,q2,n-1)[:-1]
        x3 = koch(q2,q3,n-1)[:-1]
        x4 = koch(q3,p2,n-1)
        x = x1 + x2 + x3 + x4
    return x

n = int(raw_input())
p1 = complex(0,0)
p2 = complex(100,0)

for e in koch(p1,p2,n):
    print e.real,e.imag

Measured memory_bytes: 4704
#include<bits/stdc++.h>
#define FOR(i,m,n) for(int i=m;i<(n);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(void){
  int N;
  cin >> N;
  vector<int> L(2*N);
  REP(i, 2*N) cin >> L[i];
  sort(ALL(L), greater<int>());
  int ans = 0;
  REP(i, N){
    ans += L[2*i+1];
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;

int main()
{
    string s;
    cin >> s;
    vector<bool> a(26);
    
    if(s.size()==26){
        if (s == "zyxwvutsrqponmlkjihgfedcba")
            cout << "-1" << endl;
        else
            for (int i = 25; i > 0;i--){
                a[s[i]-'a'] = true;
                if(s[i]>s[i-1]){
                    
                    rep(j, i-1) cout << s[j];
                    
                    for (char t=s[i-1]+1; t <= 'z';t++)
                        if(a[t-'a']){
                            cout << t << endl;
                            break;
                    }
                        break;
                }
            }
    }
    else{
        rep(i, s.size()) a[s[i] - 'a']=true;
        char x;
        rep(i, 26) if (a[i] == false) {
            x = 'a' + i;
            break;
        }
        cout << s << x << endl;
    }
    return 0;
}


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

int main(){
    int n,k;
    cin >> n >> k;
    int temp = 1;
    for(int i=0;i<n;i++){
        if(temp * 2 < temp + k){
            temp *= 2;
        }else{
            temp += k;
        }
    }
    cout << temp << endl;

}

Measured memory_bytes: 256
def main():
    _ = int(input())
    A = list(map(int, input().split()))

    mi = A[0]
    s = 0

    for a in A[1:]:
        if a <= mi:
            s += mi - a
        else:
            mi = a

    print(s)


if __name__ == '__main__':
    main()


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

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

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

bool solve(const string& S, const string& T) {
  int n = S.length();
  vector<int> c(26, -1);

  REP(i,n) {
    int idx = S[i] - 'a';
    if((c[idx] != -1) && (c[idx] != T[i] - 'a')) {
      return false;
    }else if(c[idx] == -1) {
      c[idx] = T[i] - 'a';
    }
  }

  vector<int> cnt(26, 0);
  REP(i,26) if(c[i] != -1) ++cnt[c[i]];
  REP(i,26) if(cnt[i] > 1) return false;
  return true;
}

int main(){
  string S, T;
  cin >> S >> T;
  cout << (solve(S, T) ? "Yes" : "No") << endl;
  return 0;
}



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

int main(){
  int N, a, b, c, d;
  
  cin >> N;
  
  a=N%10;
  b=((N-a)%100)/10;
  c=((N-a-b)%1000)/100;
  d=(N-a-b-c)/1000;
  
  if((a==b && b==c) || (b==c && c==d))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
def fight(A,B,C,D):
  i = 1
  while A>0 and C>0:
    if i%2!=0:
      C -= B
    else:
      A -= D
    i+=1
  if A<=0:
    print('No')
  else:
    print('Yes')
    
if __name__=='__main__':
  A,B,C,D = map(int,input().split())
  fight(A,B,C,D)



Measured memory_bytes: 9112
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <array>
#include <cstdio>

using namespace std;

int main()
{
    array<int, 3> a;
    if (scanf("%d%d%d", &a[0], &a[1], &a[2]) < 3) return 0;

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

    printf("%d\n", a[0] + a[1]);
    return 0;
}


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

int main() {
    int K;
    cin >> K;
    string S;
    cin >> S;
    string ans = "";

    if (S.size() <= K) {
        ans = S;
    }
    else {
        rep(i,K) {
            ans += S[i];
        }
        ans += "...";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3560
s = raw_input()
K, = map(int, raw_input().split())
L = len(s)
a = ["zzzzzz"]*5
b = {}
for i in range(L):
  for j in range(i+1,L+1):
    sij = s[i:j]
    if sij < a[4]:
      if sij not in b:
        a.append(sij)
        a.sort()
        a = a[:5]
        b[sij] = 1
    else:
      break
print a[K-1]

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

using namespace std;

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

  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  h1 = h1 * 60 + m1, h2 = h2 * 60 + m2;
  cout << h2 - h1 - k;

  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n,x,y;
    cin>>n>>x>>y;
    ll c[n];
    rep(0,i,n){
        c[i]=0;
    }
    rep(1,i,n+1){
        rep(i+1,j,n+1){
            ++c[min(j-i,abs(j-y)+abs(x-i)+1)];
            //if(min(j-i,abs(j-y)+abs(x-i)+1)==3)cout<<i<<" "<<j<<endl;
        }
    }
    rep(1,i,n){
        cout<<c[i]<<endl;
    }
}


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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)



/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */

int a, b;
void in(){
    cin >> a >> b;
}

vi cntbit(int n){
    vi ret(40, 0);
    n++;
    int cycle = 1;
    rep(i,0,40){
        cycle *= 2;

        ret[i] += (n / cycle) * cycle / 2;
        int t = n % cycle;
        ret[i] += max(0LL, t - cycle / 2);
    }
    return ret;
}

void solve(){
    
    vi bina = cntbit(a - 1);
    vi binb = cntbit(b);

    rep(i,0,40){
        binb[i] -= bina[i];
    }
    
    int base = 1;
    int ans = 0;
    rep(i,0,40
    ){
        if(binb[i] % 2 == 1) ans += base;
        base *= 2; 
    }

    print(ans);


}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

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



int main() {
    string s;
    cin >> s;
    
    if(s[2] == s[3] && s[4] == s[5])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}




Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
    ll a, b, c, d; cin >> a >> b >> c >> d;
    ll ans = -1001001001001001001;
    chmax(ans, a * c);
    chmax(ans, a * d);
    chmax(ans, b * c);
    chmax(ans, b * d);
    if (a <= 0 && 0 <= b) chmax(ans, 0ll);
    if (c <= 0 && 0 <= d) chmax(ans, 0ll);
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

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

    int n4 = n / 4 + 1;
    int n7 = n / 7 + 1;

    bool flag = false;
    rep(i, n4)
    {
        rep(j, n7)
        {
            if (4 * i + 7 * j == n)
            {
                flag = true;
            }
        }
    }
    cout << (flag ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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

ll N,p,q,ans;

int main(){
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    cin>>N;
    ll A[N],narabi[N];
    rep(i,N)cin>>A[i];
    sort(A,A+N);
    rep(i,N){
        if(A[i]<0){
            if(i!=N-1)ans-=A[i];
            else ans+=A[i];
            q++;
        }
        else{
            if(i==0)ans-=A[i];
            else ans+=A[i];
        }
    }
    out(ans);
    if(q==0){
        q=1;
        p=N-1;
    }
    else if(q==N){
        q=N-1;
        p=1;
    }
    repi(i,q,N-1){
        cout<<A[0]<<" "<<A[i]<<endl;
        A[0]-=A[i];
    }
    rep(i,q){
        cout<<A[N-1]<<" "<<A[i]<<endl;
        A[N-1]-=A[i];
    }    
}


Measured memory_bytes: 2688
#include<cstdio>
#include<vector>
#include<iostream>
using namespace std;
int gcd(int a,int b){if(a<b){swap(a,b);}if(b==0){return a;}return gcd(a%b,b);}
int main(void){
	string a,b,c;
	cin>>a>>b;
	if(a==b){cout<<"H"<<endl;}else{cout<<"D"<<endl;}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) (a < b ? b : a)
#define min(a,b) (a > b ? b : a)
#define AAA (1000000007)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


int main() {
	int i, j, k;
	ll N, M;
	ll X;
	cin >> X;


	ll Y = X / 100;
	X %= 100;
	if (X > Y*5) {
		cout << 0;
		return 0;
	}
	cout << 1;
	return 0;
}



Measured memory_bytes: 256
h,w = map(int,input().split())
a = []
for i in range(h):
	temp = input()
	atemp = []
	for k in range(w):
		atemp.append(temp[k])
	atemp.insert(0,'#')
	atemp.append('#')
	a.append(atemp)
add = ['#' for i in range(w+2)]
a.insert(0,add)
a.append(add)
for i in range(h+2):
	for k in range(w+2):
		if k != w+1:
			print(a[i][k],end='')
		else:
			print(a[i][k])

Measured memory_bytes: 4468
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define forr(i,x,y) for(int i=x;i< y;i++)
#define sci(x) int x; cin>>x;
#define scii(x,y) int x,y; cin>>x>>y;
#define sciii(x,y,z) int x,y,z; cin>>x>>y>>z;
#define tc(x) sci(x); while(x--)
int main(){
    sci(a);
    cout<<(a+(a*a)+(a*a*a))<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N;
    string S;
    cin >> N >> S;
    int x = 0;
    int ans = x;
    for (const char c : S)
    {
        x += c == 'I' ? 1 : -1;
        chmax(ans, x);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<string.h>
void Atype();
void Btype();
void wrong();

int A,B;
char b[201];
int main(){
  int n,i;
  char a,C[10000][3];

  scanf("%d",&n);
  for(i = 0;i < n;i++){
    A = 0;
    B = 0;
    scanf("%s",b);

    if(b[0] != '>')wrong();
    else{
      if(b[1] == '\'')Atype();
      else if(b[1] == '^')Btype();
      else wrong();
    }

    if(A == 0){
      strcpy(C[i],"A");
    }
    else if(B == 0){
       strcpy(C[i],"B");
    }
    else{
     strcpy(C[i],"NA");
    }
  }
  for(i=0;i<n;i++)printf("%s\n",C[i]);
  return 0;
}

void Atype(){
  B = 1;
  int x,y,i;
  char c;
  x = 0;
  y = 0;
  while(1){
    if(b[2+x] != '='){
      break;
    }
    x++;
  }
  if(b[2+x] != '#')wrong();
  if(x == 0)wrong();
  while(1){
    if(b[3+x+y] != '='){
      break;
    }
    y++;
  }
  if(x != y)wrong();
  if(b[3+x+y] != '~')wrong();
  if(b[4+x+y] != '\0')wrong();
}

void Btype(){
  A = 1;
  int x=0;
  char c,q;
  while(1){
    x++;
    if(b[2*x] == 'Q' && b[2*x+1] == '='){
      continue;
    }
    else break;
  }
  if(x == 1)wrong();
  if(b[2*x] == '~' && b[2*x+1] == '~');
  else wrong();
  if(b[2*x+2] != '\0')wrong();
}

void wrong(){
  A = 1;
  B = 1;
}

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

int main()
{
	int i,j,k,l,m;
	cin>>i>>j;
	if(j!=1&&i!=1)
	{
		cout<<1;return 0;
	}
		if(j!=3&&i!=3)
{
cout<<3; return 0;
}
			if(j!=2&&i!=2)
			{cout<<2; return 0;
			}
			
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC128C
{
    class Program
    {
        static void Main(string[] args)
        {
            var nums = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();
            var n = nums[0];
            var m = nums[1];

            // 点灯条件1
            var conds = new List<List<int>>();
            foreach (var _ in Enumerable.Range(0, m))
            {
                nums = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();

                conds.Add(nums.Skip(1).ToList());
            }

            // 点灯条件2
            var p = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();

            var allOk = 0;
            foreach (var state in Enumerable.Range(0, (int)Math.Pow(2, n)))
            {
                var list = new List<int>();
                foreach (var cond in conds)
                {
                    var sum = 0;
                    foreach (var c in cond)
                    {
                        sum += (state >> (c - 1)) & 1;
                    }

                    // 各電球とつながっているスイッチのONカウント
                    list.Add(sum % 2);
                }

                if (p.SequenceEqual(list))
                {
                    allOk++;
                }
            }

            Console.WriteLine(allOk);
        }
    }
}


Measured memory_bytes: 13396