akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
   
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define deb(x) cout << #x << "=" << x << endl
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define vi vector<int>
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define mod 1000000007
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define int long long

const int N=405;
const int INF=1e18L+5;
int dp[N][N];
int a[N];
int pre[N];
int n;


int solve(int l,int r)
{
    if(l>r)return 0;
    if(l==r)return 0;
   
    
    int &ans=dp[l][r];
    if(ans!=-1)return ans;
    ans=INF;
    for(int i=l;i<=r-1;i++)
    {
        ans=min(ans,solve(l,i)+solve(i+1,r)+pre[r]-pre[l-1]);
    }
    return ans;
}








void solve()
{
    cin>>n;
    memset(dp,-1,sizeof dp);
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)pre[i]=pre[i-1]+a[i];
    //cout<<'\n';
    int ans=solve(1,n);
    
    cout<<ans<<'\n';
    
    
   
    
   
}

int32_t main()
{
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    
	int t=1;
	//cin>>t;
	while(t--)solve();
	    
   
}


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

int main(){
    int h, w;
    cin >> h >> w;

    vector<string> red(h), blue(h);
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            red[i] += '.';
            blue[i] += '.';
            if(i % 2 == 0){
                if(j != 0) red[i][j] = '#';
                else blue[i][j] = '#';
            }
            if(i % 2 == 1){
                if(j != w-1) blue[i][j] = '#';
                else red[i][j] = '#';
            }
        }
    }

    vector<string> a(h);
    for(int i=0; i<h; i++){
        cin >> a[i];
        for(int j=0; j<w; j++){
            if(a[i][j] == '#'){
                red[i][j] = '#';
                blue[i][j] = '#';
            }
        }
    }

    for(int i=0; i<h; i++) cout << red[i] << endl;
    cout << endl;
    for(int i=0; i<h; i++) cout << blue[i] << endl;
    return 0;
}

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

struct bc{
    long long b, c;
};
bool cmp(const bc &x, const bc &y){
    return x.c > y.c;
}

