akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
// #define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr double EPS = 1e-9;



int main() {

    int n;
    cin>>n;
    map<int,int> s;
    vi v(n);
    rep(i,n){
        cin>>v[i];
        s[v[i]]++;
    }
    Rort(v);
    int ans=0;
    rep(i,n){
        if(s[v[i]]==0)continue;
        rep(j,33){
            ll po=pow(2,33-j);
            if(v[i]>=po)continue;
            ll w=po-v[i];
            int num=1;
            if(v[i]==w)num++;
            if(s[w]>=num){
                s[w]--;
                s[v[i]]--;
                ans++;
                break;
            }
        }
    }
    fin(ans);
}



Measured memory_bytes: 48512
fun main(args: Array<String>) {
    val s = readLine() ?: return
    val (a, b, c, d) = mutableListOf<Int>().apply {
        var tmp = s.toInt()
        while (tmp > 0) {
            add(tmp % 10)
            tmp /= 10
        }
        if (size < s.length) {
            add(0)
        }
    }.reversed()

    for (flg in 0..7) {
        val op1 = if (flg.and(1) != 0) '+' else '-'
        val op2 = if (flg.and(2) != 0) '+' else '-'
        val op3 = if (flg.and(4) != 0) '+' else '-'
        val total = a +
                (if (op1 == '+') b else -b) +
                (if (op2 == '+') c else -c) +
                (if (op3 == '+') d else -d)
        if (total == 7) {
            println("${a}${op1}${b}${op2}${c}${op3}${d}=7")
            return
        }
    }
}

Measured memory_bytes: 33916
N = int(input())
a = []
ainfo = []
astrs = input().split()
for astr in astrs:
    a.append(int(astr))
sorteda = sorted(a)



for pos in range(N):
    if pos == 0:
        ainfo.append([sorteda[pos], 1])
    else:
        if sorteda[pos]==sorteda[pos-1]:
            ainfo[-1][1] += 1
        else:
            ainfo.append([sorteda[pos], 1])

ans = 0
for i in ainfo:
    if i[1]<i[0]:#個数が足りないとき
        ans += i[1]
    elif i[1]>i[0]:#多いとき
        ans += i[1]-i[0]
    else:
        pass
print(ans)           
    
    

Measured memory_bytes: 24440
#include <bits/stdc++.h> 
#define forn(i,a,b) for(int i=a; i<=b; i++)
#define ford(i,a,b) for(int i=a; i>=b; i--)
using namespace std;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	string s,a[4]={"maerd","remaerd","esare","resare"};
	cin>>s;
	string k="";
	reverse(s.begin(),s.end());
	forn(i,0,s.size()-1){
		k+=s[i];
		forn(j,0,3){
			if(k==a[j]) k="";
		}
	}
	if(k=="") cout<<"YES\n";
	else cout<<"NO\n";
	return 0;
}

