akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, D;
	cin >> N >> D;
	vector<int> T(N);
	vector<int> F(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> T[i] >> F[i];
	}
	int curf = 1;
	int curt = 0;
	int curn = 0;
	bool f = true;
	for (int i = 0; i < N; i++) {
		if (abs(curf - F[i]) <= T[i] - curt) {
			if (curf + F[i]-2 <= T[i] - curt) {
				res += curn*(curf - 1);
				curn = 1;
			}
			else {
				res += curn * (T[i] - curt);
				curn++;
			}
		}
		else {
			f = false;
			break;
		}
		curt = T[i];
		curf = F[i];
		if (curn > D) {
			f = false;
			break;
		}
	}
	res += curn * (curf - 1);
	if (f) {
		cout << res << endl;
	}
	else {
		cout << -1 << endl;
	}
}

Measured memory_bytes: 4384
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    int ans = r + max(0, 100 * (10 - n));
    cout << ans << endl;

    return 0;
}


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

#define ll long long
#define mx 100005

int ar[mx];
char ch[mx];

int n,m;

void solve()
{
    ll n;
    cin>>n;
    ll re=0;
    ll tem=n/500;
    re+=1000*tem;
    n-=(tem*500);
    tem=n/5;
    re+=5*tem;
    cout<<re<<endl;
}

int main()
{
    int t=1;
    while(t--)solve();

    return 0;
}


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

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n, i = 0, j= 0, k = 0, l = 0, m = 0, a = 0, b = 0, sum = 0, x = 0, y = 0, z = 0, c, p;
    cin >> n;
    long long arr[n+1], dp[n+1];
    for(i = 1; i <= n; i++){
        cin >> arr[i];
    }
    dp[1] = 0;
    dp[2] = abs(arr[2]-arr[1]);
    for(i = 3; i <= n; i++){
        x = dp[i-1] + abs(arr[i]-arr[i-1]);
        y = dp[i-2] + abs(arr[i] - arr[i-2]);
        dp[i] = min(x,y);
    }
    cout << dp[n];

    return 0;
}


Measured memory_bytes: 1792
n = int(input())
s = []
for _ in range(n):
    s.append(input())
d = [s[0]]
ans = "Yes"
prep = s[0]
for i in range(1,n):
    if s[i] in d or prep[-1] != s[i][0]:
        ans = "No"
        break
    else:
        d.append(s[i])
        prep = s[i]
print(ans)

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

using namespace std;

#define nl '\n'

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

  vector<vector<int>> data(n+1, vector<int>(3, 0));
  for (int i = 1; i <= n; i++) {
    cin >> data[i][0] >> data[i][1] >> data[i][2];
  }

  vector<vector<int>> dp(n+1, vector<int>(3, 0));
  dp[0][0] = 0;
  dp[0][1] = 0;
  dp[0][2] = 0;

  for (int i = 1; i <= n; i++) {
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + data[i][0];
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + data[i][1];
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + data[i][2];
  }

  cout << max(max(dp[n][0], dp[n][1]), dp[n][2]) << nl;

  return 0;
}


Measured memory_bytes: 11136
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
#include <algorithm>
#include <array>
#include <string.h>
#include <vector>



int main() {
	char buf[100];
	int check[3] = {1,1,1};
	int sum = 0;
	scanf("%s", buf);

	if (strlen(buf) >= 4) {
		goto end;
	}
	

	for (int i = 0; i < 3; i++) {
		if (buf[i] == 'a') {
			if (check[0] == 0) {
				goto end;
			}
			check[0] = 0;
		}
		if (buf[i] == 'b') {
			if (check[1] == 0) {
				goto end;
			}
			check[1] = 0;
		}
		if (buf[i] == 'c') {
			if (check[2] == 0) {
				goto end;
			}
			check[2] = 0;
		}
	}

	for (int i = 0; i < 3; i++) {
		if (check[i] == 0) {
			sum++;
		}
	}
	if (sum == 3) {
		printf("Yes");
		return 0;
	}

	end:
	printf("No");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<limits.h>
#include<vector>

using namespace std;

void merge(vector<int> &A,int left,int mid,int right,int &c) {
	int n1 = mid - left;
	int n2 = right - mid;
	vector<int> L(n1+1,0);
	vector<int> R(n2+1,0);
	for (int i = 0;i < n1;i++) L[i] = A[left+i];
	for (int i = 0;i < n2;i++)R[i] = A[mid + i];
	L[n1] = INT_MAX;
	R[n2] = INT_MAX;
	int i = 0;
	int j = 0;
	for (int k = left;k < right;k++) {
		if (L[i] <= R[j]) {
			A[k] = L[i++];
			c++;
		}
		else {
			A[k] = R[j++];
			c++;
		}
	}
}
void mergeSort(vector<int> &A,int left,int right,int &c) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(A,left,mid,c);
		mergeSort(A,mid,right,c);
		merge(A,left,mid,right,c);
	}
}

