akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll res = 0;
    char a[3];
    a[0]='R';
    a[1]='G';
    a[2]='B';
    sort(a,a+3);
    do{
        vector<ll> r(4005,0);
        vector<ll> rg(4005,0);
        vector<ll> rgb(4005,0);
        for(int i=1;i<=n;i++){
            if(s[i-1]==a[0])r[i]=r[i-1]+1;
            else r[i]=r[i-1];
        }
        for(int i=1;i<=n;i++){
            if(s[i-1]==a[1])rg[i]=rg[i-1]+r[i-1];
            else rg[i]=rg[i-1];
        }
        for(int i=1;i<=n;i++){
            if(s[i-1]==a[2])rgb[i]=rgb[i-1]+rg[i-1];
            else rgb[i]=rgb[i-1];
        }
        ll ans = rgb[n];
        vector<int> rp;
        rep(i,n)if(s[i]==a[0])rp.push_back(i);
        rep(i,n){
            if(s[i]==a[1]){
                for(auto p:rp){
                    if(p>i)break;
                    else if(((2*i-p)<n)&&(s[2*i-p]==a[2]))ans--;
                }
        }
    }
    res += ans;
    }while(next_permutation(a,a+3));
    cout << res << endl;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  int x = A;
  int sum = 0;

  for (int i = 0; i < B-A+1; i++) {
    if (x/10000==x%10 && x/1000%10==x/10%10){
      sum ++;
      x++;
    }
    else
      x++;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
    if (b==0) return 1;
    ll c = power(a,b>>1);
    c = (c*c)%mod;
    if (b&1) return (c*a)%mod;
    return c;
}
ll powerwithoutmod(ll a,ll b) {
    if (b==0) return 1;
    ll c = power(a,b>>1);
    c = (c*c);
    if (b&1) return (c*a);
    return c;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)1e5+5;
const int Q = 301;
const int logN = 16;

void solve() {
	int a,b,c;
  	cin>>a>>b>>c;
  	if (a!=b && a!=c && b!=c) {
    	cout<<"No";
      return;
    }
  	else if (a==b && a==c) {
    	cout<<"No";
      return;
    }
  	cout<<"Yes";
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

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

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


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

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, C;
    cin >> N >> C;
    vector<vector<int>> color_count(3, vector<int>(C, 0));
    int D[C][C];
    for(int i = 0; i < C; i++){
        for(int j = 0; j < C; j++){
            cin >> D[i][j];
        }
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            int c;
            cin >> c;
            color_count[(i + j) % 3][c - 1]++;
        }
    }
    int ans = 1e9;
    for(int i = 0; i < C; i++){
        for(int j = 0; j < C; j++){
            for(int k = 0; k < C; k++){
                if(i != j && i != k && j != k){
                    int this_ans = 0;
                    for(int l = 0; l < C; l++){
                        this_ans += D[l][i] * color_count[0][l];
                        this_ans += D[l][j] * color_count[1][l];
                        this_ans += D[l][k] * color_count[2][l];
                    }
                    ans = min(ans, this_ans);
                }
            }
        }
    }
    cout << ans << endl;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline void fastio () {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
}

#define whats(x) cerr << #x << " = " << (x) << "\n"; 

using LL = long long;
using LD = long double;

const LL INF = LLONG_MAX;
const LL MOD = static_cast<LL>(1e9+7);
const LL N = 5e5+1;

int main() {
	fastio();

	LL n, m, k;
	cin >> n >> m >> k;

	vector<vector<char>> g(n, vector<char>(m));

	for (auto &e : g) {
		for (auto &f : e) {
			cin >> f;
		}
	}
	LL ans = 0;
	for (LL i = 0; i < (1<<n); ++i) {
		for (LL j = 0; j < (1<<m); ++j) {
			//i,j


			vector<vector<char>> g2(g);
			for (LL l = 0; l < m; ++l) {
				if (j & (1 << l) ) {
					for (LL I = 0; I < n; ++I) {
						g2[I][l] = 'r';
					}
				}
			}

			for (LL l = 0; l < n; ++l) {
				if (i & (1 << l) ) {
					for (LL J = 0; J < m; ++J) {
						g2[l][J] = 'r';
					}
				}
			}

			LL cnt = 0;
			for (LL I = 0; I < n; ++I) {
				for (LL J = 0; J < m; ++J) {
					if (g2[I][J] == '#') {
						cnt++;
					}
				}
			}
			if (cnt == k) {
				ans++;
			}
		}
	}
	cout << ans << "\n";

}

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