Measured memory_bytes: 3776
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main() {
    map<string, int> m;
    int q; cin >> q;
    while (q--) {
        int com; cin >> com;
        if (com == 0) {
            string key; int x;
            cin >> key >> x;
            m[key] = x;
        } else if (com == 1) {
            string key; cin >> key;
            cout << m[key] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 27884
import java.util.*;

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

    int days = sc.nextInt();
    int works = sc.nextInt();

    int[] workList = new int[works];

    for (int i = 0; i < works; i++) {
      workList[i] = sc.nextInt();
    }

    for (int i = 0; i < workList.length; i++) {
      days -= workList[i];
    }

    if (days < 0) {
      System.out.println("-1");
    } else {
      System.out.println(days);
    }

    sc.close();

  }

}

Measured memory_bytes: 46420
#include <bits/stdc++.h>
#define maxn 5005
#define mod 998244353
#define ll long long
using namespace std;

typedef pair<int, int> P;

int n;

int main()
{
    cin >> n;
    int x = n / 100;
    int y = n % 100;
    if (x > 0 && x <= 12 && y > 0 && y <= 12)
        printf("AMBIGUOUS");
    else if ((x == 0 || x > 12) && (y == 0 || y > 12))
        printf("NA");
    else if (x > 0 && x <= 12)
        printf("MMYY");
    else
        printf("YYMM");

    return 0;
}

Measured memory_bytes: 256
from collections import Counter
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

MOD = 10**9+7
N = int(input())
S = input()[:-1]
C = Counter(S)
ans = 1
for v in C.values():
    ans = ans*(v+1) % MOD
print(ans-1)


Measured memory_bytes: 3956
nk = list(map(int, input().split()))
n = nk[0]
k = nk[1]
a = []
ans = 0
for i in range(k):
  d = input()
  a.extend(list(map(int, input().split())))
for j in range(1, n + 1):
  if not j in a:
    ans = ans + 1
print(ans)

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

int main(){
  long long N,ans=0,t=1;
  cin>>N;
  
  if(N%2!=0){
    ans=0;
  }else{
    N=N/2;
    while(N!=0){
      ans+=N/5;
      N/=5;
    }
  }
  cout<<ans;
}


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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

pair<LL,LL> a[100000];
int b[100000];

int main() {
    ios_base::sync_with_stdio(false);
    LL n;
    cin >> n;
    int j = 0;
    for (LL i = 1; i*i <= n; ++i) {
        if (n % i == 0) {
            a[j].first = i;
            a[j].second = n/i;
            j++;
        }
    }
    for (int i = 0; i < j; ++i) {
        int c = 0, d = 0;
        while (a[i].first > 0) {
            a[i].first/=10;
            c++;
        }
        while (a[i].second > 0) {
            a[i].second/=10;
            d++;
        }
        b[i] = max(c,d);
    }
    sort (b, b + j);
    cout << b[0] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
#define vaibhavv06               \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(0);
#define endl '\n'
#define int long long
#define MM(a,b) memset(a,b,sizeof(a))
const ll MOD = 1000000007;
using namespace std;


int32_t main(){
    vaibhavv06;
	int n; cin>>n;
    int arr[n];
    for(int i=0;i<n;i++) cin>>arr[i];
    int dp[n+1][n+1];
    for(int i=n-1;i>=0;i--){
        for(int j=i;j<n;j++){
            if(i==j) dp[i][j]=arr[i];
            else dp[i][j] = max(arr[i]-dp[i+1][j],arr[j]-dp[i][j-1]);
        }
    }
    cout<<dp[0][n-1]<<endl;
}

Measured memory_bytes: 46464
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <deque>
#include <locale>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <map>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>
#include <cwchar>
#include <cwctype>
#define mp make_pair
#define fs first
#define se second
#define memset(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define MN 0LL
#define MX 20000000000000005
using namespace std;
int main(){
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	int a,b,c,d;
	cin>>a>>b>>c;
	d=100*a+10*b+c;
	if(d%4) cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
	return 0;
	#ifdef home
        eprintf("time = %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
    #endif
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define allof(a) (a).begin(),(a).end()

int d, n, m;

void solve() {
	vector< int > mise;
	mise.push_back(0); mise.push_back(d);
	
	for_(i,0,n-1) {
		int di;
		cin >> di;
		mise.push_back(di);
	}
	
	sort(allof(mise));
	
	int ans = 0;
	
	for_(i,0,m) {
		int k;
		cin >> k;
		
		auto it = upper_bound(allof(mise), k);
		int up = *it; --it;
		int low = *it;
		
		ans += min(up - k, k - low);
	}
	
	cout << ans << endl;
}

int main() {	
	while (cin >> d, d) {
		cin >> n;
		cin >> m;
		
		solve();
	}
}

Measured memory_bytes: 3544
#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;

const long long mod=1e9+7;
const int N=2e5+7;
int n;
int res=0;


int main()
{
   cin>>n;
   for(int i=1;i<=n;i++)
   res+=i;
   cout<<res<<endl;
   
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int A = stdIn.nextInt();
		int B = stdIn.nextInt();
		int C = stdIn.nextInt();
		int K = stdIn.nextInt();
		int ans = 0;
		for(int a = 0; a < K; a++){
			if(A > 0){
				A = A - 1;
				ans++;
			}
			else if(B > 0){
				B = B - 1;
			}
			else{
				C = C - 1;
				ans = ans - 1;
			}
		}
		System.out.println(ans);
		stdIn.close();
	}
}

Measured memory_bytes: 35664
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

int main(){
    int n;cin>>n;
    vector<int>x(n);
    vector<int>y(n);
    rep(i,n){
        cin>>x[i];
        y[i] = x[i];
    }
    sort(ALL(y));
    int mid = y[n/2-1];
    rep(i,n){
        if(x[i]<=mid)cout<<y[n/2]<<endl;
		else cout<<mid<<endl;
    }
}



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

Int n, q;
string s;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> s >> q;
	while(q--){
		Int k; cin >> k;
		Int ans = 0;
		Int d = 0, m = 0, dm = 0;
		for(Int i=0; i<n; ++i){
			if(s[i] == 'D'){
				++d;
			}else if(s[i] == 'M'){
				++m;
				dm += d;
			}else if(s[i] == 'C'){
				ans += dm;
			}
			if(i-k+1 >= 0){
				if(s[i-k+1] == 'D'){
					--d;
					dm -= m;
				}else if(s[i-k+1] == 'M'){
					--m;
				}
			}
		}
		cout << ans << "\n";
	}
}

Measured memory_bytes: 1948
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cctype>
#include<string>
#include<algorithm>
#include<vector>
#include<climits>
using namespace std;

static const long long INF = (1LL<<32);



int main()
{
	int N, M, R;
	cin >> N >> M >> R;

	vector <int> r(R);
	for (int i = 0; i < R; i++) {
		cin >> r[i];
		r[i]--;
	}
	
	//ワ―シャルフロイドの初期化
	long long d[200][200];

	for (int i = 0; i < N; i++) 
		for (int j = 0; j < N; j++) 
			d[i][j] = ((i == j) ? 0 : INF);

	//経路の登録(両方やる)
	int A, B, C;
	for (int i = 0; i < M; i++) {
		cin >> A >> B >> C;
		d[A - 1][B - 1] = C;
		d[B - 1][A - 1] = C;
	}

	//ワ―シャルフロイド
	for (int k = 0; k < N; k++) {
		for (int i = 0; i < N; i++) {
			if (d[i][k] == INF) continue;
			for (int j = 0; j < N; j++) {
				if (d[k][j] == INF) continue;
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}


	sort(r.begin(), r.end());
	long long ans = INF;

	do {
		long long dist = 0;
		for (int i = 1; i < R; i++)
			dist += d[r[i - 1]][r[i]];
		ans = min(ans, dist);


	} while (next_permutation(r.begin(), r.end()));

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int ans = 0, tmp = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') tmp++;
        else { chmax(ans, tmp); tmp = 0; }
    }
    chmax(ans, tmp);
    cout << ans << '\n';
    return 0;
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

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

    int X; cin >> X;
    int money = (X / 500) * 1000;
    money += ((X % 500) / 5) * 5;
    cout << money << endl;
    return 0;
}

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

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

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

int main(){
  int n;
  cin >> n;
  vector<int> d(n+5);
  rep(i,n){
    cin >> d[i];
  }

  int a = 0;
  for(int i=0;i<n-1;i++){
    for(int k=i+1;k<n;k++){
      a += d[i]*d[k];
    }
  }
  cout << a << endl;
  return 0;
}


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

int main(){
	string s;
	cin >> s;
	string year = s.substr(0,4);
	string month = s.substr(5,2);
	string day = s.substr(8,2);
	int sum = stoi(year + month + day);

	if (sum>20190430){
		cout << "TBD" <<"\n";
	}else {
		cout << "Heisei" <<"\n";
	}
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int A,B,C,X,Y,cost=0;
	scanf("%d %d %d %d %d",&A,&B,&C,&X,&Y);
	if(A+B>C*2){
		while(X>0&&Y>0){
			cost+=C*2;
			X-=1;Y-=1;
		}
	}
	if(A>C*2){
		while(X>0){
			cost+=C*2;
			X-=1;Y-=1;
		}
	}
	if(B>C*2){
		while(Y>0){
			cost+=C*2;
			X-=1;Y-=1;
		}
	}
	if(X>0||Y>0){
		while(X>0){
			cost+=A;
			X-=1;
		}
		while(Y>0){
			cost+=B;
			Y-=1;
		}
	}
	printf("%d",cost);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
/*#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define tr(container, it) \
for(typeof((container).begin()) it = (container).begin(); it != (container).end(); it++)
#define present(container, element) ((container).find(element) != (container).end())
#define cpresent(container, element) (find(all(container),element) != (container).end())
*/

using namespace std;

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

int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);

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

if(a<=k)
{
	k=k-a;
	a=0;
	if(b<=k)
	{
		k=k-b;
		b=0;
	}
	else 
	{
		b=b-k;
	}
}
else
{
	a=a-k;
}
cout<<a<<" "<<b;
return 0;
}


Measured memory_bytes: 256
def bubbleSort():
    l = int(input())
    A = list(map(int, input().split(" ")))
    count = 0
    for i in range(l-1):
        for j in range(l-1-i):
            if (A[j]>A[j+1]):
                temp = A[j]
                A[j] = A[j+1]
                A[j+1] = temp
                count += 1
    print(" ".join(map(str, A)))
    print(count)

bubbleSort()

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

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n, m;
  cin >> n >> m;
  int res = 0;
  for (int i = 1; i * i <= m; i++) {
    if (m % i == 0) {
      int k = m / i;
      if (m / i >= n) res = max(res, i);
      if (m / k >= n) res = max(res, k);
    }
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int get_str(char *str, int size)
{
    char format[100];
    if (size == 0)
        return 0;
    snprintf(format, sizeof(format), "%%%ds", size);
    scanf(format, str);
    return 0;
}

#define STR_MAX 100000
#define BUF_SIZE (STR_MAX+50)

#define DIVISOR 1000000007

static char abc[] = "ABC";

int main(void) {
    static char str[BUF_SIZE];
    get_str(str, BUF_SIZE);
    int len = strlen(str);

    static int64_t dp[4][STR_MAX+1];
    dp[0][0] = 1;
    int i, s;
    for(i = 1; i <= len; i++) {
        int wild_coff = str[i-1]=='?' ? 3 : 1;
        dp[0][i] = (dp[0][i-1]*wild_coff)%DIVISOR;
    }

    for(i = 1; i <= 3; i++) {
        for(s = 1; s <= len; s++) {
            char cur = str[s-1];
            int wild_coff = (cur == '?') ? 3 : 1;
            dp[i][s] = (dp[i][s] + dp[i][s-1]*wild_coff)%DIVISOR;
            if(cur=='?' || cur == abc[i-1]) {
                dp[i][s] = (dp[i][s] + dp[i-1][s-1])%DIVISOR;
            }
#ifdef DEBUG
            printf("dp[%d][%d] = %lld\n", i, s, dp[i][s]);
#endif
        }
    }

    printf("%d\n", (int)dp[3][len]);

    return 0;
}

Measured memory_bytes: 3328
/*
░░░░░░░▄▀▀▀▀▀▀▀▄▄░░░░░░
░░░░░░▐░░░▄▄▄▄▄░ ▀▀▄
░░░░░▐░$░▐▀░░░░▀▀▀▀▄▀
░░░░░▌░░▐░░░░░░░░░░▄▄
░░░░▐░░░░▀▄▄▄▄▄▄▀▀▀░▄▀
░░░░▌▒░▒░▒░▒░░░▄▄▄▀▀
░░░░▌▒▒░▒▒▒▒▄▄▀▀
░░░▐░░▒▒▒▄▀▀░░░░░░░
░░░▐░▒▒▒▐░░░░░░░░░
░░░▐▒▒▒▒▌░░░░░░░░
░░░▐▒▒▒░▐░░░░░░░░░▄▀▄
░░░▐▒▒░▒▐▄▄▀▀▀▀▄▄▄▀░▌
░░░▐░▒▒░▄▄▄▄▀▀▄▄▄▄▄▀
░░▐▒▒▄▒▒▀▄▄▄▄▄▀░░░▄▌░░
░░▌▒▐░▀▀▄▄▄▄▄▄▄▀▀▀░░░░
░▐▒▒▌░░░░░░░░░░░░░ 
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
#else
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
#endif
    int n;
    scanf("%d", &n);
    vector <int> a(n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }
    ll res = 1e18;
    for (int sgn = -1; sgn <= 1; sgn++)
    {
        int sign = sgn;
        if (sign)
        {
            ll pref = 0;
            ll ans = 0;
            for (int i = 0; i < n; i++)
            {
                if (sign == -1)
                {
                    ll kek = max(0ll, 1 - (pref + a[i]));
                    ans += kek;
                    sign = 1;
                    pref = (pref + a[i] > 0 ? pref + a[i] : 1);
                }
                else
                {
                    ll kek = max(0ll, (pref + a[i]) - -1);
                    ans += kek;
                    sign = -1;
                    pref = (pref + a[i] < 0 ? pref + a[i] : -1);
                }
            }
            res = min(res, ans);
        }
    }
    printf("%lld\n", res);
}


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

namespace WelcomeAtcordet
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            List<int> count = new List<int>();
            List<char> let = new List<char>();
            
            foreach(char c in input)
            {
                int index = let.FindIndex(x => x.Equals(c));

                if(index < 0)
                {
                    let.Add(c);
                    count.Add(1);
                }
                else
                {
                    count[index] = count[index] + 1;
                }
            }

            bool beautiful = true;

            foreach(int i in count)
            {
                if(i%2 == 1)
                {
                    beautiful = false;
                    break;
                }
            }

            if (beautiful)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 11220
#include <stdio.h>
#define rep(i, a, b) for(int i = (a); i < (b); ++i)

int main(){
    int a, b;
    scanf("%d %d", &a, &b);
    printf("%d %d %.10f\n", a / b, a % b, (double)a / (double)b);

    return 0;
}



Measured memory_bytes: 2100
import sys
# sys.stdin = open('input.txt')

import queue

k = int(input())
q = queue.Queue()

for i in range(1, 10):
    q.put(i)

for i in range(k):
    x = q.get()
    last_digit = x % 10
    if last_digit != 0:
        q.put(10 * x + last_digit - 1)
    q.put(10 * x + last_digit)
    if last_digit != 9:
        q.put(10 * x + last_digit +1)

print(x)

Measured memory_bytes: 12480
#include <iostream>
using namespace std;
int main(void){
    
    int R;
    
    cin >> R;
    
    if(R < 1200) cout << "ABC" << endl;
    else if(R < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
    
    return 0;
    
}

Measured memory_bytes: 256
#include <stdio.h>
typedef long long l;

int n, k;
l a[100000];

int check(l P){
  int i=0, j;
  for(j = 0; j < k; j++){
    l s = 0;
    while(s+a[i] <= P){
      s += a[i];
      i++;
      if(i == n)return n;
    }
  }
  return i;
}

int solve(){
  l left=0;
  l right = 100000*10000;
  l mid;
  int v;

  while(right - left > 1){
    mid = (right+left)/2;
    v = check(mid);
    if(v >= n)right = mid;
    else left = mid;
  }
  return right;
}

int main(void){
  int i;
  l ans;
  scanf("%d", &n);
  scanf("%d", &k);

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

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

  return 0;
}



Measured memory_bytes: 2584
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
S = [input().rstrip() for _ in range(N)]

from collections import defaultdict
d = defaultdict(int)

for s in S:
    key = s[0]
    d[key] += 1

from itertools import combinations
c = combinations("MARCH",3)
ans = 0
for x,y,z in c:
    ans += d[x]*d[y]*d[z]

print(ans)

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

int GCD(int n,int m){if(n%m==0)return m;return GCD(m,n%m);}

int main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	
	int n[50]={0};
	int i=0;
	while(cin>>n[i++]);
	int nn=i-1;
	int gcd=0,lcm=0,a=0,b=0;
	for(int j=0;j<nn;j+=2){
		gcd=GCD(n[j],n[j+1]);
		a=n[j]/gcd,b=n[j+1]/gcd;
		cout<<gcd<<" "<<gcd*a*b<<endl;
	}
	return 0;
}

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

#define loop(v, f, l) for(int v = (f), v##_ = (l); v < v##_; ++v)

using namespace std;

typedef long long int lint;
static inline int in(){ int x; scanf("%d", &x); return (x); }
static inline lint inl(){ lint x; scanf("%lld", &x); return (x); }

int main()
{
	int sum = 0;
	for(int i = 0; i < 5; i++)
	{
		sum += max(40, in());
	}
	printf("%d\n", sum / 5);
	return (0);
}

Measured memory_bytes: 1188
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main(void){
    int n,i,tmp;
    int *x;
    int *y;
    double p[4] ={};
    scanf("%d",&n);
    x = (int *)malloc(n * sizeof(int));
    y = (int *)malloc(sizeof(int) * n);
    for(i=0;i<n;i++){
        scanf("%d",&x[i]);
    }
    for(i=0;i<n;i++){
        scanf("%d",&y[i]);
        tmp = fabs(x[i] - y[i]);
        p[0] = p[0] + tmp;
        p[1] = p[1] + pow(x[i] - y[i],2);
        p[2] = p[2] + pow(tmp,3);
        if(tmp > p[3]) p[3] = tmp;
    }
    p[1] = sqrt(p[1]);
    p[2] = cbrt(p[2]);
    for(i=0;i<4;i++){
        printf("%lf\n",p[i]);
    }

    return 0;
}

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

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

void calcDist(int pos, int d, vector<int>& dist, vector<vector<int>>& G)
{
    if(dist[pos] >= 0) return;
    dist[pos] = d;
    for(auto v: G[pos]) calcDist(v, d+1, dist, G);
}

int dfs(int ans, int pos, vector<int>& dist_from_u, vector<int>& dist_from_v, vector<bool>& visited, vector<vector<int>>& G)
{
    if(visited[pos]) return ans;

    visited[pos] = true;
    for(auto v: G[pos]) ans = max(ans, dfs(ans, v, dist_from_u, dist_from_v, visited, G));

    if(dist_from_u[pos] < dist_from_v[pos]) return max(ans, dist_from_v[pos]-1);
    else return ans;
}


int main()
{
    int N, u, v;
    cin >> N >> u >> v;
    --u, --v;
    vector<vector<int>> G(N);
    REP(i, N-1){
        int A, B;
        cin >> A >> B;
        --A, --B;
        G[A].push_back(B);
        G[B].push_back(A);
    }

    vector<int> dist_from_u(N, -1), dist_from_v(N, -1);
    calcDist(u, 0, dist_from_u, G);
    calcDist(v, 0, dist_from_v, G);
    
    vector<bool> visited(N, false);
    cout << dfs(0, v, dist_from_u, dist_from_v, visited, G) << endl;

    return 0;
}

Measured memory_bytes: 12928
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=10000;

int dp[501][501];

int main(){
    int N,ma,mb;
    cin >> N >> ma >> mb;
    int a,b,c;
    for(int i=0;i<=500;i++){
        for(int j=0;j<=500;j++){
            dp[i][j]=INF;
        }
    }
    dp[0][0]=0;
    for(int i=0;i<N;i++){
        cin >> a >> b >> c;
        for(int k=500;k>=0;k--){
            for(int s=500;s>=0;s--){
                if(dp[s][k]!=INF){
                    dp[s+a][k+b]=min(dp[s+a][k+b],dp[s][k]+c);
                }
            }
        }
    }
    int ans=INF;
    for(int i=1;i<INF;i++){
        if(ma*i>500||mb*i>500) break;
        ans=min(ans,dp[ma*i][mb*i]);
    }
    if(ans==INF) cout << "-1" << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1280
# 16:15
import sys
input = lambda: sys.stdin.readline().rstrip()
import math
n, h = map(int, input().split())
sl = 0
th = []
for i in range(n):
    a, b = map(int, input().split())
    sl = max(sl, a)
    th.append(b)

th.sort()
th_damage = th.pop()
turn = 0
while (h > 0):
    if th_damage > sl:
        h -= th_damage
        if len(th) != 0:
            th_damage = th.pop()
        else:
            th_damage = 0
    else:
        turn += math.ceil(h / sl)
        break
    turn += 1

print(turn)


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

int main(){
  ll n,m;
  cin>>n>>m;
  ll ans=0;
  ans+=min(n,m/2);
  n-=min(n,m/2);
  m-=ans*2;
  ans+=m/4;
  cout<<ans<<endl;
  

  


  return 0;
}


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

namespace atcoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var hw = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			var dic = new Dictionary<char, int>();
			for (int i = 0; i < hw[0]; i++)
			{
				var input = Console.ReadLine();
				for(int j = 0;j < input.Length;j++)
				{
					if (dic.ContainsKey(input[j])) dic[input[j]]++;
					else dic.Add(input[j], 1);
				}
			}
			List<int> nokori = new List<int>();
			foreach(var a in dic)
			{
				if (a.Value % 4 != 0) nokori.Add(a.Value % 4);
			}
			bool ans = true;
			if(hw[1] % 2 == 0 && hw[0] % 2 == 0)
			{
				ans = nokori.Count == 0;
			}
			else if(hw[1] % 2 != 0 && hw[0] % 2 != 0)
			{
				int c = 0;
				foreach(var a in nokori)
				{
					if (a % 2 != 0) c++;
				}
				
				ans = (nokori.Sum() <= hw[0] + hw[1] - 1) && (c <= 1);
			}
			else
			{
				ans = nokori.All(x => x % 2 == 0);
				if (hw[0] % 2 == 0 && hw[0] < nokori.Sum()) ans = false;
				if (hw[1] % 2 == 0 && hw[1] < nokori.Sum()) ans = false;
			}
			if (ans) Console.WriteLine("Yes");
			else Console.WriteLine("No");
			//Console.ReadLine();
		}
	}
}

Measured memory_bytes: 13404
#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(){
  vector<int> s(5);
  cin >>s.at(0) >>s.at(1) >> s.at(2) >> s.at(3) >> s.at(4);
  rep(i,5){
    if(s.at(i) == 0){
      cout << i +1 << endl;
    }
}
}

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

using namespace std;

const int maxn = 1e5 + 7;

int Read(char c = 0,int re = 0){
	while(!isdigit(c = getchar()));
	re = c - '0';
	while(isdigit(c = getchar()))
		re = ((re << 2) + re << 1) + c - '0';
	return re;
}
int n;
int a[maxn];

int t[maxn];
int ans;
map<int,int>M_T;
struct Node{
	int v,cnt;
	bool operator < (const Node& a)const{
		return (cnt == a.cnt) ? (v < a.v) : (cnt < a.cnt);
	}
}p1[maxn],p2[maxn];
int tot1,tot2;
int main(){
	n = Read();
	for(int i = 1; i <= n; ++i)a[i] = Read();
	for(int i = 1; i <= n; i += 2)M_T[a[i]]++;
	for(auto it : M_T)p1[++tot1] = (Node){it.first,it.second};
	M_T.clear();
	for(int i = 2; i <= n; i += 2)M_T[a[i]]++;
	for(auto it : M_T)p2[++tot2] = (Node){it.first,it.second};
	sort(p1 + 1,p1 + tot1 + 1);
	sort(p2 + 1,p2 + tot2 + 1);
	if(tot1 == 1 && tot2 == 1){
		if(p1[tot1].v == p2[tot2].v){
			printf("%d\n",min(p1[tot1].cnt,p2[tot2].cnt));
		}
		else puts("0");
		return 0;
	}
	if(tot1 == 1){
		if(p1[tot1].v == p2[tot2].v){
			printf("%d\n",min(n - p2[tot2].cnt,(n - p1[tot1].cnt - p2[tot2 - 1].cnt)));
			return 0;
		}
		printf("%d\n",n - p1[tot1].cnt - p2[tot2].cnt);
		return 0;
	}
	if(tot2 == 1){
		if(p1[tot1].v == p2[tot2].v){
			printf("%d\n",min(n - p1[tot1].cnt,(n - p2[tot2].cnt - p1[tot1 - 1].cnt)));
			return 0;
		}
		printf("%d\n",n - p1[tot1].cnt - p2[tot2].cnt);
		return 0;
	}
	if(p1[tot1].v == p2[tot2].v)
		printf("%d\n",min(n - p1[tot1].cnt - p2[tot2 - 1].cnt,n - p1[tot1 - 1].cnt - p2[tot2].cnt));
	else
		printf("%d\n",n - p1[tot1].cnt - p2[tot2].cnt);
	return 0;
}


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

int main() {
    int m;
    cin >> m;
    for (int i = 0; i < m; i++) {
        int initialFund, year, n;
        cin >> initialFund >> year >> n;
        long long maxFund = initialFund;
        for (int j = 0; j < n; j++) {
            int interestKind, fee;
            double interestRate;
            cin >> interestKind >> interestRate >> fee;
            long long fund = initialFund;
            if (interestKind == 0) {
                int interest = 0;
                for (int k = 0; k < year; k++) {
                    interest += fund * interestRate;
                    fund -= fee;
                }
                fund += interest;
            } else {
                for (int k = 0; k < year; k++) {
                    fund += fund * interestRate;
                    fund -= fee;
                }
            }
            if (maxFund < fund) {
                maxFund = (long long) fund;
            }
        }
        cout << maxFund << endl;
    }
}

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

#define Mset(s, n)      memset(s, n, sizeof(s))
#define Rp0(i, m)       for(int i = 0; i < m; ++i)
#define Rpd(i, m, l)    for(int i = l; i >= m; --i)
#define Rp1(i ,m)       for(int i = 1; i <= m; i++)
#define All(a)          (a).begin(), (a).end()
#define Lwb             lower_bound
#define Upb             upper_bound
#define Sz(a)           int((a).size())
#define u_map           unordered_map
#define Exist(a, b)     (find(All(a), (b)) != (a).end())
#define Sort(x)         sort(All(x))
#define Gsort(x)        sort(All(x), greater<typeof(*((x).begin()))>())
#define Unique(v)       Sort(v); (v).resize(unique(ALL(v)) - (v).begin())

#define fi              first
#define se              second
#define pb              push_back
#define pf              push_front
#define is              insert
#define ooi             INT_MAX
#define ool             LLONG_MAX
#define ll              long long
#define ull             unsigned ll
#define ld              long double
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define vll             vector<ll>
#define vpll            vector<pll>
#define vpii            vector<pii>

const ll MOD = (ll) 1e9 + 7;
const ld PI = acos((ld) -1);
inline int Get_bit(int x, int k){return (x >> (k - 1)) & 1;}
inline ll Gcd(ll a, ll b) {ll r; while(b){ r = a % b; a = b; b = r;} return a;}
inline ll Lcm(ll a, ll b) {return a / Gcd(a, b) * b;}
inline ll Pow(ll n, ll k) {ll r = 1; for(; k; k >>= 1, n = n * n % MOD){if(k & 1) r = r * n % MOD;} return r;}
const int base = 311;


const int N = 1e6 + 10;

int n, k, m, query;

ll ans;
int nx[N];

void Solve(){
    cin >> n;
    cout << 1.0 * (n / 2 + ((n & 1) == 1))  / n;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);
    Solve();
}

















Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	static char[] s;
	static int id ;
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			for(int i=0; i<n; i++) {
				s = sc.next().toCharArray();
				id = 0;
				System.out.println(exp());
			}
			
		}
	}
	static int exp() {
		int res = term();
		while(s[id] == '+' || s[id] == '-') {
			if(s[id] == '+') {
				id++;
				res += term();
			}else {
				id++;
				res -= term();
			}
		}
		return res;
	}
	
	static int term() {
		int res = fact();
		while(s[id] == '*' || s[id] == '/') {
			if(s[id] == '*') {
				id++;
				res *= fact();
			}else{
				id++;
				res /= fact();
			}
		}
		
		return res;
	}
	
	static int fact() {
		int res = 0;
		if(s[id] == '(') {
			id++;
			res = exp();
			id++;
		}else if(s[id] == '+') {
			id++;
			res = fact();
		}else if(s[id] == '-') {
			id++;
			res = -fact(); 
		}else {
			res = num();
		}
		return res;
	}
	
	static int num() {
		int res = 0;
		if(Character.isDigit(s[id])) {
			while('0' <= s[id] && s[id] <= '9') {
				res *= 10;
				res += s[id] - '0';
				id++;
			}
		}
		
		return res;
	}
}






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

#define endl '\n'
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

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

const int mod = 1e9 + 7;

void solve() {

	int n;
	cin >> n;

	llong ans = 1;

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

		ans = (ans * i) % mod;

	}

	cout << ans;

}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);

	#ifdef LOCAL
		ifstream in("in");
		cin.rdbuf(in.rdbuf());
	#endif

	solve();

	return 0;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
   
    int x1,x2,x3,x4,x5;
    int count;
    for(int i=0;i<5;i++){
        scanf("%d",&count);
        if(i==0){
            x1=count;
            if(x1==0){
                printf("%d",i+1);
                return 0;
                }
            }
        if(i==1){
            x2=count;
            if(x2==0){
                printf("%d",i+1);
                return 0;
            }
        }
        if(i==2){
            x3=count;
            if(x3==0){
                printf("%d",i+1);
                return 0;
            }
        }
        if(i==3){
            x4=count;
            if(x4==0){
                printf("%d",i+1);
                return 0;
            }
        }
        if(i==4){
            x5=count;
            if(x5==0){
                printf("%d",i+1);
                return 0;
            }
        }
    }
    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

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

  ll n, m;
  cin >> n >> m;
  vs a(n), b(m);
  rep(i, n) {
    cin >> a[i];
  }
  rep(i, m) {
    cin >> b[i];
  }

  rep(y, n - m + 1) {
    rep(x, n - m + 1) {
      bool match = true;
      rep(q, m) {
        rep(p, m) {
          if (b[q][p] != a[y + q][x + p]) {
            match = false;
            goto end;
          }
        }
      }
    end:
      if (match) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;

  return 0;
}


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

using namespace std;

int main()
{

int N;

cin >> N;

int A[4];

A[0] = N%10;
N = N-A[0];
N = N/10;
A[1] = N%10;
N = N-A[1];
N = N/10;
A[2] = N%10;
N = N-A[2];
N = N/10;
A[3] = N%10;
N = N-A[3];
N = N/10;

if (((A[0] == A[1]) && (A[1] == A[2]) ) || ((A[1] == A[2]) && (A[2] == A[3])))
{
cout << "Yes" << "\n";

}
else
cout << "No" << "\n";



}

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

int main() {
  long N, M, L;
  cin >> N >> M >> L;

  vector<vector<long>> G(N, vector<long>(N, 2e18));
  for (long i = 0, a, b, c; i < M; i++) {
    cin >> a >> b >> c;
    G.at(--a).at(--b) = c;
    G.at(b).at(a) = c;
  }
  for (long i = 0; i < N; i++) {
    G.at(i).at(i) = 0;
  }
  for (long i = 0; i < N; i++) {
    for (long j = 0; j < N; j++) {
      for (long k = 0; k < N; k++) {
        G.at(j).at(k) = min(G.at(j).at(k), G.at(j).at(i) + G.at(i).at(k));
      }
    }
  }
  vector<vector<long>> G2(N, vector<long>(N, 2e18));
  for (long i = 0; i < N; i++) {
    for (long j = 0; j < N; j++) {
      if (i == j) {
        G2.at(i).at(j) = 0;
        continue;
      }
      if (G.at(i).at(j) <= L) G2.at(i).at(j) = 1;
    }
  }
  for (long i = 0; i < N; i++) {
    for (long j = 0; j < N; j++) {
      for (long k = 0; k < N; k++) {
        G2.at(j).at(k) = min(G2.at(j).at(k), G2.at(j).at(i) + G2.at(i).at(k));
      }
    }
  }
  long Q;
  cin >> Q;
  while (Q--) {
    long s, t;
    cin >> s >> t;
    long ans = G2.at(--s).at(--t);
    cout << ((ans == 2e18) ? -1 : ans - 1) << "\n";
  }
}

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

using namespace std;

int main()
{
    long long int n, w;

    cin>>n>>w;

    long long int value[n];

    long long int weight[n];

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

    long long int dp[n + 1][w + 1];

    for(long long int i = 0; i <= n; i++)
    {
        for(long long int j = 0; j <= w; j++)
        {
            if(i == 0 || j == 0)
            {
                dp[i][j] = 0;
            }
            else if(weight[i-1] <= j)
            {
                dp[i][j] = max(dp[i-1][j], dp[i-1][j - weight[i-1]] + value[i-1]);
            }
            else
            {
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    cout<<dp[n][w];

    return 0;
}

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

long long cube(int n) {
	return (long long) n * n * n;
}

int main() {
	int n, k;
	cin >> n >> k;
	long long ans;
	if (k % 2) {
		ans = cube(n / k);
	} else {
		ans = cube(n / (k / 2) / 2) + cube((n / (k / 2) + 1) / 2);
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> adj;
vector<int> t;
int dfs(int x){
    if(t[x]==1){
        return 0;
    }
    int ans=1;
    t[x]=1;
    for(int i=0;i<adj[x].size();i++){
        if(t[adj[x][i]]==0){
            ans+=dfs(adj[x][i]);
        }
    }
    return ans;
}
int main()
{
    int n;
    cin>>n;
    int m;
    cin>>m;
    vector<set<int>> a(n);
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        a[x-1].insert(y-1);
        a[y-1].insert(x-1);
    }
    adj=vector<vector<int>>(n);
    t=vector<int>(n,0);
    for(int i=0;i<n;i++){
        for(auto it:a[i]){
            int temp=it;
            adj[i].push_back(temp);
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(t[i]==0){
            ans=max(ans,dfs(i));
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 52268
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

int main(void) {
    Int x, y;
    cin >> x >> y;
    Int result = 0;
    if (x <= 3) {
        result += (4 - x) * 100000;
    }
    if (y <= 3) {
        result += (4 - y) * 100000;
    }
    if (x == 1 && y == 1) {
        result += 400000;
    }
    cout << result << endl;
    return 0;
}


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

int main() {
  int x; cin >> x;
  int ans = 0;
  
  while(x>=500) {
    x -= 500;
    ans += 1000;
  }
  
  while(x>=5) {
    x -= 5;
    ans += 5;
  }
  
  cout << ans << endl;
  return 0;

}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
 
int main() {
  int x,y,z,k ; cin>>x>>y>>z>>k;
  vector<ll>A(x);
  vector<ll>B(y);
  vector<ll>C(z);
  
  rep(i,x){cin>>A[i];};
  rep(i,y){cin>>B[i];};
  rep(i,z){cin>>C[i];};
  
  vector<ll> AB;
  rep(i,x){
    rep(j,y){
      AB.push_back(A[i]+B[j]);
    }
  }
  sort(AB.begin(),AB.end(),greater<ll>());
  AB.resize(k);
  
  vector<ll>ABC;
  rep(i,k){
    rep(j,z){
      ABC.push_back(AB[i]+C[j]);
    }
  }
  sort(ABC.begin(),ABC.end(),greater<ll>());
  rep(i,k){
    cout<<ABC[i]<<endl;
  }
}


Measured memory_bytes: 42984
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
vvi g;

vi used;

int dfs(int v){
	used[v]=1;
	int res=0;
	for(int i=0;i<g[v].size();i++){
		int u=g[v][i];
		if(!used[u]) res^=dfs(u)+1;
	}
	return res;
}

int main(){
	cin>>n;
	g=vvi(n);
	used=vi(n);
	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	if(dfs(0)) cout<<"Alice"<<endl;
	else cout<<"Bob"<<endl;
}

Measured memory_bytes: 9216
#include <iostream>

int main() {
  const int ARRAY_SIZE = 100;
  int a[ARRAY_SIZE];
  int n;

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

  for (int i = 0;i < n;i++) {
    if (i == n - 1) {
      std::cout << a[i] << std::endl;
    } else {
      std::cout << a[i] << " ";
    }
  }

  for (int i = 1; i < n; i++) {
    int v = a[i];
    int j = i - 1;
    while (j >= 0 && a[j] > v)  {
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = v;

    for (int i = 0;i < n;i++) {
      if (i == n - 1) {
        std::cout << a[i] << std::endl;
      } else {
        std::cout << a[i] << " ";
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3076