int main() {

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

	mergeSort(array, 0, array.size(), count);

	for (int i = 0;i < array.size();i++) {
		if (i != array.size() - 1) {
			cout << array[i] << ' ';
		}
		else cout << array[i] << endl;
	}
	cout << count << endl;

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MAX=100005;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,n){cout<<arr[i][j]<<" ";}cout<<endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

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

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Vec a(5);
    rep(i,5){
        cin>>a[i];
    }
    ll ans=-10;
    ll tmp=10;
    rep(i,5){
        ll amari = a[i]%10;
        if(amari==0){
            ans += a[i];
        }else{
            ans += a[i]+10-amari;
            chmin(tmp,amari);
        }
    }
    ans += tmp;
    cout<<ans<<endl;
    return  0;
}


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

int main(){
    int N;
    cin >> N;
    
    int mod = 7 + pow(10, 9);
    unsigned long long ans = 0;
    
    int sum = 0;
    long long a = 0;
    for (int i = 0; i < N; i++) {
        cin >> a;
        ans =  (ans + (a * sum) % mod) % mod;
        sum = (sum + a) % mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3552
n = int(input())
h = list(map(int,input().split()))
d = [1]+[0]*(n-1)

for i in range(n-1):
  if h[i] >= 2+ h[i+1]:
    print('No')
    exit()
  if d[i] == 1 and h[i] <= h[i+1]:
    d[i+1] = 1
  elif d[i] == 0:
    if h[i] +1 <=h[i+1]:
      d[i+1] = 1
    elif h[i] -1 == h[i+1]:
      print('No')
      exit()
      
print('Yes')

Measured memory_bytes: 14400
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> a(n); for (auto&& e : a) cin >> e;
  V<> c(2 * n + 1);
  for (int i = 0; i < 2 * n; ++i) {
    if (i & 1) c[i + 1] = c[i] - a[i % n];
    else c[i + 1] = c[i] + a[i % n];
  }
  for (int i = 0; i < n; ++i) {
    int res = c[i + n] - c[i];
    if (i & 1) res = -res;
    cout << res << " \n"[!(n + ~i)];
  }
}

Measured memory_bytes: 2560
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define REP(i,a,b) for(register int i=(a); i<(b); i++)
#define REPE(i,a,b) for(register int i=(a); i<=(b); i++)
#define PERE(i,a,b) for(register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
int main() {
	int a,b,c; scanf("%d%d%d", &a, &b, &c);
	ll s1=(ll)c-b-a;
	if(s1<0) {puts("No"); return 0;}
	ll s2=4LL*a*b;
	s1*=s1;
	if(s1>s2) puts("Yes");
	else puts("No");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

template <class T> void mini(T &l, T r) {l = min(l, r);}
template <class T> void maxi(T &l, T r) {l = max(l, r);}

//template <class T> using Tree = tree <T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(bool a) {
    return a ? "T" : "F";
}

string to_string(const char* s) {
    return to_string((string) s);
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define X first
#define Y second

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

const int N = 110;

int a[N];

void run() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
	}
	vector < pair <int, int> > v;
	for (int i = 1; i <= n; ++i) {
		if (v.empty() || v.back().X != a[i]) {
			v.emplace_back(a[i], 1);
		} else {
			v.back().Y += 1;
		}
	}
	int ans = 0;
	for (auto p : v) {
		ans += p.Y / 2;
	}
	printf("%d\n", ans);
}

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


Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[,] card = new int[4, 13];
        char[] suit = new char[] { 'S', 'H', 'C', 'D' };

        while (n-- > 0)
        {
            string[] input = Console.ReadLine().Split(' ');
            int rank = int.Parse(input[1]);
            switch (input[0])
            {
                case "S":
                    card[0, rank - 1] = 1;
                    break;
                case "H":
                    card[1, rank - 1] = 1;
                    break;
                case "C":
                    card[2, rank - 1] = 1;
                    break;
                case "D":
                    card[3, rank - 1] = 1;
                    break;
            }
        }

        for (int i = 0; i < 4; i++)
        {
            for (int j = 0; j < 13; j++)
            {
                if (card[i, j] == 0)
                {
                    Console.WriteLine("{0} {1}", suit[i], j + 1);
                }
            }
        }
    }
}


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