int main()
{
    int A,B;
    cin >> A >>B;
    int ans = -1;
    int moto = B*10;
    
    rep(i,10){
        int moto8 = moto*0.08;
        if(moto8 == A){
            ans = moto;
            break;
        }else{
            moto++;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll N = 310;
const ll M = N * N;
const ll MOD = 998244353;

void add(ll &a, ll b){
  a += b;
  if(a >= MOD) a -= MOD;
}

ll dp[M];
ll dp2[M];

int main(){
  fastIO;
  ll n;
  cin >> n;
  ll a;
  dp[0]=1;
  dp2[0]=1;
  ll s = 0;
  for(ll i = 0 ; i < n; i ++ ){
    cin >> a;
    s += a;
    for(ll j = M - 1; j >= 0 ; j -- ){
      if(dp[j] > 0){
        add(dp[j + a], dp[j]);
        add(dp[j],dp[j]);
      }
      if(dp2[j] > 0){
        add(dp2[j + a], dp2[j]);
      }
    }
  }
  ll ans = 1;
  for(ll i = 1; i <= n ; i ++ ){
    ans=(ans*3ll)%MOD;
  }
  ll take = 0;
  for(ll k = s/2 + 1; k <= s; k ++ ){
    add(take,(3ll*dp[k])%MOD);
  }
  if(s % 2 == 0){
    ll t = dp[s/2];
    t -= dp2[s/2];
    if(t<0) t += MOD;
    add(take,(3ll*t)%MOD);
  }
  cout << (ans - take + MOD) % MOD;
  return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <string.h>
using namespace std;

int main(){
  char blood[3];
  int num,a=0,b=0,o=0,ab=0;
  while(scanf("%d,%s",&num,blood) != EOF){
    if(blood[0] == 'A' && blood[1] == '\0'){
      a++;
    }
    else if(blood[0] == 'B'){
      b++;
    }
    else if(blood[0] == 'O'){
      o++;
    }
    else if(strcmp(blood,"AB") == 0){
      ab++;
    }
  }
  cout << a << endl << b << endl << ab << endl << o << endl;
}

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

using namespace std;

int main()
{
    int N,a;
    long long sum[200001];
    sum[0] = 0;
    long long min_num = 2 * 10000000000;//pow(10, 9.0);

    cin >> N;

    for (int i = 1; i <= N; i++) {
        cin >> a;
        sum[i] = sum[i - 1] + a;
    }
    
    for ( int i = 1; i < N; i++) {
        min_num = min(min_num, abs(sum[N] - (2 * sum[i])));
    }
    cout << min_num << '\n';

}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;
typedef long long ll;
#define M 1000000007
ll n,m,ans;
char s[5005];
ll dp[5005][5005];
int main(void){
    cin>>n>>s;
    m=strlen(s);
    dp[0][m]=1;
    for(int i=0;i<n;i++){
        dp[i+1][0]=(dp[i+1][0]+dp[i][0])%M;
        for(int j=0;j<=n;j++){
            if(j>0)dp[i+1][j-1]=(dp[i+1][j-1]+dp[i][j])%M;
            dp[i+1][j+1]=(dp[i+1][j+1]+dp[i][j]*2)%M;
        }
    }
    cout<<dp[n][0]<<endl;
}

Measured memory_bytes: 195712
#include <iostream>
#include <vector>

using namespace std;

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

	int ans = 0;

	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;

		if (a >= k)
		{
			ans++;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
N, A, B = map(int, raw_input().split())
S = raw_input()
S_list = list(S)
 
c1 = 0
c2 = 0
for i in range(len(S_list)):
    if c1 < A+B and S_list[i] == 'a':
        c1 += 1
        print 'Yes'
    elif c1 < A+B and c2 < B and S_list[i] == 'b':
        c1 += 1
        c2 += 1
        print 'Yes'
    else:
        print 'No'

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

if A == 0:
    print(0)
else:
    i = N // (A + B)
    j = N % (A + B)
    if j >= A:
        count = A * (i + 1)
        print(count)
    else:
        count = A * i + j
        print(count)

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int mod=1000000007;
#define PI 3.1415926535
#define pb  push_back
#define FOR(i,n) for(int i=0;i<(n);i++)
#define FORA(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define count_1(n)  __builtin_popcountll(n)
#define parity(n)   __builtin_parityll(n)   //Even parity 0 as output
void show    (int a[], int arraysize) { for (int i = 0; i < arraysize; ++i)  {cout << a[i] << " ";}	cout<<endl;}
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b);}
void sieve(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          cout << p << " ";
}
int main()
{FAST
int n,m,sum=0;
cin>>n>>m;
int a[m];
FOR(i,m)
{
	cin>>a[i];
	sum+=a[i];
}
if(sum>n)
{
	cout<<"-1\n";
}
else
{
	cout<<n-sum<<endl;
}

return  0;
}




Measured memory_bytes: 3616
#include <iostream>
using namespace std;
int main(){

  int a,b;

  cin>>a>>b;

  if(a < b){
 
    cout<< "a < b" << endl;}

  else if(a > b){
    cout<< "a > b" << endl;}

  else{
    cout<< "a == b" << endl;}

  return 0;}

Measured memory_bytes: 1156
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#define rep(index,num) for(int index=0;index<num;index++)
#define eps 1e-15
typedef long long ll;
int main(){
	char s[101];
	int count[26]={0};
	int ok=1;
	scanf("%s",s);
	rep(i,100){
		if(s[i]=='\0') break;
		else count[s[i]-'a']++;
	}
	rep(i,26){
		if(count[i]%2==1){
			ok=0;
			break;
		}
	}
	if(ok==1) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 128
n = int(input())


def intsum(n):
    return (n * n + n) // 2


tmp = 0
for i in range(n):
    if intsum(i + 1) >= n:
        tmp = i + 1
        break
for i in range(tmp):
    if i + 1 == intsum(tmp) - n:
        continue
    print(i + 1)



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

using namespace std;

int main() {
    long long a, b, c, d;

    cin >> a >> b >> c >> d;
    long long g = c / __gcd(c, d) * d;

    long long ret = 0;
    ret = (b - a) + 1;
    //cout << g << endl;
    ret = ret - (b / c) - (b / d) + (b / g);
    //cout << ret << endl;;
    ret = ret + ((a - 1) / c) + ((a - 1) / d) - ((a - 1) / g);
    cout << ret << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int M,K,i;
int main(){
	cin>>M>>K;
	if(M==1)
		if(K==0)cout<<"0 0 1 1"<<endl;
		else cout<<-1<<endl;
	else if(K>=1<<M)cout<<-1<<endl;
	else{
		for(i=0;i<1<<M;i++)if(i!=K)cout<<i<<" ";
		cout<<K<<" ";
		for(i=1<<M;i--;)if(i!=K)cout<<i<<" ";
		cout<<K<<endl;
	}
}


Measured memory_bytes: 1792
def main():
    A = [list(map(int,input().split())) for i in range(3)]
    N = int(input())
    b = [int(input()) for _ in range(N)]

    for i in range(N):
        for j in range(3):
            for h in range(3):
                if A[j][h] == b[i]:
                    A[j][h] = 0

    if A[0][0]==0 and A[0][1]==0 and A[0][2]==0:
        return 'Yes'
    elif A[1][0]==0 and A[1][1]==0 and A[1][2]==0:
        return 'Yes'
    elif A[2][0]==0 and A[2][1]==0 and A[2][2]==0:
        return 'Yes'
    elif A[0][0]==0 and A[1][0]==0 and A[2][0]==0:
        return 'Yes'
    elif A[0][1]==0 and A[1][1]==0 and A[2][1]==0:
        return 'Yes'
    elif A[0][2]==0 and A[1][2]==0 and A[2][2]==0:
        return 'Yes'
    elif A[0][0]==0 and A[1][1]==0 and A[2][2]==0:
        return 'Yes'
    elif A[0][2]==0 and A[1][1]==0 and A[2][0]==0:
        return 'Yes'

    return ('No')

print(main())


Measured memory_bytes: 9324
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#define ll long long
using namespace std;

const int N=200005;

struct E{
	int to,next;
}mem[N<<1];
int n,num,x,y,rt;
ll all;
bool tag;
int head[N],d[N];
ll a[N],dp[N],b[N];

void add(int x,int y){
	num++;
	mem[num].to=y; mem[num].next=head[x];
	head[x]=num;
}

void dfs(int k,int pre){
	int j,u,cnt=0,mx,sum;
	if (!tag) return;
	if (d[k]==1) return;
	for (j=head[k];j;j=mem[j].next){
		u=mem[j].to;
		if (u==pre) continue;
		dfs(u,k);
	}
	for (j=head[k];j;j=mem[j].next){
		u=mem[j].to;
		if (u==pre) continue;
		b[++cnt]=dp[u];
	}
	if (!tag) return;
	sort(b+1,b+1+cnt);
	mx=0; sum=0;
	for (j=1;j<=cnt;j++) sum+=b[j];
	if (a[k]>sum||sum>2ll*a[k]){
		printf("NO\n");
		tag=0;
		return;
	}
	if (b[cnt]>a[k]){
		printf("NO\n");
		tag=0;
		return;
	}
	dp[k]=2ll*a[k]-sum;
}

int main(){
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	int i;
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%lld",&a[i]);
	for (i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
		d[x]++; d[y]++;
	}
	if (n==2){
		if (a[1]!=a[2]) printf("NO\n");
		else printf("YES\n");
		return 0;
	}
	tag=1;
	for (i=1;i<=n;i++)
		if (d[i]>1){
			rt=i;
			break;
		}
	for (i=1;i<=n;i++)
		if (d[i]==1){
			dp[i]=a[i];
			all+=a[i];
		}
	dfs(rt,0);
	if (tag){
		if (dp[rt]!=0) printf("NO\n");
		else printf("YES\n");
	}
	return 0;
}

Measured memory_bytes: 10880
// Vicfred
// https://atcoder.jp/contests/abc052/tasks/arc067_b
// greedy
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

void main() {
    long n, a, b;
    readf("%s %s %s", &n, &a, &b);
    readln;

    long[] x = readln.split.map!(to!long).array;

    long answer = 0;
    for(int i = 1; i < n; ++i) {
        answer += min(b, (x[i]-x[i-1])*a);
    }

    answer.writeln;
}



Measured memory_bytes: 4532
#include <iostream>
#include<vector>
#include <math.h>
#include<stdio.h>
#include <climits>
#include<algorithm>
#include<string>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define LL  long long 
#define Pi 3.14159265358979;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	vector<char> t;
	char x;
	int d=0,i = 0, j = 0, run=0;
	int ans;
	
	while (cin >> x) {
		t.push_back(x);
	}
	
	rep(i,t.size()) {
		if (t[i] == '?') t[i] = 'D';
		cout << t[i];
	}


	cout << "\n";
	
}


Measured memory_bytes: 3796
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

// https://atcoder.jp/contests/abc088/tasks/abc088_b
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();

		Integer[] numbers = new Integer[n];
		for(int i=0;i<n;i++) {
			numbers[i] = scanner .nextInt();
		}

		scanner.close();

		// 配列をソート（降順）
		Arrays.sort(numbers,Collections.reverseOrder());

		int sum1 = 0;
		int sum2 = 0;
		for(int i=0;i<n;i++) {
			if(i%2==0) {
				sum1 = sum1 + numbers[i];
			} else {
				sum2 = sum2 + numbers[i];
			}
		}
		System.out.println(sum1-sum2);
	}

}

Measured memory_bytes: 23124
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <numeric>
 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
ll N,K;
ll A[200005];
ll B[200005];
ll C[400005];
ll D[400005];
ll m;
ll plu;
int main() {
    cin >> N >> K;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    for(int i=0;i<K;i++){
        for(int j=0;j<N;j++){
            plu++;
            C[A[j]+j+1] -= 1;
            plu += C[j];
            C[j] = 0;
            B[j] = plu;
        }
        plu = 0;
        for(int j=0;j<N;j++){
            D[A[N-j-1]+j+1] -= 1;
            plu += D[j];
            B[N-j-1] += plu;
            D[j] = 0;
            plu++;
        }
        bool found = true;
        for(int j=0;j<N;j++){
            if(B[j] != N){
                found = false;
            }
            A[j] = B[j];
            B[j] = 0;
            
        }
        if(found){
            for(int i=0;i<N;i++){
                cout << A[i] << " ";
            }
            return 0;
        }
        plu = 0;
    }
    
    for(int i=0;i<N;i++){
        cout << A[i] << " ";
    }
    
    return 0;
}


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

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


Measured memory_bytes: 256
def win(t):
  if t == "g":
    return "p"
  if t == "c":
    return "g"
  if t == "p":
    return "c"

N, K = map(int, input().split())
G, C, P = map(int, input().split())
T = input().replace("r", "g").replace("s", "c")

point = {"g": G, "c": C, "p": P}

check = [None] * (N + K)
answer = 0
for i in range(N):
  w = win(T[i])
  if check[i] != w:
    answer += point[w]
    check[i + K] = w
    
print(answer)

Measured memory_bytes: 4656
#include <bits/stdc++.h>
#include <math.h>
#include <iostream>
#include <stdlib.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
 
int main(void){
    string S;
    cin >> S;
    int n = (int)(S.length());
    REP(i,n){
        if(i%2==1&&S[i]=='R'){
            cout << "No" << endl;
            return 0;
        }
        else if(i%2==0&&S[i]=='L'){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

const ll mod = 1000000007 ;

bool isInteger(double n)
{
	if(floor(n)==ceil(n))
		return true ;
	return false ;
}

using namespace std ;

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


Measured memory_bytes: 3572
import scala.io.StdIn

object Main extends App {

  val Array(h, w) = StdIn.readLine().split(' ').map(_.toInt)

  val tiles = (0 until h).map(_ => StdIn.readLine().split(' ')).toArray
  val square = Array.fill[Int](h + 1, w + 1)(0)
  var max = 0

  (1 to h).foreach { i =>
    (1 to w).foreach { k =>
      square(i)(k) = if (tiles(i - 1)(k - 1) == "0") {
        (scala.math.min(square(i)(k - 1),
          scala.math.min(square(i - 1)(k - 1), square(i - 1)(k)))) + 1
      } else {
        0
      }

      max = scala.math.max(square(i)(k), max)
    }
  }

  println(max * max)

}


Measured memory_bytes: 192140
N,M = map(int,input().split())
XYZ = [list(map(int,input().split())) for _ in [0]*N]
W = [[0]*N for _ in [0]*4]
for i,xyz in enumerate(XYZ):
    x,y,z = xyz
    W[0][i] = x+y+z
    W[1][i] = x+y-z
    W[2][i] = x-y+z
    W[3][i] = x-y-z
ans = 0
for i in range(4):
    W[i].sort()
    ans = max(ans,
             abs(sum(W[i][:M])),
             abs(sum(W[i][-M:])))
if M==0:ans=0
print(ans)

Measured memory_bytes: 3444
n = gets.chomp.to_i
b_arr = gets.chomp.split(" ").map(&:to_i) + [10**5+1]

a_arr = []
b_arr.each_cons(2).with_index do |(b1, b2), i|
  a_arr[i] = (a_arr[i].nil? ? b1 : [a_arr[i], b1].min)
  if b1 > b2 then
    a_arr[i+1] = b2
  else
    a_arr[i+1] = b1
  end
end

puts a_arr.inject(&:+)


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int main(){
	int N;
	cin>>N;
	V<int> a(N);
	rep(i,N) cin>>a[i],a[i]*=N;
	int sm = 0;
	rep(i,N) sm += a[i];
	sm/=N;
	int x = 0;
	rep(i,N){
		if(abs(sm-a[x])>abs(sm-a[i])) x = i;
	}
	cout<<x<<endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<ll> v;
  ll sum = 0;
  rep(i,N){
    ll a;
    cin >> a;
    v.push_back(a);
    sum += a;
  }

  ll mn = sum;
  ll base = 0;
  rep(i,N){
    base += v[i];
    mn = min(mn, abs((sum-base)-base));
  }

  cout << mn << endl;
  
  
  return 0;
}



Measured memory_bytes: 2420
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);


int main() {
    int a, b;
    cin >> a >> b;
    if (b % a == 0) cout << a + b << endl;
    else cout << b - a << endl;
    return 0;
}

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

vector<string> splitWords(string s)
{
    vector<string> words;
    for(int i = 0; i < (int)s.size(); ++i)
    {
        string w = s.substr(i,1);
        int j = i+1;
        while(j < (int)s.size()
        && s[i] == s[j])
        {
            w+=s[j];
            ++i;
            ++j;
        }
        words.push_back(w);
    }
    return words;
}

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

    vector<string> words;
    words = splitWords(s);

    if(words[0] == s)
    {
        cout << (long long)s.size()*k/2 << endl;
        return 0;
    }

    long long int count = 0;
    for(int i = 0; i < (int)words.size(); ++i)
    {
        if(i == 0
        || i == (int)words.size()-1)
        {
            continue;
        }
        count += ((long long)words[i].size() / 2) * k;
    }
    
    count += (long long)((words.begin())->size()) / 2;
    count += (long long)((words.rbegin())->size()) / 2;
    string ab = *(words.begin()) + *(words.rbegin());

    vector<string> abWords = splitWords(ab);
    for(int i = 0; i < (int)abWords.size(); ++i)
    {
        count += ((long long)abWords[i].size() / 2) * (k-1);
    }

    cout << count << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int id,degree;
      int[] child;
      String[] words;
      Tree tree = new Tree(n);

      for(int i=0,k=0; i<n; i++,k=0){
        words = br.readLine().split(" ");
        id = Integer.parseInt(words[k++]);
        tree.node[id].id     = id;
        tree.node[id].degree = degree = Integer.parseInt(words[k++]);
        tree.node[id].child  = child  = new int[degree];

        for (int j=0,c=0,l=0; j<degree; j++,l=c) {
          c = child[j] = Integer.parseInt(words[k++]);

          if( j==0 ) tree.node[id].leftChild = c;
          else tree.node[l].rightSibling = c;

          tree.node[c].parent = id;
        }
      }

      int root=0;
      for (TreeNodeB e : tree.node)
        if(e.parent == Tree.NIL) root = e.id;
      tree.calcDepth(root, 0);

      System.out.print(tree.dispTreeNode());
    }
    catch(IOException e) {
      System.out.println("IOException!");
    }
  }
}

class Tree {

  static final int NIL = -1;
  TreeNodeB[] node;

  public Tree(int size) {
    node = new TreeNodeB[size];
    for (int i=0; i < size; i++) {
      node[i] = new TreeNodeB();
    }
  }

  void calcDepth(int u, int p) {
    do {
      node[u].setDepth(p);

      if( node[u].leftChild != Tree.NIL )
        calcDepth(node[u].leftChild, p+1);
      
      u = node[u].rightSibling;
    } while( u != Tree.NIL);
  }

  public String dispTreeNode() {
    StringBuilder s = new StringBuilder();

    for (TreeNodeB n : node)
      s.append(n).append("\n");

    return s.toString();
  }
}

class TreeNodeB {
  int id,degree,parent;
  private int depth,type;
  int leftChild,rightSibling;
  int[] child;

  public TreeNodeB() {
    this.id =
    this.degree =
    this.parent =
    this.leftChild =
    this.rightSibling = Tree.NIL;
  }

  public String getType() {
    switch(type) {
      case 0:
        return "root";
      case 1:
        return "internal node";
      default:
        return "leaf";
    }
  }
  public void setDepth(int d) {
    depth = d;
    if(depth > 0) {
      if(degree > 0)
        setType(1);
      else
        setType(2);
    }
  }
  public void setType(int t) {
    this.type = t;
  }

  @Override
  public String toString() {
    return "node " + id + ": parent = " + parent + ", depth = " + depth + ", "
      + getType() +", " + Arrays.toString(child);
  }
}


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

int main(void) {

    int n, k;
    int sum = 0;
    vector<int> x;
    cin >> n;
    cin >> k;
    for (int i = 0; i < n; i++) {
        int xx;
        cin >> xx;
        x.emplace_back(xx);
    }
    for (auto y : x) {
        sum += (y < abs(y - k)) ? 2 * y : 2 * abs(y - k);
    }
    cout << sum << endl;
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
  ll dp[100005][13];
int main() {
  string s; cin >> s;
  int n = s.size();
  dp[0][0] = 1;
  for(ll i=0;i<n;i++) {
    int t;
    if (s[i] == '?') t = -1;
    else t = s[i] - '0';
    for(ll j=0;j<10;j++) {
      if (t != -1 && t != j) continue;
      for(ll k=0;k<13;k++) {
        dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
      }
    }
    for(int j=0;j<13;j++) dp[i + 1][j] %= mod;
  }

  cout << dp[n][5] << endl;
}


Measured memory_bytes: 10624
#include <bits/stdc++.h> 
using namespace std; 
#define vll vector<long long>
#define mll map<long long,long long>
#define pb push_back
typedef  long long ll;
typedef long double ld;
long double pi=3.14159265358979323846;

vll al[500005];
ll vis[500005],color[500005],I[101][101];

ll gcd(ll a,ll b)
{
    if (b==0) return a;
    return gcd(b,a%b);
}

bool isPrime(int n)
{
    if (n<=1) return false; 
    if (n<=3) return true; 
    if (n%2==0||n%3==0) return false; 
    for (int i=5;i*i<=n;i=i+6) if (n%i==0||n%(i+2)==0) return false; 
    return true; 
}

ll bpow(ll n, ll po)
{
	ll res=1;
	while(po>0)
	{
		if(po%2)
		{
			res*=n;
			po--;
		}
		else
		{
			n*=n;
			po/=2;
		}
	}
	return res;
}

ll binpow(ll n, ll po, ll mod)
{
	ll res=1;
	while(po>0)
	{
		if(po%2)
		{
			res=(res*n)%mod;
			po--;
		}
		else
		{
			n=(n*n)%mod;
			po/=2;
		}
	}
	return res;
}

ll swap(ll a, ll b)
{
	a=a+b;
	b=a-b;
	a=a-b;
}

ll fact(ll n) { 
   if ((n==0)||(n==1))
      return 1;
   else
      return n*fact(n-1);
}

ll C(ll n, ll r) {
    if(r > n - r) r = n - r; 
    ll ans = 1;
    ll i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
        ans=ans%1000000007;
    }

    return ans;
}

//bool bipartite_dfs(ll node, ll flag)
//{
//	vis[node]=1;
//	ll cflag=flag;
//	color[node]=cflag;
//	for(ll child : al[node])
//	{
//		if(!vis[child])
//		{
//			bool n=bipartite_dfs(child,1-cflag);
//			if(n==false) return false;
//		}
//		else if(color[child]==color[node]) return false;
//	}
//	return true;
//}

void mmul(ll A[][101], ll B[][101], ll dim)
{
	ll res[dim][dim];
	for(ll i=0;i<dim;i++) for(ll j=0;j<dim;j++)
	{
		res[i][j]=0;
		for(ll k=0;k<dim;k++) res[i][j]=(res[i][j]+A[i][k]*B[k][j])%1000000007;
	}
	for(ll i=0;i<dim;i++) for(ll j=0;j<dim;j++) A[i][j]=res[i][j];
}

void mpow(ll A[][101],ll dim, ll po)
{
	for(ll i=0;i<dim;i++) for(ll j=0;j<dim;j++)
	{
		if(i==j) I[i][j]=1;
		else I[i][j]=0;
	}
	while(po>0)
	{
		if(po%2==1)
		{
			mmul(I,A,dim);
			po--;
		}
		else
		{
			mmul(A,A,dim);
			po/=2;
		}
	}
	for(ll i=0;i<dim;i++) for(ll j=0;j<dim;j++) A[i][j]=I[i][j];
}


int main()
{
	ll n,ans=0;
	cin>>n;
	ll b=n;
	for(ll i=2;i*i<=b;i++)
	{
		ll x=0;
		while(n%i==0)
		{
			x++;
			n/=i;
		}
		ll g=1;
		while(g*(g+1)/2<=x)
		{
			ans++;
			g++;
		}
	}
	if(n>1) ans++;
	cout<<ans;
}

Measured memory_bytes: 15332
using System;

namespace abc131_c
{
    class Program
    {
        static void Main(string[] args)
        {
            var tmp = Console.ReadLine().Split();
            var a = long.Parse(tmp[0]);
            var b = long.Parse(tmp[1]);
            var c = long.Parse(tmp[2]);
            var d = long.Parse(tmp[3]);
            var lcm = c * d / Gcd(c, d);

            var numberADiv = a / c + a / d - a / lcm;
            var numberBDiv = b / c + b / d - b / lcm;
            var totalDiv = numberBDiv - numberADiv;
            var result = b - a - totalDiv;
            if (a % c != 0 && a % d != 0)
            {
                result++;
            }
            Console.WriteLine(result);
        }

        private static long Gcd(long m, long n)
        {
            while (true)
            {
                if (m < n)
                {
                    var m2 = m;
                    m = n;
                    n = m2;
                    continue;
                }

                if (n == 0) return m;
                var m1 = m;
                m = n;
                n = m1 % n;
            }
        }
    }
}


Measured memory_bytes: 13140
import sys
sys.setrecursionlimit(500000)
input = sys.stdin.readline
N = int(input()); MOD=pow(10,9)+7
G = [[] for _ in range(N)]
for i in range(N-1):
  a,b = map(int,input().split())
  a-=1;b-=1
  G[a].append(b);G[b].append(a)
#print(G)
ans = 0

def dfs(v,p): #自分と親
  global ans #ansをGlobal変数として宣言
  res = 1 #戻り値。vを含めた部分木のサイズ。自分の分で最初は1
  ts = [] #vから生えている部分木のリスト
  for u in G[v]:
    if u == p:
      continue
    t = dfs(u,v) #uの部分木のサイズが戻り値
    res += t
    ts.append(t)
  if p != -1: #根以外なら親側の部分木が存在する。
    ts.append(N-res)
  now = pow(2,N-1,MOD) - 1 #自分以外を決めるのが2^(N-1)通り。自分以外が全部0が1通り。
  for x in ts:
    now -= pow(2,x,MOD) - 1 #各部分木に一個以上黒がある場合の数。全通り - 全部白
  ans = (ans+now)%MOD
  return res #vを含めた部分木のサイズ

dfs(0,-1)
ALL = pow(2,N,MOD)
#print(ans,ALL)
ans = ans*pow(ALL,MOD-2,MOD)%MOD #フェルマーの小定理より1/ALL = ALL^(MOD-2)
print(ans)
           

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

int main(){

  double h;
  double max=0,min=10000000;

  while(cin >> h){

    if(h>max){
      max=h;
    }
    if(h<min){
      min=h;
    }
  }
  cout << max-min << endl;
  return 0;
}

Measured memory_bytes: 3260
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;



int main(void){
    ll n,k;
    cin>>n>>k;
    int ans = 0;
    while(n>=k){
        n/=k;
        ans++;
    }
    cout<<ans+1<<endl;
    return 0;
}

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

int main()
{
    string X;
    cin >> X;

    int S = 0;
    int T = 0;
    for(char c:X)
    {
        if(c == 'T')
        {
            if(S) S--;
            else T++;
        }
        else
        {
            S++;
        }
    }
    cout << S+T << '\n';
    return 0;
}

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

int main(void) {
  string b;
  cin >> b;
  for (auto c : b) {
    if (c == 'A') cout << "T";
    if (c == 'T') cout << "A";
    if (c == 'G') cout << "C";
    if (c == 'C') cout << "G";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;
using pll = pair<ll, ll>;
using T = tuple<ll, int, int>;

int n, m;
ll s;

const int max_a = 50;
const int max_n = 50;
const ll max_s = (max_n - 1) * max_a + 10;

struct Edge{
  int to, fare;
  ll time;
  Edge(int to, int f, ll t) : to(to), fare(f), time(t){}
};

vector<vector<Edge>> g;

vector<ll> c;
vector<ll> d;

vector<vector<ll>> dist;
void dijkstra(int start){
  dist.assign(n, vector<ll>(max_s + 1, LINF));
  dist[start][s] = 0;
  priority_queue<T, vector<T>, greater<T>> que;
  que.push(T(dist[start][s], start, s));

  while(!que.empty()){
    auto v = que.top();
    que.pop();
    int from, cur_s;
    ll dis;
    tie(dis, from, cur_s) = v;
    if(dis > dist[from][cur_s])continue;

    int ns = min(cur_s + c[from], max_s);
    if(dist[from][cur_s] + d[from] < dist[from][ns]){
      dist[from][ns] = dist[from][cur_s] + d[from];
      que.push(T(dist[from][ns], from, ns));
    }

    for(auto nv : g[from]){
      int to = nv.to;
      ll time = nv.time;
      int fare = nv.fare;
      int ns = cur_s - fare;
      if(ns < 0)continue;
      if(dist[from][cur_s] + time < dist[to][ns]){
	      dist[to][ns] = dist[from][cur_s] + time;
	      que.push(T(dist[to][ns], to, ns));
      }
    }
  }
}

int main(){
  cin >> n >> m >> s;
  g.resize(n);
  for(int i = 0; i < m; ++i){
    int u, v, a;
    ll b;
    cin >> u >> v >> a >> b;
    --u;
    --v;
    g[u].emplace_back(v, a, b);
    g[v].emplace_back(u, a, b);
  }
  c.resize(n);
  d.resize(n);  
  for(int i = 0; i < n; ++i){
    cin >> c[i] >> d[i];
  }

  s = min(s, max_s);
  dijkstra(0);

  for(int i = 1; i < n; ++i){
    ll ans = LINF;
    for(int j = 0; j <= max_s; ++j){
      ans = min(ans, dist[i][j]);
    }
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 6224
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define MAX 501
#define B 100
#define dmp make_pair
#define dpb push_back
#define fi first
#define se second
#define P pair<int,int>
typedef long long ll;
const int inf = 1e9;
const ll INF = 1e18;
using namespace std;
//__gcd(a,b), __builtin_popcount(a);

chrono::system_clock::time_point  start;
void timerstart(){start = chrono::system_clock::now();}
void timerend(){
	auto end = chrono::system_clock::now();
	int elapsed = chrono::duration_cast<chrono::milliseconds>(end-start).count();
	printf("%d[ms]\n", elapsed);
}

int a[MAX], b[MAX], c[MAX], d[MAX];
int main(){
	int n;
	scanf("%d", &n);
	rrep(i,n-1){
		scanf("%d%d%d", &a[i], &b[i], &c[i]);
	}
	
	int p, t;
	for(int i = 1;i < n;i++){
		p = 0;
		for(int j = i;j < n;j++){
			if(p <= b[j]){
				p += b[j]-p;
			}else{
				t = (p-b[j])%c[j];
				if(t != 0)p += c[j]-t;
				//printf("*%d %d* ", c[], t);
			}
			p += a[j];
			//printf("%d ", p);
		}
		printf("%d\n", p);
	}
	printf("0\n");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b,c,d,e,f;
	while(~scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f)){
		double y=(double)(c*d-a*f)/(double)(b*d-a*e);
		if(a!=0)
		printf("%.3f %.3f\n",(c-b*y)/a,y);
		else
		printf("%.3f %.3f\n",(f-e*y)/d,y);
	}
}

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

int main ()
{
	int a[100][100]={0},m,n,i,j;
	cin>>n>>m;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			char tmp;
			cin>>tmp;
			if(tmp=='#')
				a[i][j]=-1;
			else
				a[i][j]=0;
		}
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			if(a[i][j]==-1)
				continue;
			if(a[i-1][j]==-1)
				a[i][j]++;
			if(a[i-1][j-1]==-1)
				a[i][j]++;
			if(a[i-1][j+1]==-1)
				a[i][j]++;
			if(a[i][j-1]==-1)
				a[i][j]++;
			if(a[i][j+1]==-1)
				a[i][j]++;
			if(a[i+1][j+1]==-1)
				a[i][j]++;
			if(a[i+1][j-1]==-1)
				a[i][j]++;
			if(a[i+1][j]==-1)
				a[i][j]++;
		}
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			if(a[i][j]==-1)
				cout<<"#";
			else
				cout<<a[i][j];
		}
		cout<<endl;
	}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e3 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;
 
int a[N][N];

signed main() {
    IOS;
    int n, m, k;
    cin >> n >> m >> k;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            char c; cin >> c;
            a[i][j] = c - '0';
            a[i][j] += a[i][j-1] + a[i-1][j] - a[i-1][j-1];
        }
    }
    int ans = inf;
    for(int i = 0; i < (1 << (n-1)); i++){
        vector<int> v;
        v.push_back(0);
        for(int j = 0; j < n; j++){
            if((1 << j) & i)
                v.push_back(j+1);
        }
        v.push_back(n);
        int l = 0;
        bool f = 1;
        int cur = __builtin_popcountll(i);
        for(int j = 1; j <= m; j++){
            for(int r = 1; r < (int)v.size(); r++){
                int s = a[v[r]][j] - a[v[r]][j-1] - a[v[r-1]][j] + a[v[r-1]][j-1];
                if(s > k)
                    f = 0;
            }
            for(int r = 1; r < (int)v.size(); r++){
                int s = a[v[r]][j] - a[v[r]][l] - a[v[r-1]][j] + a[v[r-1]][l];
                if(s > k){
                    cur++;
                    l = j - 1;
                    break;
                }
            }
        }
        if(f)
            ans = min(ans, cur);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main()
{
    int n, C;
    scanf("%d %d", &n, &C);
    int i, j, k;
    int d[33][33];
    for (i = 0; i < C; i++)
        for (j = 0; j < C; j++)
            scanf("%d", &d[i][j]);
    int c[505][505];
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < n; j++)
        {
            scanf("%d", &c[i][j]);
            c[i][j]--;
        }
    }
    int ans = 2000000000;
    int x, y;
    int a;
    int v[3][33];
    for (i = 0; i < 3; i++)
        for (j = 0; j < C; j++)
            v[i][j] = 0;
    for (i = 0; i < C; i++)
        for (x = 0; x < n; x++)
            for (y = 0; y < n; y++)
                v[(x + y) % 3][i] += d[c[x][y]][i];
    for (i = 0; i < C; i++)
    {
        for (j = 0; j < C; j++)
        {
            if (i != j)
            {
                for (k = 0; k < C; k++)
                {
                    if (i != k && j != k)
                    {
                        a = v[0][i] + v[1][j] + v[2][k];
                        if (ans > a)
                            ans = a;
                    }
                }
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1152
// ctrl+shift+b
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N; cin >> N;
    string s = to_string(N);
    rep(i, s.size()){
        if (s[i] == '1'){s[i] = '9';}
        else if (s[i] == '9'){s[i] = '1';}
    }
    cout << stoi(s) << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int main() {
    int a[5][205], dp[5][105];

    int n;
    cin >> n;
    for(int i=1; i<=2; i++) for(int j=1; j<=n; j++) cin >> a[i][j];
    for(int i=1; i<=2; i++) {
        for(int j=1; j<=n; j++) {
            dp[i][j] = max(dp[i][j-1], dp[i-1][j]) + a[i][j];
        }
    }
    cout << dp[2][n];
}

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

int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int ans = 0;
  if(a < c){
    ans = min(b, d) - c;
    if(ans < 0) ans = 0;
  }
  else if(c < a){
    ans = min(b, d) - a;
    if(ans < 0) ans = 0;
  }
  else{
    ans = min(b, d) - a;
  }
    
  

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000000



int main(){
	
	long long N;
	cin>>N;
	
	map<long long,int> mp;
	
	for(long long i=2;i*i<=N;i++){
		
		while(N%i==0){
			mp[i]++;
			N/=i;
		}
	}
	
	if(N!=1)mp[N]++;
	
	long long ans = 0;
	
	for(auto a:mp){
		for(int i=1;true;i++){
			if(a.second<i)break;
			a.second-=i;
			ans++;
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}

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

int main(void)
{
    int n, k;
    cin >> n >> k;

    vector<int> s_height(n,0);

    for(int i = 0; i < n; ++i)
    {
        int tmp;
        cin >> tmp;
        s_height.at(i) = tmp;
    }
    
    vector<int> s_cost(n,2000000000);
    s_cost.at(0) = 0;

    for(int i = 0; i < n; ++i)
    {
        for(int j = 1; j <= k; ++j)
        {
            if(i+j < n) s_cost.at(i+j) = min(s_cost.at(i+j), s_cost.at(i)+abs(s_height.at(i+j)-s_height.at(i)));
        }
    }

    cout << s_cost.at(n-1) << endl;

    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int p,n,k; 
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&p);
		if(p!=i){
			k++;
		}
	}
	if(k>2){
		printf("NO");
	}
	else printf("YES");
	return 0;
} 


Measured memory_bytes: 384
s = input()
s0 = int(s[0]) * 10 + int(s[1])
s1 = int(s[2]) * 10 + int(s[3])

if 0 < s0 < 13:
    if 0 < s1 < 13:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 0 < s1 < 13:
        print("YYMM")
    else:
        print("NA")


Measured memory_bytes: 2940
s=input()
s2=s[0: :2]
s1=s[1: :2]
ans=0

for i in range(len(s1)):
    if s1[i]=='L' or s1[i]=='U' or s1[i]=='D':
        ans+=1
    else:
        print('No')
        break

if ans==len(s1):   
    for i in range(len(s2)):
        if s2[i]=='R' or s2[i]=='U' or s2[i]=='D':
            ans+=1
        else:
            print('No')
            break
        
if ans==len(s):
    print('Yes')  

Measured memory_bytes: 3064
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  int n, a;
  cin >> n >> a;

  cout << (n * n - a) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

char ChangeChara(std::string S, int i){
	char s;
	if (S[i] == 'A') s = 'a';
	else if (S[i] == 'B') s = 'b';
	else if (S[i] == 'C') s = 'c';

	return s;
}

int main()
{
	int N = 0, K = 0;
	std::string S, ans;
	 std::cin >> N >> K >> S;
	 K--;
	 ans = S;
	 ans[K] = ChangeChara(S, K);

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256