int main() {
    int n, m, i, j;
    cin >> n >> m;
    long long a[n];
    bc d[m];
    for(i = 0; i < n; i++) {
        cin >> a[i];
    }
    for(i = 0; i < m; i++) {
        cin >> d[i].b >> d[i].c;
    }
    sort(a, a + n);
    sort(d, d + m, cmp);

    int ai = 0, flg = 0;
    for(i = 0; i < m && ai < n; i++){
        for(j = 0; j < d[i].b && ai < n; j++){
            if(a[ai] < d[i].c){
                a[ai] = d[i].c;
            }
            else{
                flg = 1;
                break;
            };
            ai++;
        }
        if(flg == 1) break;
    }
    cout << accumulate(a, a + n, 0LL) << endl;
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

string s;
int p;

int main() {
	cin >> s;
	rep(i,s.length()) {
		if (i%2==0 && s[i]=='p') p--;
		else if (i%2==1 && s[i]=='g') p++;
	}
	cout << p << ln;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  ll x, y;
  cin >> x >> y;
  int ans = 0;
  ll now = x;
  while(1){
    if(now <= y) ans++;
    else break;
    now *= 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
const int inf = 1 << 30;
const ll linf = 1e18;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    bool flag = false;
    if(N / 100 == 7) flag = true;
    N %= 100;
    if(N / 10 == 7) flag = true;
    N %= 10;
    if(N == 7) flag = true;
    cout << (flag ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3612
fun main(args: Array<String>){
    val N = readLine()!!.toInt()
    val a: Array<Int> = readLine()!!.split(' ').map { it -> it.toInt() }.toTypedArray()

    var counter = 0

    a.reduce {s1, s2 ->
         if (s1 == s2){counter++; 101} else {s2}
    }

    println(counter++)
}

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

int n,k,sz,q[2010],dist[2010],ans=1e9;
vector<int> pos[2010];

inline void bfs()
{
	for(int i=0;i<sz;i++)
	{
		int cur=q[i];
		for(int j:pos[cur])
		{
			int w=dist[cur]+2;
			if(dist[j]<=w) continue;
			dist[j]=w;
			q[sz++]=j;
		}
	}
}

inline int solveVertex(int i)
{
	fill(dist,dist+n,1e9);
	dist[i]=0;
	sz=0;
	
	q[sz++]=i;
	bfs();
	int sum=0;
	for(int j=0;j<n;j++) if(dist[j]>k) sum++;
	
	return sum;
}

inline int solveEdge(int i,int j)
{
	fill(dist,dist+n,1e9);
	dist[i]=dist[j]=1;
	sz=0;
	
	q[sz++]=i;
	q[sz++]=j;
	bfs();
	int sum=0;
	for(int m=0;m<n;m++) if(dist[m]>k) sum++;
	
	return sum;
}

int main()
{
	cin>>n>>k;
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		cin>>a>>b;
		a--;b--;
		pos[a].push_back(b);
		pos[b].push_back(a);
	}
	
	for(int i=0;i<n;i++) ans=min(ans,solveVertex(i));
	for(int i=0;i<n;i++)
		for(int j:pos[i])
			if(j>i) ans=min(ans,solveEdge(i,j));
	
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long double PI = acos(-1);
#define chmin(i, j) i = min(i, j);
#define chmax(i, j) i = max(i, j);
#define rep(i, n) for(int i=0;i<n;i++)
ll MOD = 1000000007;
ll fact(ll m) {
  if(m == 0 || m == 1) return 1LL;
  else return (m * fact(m-1LL)) % MOD;
}
bool custom(pair<ll, ll> a, pair<ll, ll> b) {
  if(a.first == b.first) return (a.second > b.second);
  else return a.first < b.first;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<ll> a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  map<int, ll> cnt;
  ll ans = 0;
  vector<ll> total(n);
  for(int i=0;i<n;i++) {
    if(i == 0) total[i] = a[i];
    else total[i] = total[i-1] + a[i];
    cnt[total[i]%m]++;
  }
  for(auto it=cnt.begin();it!=cnt.end();it++) {
    ll a = it->second;
    if(it->first == 0) ans += a;
    ans += a * (a-1) / 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll
#define INF 1e16
#define mod 1000000007
int main(){
    ll n;
    cin>>n;
    repl(i,1,10) repl(j,1,10) if(i*j==n) {
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;

    return 0;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);


int g[15][15];
bool flag[1050000];
const int INF = 1001001001;
const int di[] = { -1,0,1,0 };
const int dj[] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int main() {
	string s;
	cin >> s;
	ll k;
	cin >> k;
	int n = s.size();
	int one = 0;
	string target;
	int ans = 1;
	rep(i, n) {
		if (s[i] == '1')one++;
		else {
			target += s[i];
			break;
		}
	}
	if (one >= k)cout << ans << endl;
	else cout << target << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int main(){
    long long  w,h,x,y;
    while(~scanf("%lld%lld%lld%lld",&w,&h,&x,&y)){
        double ans=(w*h)/2.0;
        int flag=0;
        if((x==w/2.0)&&(y==h/2.0)){
            flag=1;
        }
        printf("%lf %d\n",ans,flag);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n, k;
    cin >> n >> k;
    vint p(n);
    rep(i, n) cin >> p[i];

    vll sum(n+1);
    sum[0] = 0;
    rep(i, n) sum[i+1] = sum[i] + p[i];

    ll mx = 0;
    rep(i, n-k+1) {
        ll s = sum[i+k] - sum[i];
        mx = max(mx, s);
    }

    double ans = ((double)mx+(double)k) / 2.0;

    printf("%.10f\n", ans);
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int digit(int n) {
    int ret = 0;
    while (n > 0) {
        ret++;
        n /= 10;
    }
    return ret;
}

int main(){
    int n;
    cin >> n;
    int res = 0;
    for (int i = 1; i <= n; ++i) {
        if (digit(i) % 2 == 1) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 3628
#include<queue>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

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

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N, M;
VI G[200011], H;

void MAIN() {
#ifdef LOCAL
    N = 200000;
    M = 200000;
#else
    scanf("%d%d", &N, &M);
#endif

    REP (i, N) {
	int l, r;
#ifdef LOCAL
        l = rand() % M;
        r = rand() % M;
	if (l > r) swap(l, r);
	l++;
	r += 2;
	l = 1;
#else
	scanf("%d%d", &l, &r);
#endif

	G[l].push_back(r);
    }

    int match = 0;
    REP (i, M+1) {
	sort(G[i].begin(), G[i].end());

	while (match < i && !G[i].empty()) {
	    match++;
	    G[i].pop_back();
	}

	H.insert(H.end(), G[i].begin(), G[i].end());
    }
    sort(H.begin(), H.end());

    int pos = 0;
    for (int i=match+1; i<=M; i++) {
	if (pos < (int)H.size() && H[pos] <= i) {
	    match++;
	    pos++;
	}
    }

    int ans = N - match;
    printf("%d\n", ans);
    eprintf("%d\n", match);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 8948
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N,X;
    cin>>N>>X;
    vint L(N);
    for (size_t i = 0; i < N; i++)
    {
        cin>>L[i];
    }
    int D = 0;
    int ans=1;
    for (size_t i = 0; i < N; i++)
    {
        D+=L[i];
        if(D<=X)
        ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
double abs(double x){
  if(x < 0)return 0.0-x;
  else return x;
}
int main(){
  int N,n;
  double m,t,S=0,M[110];
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> M[i];
    S += M[i];
  }
  m = S/(double)N;
  for(int i=0;i<N;i++){
    t = abs(m-M[i]);
    if(S > t){
      n = i;
      S = t;
    }
  }
  cout << n;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

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

    int H, W, M;
    cin >> H >> W >> M;
    map<ll, ll> x, y;
    map<pll, bool> z;
    vector<ll> h(M), w(M);

    rep(i, M) {
        cin >> h[i] >> w[i];
        x[h[i]]++;
        y[w[i]]++;
        z[{h[i], w[i]}] = true;
    }

    vector<ll> maxs, mays;
    int ma = 0, maxx = 0;
    for (auto p : x) {
        if (p.second > ma)
            ma = p.second, maxx = p.first;
    }

    maxs.push_back(maxx);

    for (auto p : x) {
        if (p.second == ma && p.first != maxx)
            maxs.push_back(p.first);
    }

    int maa = 0, maxy = 0;
    for (auto p : y) {
        if (p.second > maa)
            maa = p.second, maxy = p.first;
    }

    mays.push_back(maxy);

    for (auto p : y) {
        if (p.second == maa && p.first != maxy)
            mays.push_back(p.first);
    }

    bool judge = 0;
    rep(i, maxs.size()) {
        rep(j, mays.size()) {
            if (!z[{maxs[i], mays[j]}]) {
                judge = 1;
                break;
            }
        }
    }

    cout << ((judge) ? ma + maa : ma + maa - 1) << endl;
}

Measured memory_bytes: 87548
//by Judge
#include<bits/stdc++.h>
#define fp(i,a,b) for(register int i=(a),I=(b)+1;i<I;++i)
#define ll long long
using namespace std;
char sr[1<<21],z[20];int CCF=-1,Z;
inline void Ot(){fwrite(sr,1,CCF+1,stdout),CCF=-1;}
inline void print(int x,char chr='\n'){
	if(CCF>1<<20)Ot();if(x<0)sr[++CCF]=45,x=-x;
	while(z[++Z]=x%10+48,x/=10);
	while(sr[++CCF]=z[Z],--Z);sr[++CCF]=chr;
} int n,m,A,B;
int main(){ cin>>n>>m>>A>>B;
	fp(i,1,n){
		fp(j,1,m) sr[++CCF]=((i<=B)^(j<=A))+48;
		sr[++CCF]='\n';
	} return Ot(),0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <math.h>

int main() {
	double DDblCulCells, DDblAllCells, DDblWhiteCells;
	double DDblBlackCells;

	std::cin >> DDblCulCells >> DDblWhiteCells;

	DDblAllCells = pow(DDblCulCells, 2);

	DDblBlackCells = DDblAllCells - DDblWhiteCells;

	std::cout << DDblBlackCells << std::endl;
}

Measured memory_bytes: 3688
N=int(input())
X=input()

k=0
for i in range(N):
  if X[i]=="1":
    k+=1

A=int(X,2)
#apは0->1の時の一回目の変換の値。
ap=A%(k+1)

am=100
if k != 1:
  am=A%(k-1)

popc_list=[-1]*(k+3)

def F(num):
  #print(str(num)+"called")
  if num==0:
    return 0
  if popc_list[num]!=-1:
    return popc_list[num]
  
  popc=0
  for s in bin(num):
    if s == "1":
      popc+=1
      
  popc_list[num]=F(num%popc)+1
  return popc_list[num]
  

for i in range(N):
  if X[i] == "0":
    print(F((ap+pow(2,N-1-i,k+1))%(k+1))+1)
  else:
    if k == 1:
      print(0)
      continue
    print(F((am-pow(2,N-1-i,k-1))%(k-1))+1)
"""
print(popc_list)
print(k)
"""

Measured memory_bytes: 10328
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.Comparator;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            final int n = in.nextInt();
            List<TaskC.Point> pointA = new ArrayList<>();
            List<TaskC.Point> pointB = new ArrayList<>();
            Comparator<TaskC.Point> min = Comparator.comparing(TaskC.Point::getMin);
            Comparator<TaskC.Point> max = Comparator.comparing(TaskC.Point::getMax);

            for (int i = 0; i < n; i++) {
                pointA.add(new TaskC.Point(in.nextInt(), in.nextInt()));
            }
            for (int i = 0; i < n; i++) {
                pointB.add(new TaskC.Point(in.nextInt(), in.nextInt()));
            }

            pointA.sort(max);
            pointB.sort(min);
            int ans = 0;
            int index = pointA.size() - 1;
            while (index >= 0) {
                TaskC.Point ca = pointA.get(index);
                for (int i = 0; i < pointB.size(); i++) {
                    TaskC.Point cb = pointB.get(i);
                    if (ca.getX() < cb.getX() && ca.getY() < cb.getY()) {
                        pointA.remove(ca);
                        pointB.remove(cb);
                        ans++;
                        index--;
                        break;
                    } else if (i == pointB.size() - 1) {
                        index--;
                    }
                }
            }
            out.println(ans);
        }

        static class Point {
            private int x;
            private int y;

            public Point(int x, int y) {
                this.x = x;
                this.y = y;
            }

            public int getX() {
                return this.x;
            }

            public int getY() {
                return this.y;
            }

            public int getMax() {
                return Math.max(x, y);
            }

            public int getMin() {
                return Math.min(x, y);
            }

        }

    }
}


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


def check_flip(N, M, K):
    for i in range(N+1):
        for j in range(M+1):
            if (N-i)*j + (M-j)*i == K:
                return True
    return False


if __name__ == '__main__':
    N, M, K = map(int, input().split())
    if check_flip(N, M, K):
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <algorithm>

using namespace std;


bool solve(int &a, int &b){

	//cout<< a<< " "<< b<<endl;
	int c = a+b;
	int d = 0;
	while(c){
		c /= 10;
		d++;
	}
	cout<< d<< endl;
	
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	int a=0,b=0;
	while(cin>>a>>b){
		solve(a,b);
	}

	return 0;
}

 

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

#define ll long long
using namespace std;

const int N = 2e5;
int A[N], p[N];

int find(int a){
	return p[a]==a ? a : (p[a]=find(p[a]));
}


void merge(int a, int b){
	a = find(a);
	b = find(b);
	p[b] = a;
}

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

	int n, m;
	cin >> n >> m;

	for(int i=1; i<=n; i++)
		cin >> A[i];
		
	for(int i=1; i<=n; i++)
		p[i] = i;
		
	for(int i=1; i<=m; i++){
		int a, b;
		cin >> a >> b;
		merge(a, b);
	}

	int ans = 0;
	for(int i=1; i<=n; i++)
		if(find(i) == find(A[i]))
			ans++;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
/// Kazuki Hoshino


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define endl '\n'
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

ll n, k, ans, a , b;

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

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

cin >> n >> k;

if(k%2){

    rep(i, 1, n){
        if(i%k==0)ans++;
    }
    cout << ans*ans*ans << endl;

}

else {

    rep(i, 1, n){
    if(i%k==0)a++;
    if(i%k==(k/2))b++;
    }

    cout << a*a*a + b*b*b << endl;

}











return 0;}
///....


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.NavigableMap;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
    
    private static int N;
    private static int M;
    private static boolean[] isAC;
    
    private static NavigableMap<Integer, Integer> submitTimes = new TreeMap<>();
    
    private static final String AC = "AC";
    private static final String WA = "WA";
    

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

        N = sc.nextInt();
        M = sc.nextInt();
        
        isAC = new boolean[N+1];
        Arrays.fill(isAC, false);
        
        for (int i = 0; i < M; i++) {
            int p = sc.nextInt();
            String S = sc.next();
            
            if(submitTimes.containsKey(p)) {
                if(isAC[p]) {
                    continue;
                }else {
                    submitTimes.put(p, submitTimes.get(p) + 1);
                }

            }else {
                submitTimes.put(p, 1);
            }
            
            if(S.equals(AC)) {
                isAC[p] = true;
            }
        }
        
        int sumAC = 0;
        int sumPenalty = 0;
        
        for(int i=1;i<N+1;i++) {
            if(!isAC[i]) {
                continue;
            }
            
            sumAC++;
            sumPenalty += submitTimes.get(i) -1;
        }
        
        System.out.println(sumAC + " " + sumPenalty);
    }
}


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

#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define reset(a, v) memset((a), v, sizeof(a))

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

const int N = 4005;

int n;
int preRed[N], preGreen[N], preBlue[N];

int getNum(char s) {
	if (s == 'R') return 1;
	if (s == 'G') return 2;
	return 3;
}

int getOther(char s1, char s2) {
	int a1 = getNum(s1), a2 = getNum(s2);
	int a3 = a1^a2;
	return a3;
}

int main() {
	scanf("%d", &n);
	char S[N]; scanf("%s", S);
	for (int i = 0; i < n; i++) {
		if (i > 0) {
			preRed[i] = preRed[i-1];
			preGreen[i] = preGreen[i-1];
			preBlue[i] = preBlue[i-1];
		}

		if (S[i] == 'R') {
			preRed[i]++;
		}
		else if (S[i] == 'G') {
			preGreen[i]++;
		}
		else {
			preBlue[i]++;
		}
	}

	ll ans = 0;
	for (int i = 0; i < n-1; i++) {
		for (int j = i+1; j < n; j++) {
			if (S[i] == S[j]) continue;
			int k = getOther(S[i],S[j]);
			// printf("i=%d, j=%d, k=%d\n", i,j,k);
			int diff = j-i;
			if (k == 1) {
				ans += preRed[n-1] - preRed[j-1];
				if (j+diff < n && S[j+diff] == 'R') ans--;
			}
			else if (k == 2) {
				ans += preGreen[n-1] - preGreen[j-1];
				if (j+diff < n && S[j+diff] == 'G') ans--;
			}
			else {
				ans += preBlue[n-1] - preBlue[j-1];
				if (j+diff < n && S[j+diff] == 'B') ans--;
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3856
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

N,X = map(int,input().split(" "))

city = input().split(" ")

kouyaku = abs(int(city[0]) - X)

for i in range(N):
  kouyaku = gcd(kouyaku,abs(int(city[i]) - X))
  
print(kouyaku)

Measured memory_bytes: 11096
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b;
    cin>>a>>b;
    ll d=__gcd(a,b);
    cout<<(a*b/d);
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int main() {
  int k, n;
  // char mt;
  // vector<char> m;

  string s;
  cin >> n;
  // for (int i = 0; i < n; ++i) {
  //   cin >> mt;
  //   m.push_back(mt);
  // }
  cin >> s;
  cin >> k;

  char moji = s[k-1];

  string out;
  for (auto c : s){
    if(c == moji)
      out.push_back(c);
    else
      out.push_back('*');
  }
  cout << out <<endl;
  // for (auto l : s) {
  //   cout << l << endl;
  // }

  // int minn = *min_element(p.begin(), p.end());
  // cout << minn << endl;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#[allow(unused_imports)]
use std::io::{self, Write};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
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)*}
    };
}
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)*}
    };
}
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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, char) => {
        read_value!($next, String).chars().collect::<Vec<char>>()[0]
     };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
     };
    ($next:expr, isize1) => {
        read_value!($next, isize) - 1
    };
     ($next:expr, $t:ty) => {
         $next().parse::<$t>().expect("Parse error")
    };
}
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}
#[allow(dead_code)]
const MOD: u64 = 1000000007;
#[allow(dead_code)]
fn to_num(c: char) -> i64 {
    c as i64 - 48
}


fn main() {
    input!{
        N: u32,
        A: [usize; N],
    }
    let mut count = HashMap::new();

    for a in &A {
        *count.entry(a).or_insert(0) += 1;
    }

    let mut valid = true;
    for (&k, v) in count {
        if v != 2 {
            if k == 0 && v == 1 {
                continue;
            } else {
                valid = false;
                break;
            }
        }
    }

    if valid {
        let mut ans = 1;
        for _ in 0..(N/2) {
            ans = (ans * 2) % MOD;
        }
        println!("{}", ans);
    } else {
        println!("0");
    }
}

Measured memory_bytes: 12540
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<map>
using namespace std;
#define int long long
int ans = 0;
int N;

bool check(string s){
    map<char,int> mp;
    for(int i = 0; i < s.size();i++){
        mp[s[i]] += 1;
    }

    if(mp.size() < 3){
        return false;
    }else{
        return true;
    }
}
void recursion(string s){
    if(s == ""){
        recursion(s+"3");
        recursion(s+"5");
        recursion(s+"7");
        return;
    }

    int x = std::stoll(s);
    if(x > N){
        return;
    }else{
        if(check(s)) ans += 1;
        recursion(s+"3");
        recursion(s+"5");
        recursion(s+"7");
    }
}
signed main(){
    cin >> N;
    recursion("");

    cout << ans << endl;
}

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

typedef pair<int,int> pii;
map <pii, int> mp;
int n, m;
bool solve()
{
	for (int i = 2; i < n; ++i)
	{
		if (mp.count(pii(1, i)) &&  mp.count(pii(i, n)))
			return 1;
	}
	return 0;

}
int main()
{
	cin.sync_with_stdio(0);
	cin >> n >> m;
	for (int i = 1; i <= m; ++i)
	{
		int x, y;
		cin >> x >> y;
		if (x > y) swap(x, y);
		mp[pii(x, y)] = 1;
	}
	if (solve()) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
}


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

using namespace std;
using ll = long long;

/***********debug tools***********/
template<class T> inline ostream& operator<<(ostream& os,vector<T> arr) {os << "["; for(int i = 0; i < (int)arr.size(); i++)os << arr[i] << (i == (int)arr.size() - 1 ? "]" : ",");os << endl;return os;}
template<typename A, typename B> ostream& operator<<(ostream& os, const pair<A,B>& p){os << "{" << p.first << "," << p.second << "}";return os; }
#define prvec(v) cerr<<#v<<": [";for(int __i = 0;__i < (int)(v).size(); __i++)cerr<<((v)[__i])<<(__i+1==(int)(v).size()?"]\n":",");
#define print(x) cerr<<#x<<": "<<(x)<<endl
/*********************************/

int main()
{
    int n;
    cin >> n;
    ll sum = 0;
    for(int i = 0; i < n; i++) {
        sum += (ll)(i + 1) * (n - i);
    }

    
    for(int i = 0; i < n - 1; i++) {
        ll a, b; cin >> a >> b; a--, b--;
        if(a > b)swap(a,b);
        ll cur = (a + 1) * (n - b);
        sum -= cur;
    }
    cout << sum << endl;

}

Measured memory_bytes: 3540
#include <iostream>
#include <algorithm>
using namespace std;
const int N=1e5+5;
int b[N];

bool cmp(int x,int y)
{
	return x>y;
}

int main()
{
	int n,h,ma=0;
	cin>>n>>h;	
	for(int i=0;i<n;i++){
		int t;
		cin>>t>>b[i];
		if(t>ma)
			ma=t;
	}
	sort(b,b+n,cmp);
	int m=0,s=0;
	while(h>0){
		if(b[m]>=ma){
			h-=b[m];
			s++;
			m++;
		}
		else{
			s+=h/ma;
			if(h%ma>0)
				s++;
			break; 
		}
	}
	cout<<s<<endl;
	return 0;	
} 

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int dp[1001][1001];
char mp[1001][1001];
int main()
{
  int h,w;
  long long mod=1000000000+7;
  cin>>h>>w;
  for(int i=1; i<=h; i++){
    for(int j=1; j<=w; j++){
      cin>>mp[i][j];
    }
  }
  dp[1][1]=1;
  for(int i=1; i<=h; i++){
    for(int j=1; j<=w; j++){
      if(mp[i][j]!='#'){
	dp[i][j]+=(dp[i-1][j]%mod+dp[i][j-1]%mod)%mod;
      }
    }
  }
  cout<<dp[h][w]<<'\n';
  return 0;
}


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

int main(){
	long long N,A,B;
	cin >> N >> A >> B;
	if(N==1){
		if(A!=B)cout << "0" << endl;
		else cout << "1" << endl;
	}
	else if(A>B)cout << "0" << endl;
	else cout << (N-1)*B+A-((N-1)*A+B)+1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

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

const ll mod = 998244353;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}

inline ll add(ll a, ll b){
    return take_mod(a+b);
}

inline ll sub(ll a, ll b){
    return take_mod(a-b);
}


inline ll mul(ll a, ll b){
    return take_mod(a * b);
}

inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return pow(x, mod-2);
}

