akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int M = (1e9)+7;
const int N = 1e6+5;

int spf[N];
vector<int> p;
void sieve()
{
    for(int i=2;i<N;i++)
    {
        if(!spf[i])
        {
            spf[i]=i;
            p.pb(i);
            for(int j=i*i;j<N;j+=i)if(!spf[j])spf[j]=i;
        }
    }
}

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    sieve();
    for(int ti=1;ti<=tc;ti++)
    {
        int n;
        cin>>n;
        int a[n],b[n];
        for(int i=0;i<n;i++)cin>>a[i]>>b[i];
        for(int i=0;!(n%2) && i<n;i++)a[i]*=2LL,b[i]*=2LL;
        sort(a,a+n);
        sort(b,b+n);
        int mi = a[n/2];
        if(!(n%2))mi+=a[(n/2)-1],mi/=2LL;
        int ma = b[n/2];
        if(!(n%2))ma+=b[(n/2)-1],ma/=2LL;
        int ans = ma-mi+1;
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 14960
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define pb push_back
#define pf push_front
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
typedef long long ll;
typedef pair<char, char> c_c;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
const int INF = 1000000007;
const ll LLINF = 1000000000000000007LL;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b, c;
    cin >> a >> b >> c;

    cout << (a+b+c >= 22 ? "bust" : "win") << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int h,w;
	cin>>h>>w;
	vector <vector <int> > a(h,vector <int> (w));
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			cin>>a[i][j];
		}
	}
	vector <int> y1,x1,y2,x2;
	for(int i=0;i+1<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(a[i][j]%2==1)
			{
				a[i+1][j]++;
				a[i][j]--;
				y1.push_back(i);
				x1.push_back(j);
				y2.push_back(i+1);
				x2.push_back(j);
			}
		}
	}
	for(int j=0;j+1<w;j++)
	{
		if(a[h-1][j]%2==1)
		{
			a[h-1][j+1]++;
			a[h-1][j]--;
			y1.push_back(h-1);
			x1.push_back(j);
			y2.push_back(h-1);
			x2.push_back(j+1);
		}
	}
	cout<<y1.size()<<"\n";
	for(int i=0;i<y1.size();i++)
	{
		printf("%d %d %d %d\n",y1[i]+1,x1[i]+1,y2[i]+1,x2[i]+1);
	}
 	return 0;
}


Measured memory_bytes: 5224
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 4010

long long ni[N][N];




int main() {
	f(i, N) {
		ni[i][0] = 1;
		ni[i][i] = 1;
		f(j, i - 1) {
			ni[i][j + 1] = (ni[i - 1][j] + ni[i - 1][j+1]) % MOD;
         }
	}
	long long n, m, ans, s, x;
	scanf("%lld %lld", &n, &m);
	if ((n == 0) || (m == 0)) {
		printf("1\n");
		return 0;
	}
	ans = 0;
	for(long long i=1;i<=m;i++){
		if (i == m) {
			ans = (ans + n + 1) % MOD;
		}
		else {
			s = 0;
			for (long long j = n - m + i; j >= 0; j--) {
				if ((n - m + i - j) <= (m - i - 1)) {
					s = (s + ni[m - i - 1][n - m + i - j]) % MOD;
				}
					x = (ni[m - 1][i - 1] * (j + 1)) % MOD;
					x = (x*s) % MOD;
					ans = (ans + x) % MOD;
			}
		}
	}
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 124032
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>
#include <string>

#include <cstdint>

#define REP(i,n) for(int64 i=0; i<(int64)(n); ++i)
#define REPS(i,n) for(int64 i=1; i<(int64)(n); ++i)
#define RREP(i,n) for(int64 i=(int64)(n)-1; i>=0; --i)
#define UPDATE_MAX(a,b) (a) = std::max((a),(b))
#define UPDATE_MIN(a,b) (a) = std::min((a),(b))
#define ALL(v) (v).begin(),(v).end()
#define STARTS_WITH(SRC_ITERATOR,T) std::equal((T).begin(),(T).end(),SRC_ITERATOR)

#define ENSTRING(v) #v
#define PRINT_VAR(VAR) std::cerr << ENSTRING(VAR) << ":" << (VAR) << " @ L" << __LINE__ << endl

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

using namespace std;
using int64 = int64_t;
using uint64 = uint64_t;

template <typename _Ty>
ostream& operator << (std::ostream& ost, const std::vector<_Ty>& v) {
	if (v.empty()) {
		ost << "{}";
		return ost;
	}
	auto it = v.begin();
	ost << "{" << *it++;
	for (; it != v.end(); ++it) {
		ost << ", " << *it;
	}
	ost << "}";
	return ost;
}

enum status {
	isA,isB,isC
};

int64 find_min(int64 count,int64 A,int64 B,int64 C){
	status mins,maxs,mids;
	int64 num[3] = {A,B,C};

	if(A < B){
		if(A > C){
			// B > A > C
			maxs = isB; mids = isA; mins = isC;
		} else if (A < C) {
			if (B > C){
				// B > C > A
				maxs = isB; mids = isC; mins = isA;
			}else if(C > B){
				// C > B > A
				maxs = isC; mids = isB; mins = isA;
			}else{
				// B = C > A
				maxs = isB; mids = isC; mins = isA;
			}
		} else {
			// B > A = C
			return count + B - A;
		}
	} else if(A > B) {
		if (C < A) {
			if (C < B){
				// A > B > C
				maxs = isA; mids = isB; mins = isC;
			} else if (C > B) {
				// A > C > B
				maxs = isA; mids = isC; mins = isB;
			} else {
				// A > B = C
				return count + A - B;
			}
		} else if(C > A) {
			// C > A > B
			maxs = isC; mids = isA; mins = isB;
		} else {
			// A = C > B
			maxs = isA; mids = isC; mins = isB;
		}
	} else {
		if (C < A) {
			// A = B > C
			maxs = isA; mids = isB; mins = isC;
		} else if(C > A) {
			// A = B < C
			return count + C - A;
		} else {
			// A = B = C
			return count;
		}
	}

	if((num[mids] - num[mins]) & 1){
		num[maxs] += 1; num[mins] += 1; ++count;
		return find_min(count, num[0],num[1],num[2]);
	} else {
		int64 op_cnt = (num[mids] - num[mins]) / 2;
		count += op_cnt;
		num[mins] += 2 * op_cnt;
		return find_min(count, num[0],num[1],num[2]);
	}
	return -1;
}

int main(int argc,char *argv[]){
	int64 A,B,C;
	int64 result;

	cin >> A >> B >> C;

	result = find_min(0,A,B,C);

	cout << result << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int a, b, num;
	int def;

	cin >> a >> b;

	def = b - a;

	num = 0;
	for (int i = 1; i <= def; i++) {
		num += i;
	}

	cout << num - b << endl;

	return 0;
}

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

using namespace std;

#define ALL(x) x.begin(), x.end()

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

const int maxn = 3005;

int dp[maxn][maxn];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(15);
	cout << fixed;

	string s, t;
	cin >> s >> t;

	for (int i = 1; i <= s.length(); i++) {
		for (int j = 1; j <= t.length(); j++) {
			if (s[i - 1] == t[j - 1])
				dp[i][j] = dp[i - 1][j - 1] + 1;
			else
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
		}
	}

	string res;

	int i = s.length(), j = t.length();

	while (i && j) {
		if (dp[i][j] == dp[i - 1][j - 1] + 1 && s[i - 1] == t[j - 1])
			res += s[i - 1], i--, j--;
		else {
			if (dp[i][j] == dp[i - 1][j])
				i--;
			else
				j--;
		}
	}
	
	reverse(ALL(res));
	cout << res << endl;
}