int main(){
    int a,b;
    int x,y;
    cin >> a >> b;
    rep(i,10000){
        x=((i+1)*2)/25;
        y=((i+1))/10;
        if ((x==a)&&(y==b)){
            cout << i+1 << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
//                                               KEEP GRINDING
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>   new_data_set;

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define int long long
#define ld long double
#define MOD 1000000007
#define mod 998244353
#define precise(i) fixed << setprecision(10) << i
#define f(i,a,b) for(int i=a;i<b;++i)

#define endl '\n'
#define debug cout<<endl;cout<<"\n========================================\n"<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl;
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl;
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl;
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl;

#define all(a) a.begin(),a.end()
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define mx(a) *max_element(a)
#define mn(a) *min_element(a) 
#define LB lower_bound  //THIS GIVES THE ITR TO THE ELEMENT IN RANGE [SI,EI) THAT IS >= OUR VALUE 
#define UB upper_bound  //THIS GIVES THE ITR TO THE ELEMENT IN RANGE [SI,EI) THAT IS > OUR VALUE 

#define fr first
#define sc second

#define MAXN 200050
#define INF 9223372036854775807
signed main(){
    fastio
	int n;
	cin>>n;
	vector<int> a(n),b(n);
	f(i,0,n)
	    cin>>a[i]>>b[i];
	sort(all(a));
	sort(all(b));
	int x,y;
	if(n%2){
		x=a[ n/2 ];
		y=b[ n/2 ];
	}else{
		x=a[ (n-1)/2 ]+ a[ (n-1)/2  + 1];
		y=b[ (n-1)/2 ]+ b[ (n-1)/2  + 1];
	}
	cout<<y-x+1;
	
}

Measured memory_bytes: 6368
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
#ifdef _WIN32
#define __builtin_popcount __popcnt
#endif
int n, d, p, q;
int main() {
	while (cin >> n, n) {
		vector<int> bit;
		vector<int> c(5);
		while (n--) {
			cin >> d >> p >> q; q--;
			if (d == 1) {
				int r = *max_element(c.begin() + q, c.begin() + q + p);
				int b = (1 << (q + p)) - (1 << q);
				if (bit.size() == r) bit.push_back(b);
				else bit[r] |= b;
			}
			else {
				for (int i = c[q]; i < c[q] + p; i++) {
					if (bit.size() == i) bit.push_back(1 << q);
					else bit[i] |= 1 << q;
				}
			}
			vector<int> bit2;
			for (int i : bit) {
				if (i != 31) bit2.push_back(i);
			}
			bit = bit2;
			for (int i = 0; i < 5; i++) {
				c[i] = 0;
				for (int j = bit2.size() - 1; j >= 0; j--) {
					if (bit2[j] & (1 << i)) {
						c[i] = j + 1; break;
					}
				}
			}
		}
		int ret = 0;
		for (int i : bit) ret += __builtin_popcount(i);
		cout << ret << endl;
	}
	return 0;
}

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

int main(){
    long double a,b,c;cin >> a >> b >> c;
    if((long double)2*sqrt(a*b) < c - a - b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import copy
N=int(input())
T=list(map(int,input().split()))
M=int(input())
Drink=[list(map(int,input().split())) for _ in range(M)]
for i in range(M):
    p=Drink[i][0]
    x=Drink[i][1]
    answer=copy.deepcopy(T)
    answer[p-1]=x
    print(sum(answer))


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

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<tuple<int,int,int>> edges;
	--n;
	int now = 1;
	while (n) {
		if (n % 2 == 0) {
			edges.emplace_back(now,20,n);
			--n;
		}
		edges.emplace_back(now,now + 1,0);
		edges.emplace_back(now,now + 1,(n + 1) / 2);
		n >>= 1;
		++now;
	}
	while (now < 20) edges.emplace_back(now,now+1,0),++now;
	cout << now <<" " << (int)edges.size() <<"\n";
	for (auto&x : edges) {
		cout << get<0>(x) <<" " << get<1>(x) <<" " << get<2>(x) <<"\n";
	}
}

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

#define pb push_back
#define mp make_pair

#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = (int)(1e6 + 5);
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e9 + 11);

int main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    int ret = 0;
    for (int i = 0; i < (int)s.size() / 2; ++i) {
        if (s[i] != s[s.size() - i - 1])
            ++ret;
    }
    cout << ret;
    return 0;
}


Measured memory_bytes: 256
#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>;

ll pow5(ll x) {
	return x * x * x * x * x;
}

int main() {
	ll x;
	cin >> x;
	for(ll a = 0; a <= 1000; a++) {
		for(ll b = -1000; b <= 1000; b++) {
			if (pow5(a) - pow5(b) == x) {
				cout << a << ' ' << b << endl;
				return 0;
			}
		}
	}
}


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

int main() {
  int64_t N;
  cin>>N;
  int64_t A=1;
  for(int64_t i=2;i*i<=N;i++){
    if(N%i==0){
      A=i;
    }
  }
  int64_t X=N/A,Z=0;
  while(X!=0||A!=0){
    Z++;
    X/=10;
    A/=10;
  }
  cout<<Z<<endl;
}



Measured memory_bytes: 3584
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

bool map[5000][6];
int N;

void func(){

	int max_height = 5*N-1;

	for(int row = 0; row <= max_height; row++){
		for(int col = 1; col <= 5; col++){
			map[row][col] = false;
		}
	}

	int top_pos[6] = {0,0,0,0,0,0};

	int dir,len,loc,tmp_max;
	stack<int> delete_row;
	bool FLG;

	for(int loop = 0; loop < N; loop++){
		scanf("%d %d %d",&dir,&len,&loc);

		if(dir == 1){
			tmp_max = 0;
			for(int col = loc; col <= loc+len-1; col++){
				tmp_max = max(tmp_max,top_pos[col]);
			}

			for(int col = loc; col <= loc+len-1; col++){
				map[tmp_max][col] = true;
				top_pos[col] = tmp_max+1;
			}
		}else{
			for(int i = 0; i < len; i++){
				map[top_pos[loc]+i][loc] = true;
			}
			top_pos[loc] += len;
		}

		tmp_max = 0;
		for(int col = 1; col <= 5; col++){
			tmp_max = max(tmp_max,top_pos[col]);
		}

		for(int row = 0; row <= tmp_max;row++){
			FLG = true;
			for(int col = 1; col <= 5; col++){
				if(map[row][col] == false){
					FLG = false;
					break;
				}

			}
			if(FLG){
				for(int col = 1; col <= 5; col++){
					map[row][col] = false;
				}
				delete_row.push(row);
			}
		}

		while(!delete_row.empty()){

			for(int col = 1; col <= 5; col++){
				for(int row = delete_row.top()+1; row <= top_pos[col]; row++){
					if(map[row][col]){
						map[row][col] = false;
						map[row-1][col] = true;
					}
				}
				for(int row = top_pos[col]; row >= 0; row--){
					if(row == 0){
						if(map[row][col]){
							top_pos[col] = 1;
						}else{
							top_pos[col] = 0;
						}
						break;
					}else{
						if(map[row][col]){
							top_pos[col] = row+1;
							break;
						}
					}
				}
			}

			tmp_max = 0;
			for(int col = 1; col <= 5; col++){
				tmp_max = max(tmp_max,top_pos[col]);
			}

			for(int row = 0; row <= tmp_max;row++){
				FLG = true;
				for(int col = 1; col <= 5; col++){
					if(map[row][col] == false){
						FLG = false;
						break;
					}

				}
				if(FLG){
					for(int col = 1; col <= 5; col++){
						map[row][col] = false;
					}
					delete_row.push(row);
				}
			}
			delete_row.pop();
		}
	}

	max_height = 0;
	for(int col = 1; col <= 5; col++){
		max_height = max(max_height,top_pos[col]);
	}

	int ans = 0;
	for(int row = 0; row <= max_height; row++){
		for(int col = 1; col <= 5; col++){
			if(map[row][col]){
				ans++;
			}
		}
	}

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

int main(){

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}
	return 0;
}

Measured memory_bytes: 3176
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

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



int main(void){

	int H, W; cin >> H >> W;
	vector<string> a(H);
	REP(i,H) cin >> a[i];

	vector<bool> goodh(H,false);
	vector<bool> goodw(W,false);

	REP(i,H){
		REP(j,W){
			if(a[i][j] == '#'){
				goodh[i] = true;
				goodw[j] = true;
			}
		}
	}

	REP(i,H){
		if(goodh[i]){
			REP(j,W){
				if(goodw[j] == true) cout << a[i][j];
			}
			cout << endl;
		}

	}


	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
#define rep(i,n) for(int i=1;i<n+1;i++)
int main(){

  int N,Q;
  long long int K;
  cin>>N>>K>>Q;
  int A[Q];
  rep(i,Q)
    cin>>A[i];
  map<int,int> m;
  long long int arr[N];
  rep(i,N)
    arr[i]=K;
  rep(i,Q)
    m[A[i]]++;
  rep(i,N)
    arr[i]-=Q-m[i];
  rep(i,N){
    if(arr[i]>0)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;

  }
    
  
    
  
  


  return 0;
}


Measured memory_bytes: 6528
def gcd(a,b):
  while b:a,b=b,a%b
  return a
k=int(input())
ans=0
for i in range(1,k+1):
  for j in range(1,k+1):
    x=gcd(i,j)
    for k in range(1,k+1):
      ans+=gcd(k,x)
print(ans)

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

int main() {
    int N;
    cin>>N;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin>>a.at(i);
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    int alice=0,bob=0;
    for(int i=0;i<N;i++){
        if(i%2==0){
            alice+=a.at(i);
        }
        else{
            bob+=a.at(i);
        }
    }
    cout<<alice-bob<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
const int MOD = 1e9+7;
const int MAX = 5100;
ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i-1]*i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

ll COM(int n, int k){
    if(n<k) return 0;
    if(n<0 || k<0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

ll f(int S, int n){
  S -= 3*n;
  if(S<0) return 0;
  return COM(S+n-1,S);
}
  
int main(){
  COMinit();
  int S;
  cin >> S;
  ll ans = 0;
  int maxdigit = S / 3;
  for(int i=1; i<=maxdigit; i++){
    ans += f(S,i);
    ans %= MOD;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3708
import java.util.*;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    // int N = scanner.nextInt();
    // scanner.nextLine();
    // int[] n = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    static void solve(Scanner scanner) {
        int N = scanner.nextInt();
        long X = scanner.nextLong();
        scanner.nextLine();
        int[] a = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();

        long[][] min = new long[N][N];
        for (int i = 0; i < N; i++) {
            Arrays.fill(min[i], Long.MAX_VALUE / 2);
            min[i][i] = a[i];
        }
        for (int i = 1; i < N; i++) {
            for (int l = 0; l < N; l++) {
                min[l][Math.floorMod(l + i, N)] = Math.min(min[l][Math.floorMod(l + i - 1, N)], a[Math.floorMod(l + i, N)]);
            }
        }

        long ans = Long.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            long tmp = i * X;
            for (int j = 0; j < N; j++) {
                tmp += min[Math.floorMod(j - i, N)][j];
            }
            ans = Math.min(ans, tmp);
        }
        System.out.println(ans);
    }

}

Measured memory_bytes: 83516
#include <stdio.h>
#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

#define Max(a, b) (a > b ? a : b)

int main() {
  int n, z, w;
  scanf("%d%d%d", &n, &z, &w);
  int a[n];
  for (int i=0; i<n; i++)
    scanf("%d", a+i);
  int ans;
  if (n == 1)
    ans = abs(a[n-1]-w);
  else
    ans = Max(abs(a[n-1]-w), abs(a[n-2]-a[n-1]));
  printf("%d\n", ans);
  return 0;
}


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

using namespace std;
typedef long long ll;

#define out(ans) cout << ans << endl
#define in(n) cin >> n
#define floop(i, N) for (ll i = 0; i < N; i++)
#define floop1(i, N) for (ll i = 1; i <= N; i++)
#define floopi(i, j, N) for (ll j = i + 1; j < N; j++)

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

void solve();
bool judge(int n);

int main()
{
    solve();
}

void solve()
{
    int n;
    in(n);
    ll ans = 0;
    floop1(i, n)
    {
        if (judge(i))
        {
            ans++;
        }
    }
    out(ans);
}

bool judge(int n)
{
    ll count = 0;
    floop(i, n / 2)
    {
        if (n % (i + 1) == 0 && (i + 1) % 2 == 1)
        {
            count++;
        }
    }
    if (count == 7)
    {
        return true;
    }
    else
    {
        return false;
    }
}

Measured memory_bytes: 256
// Comment
//

#include <bits/stdc++.h>

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
using ll = long long;
using pi = pair<int, int>;
const int INF = 0x3f3f3f3f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 3e5 + 100;

int N, Sum[2][MAX_N];
char S[MAX_N];
int main() {
	cin >> N;
	scanf("%s", S+1);
	for(int i=1; i<=N; i++) Sum[0][i] = Sum[0][i-1] + (S[i] == 'E');
	for(int i=N; i>=1; i--) Sum[1][i] = Sum[1][i+1] + (S[i] == 'W');

	int ans = 0;
	for(int i=1; i<=N; i++) ans = max(ans, 1 + Sum[0][i-1] + Sum[1][i+1]);
	printf("%d\n", N-ans);
	return 0;
}


Measured memory_bytes: 6448
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
//usage
//input! {
//  h: i32;
//  v: [i32; n]
//  x: [[i32; n]; m]
//  f: chars <- Vec<char>
//}
fn repeat_pow_mod(n: i64, k: i64, m: i64) -> i64 {
    // n^k % m
    let mut res = 1;
    if k > 0 {
        res = repeat_pow_mod(n, k / 2, m);
        if k % 2 == 0 {
            res = res * res % m;
        }else {
            res = (res * res % m) * n % m;
        }
    }

    return res
}
fn mod_combination(n: i64, k: i64, m: i64) -> i64 {
    //nCk % m
    let num = (n - k + 1..n + 1).fold(1, |prod, x| prod * x % m);
    let den = (1..k + 1).fold(1, |prod, x| prod * x % m);
    num * repeat_pow_mod(den, m - 2, m) % m
}

fn main() {
    input!{
        n: i64,
        a: i64,
        b: i64
    }
    let m = 1000000007;
    let t = repeat_pow_mod(2, n, m) - 1;
    let ca = mod_combination(n, a, m);
    let cb = mod_combination(n, b, m);
    let mut ans = t - ca - cb;
    println!("{}", if ans < 0 {while ans < 0 {ans += m;} ans} else {ans});
}

Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<ll, P> E;
#define MOD (1000000007ll)
#define l_ength size
#define PI 3.14159265358979
 
void mul_mod(ll& a, ll b){
    a *= b;
    a %= MOD;
}

void add_mod(ll& a, ll b){
    a += b;
    a %= MOD;
}

int main(void){
	int a,b;
	cin >> a >> b;
	cout << ((a>b)?(a-1):a) << endl;
	return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
   return os<<"{"<<p.fs<<","<<p.sc<<"}";
}
template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
   os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}
template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}



signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll x,y;cin>>x>>y;
  rep(i,0,x+1){
    ll j=x-i;
    if(2*i + 4*j == y){
      cout<<"Yes"<<ENDL;
      return 0;
    }
  }

  cout<<"No"<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 3648
s = input()
ans = 'AC'
if s[0] != 'A':
    ans = 'WA'
elif s[2:-1].count('C') != 1:
    ans = 'WA'
elif s[1:].replace('C','').lower() != s[1:].replace('C',''):
    ans = 'WA'
print(ans)

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

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

	int n; cin >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < n; ++i) {
		cin >> b[i];
	}
	reverse(b.begin(), b.end());
	int start = -1, fin = -1;
	for (int i = 0; i < n; ++i) {
		if (b[i] == a[i]) {
			if (start == -1) start = i;
			fin = i;
		}
	}
	bool bad = 0;
	if (start != -1) {
		for (int i = 0, j = start; j <= fin; ++i) {
			if (i == start) i = fin + 1;
			if (i >= n) {
				bad = 1;
				break;
			}
			if (a[i] != b[j] && b[i] != b[j]) {
				swap(b[i], b[j++]);
			}
		}
		for (int i = 0; i < n; ++i)
			bad |= (a[i] == b[i]);
	}
	if (bad) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
		for (int i = 0; i < n; ++i) {
			if (i) cout << " ";
			cout << b[i];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 4776
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    map<int,int>dmp,tmp;
    vector<int>d(n);
    
    REP(i,n){
        cin >> d[i];
        dmp[d[i]]++;
    }
    int m;
    cin >> m;
    vector<int>t(m);
    REP(i,m){
        cin >> t[i];
        tmp[t[i]]++;
    }
    for(auto itr = tmp.begin(); itr != tmp.end(); ++itr) {
        if(dmp[itr->first] < itr->second){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 23504
#include <bits/stdc++.h>
using namespace std;
const int N=2000;
int a[N+1];
int main(){
  int n,k,q;
  scanf("%d%d%d",&n,&k,&q); 
  for (int i=0;i<n;i++)
    scanf("%d",&a[i]);
  int ans=1e9;
  for (int& bound:a) {
    vector<int>t;
    vector<int>s;
    for (int i=0;i<=n;i++){
      if (i==n||a[i]<bound){
        sort(t.begin(),t.end());
        for (int i=0;i<=(int)t.size()-k;i++)
          s.push_back(t[i]);
        t.clear();
      }else t.push_back(a[i]);
    }
    if ((int)s.size()<q) continue;
    sort(s.begin(),s.end());
    ans=min(ans,s[q-1]-bound);
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // min, max, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define rep(i,n) rep1(i,0,n)
#define rep1(i,m,n) for(int i=m;i<(n);i++)
#define All(v) (v).begin(),(v).end()
using ll = long long;
const int inf = 1<<30;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
const double PI = acos(-1);
int main(){
    int n;
    cin>>n;
    int res = 0;
    rep(i,n){
        int a;
        cin >> a;
        a--;
        res+=a;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int a[301][301];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            cin>>a[i][j];
        }
    }
    ll ans=0;
    int c=1;
    ll d[n+1][n+1];
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i==j){
                d[i][j]=0;
            }
            else{
                d[i][j]=inf;
            }

        }
    }
    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                if(i!=k && j!=k){
                    if(d[i][j]>a[i][k]+a[k][j]){
                        d[i][j]=a[i][k]+a[k][j];
                    }
                }
            }
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(d[i][j]<a[i][j]){
                c=0;
            }
            else if(d[i][j]>a[i][j]){
                ans+=a[i][j];
            }
        }
    }
    if(c==0)
        ans=-1;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int n;