// nは上限
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}

// nは上限
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}

ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}

ll comb(ll n, ll k){
    return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}


int main(){
    make_fact(101000);
    ll N;   cin >> N;
    string s;   cin >> s;

    ll x[3];    fill(x, x+3, 0);
    ll res = 1;
    for(int i = 0; i < 3 * N; i++){
        int index;
        if(s[i] == 'R'){
            index = 0;
        }
        else if(s[i] == 'G'){
            index = 1;
        }
        else{
            index = 2;
        }

        bool emp = 0;
        ll tmp = LONG_LONG_MAX;
        ll tmp2 = 1;
        for(int j = 0; j < 3; j++){
            if(index == j)  continue;
            tmp = min(x[j], tmp);
            tmp2 = max(x[j], tmp2);
            if(x[j] == 0){
                emp++;
            }
        }

        if(emp == 2){
            x[index]++;
        }
        else if(emp == 1){
            if(x[index] >= tmp2){
                x[index]++;
            }
            else{
                res = mul(res, tmp2 - x[index]);
                x[index]++;
            }
        }
        else{
            res = mul(res, tmp);
            for(int j = 0; j < 3; j++){
                if(index == j)  continue;
                x[j]--;
            }
        }
//        cout << i << " " << res << endl;
    }

    cout << mul(res, fact[N]) << endl;


    return 0;
}