Measured memory_bytes: 35456
#include <utility>
#include <algorithm>
#include <iostream>

using namespace std;

int T;
int gx, gy;
int P;
int sx,sy,ex,ey;

int main(){
  cin >> T;
  

  for(int i = 0;i<T;++i){
    cin >> gx;
    cin >> gy;

    cin >> P;
    int Vert[gx+10][gy+10];
    int Horiz[gx+10][gy+10];

    for(int j=0;j<=gx+1;++j){
      for(int k=0;k<=gy+1;++k){
	Vert[j][k] = 1;
	Horiz[j][k] = 1;
      }
    }
      
    for(int j=0;j<=gx;++j){//??????
      Vert[j][0] = 0;
    }
    for(int j=0;j<=gy;++j){//??????
      Horiz[0][j] = 0;
    }
      
    for(int j=0;j<P;++j){//????????????????????????
      cin >> sx;
      cin >> sy;
      cin >> ex;
      cin >> ey;
	
      if(sy < ey){
	Vert[ex][ey] = 0;
      }
      if(sy > ey){
	Vert[sx][sy] = 0;
      }
      if(sx < ex){
	Horiz[ex][ey] = 0;
      }
      if(sx > ex){
	Horiz[sx][sy] = 0;
      }
    }

    /*
    for(int j=0;j<=gy;++j){
      for(int k=0;k<=gx;++k){
	if(Horiz[k][j] == 1 && Vert[k][j] == 1){
	  cout <<  "+";
	}
	else if(Horiz[k][j] == 0 && Vert[k][j] == 1){
	  cout <<  "|";
	}
	else if(Horiz[k][j] == 1 && Vert[k][j] == 0){
	  cout <<  "-";
	}
	else if(Horiz[k][j] == 0 && Vert[k][j] == 0){
	  cout <<  "o";
	}
	else{//error
	  cout << "x";
	}
      }
      cout << endl;
    }
    cout << endl << endl;
    */
    
    int Keiro[gx+10][gy+10];//Keiro?????????
    for(int j=0;j<=gy;++j){
      for(int k=0;k<=gx;++k){
	Keiro[k][j] = 0;
      }
    }
    Keiro[0][0] = 1;

    
    for(int j=0;j<=gy;++j){
      for(int k=0;k<=gx;++k){
	if(Horiz[k][j] == 1)Keiro[k][j] += Keiro[k-1][j];
	if(Vert[k][j] == 1)Keiro[k][j] += Keiro[k][j-1];
      }
    }
    /*
    for(int j=0;j<=gy;++j){
      for(int k=0;k<=gx;++k){
	cout << Keiro[k][j] << " ";
      }
      cout << endl;
    }
    cout << endl << endl;
    */
    if (Keiro[gx][gy] == 0)cout << "Miserable Hokusai!" << endl;
    else{
      cout << Keiro[gx][gy] << endl;//answer
    }
  }//DataSet??????????????????

  }

Measured memory_bytes: 3068
#include <cstddef>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>
#include <regex>
#include <complex>