int main() {
    cin>>n;
    int ans=0;
    for (int i=1;i<=n;i++) {
        if (i%2==0) continue;
        int num=0;
        for (int j=1;j<=sqrt(i);j++) {
            if (i%j==0) {
                if (j*j==i) num++;
                else num+=2;
            }
        }
        if (num==8) ans++;
    }
    cout<<ans;
    return 0;
}

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

import sys
from copy import deepcopy

def input(): return sys.stdin.readline().strip()
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

H,W,K=MAP()
orgn=[[0]*W for i in range(H)]
for i in range(H):
    nums=input()
    for j in range(W):
        orgn[i][j]=int(nums[j])

def drop():
    for i in range(H-1, 0, -1):
        for j in range(W):
            if grid[i][j]==0 and grid[i-1][j]!=0:
                k=i
                while k<H and grid[k][j]==0:     
                    grid[k][j]=grid[k-1][j]
                    grid[k-1][j]=0
                    k+=1

def check(times):
    sm=0
    for i in range(H):
        st=0
        cnt=1
        for j in range(1, W):
            if grid[i][j-1]==grid[i][j]:
                cnt+=1
            else:
                if cnt>=K:
                    sm+=grid[i][j-1]*cnt
                    for k in range(st, j):
                        grid[i][k]=0
                cnt=1
                st=j
        else:
            if cnt>=K:
                sm+=grid[i][j]*cnt
                for k in range(st, j+1):
                    grid[i][k]=0
    return 2**times*sm