Measured memory_bytes: 1668
use std::io::*;
use std::str::FromStr;

fn main() {
	let n: u64 = read();
	let mut sum: u64 = 0;
	for i in 1..n+1 {
		if (i % 3 != 0) && (i % 5 != 0) {
			sum += i;
		}
	}
	println!("{}", sum);
}

fn read<T: FromStr>() -> T {
	let stdin = stdin();
	let stdin = stdin.lock();
	let token: String = stdin
		.bytes()
		.map(|c| c.expect("failed to read char") as char)
		.skip_while(|c| c.is_whitespace())
		.take_while(|c| !c.is_whitespace())
		.collect();
	token.parse().ok().expect("failed to parse token")
}



Measured memory_bytes: 2148
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, r = map(int, readline().split())
if 10 < n:
    print(r)
else:
    print(100 * (10 - n) + r)


Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

int main() {
	int h, w;
	cin >> h >> w;
	vector<string> mp(h);
	rep(i, h) cin >> mp[i];
	vector<vector<char>> ans(h, vector<char>(w));
	rep(i, h)rep(j, w) {
		if (mp[i][j] == '.') ans[i][j] = '0';
		else ans[i][j] = '#';
	}
	rep(i, h) {
		rep(j, w) {
			if (ans[i][j] == '#') {
				if (i > 0&&ans[i-1][j]!='#') ans[i - 1][j]++;
				if (i < h - 1&&ans[i+1][j]!='#') ans[i + 1][j]++;
				if (j > 0&&ans[i][j-1]!='#') ans[i][j - 1]++;
				if (j < w - 1&&ans[i][j+1]!='#') ans[i][j + 1]++;
                if(i>0&&j>0&&ans[i-1][j-1]!='#') ans[i-1][j-1]++;
               if(i<h-1&&j>0&&ans[i+1][j-1]!='#') ans[i+1][j-1]++;
               if(i>0&&j<w-1&&ans[i-1][j+1]!='#') ans[i-1][j+1]++;
               if(i<h-1&&j<w-1&&ans[i+1][j+1]!='#') ans[i+1][j+1]++;
			}
		}
	}
	rep(i, h) {
		rep(j, w) cout << ans[i][j];
		cout << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,a,b,c;
    string ch,sr,st;
    cin>>ch>>sr;
    cin>>a>>b;
    cin>>st;
    if(st==ch)
    {
        c=a-1;
        cout<<c<<" "<<b<<endl;
    }
    else
    {
        cout<<a<<" "<<(b-1)<<endl;
    }
    return 0;

}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

class program
{
    static public int mod = 1000000007;
    static void Main()
    {
        var n = rint();
        var a = inta();
        var table = new int[n + 1];
        for (int i = 0; i < n; i++)
            table[a[i]]++;
        long ans = 0;
        for (int i = 0; i <= n; i++)
            ans += ((long)table[i] * (table[i] - 1)) / 2;
        for(int i = 0; i < n; i++)
        {
            long w = ans;
            if(table[a[i]] > 0)
            {
                w -= table[a[i]] - 1;
            }
            WriteLine(w);
        }
    }

    static int pow(int a, int b) { string binary = Convert.ToString(b, 2); int bileng = binary.Length; long a_power = a; long value = 1; for (int i = bileng - 1; i >= 0; i--) { if (binary[i] == '1') { value = value * a_power % mod; } a_power = a_power * a_power % mod; } return (int)value; }
    static string rstr() { return ReadLine(); }
    static int rint() { return int.Parse(ReadLine()); }
    static long rlong() { return long.Parse(ReadLine()); }
    static string[] stra() { return ReadLine().Split(' '); }
    static char[] chara() { string[] a = stra(); string b = ""; for (int i = 0; i < a.Length; i++) { b += a[i]; } return b.ToCharArray(); }
    static int[] inta() { string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; }
    static long[] longa() { string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; }
    static double[] doublea() { string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_double_array[countup_i] = double.Parse(read_str_array[countup_i]); } return return_double_array; }
    static long GCD(long a, long b) { if (a < b) { long temp = a; a = b; b = temp; } if (a % b == 0) { return b; } else { long temp = b; b = a % b; a = temp; return GCD(a, b); } }
    static long LCM(long a, long b) { return a * b / GCD(a, b); }
    static void WriteArray2(int[,] a, int b, int c) { for (int i = 0; i < b; i++) { for (int j = 0; j < c; j++) { if (j != 0) Write(" "); Write(a[i, j]); } WriteLine(); } }
    static void WriteArray(int[] a, int b) { for (int i = 0; i < b; i++) { Write(" "); Write(a[i]); } WriteLine(); }
}