using ll = long long;
using ull = unsigned long long;
using ld = long double;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;
    // cerr.rdbuf(nullptr);

    int n;
    cin >> n;
    vec<pair<int, int>> A(n);

    for (int i = 0; i < n; ++i)
    {
        cin >> A[i].first;
        A[i].second = i;
    }
    
    sort(A.rbegin(), A.rend());

    for (int i = 0; i < n; ++i)
    {
        if (A[0].second == i)
            cout << A[1].first << endl;
        else
            cout << A[0].first << endl;
    }
    


    return 0;
}

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

int linearSearch(int A[], int n, int key) {
    int i = 0;
    A[n] = key;
    while(A[i] != key) {
        i++;
    }
    return i != n;
}

int main() {
    int n, S[10001], q, key, sum = 0;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> S[i];
    }
    cin >> q;
    for(int i = 0; i < q; i++) {
        cin >> key;
        if(linearSearch(S, n, key)) {
            sum++;
        }
    }

    cout << sum << endl;
}


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

B = []
b = 0
e = 10 ** 9 + 7

for i in range(N - 1):
    b += A[N - 1 - i]
    b = b % e
    B.append(b)

result = 0

for i in range(N - 1):
    result += A[i] * B[N - 2 - i]
    result = result % e

print(result)

Measured memory_bytes: 106760
N = int(input())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


div = make_divisors(N)

if div[-1] ** 2 == N:
    print(div[-1]*2 - 2)

else:
    x = div[-2] - 1
    y = div[-1] - 1

    print(x + y)


Measured memory_bytes: 3268
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	int k;
	cin>>s>>k;
	int n=s.length();
	vector<string> v;
	for(int i=0;i<n;i++)
		for(int j=1;i+j<=n && j<=5;j++)
			if(find(v.begin(), v.end(), s.substr(i,j))==v.end())
				v.push_back(s.substr(i,j));
	sort(v.begin(), v.end());
	return cout<<v[k-1], 0;
}

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

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

Measured memory_bytes: 3084
/*
 Shahadat Hossain
 I.C.T Department
 Comilla University
 Session: 2013-2014
 */

#include<bits/stdc++.h>
using namespace std;

#define int long long
#define valid(x,y) x>=0 && y>=0 && x<n && y<n
#define all(x) x.begin(),x.end()
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define ms(a,b) memset(a, b, sizeof(a))
#define eps 1e-5
#define input freopen("/Users/shahadat/Desktop/input.txt", "r", stdin)
#define output freopen("/Users/shahadat/Desktop/output.txt", "w", stdout)
#define d(x) cout << #x << " = " << x << endl
#define dd(x,y) cout << #x << " = " << x << "   " << #y << " = " << y << endl
#define ddd(x,y,z) cout << #x << " = " << x << "   " << #y << " = " << y << "   " << #z << " = " << z << endl
//fprintf(stdout,"\nTIME: %.3lf sec\n", (double)clock()/(CLOCKS_PER_SEC));
//int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
#define bit(n,k) (((n)>>(k))&1)
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define pr(x) {cout << (x) << '\n';  }
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define mask(i) ((1LL<<(i)))
#define endl '\n'
double const PI = acos(-1);
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

int const N = 1e5 + 5;
const int INF = 1e15;

int n, W;
int weight[N], value[N];
int dp[101][100001];

int fun(int pos, int val){
    if(pos == n){
        if(val == 0) return 0;
        return 1e18L;
    }
    
    if(dp[pos][val] != -1) return dp[pos][val];
    
    int res = fun(pos + 1, val);
    if(val >= value[pos])
        res = min(res, weight[pos] + fun(pos + 1, val - value[pos]));
    return dp[pos][val] = res;
}

int32_t main(){
    cin >> n >> W;
    ms(dp, -1);
    
    for(int i = 0; i < n; i++){
        cin >> weight[i] >> value[i];
    }
    
    int res = 0;
    for(int i = 100000; i >= 1; i--){
        int temp = fun(0, i);
        if(temp <= W){
            res = max(res, i);
            break;
        }
    }
    cout << res << endl;

}




Measured memory_bytes: 80128
import java.util.*

const val MOD: Long = (1e9+7).toLong()
fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun <T : Comparable<T>> Iterable<T>.argmax(): Int? = withIndex().maxBy{it.value}?.index
fun <T : Comparable<T>> Iterable<T>.argmin(): Int? = withIndex().minBy{it.value}?.index

fun main(args: Array<String>) {
    val reader = System.`in`.bufferedReader()
    val s = reader.readLine()!!
    val n = s.length

    val a = Array(n, {0L})
    for (i in 1..n-2) {
        if (s.substring(i..i+1) == "BC") {
            var f = false
            for (d in i-1 downTo 0) {
                if (a[d] > 0) {
                    a[i] += a[d]
                    break
                }
                if (f) {
                    break
                }
                if (s[d] == 'A') {
                    a[i] += 1L
                } else if (s[d] == 'B') {
                    break
                } else if (s[d] == 'C') {
                    f = true
                }
            }
        }
    }

    println(a.sum())
}


Measured memory_bytes: 45884
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define pii pair<ll,ll>
#define sc(x) scanf("%lld",&x)
 
int main(){
	io;
	string s;
	cin>>s;
	if(s[3]==s[2] && s[4]==s[5]){
		cout<<"Yes";
		return 0;
	}cout<<"No";
	return 0;
}