ans=0
for i in range(H):
    for j in range(W):
        grid=deepcopy(orgn)
        grid[i][j]=0    
        res=1
        score=times=0
        while res:
            drop()
            res=check(times)
            score+=res
            times+=1
        ans=max(ans, score)

print(ans)


Measured memory_bytes: 57948
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 222;

int main()
{
        // freopen("../in.txt","r",stdin);
        // freopen("../out.txt","w",stdout);
        int x,a;
        cin>>x>>a;
        if(x<a) cout<<0<<endl;
        else    cout<<10<<endl;
        return 0;
}


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


int main() {
   int H, N;
  cin >> H >> N;
  int some = 0;
  for(int i = 0; i < N; i++){
    int x;
    cin >> x;
    some += x;
  }
  if(some >= H){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
  return 0;
}

Measured memory_bytes: 256
def main():
    H,W = [int(n) for n in input().split()]
    grid = [[0 if n=="." else 1 for n in input()] for _ in range(H)]
    INF = 10**10
    graph = [[INF]*H*W for _ in range(H*W)]
    for i in range(H):
        for j in range(W):
            if grid[i][j] == 0:
                graph[i*W+j][i*W+j]=0
                if i<H-1 and grid[i+1][j]==0:
                    graph[i*W+j][(i+1)*W+(j)] = 1
                    graph[(i+1)*W+(j)][i*W+j] = 1
                if j>0 and grid[i][j-1] == 0:
                    graph[i*W+j][(i)*W+j-1] = 1
                    graph[(i)*W+j-1][i*W+j] = 1
                if j<W-1 and grid[i][j+1] == 0:
                    graph[i*W+j][(i)*W+(j+1)] = 1
                    graph[(i)*W+(j+1)][i*W+j] = 1
                if i>0 and grid[i-1][j] == 0:
                    graph[i*W+j][(i-1)*W+(j)] = 1
                    graph[(i-1)*W+(j)][i*W+j] = 1
    
    
    for k in range(H*W):
        for i in range(H*W):
            for j in range(H*W):
                graph[i][j] = min(graph[i][j], graph[i][k]+graph[k][j])
    # for i in range(H*W):
    #     for j in range(W*H):
    #         print(graph[i][j], end="\t")
    #     print()
    m = 0
    for i in range(H*W):
        for j in range(H*W):
            if graph[i][j] == INF:
                continue
            m = max(m,graph[i][j])
    print(m)
main()
    


Measured memory_bytes: 41840
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    int sum = 0;
    REP(i, N) {
        cin >> A[i];
        sum += A[i];
    }

    int selected = 0;
    REP(i, N) {
        if(A[i] * 4 * M >= sum ) selected++;
    }

    if(selected >= M) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3616
A,B = map(int, input().split())

tmp_A, tmp_B = max(A,B), min(A,B)

while 1:
  if tmp_A % tmp_B != 0:
    tmp = tmp_B
    tmp_B = tmp_A%tmp_B
    tmp_A = tmp
  else:
    if tmp_B == 1:
      result = A*B
      break
    else:
      result = int(A*B/tmp_B)
      break
print(result)

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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; }

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    int A, B, C, D;
    cin >> A >> B >> C >> D;

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

Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <cmath>
#include <string>
#include <iomanip>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <unordered_map>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define inf 1013161010
#define ninf -1013161010
#define mod 1000000007
#define ll long long
#define lf long double
#define in(x) scanf("%d",&x);
#define sz(x) ((int)x.size())
#define lld l64d
#define rep(i,n) for(i=0;i<n;i++)
#define rrep(i,n) for(i=n-1;i>=0;i--)
#define rep1(i,a,b) for(i=a;i<=b;i++)
#define rrep1(i,a,b) for(i=a;i>=b;i--)
#define stlfor(i,t) for(auto i =t.begin();i!=t.end();i++)
#define fr freopen("x.txt","r",stdin)
#define frc freopen("y.txt","w",stdout)
#define all(x) x.begin(),x.end()
#define set0(x) memset(x,0,sizeof(x))
#define dbg cout<<"yo "<<endl;
#define pset(n) fixed<<showpoint<<setprecision(n)