Measured memory_bytes: 52524
#include<stdio.h>
#include<vector>

int main()
{
	int n;
	std::vector<bool> s;

	scanf("%d", &n);
	while (n)
	{
		if (n % 2)
		{
			s.push_back(1);
			n--;
		}
		else
			s.push_back(0);
		n /= -2;
	}

	if (s.size())
		for (int i = s.size() - 1; i >= 0; i--)
		{
			if (s[i])
				printf("1");
			else
				printf("0");
		}
	else
		printf("0");
	printf("\n");

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m,l;
	m=0;
	cin>>n;
	l=n;
	while(n>0){
		m+=n%10;
		n /= 10;
	}
	if(l%m==0){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}

}

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

int main() {
	int A, B, C;
	int c5 = 0, c7 = 0;
	for (int i = 0; i < 3; i++) {
		int n;
		cin >> n;
		if (n == 5) c5++;
		if (n == 7) c7++;
	}

	if (c5 == 2 && c7 == 1) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

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

/*============================ DEBUGGING =============================*/

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

/*============================= DEFINES ==============================*/

#define eps 1e-9
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define B begin()
#define E end()
#define F first
#define S second
#define tostr(x) to_string(x)
#define SZ(x) ((int)x.size())
#define ins insert
#define rep(i,x,y) for(int i=x;i<y;i++)
#define per(i,x,y) for(int i=x;i>y;i--)
#define repi(i,x,y) for(int i=x;i<=y;i++)
#define peri(i,x,y) for(int i=x;i>=y;i--)
#define inf (ll)LLONG_MAX
#define ds1(i,x) for(auto i=x.begin();i!=x.end();i++)
#define ds2(i,x) for(auto i:x)
#define fib(n) ceil(pow((1+sqrt(5),n)-pow((1-sqrt(5),n)/(float)(pow(2,n)*sqrt(5)
#define FIO {ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
#define dig(n) (int)(log10(n)+1)
#define ss(x,k) substr(x,k)  // x is the start pos and k is the length of substr.
#define set(x,k) memset(x,k,sizeof x)

/*============================== TYPEDEFS ============================*/

typedef long long ll;
typedef long l;
typedef string str;
typedef vector<int> vi;
typedef vector<ll> vlli;
typedef vector<bool> vb;
typedef queue<int> qi;
typedef vector<pair<int,int> > vpii;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
/*============================ START FROM HERE =======================*/

int main(){
	FIO
	
	int n;cin>>n;
	int a[n];
	int s=0;
	rep(i,0,n){cin>>a[i];s+=a[i];}
	int ans=0;
	rep(i,0,n){
		ans+=a[i]*(s-a[i]);
		s-=a[i];
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define FI(i, a, b) for (int i = (a); i <= (b); ++i)
#define FD(i, b, a) for (int i = (b); i >= (a); --i)
#define DEBUG(x) cerr << #x << ": " << (x) << endl;
 
int main() {
  int a, b;
  cin >> a >> b;
  if (a >= 10 || b >= 10) puts("-1");
  else printf("%d\n", a * b);
}


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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int x = 100*a+10*b+c;
    if(x % 4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
 }

Measured memory_bytes: 256