Measured memory_bytes: 256
while True:
    try:
        a0 = float(input().strip())
        s = a0
        for i in range(1,10):
            if i % 2 == 1:
                a1 = a0*2
            else:
                a1 = a0/3
            s += a1
            a0 = a1
        print(s)

    except EOFError:
        break

Measured memory_bytes: 7408
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int main() {
    vector<int> X(5);
    rep(i, 5) cin >> X.at(i);

    // 10の倍数にした後の合計値
    int sum = 0;
    rep(i, 5) {
        sum += (X.at(i) % 10 == 0) ? X.at(i) : (X.at(i) / 10 + 1) * 10;
    }

    // 最後の数で発生する余剰分
    int minL = MOD;
    rep(i, 5) {
        if(X.at(i) % 10 != 0) {
            minL = min(minL, X.at(i) % 10);
        }
    }

    // 最初から10の倍数の場合は余剰分が発生しない
    int ans = (minL == MOD) ? sum : sum - (10 - minL);

    cout << ans << endl;

    return 0;
}


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

using ll = long long;

const int mod = 1000000007;
const int INF = 1000000000;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    set<int> s;
    for (int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        s.insert(A);
    }
    string ans = "NO";
    if (N == s.size()) ans = "YES";
    cout << ans << endl; 
}


Measured memory_bytes: 9600
using System;
using System.Linq;

namespace ABC057
{
    class B
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var ab = Enumerable.Repeat(0, nm[0]).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();
            var cd = Enumerable.Repeat(0, nm[1]).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();

            for (int i = 0; i < nm[0]; i++)
            {
                var dist = int.MaxValue;
                var res = 0;
                for (int j = nm[1] - 1; j >= 0; j--)
                {
                    if (Math.Abs(ab[i][0] - cd[j][0]) + Math.Abs(ab[i][1] - cd[j][1]) <= dist)
                    {
                        dist = Math.Abs(ab[i][0] - cd[j][0]) + Math.Abs(ab[i][1] - cd[j][1]);
                        res = j + 1;
                    }
                }
                Console.WriteLine(res);
            }
        }
    }
}


Measured memory_bytes: 13524
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).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; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

struct info {
    int a, b, c, d;
};
int n, m, q; 
vector<info> in;
int ans = 0;
void rec (int i, vector<int> x) {
    if (i != n) {
        rep (j, (x.size() == 0 ? 1 : x.back()), m + 1) {
            vector<int> y = x;
            y.push_back(j);
            rec(i + 1, y);
        }
    } else {
        // for (int i : x) cout << i << " "; cout << "\n";
        int tmp = 0;
        rep (i, q) {
            if (x[in[i].b - 1] - x[in[i].a - 1] == in[i].c) tmp += in[i].d;
        }
        chmax(ans, tmp);
    }
}

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m >> q;
    in.resize(q);
    rep (_, q) cin >> in[_].a >> in[_].b >> in[_].c >> in[_].d;
    // int ans = 0;
    rep (i, m + 1) {
        vector<int> x;
        rec(0, x);
    }
    cout << ans << "\n";
    // rep (a0, 1, m + 1) {
    // rep (a1, a0, m + 1) {
    // rep (a2, a1, m + 1) {
    // rep (a3, a2, m + 1) {
    // rep (a4, a3, m + 1) {
    // rep (a5, a4, m + 1) {
    // rep (a6, a5, m + 1) {
    // rep (a7, a6, m + 1) {
    // rep (a8, a7, m + 1) {
    // rep (a9, a8, m + 1) {
    
    // }
    // }
    // }    
    // }    
    // }    
    // }    
    // }    
    // }    
    // }
    // }
    return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>
#include<string.h>
int main()
{
	int i;
	double a,sum;
	double s[10];
	while (scanf("%lf",&a) != EOF) {
		s[0] = a;
		sum = a;
		for (i=1;i<10;i++) {
			if (i%2!=0) {
				s[i] = s[i-1]*2;
			} else {
				s[i] = s[i-1]/3;
			}
			sum+=s[i];
		}
		printf("%lf\n", sum);
	}
	return 0;
}

Measured memory_bytes: 648
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
 
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
 
using namespace std;
 
typedef long long ll;

int main(int argc, char const *argv[])
{
  ll n,m;
  cin >> n>> m;
  vector<ll> l(m),r(m);
  REP(i,m){
    cin >> l[i] >> r[i];
  }
  ll res = 0;
  ll left = 0;
  ll right = pow(10,5)+1;
  REP(i,m){
    left = max(l[i],left);
    right = min(r[i],right);
  }
  if (right-left < 0) {
    cout << 0 << endl;
  }
  else {

  cout << right-left+1 << endl;
  }
  return 0;
}


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

#include <vector>
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
using namespace std;

int main() {
  long long a[2], b[2];
  cin >> a[0] >> a[1] >> b[0] >> b[1];
  long long tmp = a[0] * b[0];
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      tmp = max(a[i] * b[j], tmp);
    }
  }
  cout << tmp << endl;
}

Measured memory_bytes: 3632
dirs = {'R': (1, 0), 'L': (-1, 0), 'U': (0, 1), 'D': (0, -1)}

N = int(input())
P = {d: [] for d in dirs}
for i in range(N):
    x, y, d = input().split()
    x, y = map(int, (x, y))
    P[d].append((x, y))

def fst(x): return x[0]
def snd(x): return x[1]
inf = float('inf')