#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<ll,ll> >
#define si set<int>
#define mii map<int,int>
#define umii unordered_map<int,int>
#define vi vector<int>
#define pb push_back
#define ff first
#define ss second
#define mp make_pair

typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> OST;

ll toint(const string &s) { stringstream ss; ss << s; ll x; ss >> x; return x; }
string tostring ( ll number ){  stringstream ss; ss<< number; return ss.str();}

const lf pi = 2*acos(0);
const int nn = 2000006;
const lf EPS = 0.000000001;

ll gcd(ll a,ll b){return (b==0)? a:gcd(b,a%b); }
void nope(int num = 0){ if(num==0) cout<<"NO"; else cout<<"-1"; exit(0); }

ll a[nn], b[nn];
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll i,j,n,tt;
    tt=1;
    //cin>>tt;
    while(tt--)
    {
        ll n, h;
        cin>>n>>h;
        ll maxa=0, maxb=0, sum, sm, hx, tmp;
        rep(i, n)
        {
            cin>>a[i]>>b[i];
            sum+=b[i];
            maxa = max(a[i], maxa);
            maxb = max(b[i], maxb);
        }

        ll ans= 0;
        if(maxa>=maxb)
        {
            if(h%maxa==0)
                ans = h/maxa;
            else
                ans = h/maxa+1;
            cout<<ans<<endl;

            return 0;
        }
        ans = 100000000000000000;
        sort(b, b+n);
        sm=0;
        for(i=n-1;i>=0;i--)
        {
            sm+=b[i];
            hx = h-sm;
            tmp = n-i;
            if(hx<=0)
                ans = min(ans, tmp);
            else if(hx%maxa==0)
                tmp = tmp+(hx/maxa);
            else
                tmp = tmp+(hx/maxa)+1;
            ans = min(ans, tmp);
        }
        cout<<ans<<endl;


    }
    return 0;
}



Measured memory_bytes: 5120
H,N=map(int,input().split())
damage = list(map(int,input().split()))
#print(damage)
damage.sort(reverse=True)
sum=0
for i in range(N):
    sum+=damage[i]
    if sum>=H:
        print("Yes")
        break
    elif i==N-1:
        print("No")
        

Measured memory_bytes: 13964
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
const ll N=2e5+5,M=1000;
ll n,k,a[N],prfx[N];
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n>>k;
    for(ll i=1;i<=n;i++)cin>>a[i];
    for(ll cnt=1;cnt<=min(M,k);cnt++){
        for(ll i=0;i<=n;i++)prfx[i]=0;
        for(ll i=1;i<=n;i++){
            ll l=i-a[i];
            ll r=i+a[i]+1;
            l=max(0,l);
            r=min(n+1,r);
            prfx[r]--;
            prfx[l]++;
        }
        for(ll i=1;i<=n;i++)prfx[i]+=prfx[i-1];
        for(ll i=1;i<=n;i++)a[i]=prfx[i];
    }

    for(ll i=1;i<=n;i++)cout<<a[i]<<" ";
}


Measured memory_bytes: 5224