# 方向別のX・Yの最大最小
S = {d: {'xmin': min(map(fst, P[d]), default= inf),
         'xmax': max(map(fst, P[d]), default=-inf),
         'ymin': min(map(snd, P[d]), default= inf),
         'ymax': max(map(snd, P[d]), default=-inf) }
     for d in dirs}

# 変化がある時刻は0と以下のt1, t2, t3
# S[L][xmax] - t1 == max(S[U][xmax], S[D][xmax]), t < t1 -> S[UD] < S[L]
# S[R][xmax] + t2 == max(S[U][xmax], S[D][xmax]), t < t2 -> S[R]  < S[UD]
# S[L][xmax] - t3 == S[R][xmax] + t3,             t < t3 -> S[R]  < S[L]

dirs = {d: {'x': dirs[d][0], 'y': dirs[d][1]} for d in dirs}
vars = ('xmax', 'xmin', 'ymax', 'ymin')
maxmin = {'max': max, 'min': min}
maxmin = {v: maxmin[v[-3:]] for v in vars}

# 変化がある時刻の集合
T = set()
T.add(0)
for v in vars:
    u, d, c1, c2 = ('R', 'L', 'U', 'D') if v.startswith('x') else \
                   ('U', 'D', 'R', 'L')
    C  = maxmin[v](S[c1][v], S[c2][v])
    t1 =  S[d][v] - C  # inf - inf == nan
    t2 = -S[u][v] + C
    t3 = (S[d][v] - S[u][v]) / 2
    T.update([t1, t2, t3])

# 各時刻のxmax, xmin, ymax, yminを計算
q = inf
for t in (t for t in T if 0 <= t < inf):
    Q = {v: maxmin[v](S[d][v] + t * dirs[d][v[0]] for d in dirs)
         for v in vars}
    q = min(q, (Q['xmax'] - Q['xmin']) * (Q['ymax'] - Q['ymin']))

print(q)


Measured memory_bytes: 17012
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    string S;
    cin>>N>>S;

    int ans=1;
    for(int i=1;i<N;i++){
        if(S[i]!=S[i-1])ans++;
    }
    cout << ans << endl;

    



}


Measured memory_bytes: 512
#include<iostream>
#define MAX_N 100
#define MAX_M 100
#define MAX_L 100

using namespace std;

int n, m, l;
long long a[MAX_N][MAX_M], b[MAX_M][MAX_L];
long long ans[MAX_N][MAX_L];

void solve() {
    for(int i = 0; i < n; i++) {
        for(int k = 0; k < l; k++) {
            for(int j = 0; j < m; j++) {
                ans[i][k] += a[i][j] * b[j][k];
            }
        }
    }
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < l-1; j++) {
            cout << ans[i][j] << " ";
        }
        cout << ans[i][l-1] << endl;
    }
}

int main() {
    cin >> n >> m >> l;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    for(int j = 0; j < m; j++) {
        for(int k = 0; k < l; k++) {
            cin >> b[j][k];
        }
    }
    solve();
}


Measured memory_bytes: 3284
h, w = map(int, input().split())
a = [["" for _ in range(w)] for _ in range(h)]
for y in range(h):
    s = input()
    for x in range(w):
        a[y][x] = s[x]
igny = [False] * h
ignx = [False] * w

def YYY(i, j):
    if j == h - 1:
        return a[j][i] == "."
    else:
        if YYY(i, j + 1):
            return a[j][i] == "."
    return False

def XXX(i, j):
    if i == w - 1:
        return a[j][i] == "."
    else:
        if XXX(i + 1, j):
            return a[j][i] == "."
    return False

for x in range(w):
    ignx[x] = YYY(x, 0)

for y in range(h):
    igny[y] = XXX(0, y)

for y in range(h):
    if igny[y] == False:
        for x in range(w):
            if ignx[x] == False:
                print(a[y][x], end = "")
        print()


Measured memory_bytes: 4724
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007
#define NMAX 10000001
signed main(){

    int c[NMAX]={0};
    c[0]=0;
    c[1]=1;
    for(int i=2;i<NMAX;i++){
        c[i]+=2;
        for(int j=i+i;j<NMAX;j+=i){
            c[j]++;
        }
    }

    int N;
    cin>>N;

    int ans=0;
    for(int i=1;i<=N;i++){
        ans+=c[i]*i;
        /*int b=0;
        for(int j=1;j<=i;j++){
            if(i%j==0) b++;
        }
        if(b!=c[i])  cout<<i<<","<<c[i]<<" "<<b<<endl;*/
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 81312
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <assert.h>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(){
  ll n;
  cin>>n;
  ll x = 0;
  vector<ll> v;
  rep(i,0,n){
    ll a;
    cin>>a;
    v.pb(a);
    x ^= a;
  }
  vector<ll> ans;
  rep(i,0,v.sz){
    ans.pb(v[i]^x);
  }
  rep(i,0,ans.sz){
    cout << ans[i];
    if(i!=ans.sz-1)cout << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 7988
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
using namespace std;
int main()
{
    ll a,b,i;
    cin>>a>>b;
    if(a>=1&&a<=9)
    {
        if(b>=1&&b<=9)
        {
            cout<<a*b<<endl;

        }
    else
        cout<<-1<<endl;
    }
    else
        cout<<-1<<endl;


    return 0;
}





Measured memory_bytes: 3568
import math

cos60 = math.cos(math.radians(60))
sin60 = math.sin(math.radians(60))

def kock(n, p1, p2):
    if n == 0:
        return

    s = ((p1[0] * 2 + p2[0]) / 3, (p1[1] * 2 + p2[1]) / 3)
    t = ((p1[0] + p2[0] * 2) / 3, (p1[1] + p2[1] * 2) / 3)
    u = ((t[0] - s[0]) * cos60 - (t[1] - s[1]) * sin60 + s[0],
         (t[0] - s[0]) * sin60 + (t[1] - s[1]) * cos60 + s[1])

    kock(n-1, p1, s)
    print(*s)
    kock(n-1, s, u)
    print(*u)
    kock(n-1, u, t)
    print(*t)
    kock(n-1, t, p2)

n = int(input())
p1 = (0.0, 0.0)
p2 = (100.0, 0.0)
print(*p1)
kock(n, p1, p2)
print(*p2)

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

struct Node {
    int key;
    struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key   = k;
    z->left  = NIL;
    z->right = NIL;
    
    while(x != NIL) {
        y = x;
        if(z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    
    z->parent = y;
    if(y == NIL) {
        root = z;
    } else {
        if( z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u) {
    if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
    
int main(void) {
    int n, i, x;
    char com[16];
    scanf("%d",&n);
    
    for(i=0;i<n;i++) {
        scanf("%s",com);
        if(!strcmp(com,"insert")) {
            scanf("%d",&x);
            insert(x);
        } else if(!strcmp(com,"print")) {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}


Measured memory_bytes: 25176
import java.util.*

fun main(args: Array<String>) = yorukatsu19e()

fun yorukatsu19e() {
    val (n, width, damage) = readLine()!!.split(' ').map { it.toLong() }
    data class Monster(val position: Long, val health: Long)

    val monsters = (1..n).map {
        readLine()!!.split(' ').map { it.toLong() }.let { Monster(it[0], it[1]) }
    }.sortedBy { it.position }

    data class Bomb(val end: Long, val amount: Long)

    val bombs = ArrayDeque<Bomb>()
    var currDamageSum = 0L
    var answer = 0L

    for ((position, health) in monsters) {
        while (bombs.isNotEmpty() && bombs.peek().end < position) {
            val bomb = bombs.poll()
            currDamageSum -= damage * bomb.amount
        }
        val need = Math.max(Math.ceil((health - currDamageSum).toDouble() / damage).toLong(), 0)
        if (need == 0L) continue
        currDamageSum += need * damage
        bombs.add(Bomb(position + width * 2, need))
        answer += need
    }

    println(answer)
}


Measured memory_bytes: 121016
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 300005
using namespace std;
struct P{
	int x,y,id;
}a[N];
int W,H,n,w[N],m,ans=0,X[N],Y[N];
pair<int,int> b[N];
void get(){
	m=0;
	for(int i=1;i<=n;i++) b[i]=make_pair(a[i].y,i);
	b[n+1]=make_pair(H,0);
	b[n+2]=make_pair(0,0);
	sort(b+1,b+n+3);
	for(int i=1;i<=n+2;i++){
		if(i==1||b[i].first!=b[i-1].first) w[++m]=b[i].first;
		a[b[i].second].y=m;
	}
}
bool cmpid(P a,P b){
	return a.id<b.id;
}
bool cmpy(P a,P b){
	return a.y<b.y;
}
struct trie{
	int mx,add;
}t[N<<2];
void pwd(int k,int l,int r){
	if(l==r) return;
	if(t[k].add){
		t[k<<1].add+=t[k].add;
		t[k<<1|1].add+=t[k].add;
		t[k<<1].mx+=t[k].add;
		t[k<<1|1].mx+=t[k].add;
		t[k].add=0;
	}
}
void build(int k,int l,int r){
	t[k].add=t[k].mx=0;
	if(l==r){
		t[k].mx=-w[l];
		return;
	}
	int mid=l+r>>1;
	build(k<<1,l,mid);
	build(k<<1|1,mid+1,r);
	t[k].mx=max(t[k<<1].mx,t[k<<1|1].mx);
}
int s1[N],top1,s2[N],top2;
void update(int k,int l,int r,int L,int R,int val){
	if(L>R) return;
	pwd(k,l,r);
	if(L<=l&&R>=r){
		t[k].mx+=val;
		t[k].add+=val;
		return;
	}
	int mid=l+r>>1;
	if(L<=mid) update(k<<1,l,mid,L,R,val);
	if(R>mid) update(k<<1|1,mid+1,r,L,R,val);
	t[k].mx=max(t[k<<1].mx,t[k<<1|1].mx);
}
void solve(){
	get();
	build(1,1,m);
	sort(a+1,a+n+1,cmpy);
	ans=max(ans,H-w[a[n].y]+W);
	ans=max(ans,w[a[1].y]+W);
	top1=top2=0;
	int nx=W/2;
	a[0].y=1;
	for(int i=1,p=1;i<=m;i++){
		ans=max(ans,w[i]+t[1].mx);
		update(1,1,m,i,i,W);
		if(a[p].y==i){
			if(a[p].x<=nx){
				update(1,1,m,a[s1[top1]].y,i-1,-a[p].x);
				while(top1&&a[s1[top1]].x<a[p].x){
					update(1,1,m,a[s1[top1-1]].y,a[s1[top1]].y-1,-a[p].x+a[s1[top1]].x);
					top1--;
				}
				s1[++top1]=p;
			}
			if(a[p].x>=nx){
				update(1,1,m,a[s2[top2]].y,i-1,a[p].x-W);
				while(top2&&a[s2[top2]].x>a[p].x){
					update(1,1,m,a[s2[top2-1]].y,a[s2[top2]].y-1,a[p].x-a[s2[top2]].x);
					top2--;
				}
				s2[++top2]=p;
			}
			p++;
		}
	}
}
int main(){
	scanf("%d%d%d",&W,&H,&n);
	ans=max(W,H)+1;
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a[i].x,&a[i].y);
		a[i].id=i;
		X[i]=a[i].x;Y[i]=a[i].y;
	}
	solve();
	sort(a+1,a+n+1,cmpid);
	for(int i=1;i<=n;i++) a[i].x=Y[i],a[i].y=X[i];
	swap(W,H);
	solve();
	printf("%d",ans+ans);
	return 0;
}

Measured memory_bytes: 19840
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	cout << fixed << setprecision(10);
	int n; cin>>n;
	long double ans=0;
	rep(i,0,n){
		long double a; cin>>a;
		ans+=(1/a);
	}
	cout<<1/ans;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
#define deb(x) cout << #x": " << (x) << endl;

int main(){ _
  lli n;
  cin >> n;
  vector <lli> a(n);
  lli x;
  fore (i,0,n){
    cin >> x;
    a[i] = x;
  }
  vector <lli> b(n);
  b[0] = 0;
  b[1] = abs(a[0] - a[1]) + b[0];
  fore (i,2,n){
    if ((abs(a[i - 1] - a[i]) + b[i - 1]) < (abs(a[i - 2] - a[i]) + b[i - 2])){
      b[i] = abs(a[i - 1] - a[i]) + b[i - 1];
    }
    else{
      b[i] = abs(a[i - 2] - a[i]) + b[i - 2];
    }
  }
  cout << b[n - 1] << ENDL;
  return 0;
}


Measured memory_bytes: 4764
H, N = map(int, input().split())
magic = [list(map(int, input().split())) for _ in range(N)]


max_magic = 0
for a, _ in magic:
    max_magic = max(max_magic, a)

amount = H + 1
dp = [0] * (amount + max_magic)
dp[0] = 0

ret = float('inf')

for amt in range(1, amount + max_magic):
    t = [dp[amt - a] + b if amt - a >= 0 else float('inf') for a, b in magic]

    dp[amt] = min(t)

    if amt >= H:
        ret = min(dp[amt], ret)

print(ret)



Measured memory_bytes: 55900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> h(n + 1);
  h[0] = 0;
  REP(i, n) { cin >> h[i + 1]; }

  const ll INF = 1e15;
  vector<vector<ll>> dp(n + 1, vector<ll>(n + 3, INF));
  dp[0][0] = 0;

  FOR(i, 1, n + 1) FOR(j, 1, n - k + 1) {
    ll t = INF;
    REP(l, i) { t = min(t, dp[l][j - 1] + max(h[i] - h[l], 0LL)); }
    dp[i][j] = t;
  }
  ll ans = INF;
  REP(i, n + 1) { ans = min(ans, dp[i][n - k]); }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
int main(void){
 char c[200001];
 scanf("%s",c);
 int i=0,j=strlen(c)-1;
 while(c[i]!='A') i++;
 while(c[j]!='Z') j--;
 printf("%d",j-i+1);
 return 0;
}

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

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

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


int main(){
  int N, H, prevH;
  int step = 0, ans = 0;

  scanf("%d", &N);

  prevH = -1;

  for (int i=0; i<N; i++) {
    scanf("%d", &H);

    if (prevH >= H) {
      step++;
    } else {
      step = 0;
    }

    ans = max(ans, step);
    prevH = H;
  }

  printf("%d\n", ans);

  return 0;
}


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

int main(){
  int h, w;
  char k;
  cin >> h >> w;
  bool a[h+2][w+2];
  bool flag = true;
  for(int i = 0; i <= h+1; i++)
    for(int j = 0; j <= w+1; j++)
      a[i][j] = false;
  for(int i = 1; i <= h; i++){
    for(int j = 1; j <= w; j++){
      cin >> k;
      if(k == '#') a[i][j] = true;
    }
  }
  for(int i = 1; i <= h; i++){
    for(int j = 1; j <= w; j++){
      if(a[i][j] && !(a[i-1][j] || a[i+1][j] || a[i][j-1] || a[i][j+1]))
        flag = false;
    }
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define endl "\n"
#define mod 1000000007
#define ps(x,noOfDecimal) fixed<<setprecision(noOfDecimal)<<x

using namespace std;

signed main()
{
    if (fopen("input.txt", "r")) {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
    std::ios::sync_with_stdio(false);
    int t = 1;
    // cin >> t;
    while (t--) {
        int n, tl;
        cin >> n >> tl;
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            int a; cin >> a;
            if (a >= tl)cnt++;
        }
        cout << cnt;
    }
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int main(int argc, char *argv[])
{
  int n;

  i64 buff[2];
  scanf("%d",&n);
  buff[0]=2;buff[1]=1;

  for (int i = 0; i < n-1; i++) {
    buff[i%2]=buff[0]+buff[1];
  }

  printf("%lld\n",buff[n%2]);
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)


// Write From This Line
int main()
{
	string s;
	cin >> s;
	rep(i,3) {
		if(s[i] == '7'){
			cout << "Yes" << endl;
			return 0;
		}
	}
	puts("No");
}


Measured memory_bytes: 3544
#include <stdio.h>
#define MAX 10000
#define NILL -1

struct Node{
    int parent,lef,rig;
};

struct Node tree[MAX];
int n,dep[MAX],hi[MAX];

void setDep(int,int);
int setHei(int);
int getSi(int);
void print(int);

int main(){
    int val,le,ro,root = 0,i;
    scanf("%d",&n);
    
    for(i=0;i<n;i++) tree[i].parent = NILL;
    
    for(i=0;i<n;i++){
        scanf("%d %d %d",&val,&le,&ro);
        tree[val].lef = le;
        tree[val].rig = ro;
        if( le != NILL) tree[le].parent = val;
        if( ro != NILL) tree[ro].parent = val;
    }
    
    for(i=0;i<n;i++) if(tree[i].parent == NILL) root = i;
    
    setDep(root,0);
    setHei(root);
    
    for(i=0;i<n;i++) print(i);
    
    return 0;
}


void setDep(int u,int d){
    if( u == NILL) return;
    dep[u] = d;
    setDep(tree[u].lef,d+1);
    setDep(tree[u].rig,d+1);
}

int setHei(int u){
    int h = 0,hh = 0;
    if(tree[u].lef != NILL)
        h = setHei(tree[u].lef) + 1;
    if(tree[u].rig != NILL)
        hh = setHei(tree[u].rig) + 1;
    return hi[u] = (h > hh ? h : hh);
}

int getSi(int u){
    if(tree[u].parent == NILL) return NILL;
    if(tree[tree[u].parent].lef != u && tree[tree[u].parent].lef != NILL)
        return tree[tree[u].parent].lef;
    if(tree[tree[u].parent].rig != u && tree[tree[u].parent].rig != NILL)
        return tree[tree[u].parent].rig;
    return NILL;
}

void print(int u){
    printf("node %d: ",u);
    printf("parent = %d, ",tree[u].parent);
    printf("sibling = %d, ",getSi(u));
    int deg =0;
    if(tree[u].lef != NILL) deg++;
    if(tree[u].rig != NILL) deg++;
    printf("degree = %d, ",deg);
    printf("depth = %d, ",dep[u]);
    printf("height = %d, ",hi[u]);
    
    if(tree[u].parent == NILL){
        printf("root\n");
    }else if( tree[u].lef == NILL && tree[u].rig == NILL){
        printf("leaf\n");
    }else {
        printf("internal node\n");
    }
}




Measured memory_bytes: 2048
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;



int main(void)
{
	//変数の宣言
	int n,m;
	int vec[30];
	char s[10];

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int temp3=0;
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	char dummy;
	char stemp[11];
	
	//データの読み込み


//	scanf("%d %d",&n,&m);
//	scanf_s("%d %d",&n,&m);

	scanf("%s",&s);
//	scanf_s("%s",&s,10);


/*	for(i=0;i<n;i++){
//		scanf("%d",&b[i]);
		scanf_s("%d",&b[i]);
	}*/


/*	for(i=0;i<n;i++){
//		scanf("%c",&c[i]);
		scanf_s("%c",&c[i]);
		d[i]=0;
	}*/


	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

//	clock_t start=clock();

	for(i=0;i<26;i++){
		vec[i]=0;
	}

	for(i=0;i<3;i++){
		vec[s[i]-'a']++;
	}

	if(vec[0]==1&&vec[1]==1&&vec[2]==1){
		printf("Yes");
	}else{
		printf("No");
	}

//	clock_t end=clock();

	//	printf("計算部分終了\n");

	//出力
	//printf("%d",min(sum+2*m,n-1));

//	printf("time=%lf",(double)(end-start)/CLOCKS_PER_SEC);
	//	printf("結果の出力終了\n");

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin>>s;
  int n=s.size();
  string ans="";
  for(int i=0;i<n;i++){
    if(s[i]!='B')
      ans+=s[i];
    else if(ans!="") ans.erase(ans.size()-1,1);
  }
  cout<<ans<<endl;
  
}

Measured memory_bytes: 256
// 嘘解法です！！！！！

#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T>
inline bool chmin(T &a, T b) { return a > b && (a = b, true); }

int main() {

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

	int N, M;
	cin >> N >> M;

	vector<vector<int>> d(N, vector<int>(N, INF));
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		d[a][b] = 1;
	}
	DMP(d);

	for (int k = 0; k < N; k++) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				if (d[i][k] == INF || d[k][j] == INF) continue;
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	DMP(d);

	int mincyc = INF;
	vector<int> ans;
	for (int i = 0; i < N; i++) chmin(mincyc, d[i][i]);
	if (mincyc == INF) cout << -1 << "\n";
	else {

		int st = -1;
		for (int i = 0; i < N; i++) {
			if (d[i][i] == mincyc) {
				st = i;
				break;
			}
		}

		int now = st;
		ans.emplace_back(st);
		while (ans.size() < mincyc) {

			for (int i = 0; i < N; i++) {
				if (d[i][i] == mincyc && d[now][i] == 1 && mincyc == d[i][st] + d[st][i]) {
					ans.emplace_back(i);
					now = i;
					break;
				}
			}

		}

		cout << ans.size() << "\n";
		for (const auto &e : ans) cout << e + 1 << "\n";
	}

	return 0;
}

Measured memory_bytes: 6272