akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC129_C
{
    class Program
    {
        static long[] fibo = new long[100001];
        static long mod = 1000000007;
        static void Main(string[] args)
        {
            var NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var a = new int[NM[1]];
            var imp = false;
            for (int i = 0; i < NM[1]; i++)
            {
                a[i] = int.Parse(Console.ReadLine());
                if (i > 0 && a[i] - a[i - 1] == 1)
                {
                    imp = true;
                }
            }

            if (imp)
            {
                Console.WriteLine(0);
            }
            else
            {
                long ans = 0;
                var temp = 0;
                foreach (var i in a)
                {
                    if (ans == 0)
                    {
                        ans += CalcFibo(i - 1 - temp);
                    }
                    else
                        ans *= CalcFibo(i - 1 - temp);
                    ans %= mod;

                    temp = i + 1;
                }

                if (ans == 0)
                {
                    ans += CalcFibo(NM[0] - temp);
                }
                else
                    ans *= CalcFibo(NM[0] - temp);
                ans %= mod;

                Console.WriteLine(ans);
            }
        }

        static long CalcFibo(int n)
        {
            if (n <= 1) return 1;
            if (fibo[n] != 0) return fibo[n];
            fibo[n] = (CalcFibo(n - 1) + CalcFibo(n - 2))%mod;

            return fibo[n];
        }
    }
}


Measured memory_bytes: 14176
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

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

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

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

	return 0;
}

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

int main() {
  string n;
  cin >> n;
  string ans = "No";
  rep(i, int(n.length())) {
    if (n[i] == '7') ans = "Yes";
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<(n);i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
vector<string>res;
void dfs(int n,string s,int m){
    if(s.length()==n){
        res.push_back(s);
        return;
    }
    for(char a = 'a';(a-'a')<=m+1;a++){
        dfs(n,s+a,max(a-'a',m));
    }
}
int main(){
    int n;cin>>n;
    dfs(n,"a",0);
    sort(been(res));
    for(auto s:res){
        cout<<s<<endl;
    }
}

Measured memory_bytes: 7796
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main()
{
  int n;
  cin >> n;
  int x[n], y[n];
  double D[4]={};
  for(int i=0;i<n;i++)
    cin >> x[i];
  for(int i=0;i<n;i++)
    cin >> y[i];
  D[0] = fabs(x[0]-y[0]);
  for(int i=0;i<n;i++)
    {
      D[1] += abs(x[i]-y[i]);
      D[2] += (x[i]-y[i])*(x[i]-y[i]);
      D[3] += fabs((x[i]-y[i])*(x[i]-y[i])*(x[i]-y[i]));
      fabs(x[i]-y[i]) >= D[0] ? ( D[0] = fabs(x[i]-y[i]) ):(0);
    }
  D[2] = sqrt(D[2]);
  D[3] = pow(D[3], (double)1/3);

  cout << fixed << setprecision(6)
       << D[1] << endl
       << D[2] << endl
       << D[3] << endl
       << D[0] << endl;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = a; i < n; i++)
#define Repr(i, n, a) for (int i = n; i >= a; i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    vector<int> c(n);
    rep(i, n) c[i] = a[i] + b[i];
    sort(all(c));
    reverse(all(c));
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (i % 2 == 1)
            continue;
        else
            ans += c[i];
    }
    rep(i, n) ans -= b[i];
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;

signed main(){
	
	int k,a,b,ans=0;
	cin>>k>>a>>b;
	if(b-a<2 || k<2)ans=1+k;
	else{
	    //a-1 k-(a-1)
	    k-=(a-1);
	    //ans+=(a-1);
	    ans=a+(b-a)*(k/2)+k%2;
	}
	cout<<ans<<endl;
}

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

int main(){

	int N;
	int state = 1; //??????
	cin >> N;
	char ID[N][11];
	for (int i = 0; i <= N-1; i++){
		cin >> ID[i];
	}

	int M;
	cin >> M;
	char IC[M][11];

	for (int i = 0; i <= M-1; i++){
		cin >> IC[i];
		int check = 0;
		for (int j = 0; j<= N-1; j++){
			if(strcmp(IC[i],ID[j]) == 0){
				if (state == 1){
					state = 0;
					check = 1;
					cout << "Opened by" << " " << ID[j] << endl;
				}
				else if (state == 0){
					state = 1;
					cout << "Closed by" << " " << ID[j] << endl;
					check = 1;
				}
			}
		}
		if (check == 0){
				cout << "Unknown" << " " << IC[i] << endl;
			}
	}
}

Measured memory_bytes: 1164
#include<iostream> 
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++) 

int main() {
    int K, A, B;
    cin >> K >> A >> B;
    int Counter = 0;
    for (int i = A; i <= B; i++) {
        if (i % K == 0) {
            Counter += 1;
        }
    }

    if (Counter == 0) {
        cout << "NG" << endl;
    } else cout << "OK" << endl;

}

Measured memory_bytes: 3652
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
#include<set>
#include<array>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i);
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

using namespace std;

int main(){
  
  int n;
  cin >> n;
  vector<int> l = vector<int>(n,0);
  rep(i,n){
    cin >> l[i];
    l[i]-=1;
  }
 
  int cnt=0;
  rep(i,n){
    if(i == l[l[i]]) cnt++;
  }

  cout << cnt/2 << endl;
}




Measured memory_bytes: 640
import java.util.*;

public class Main {
	static Test[] tests;
	static int d;
	static int g;

	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		d = sc.nextInt();
		g = sc.nextInt();
		tests = new Test[d];
		for (int i = 0; i < d; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			tests[i] = new Test(i + 1, a, b);
		}
		System.out.println(getResult(0, 0, 0, 0, 0).count);
	}
	
	static Result getResult(int idx, int count, int point, int rCount, int rPoint) {
		if (point >= g) {
			return new Result(count, point);
		}
		if (idx >= d) {
			for (int i = 1; i <= rCount; i++) {
				if (point + i * rPoint >= g) {
					return new Result(count + i, g);
				}
			}
			return null;
		}
		Result r1 = getResult(idx + 1, count + tests[idx].count, point + tests[idx].getBonus(), rCount, rPoint);
		Result r2 = getResult(idx + 1, count, point, tests[idx].count - 1, tests[idx].getPoint());
		if (r1 == null) {
			return r2;
		} else if (r2 == null) {
			return r1;
		} else {
			if (r2.count < r1.count) {
				return r2;
			} else {
				return r1;
			}
		}
	}
	
	static class Result {
		int count;
		int point;
		
		public Result(int count, int point) {
			this.count = count;
			this.point = point;
		}
		
		public String toString() {
			return "count:" + count + " point:" + point;
		}
	}
	
	static class Test {
		int idx;
		int count;
		int bonus;
		
		public Test(int idx, int count, int bonus) {
			this.idx = idx;
			this.count = count;
			this.bonus = bonus;
		}
		
		public int getBonus() {
			return count * getPoint() + bonus;
		}
		
		public int getPoint() {
			return idx * 100;
		}
	}
}


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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = (1LL<<31)-1;
const int mod = 1e9 + 7;

struct SegmentTree {
  vector<int> data;
  int sz;
  SegmentTree(int n) {
    sz = 1; while(sz < n) sz <<= 1;
    data.resize(2*sz-1, 0);
  }
  void add(int a, int b, int x, int k, int l, int r) {
    if(r <= a || b <= l) return;
    if(a <= l && r <= b) {
      data[k] += x;
      return;
    }
    add(a, b, x, 2*k+1, l, (l+r)/2);
    add(a, b, x, 2*k+2, (l+r)/2, r);
  }
  void add(int a, int b, int x) {
    add(a, b, x, 0, 0, sz);
  }
  int query(int i, int k, int l, int r) {
    if(r - l == 1) return data[k];
    if(l <= i && i <= r) {
      if(i < (l+r)/2) return query(i, 2*k+1, l, (l+r)/2) + data[k];
      else return query(i, 2*k+2, (l+r)/2, r) + data[k];
    }
    return inf;
  }
  int query(int i) {
    return query(i, 0, 0, sz);
  }
};

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, q;
  cin >> n >> q;
  SegmentTree seg(n);
  rep(i, q) {
    int com, s, t, x;
    cin >> com >> s;
    if(com == 0) cin >> t >> x, seg.add(s-1, t, x);
    else cout << seg.query(s-1) << endl;
  }

  return 0;
}

Measured memory_bytes: 4936
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long int n,m=1; cin>>n;
  long long int a[n+2];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if(a[i]==0){
      cout<< 0 <<endl;
      exit(0);
    }
  }
  for (int i = 0; i < n; i++) {
    if(1000000000000000000/a[i]<m||m<0){
      cout<< -1 <<endl;
      exit(0);
    }
    
    m*=a[i];
  }
    cout<< m <<endl;

}

Measured memory_bytes: 4364
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

int n;
vector<mp> vs[10005];
int kar[10005];

int dfsb(int no,int p){
	kar[no]=0;
	rep(i,vs[no].size()){
		int to=vs[no][i].fir,
			co=vs[no][i].sec;
		if(to==p)continue;
		int tc=dfsb(to,no)+co;
		kar[no]=max(kar[no],tc);
	}
	return kar[no];
}

int dp[10005];

void dfs(int no,int p){
	vector<int> nds(1,dp[no]);
	rep(i,vs[no].size()){
		int to=vs[no][i].fir,
			co=vs[no][i].sec;
		if(to==p)continue;
		nds.push_back(kar[to]+co);
	}
	sort(nds.begin(),nds.end(),greater<int>());
	dp[no]=nds[0];
	rep(i,vs[no].size()){
		int to=vs[no][i].fir,
			co=vs[no][i].sec;
		if(to==p)continue;
		int upc=nds[0];
		if(kar[to]+co==upc)upc=nds[1];
		upc+=co;
		dp[to]=max(dp[to],upc);
		
		dfs(to,no);
	}
}

int main(void){
	scanf("%d",&n);
	rep(i,n-1){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		vs[a].push_back(mp(b,c));
		vs[b].push_back(mp(a,c));
	}
	dfsb(0,-1);
	//rep(i,n)printf("%d\n",kar[i]);
	dfs(0,-1);
	
	rep(i,n)printf("%d\n",dp[i]);

	return 0;
}

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

void lcs(string s1,string s2,int l1,int l2)
{
    int dp[l1+5][l2+5];
    for(int i=0; i<=l1; i++)
        dp[i][0]=0;
    for(int i=0; i<=l2; i++)
        dp[0][i]=0;

    for(int i=1; i<=l1; i++)
    {
        for(int j=1; j<=l2; j++)
        {
            if(s1[i-1] == s2[j-1])
                dp[i][j]=1+dp[i-1][j-1];
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    int index=dp[l1][l2];
    char LCS[index+5];
    LCS[index]='\0';
    int i=l1;
    int j=l2;

    while (i > 0 && j > 0)
    {
        if (s1[i-1] == s2[j-1])
        {
            LCS[index-1] = s1[i-1];
            i--;
            j--;
            index--;
        }
        else if (dp[i-1][j] > dp[i][j-1])
            i--;
        else
            j--;
    }

    cout<<LCS<<endl;
}

int main()
{
    string s1,s2;
    cin>>s1>>s2;
    int l1=s1.length();
    int l2=s2.length();
    lcs(s1,s2,l1,l2);
}


Measured memory_bytes: 35456
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long long X, A, B, uresisa = 0;
    cin >> X;
    A = X / 500; //500円の枚数
    B = (X - (A * 500))/ 5; //5円の枚数
    
   // cout << A << " "<< B;
    uresisa = A * 1000 + B * 5;
    cout << uresisa;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<ll, ll> p;

#define MOD 1000000007

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    ll mod = pow(10, 9) + 7;

    string L;
    cin >> L;

    ll base = 1LL;
    ll ans = 0;

    for(ll i = 0; i < L.length(); i++) {
        if(L[i] == '0') continue;
        ll k = modpow(3LL, L.length() - i - 1LL, mod);
        k %= mod;
        k *= base;
        k %= mod;
        base *= 2LL;
        base %= mod;
        ans += k;
        ans %= mod;
    }

    ans += base;
    ans %= mod;

    cout << ans << endl;
}

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

using namespace std;

int main() {
	int N;
	cin >> N;
	int pars[N+1];
	int nc[N+1];
	vector<vector<int>> child;
	pars[1] = 0;
	for (int i = 0; i <= N; i++) {
		vector<int> b;
		child.push_back(b);
		nc[i] = 0;
	}
	for(int i = 2; i <= N; i++) {
		cin >> pars[i];
		child[pars[i]].push_back(i);
		nc[pars[i]]++;
	}
	int X[N+1];
	for (int j = 1; j <= N; j++) {
		cin  >> X[j];
	}
	queue<int> q;
	int others[N+1];
	for (int i = 1; i <= N; i++) {
		if (nc[i] == 0) q.push(i);
		others[i] = 0;
	}
	bool ans = true;
	while (!q.empty()) {
		int num = q.front();
		q.pop();
		nc[pars[num]]--;
		if (nc[pars[num]] == 0) q.push(pars[num]);

		others[num] = 0;
		vector<int> swaps;
		int csum = 0;

		for (int i = 0; i < child[num].size(); i++) {
			int v = child[num][i];
			int o1 = min(X[v], others[v]);
			int o2 = max(X[v], others[v]);
			csum += o1;
			others[num] += o2;
			swaps.push_back(o2-o1);
		}
		if (csum > X[num]) {
			ans = false;
			break;
		}
		bool reach[X[num]+1];
		for (int i = 0; i <= X[num]; i++) {
			reach[i] = false;
		}
		reach[csum] = true;

		for (int i = 0; i < swaps.size(); i++) {
			int cur = swaps[i];
			for (int j = X[num]; j >= csum; j--) {
				if (j-cur >= csum && reach[j-cur] && j-cur >= 0) {
					reach[j] = true;
				}
			}
		}
		for (int j = X[num]; j >= csum; j--) {
			if (reach[j]) {
				others[num] -= j-csum;
				break;
			}
		}
	}
	if (ans) cout << "POSSIBLE\n";
	else cout << "IMPOSSIBLE\n";
	// cin >> ans;
}

Measured memory_bytes: 256
#include"iostream"
#include"stdio.h"
using namespace std;
int ball[11];
bool flag;
 
void Dfs(int i,int left,int right)
{
    if(flag) return;
    if(i==10) {flag=true;return;}
 
    if(ball[i]>left)
        Dfs(i+1,ball[i],right);
    if(ball[i]>right)
        Dfs(i+1,left,ball[i]);
}
 
int main()
{
    int t;
    while(scanf("%d",&t)==1)
    {
        while(t--){
            flag=false;
            for(int i=0;i<10;i++)
                cin>>ball[i];
            Dfs(0,0,0);
            if(flag)
                cout<<"YES"<<endl;
            else
                cout<<"NO"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  int X, Y, Z; cin >> X >> Y >> Z;
  cout << (X-Z)/(Y+Z) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()



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



int main() {
    ll k;
    string s;
    cin >> k >> s;
    ll len = s.length();
    if(len <= k){
        cout << s <<endl;
    } else{
        REP(i, k){
            cout << s[i];
        }
        cout << "..." << endl;
    }
}


Measured memory_bytes: 3628
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

c11, c12, c13 = map(int, input().strip().split(" "))
c21, c22, c23 = map(int, input().strip().split(" "))
c31, c32, c33 = map(int, input().strip().split(" "))
if c11 - c12 == c21 - c22 == c31 - c32 and c12 - c13 == c22 - c23 == c32 - c33 and c13 - c11 == c23 - c21 == c33 - c31 and c11 - c21 == c12 - c22 == c13 - c23 and c21 - c31 == c22 - c32 == c23 - c33 and c31 - c11 == c32 - c12 == c33 - c13:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n, m = map(int, input().split())
p = list(map(int, input().split()))
uf = UnionFind(n)
for i in range(m):
  x, y = map(int, input().split())
  x -= 1
  y -= 1
  uf.union(x, y)

ans = 0
for i in range(n):
  p[i] -= 1
  if p[i] == i:
    ans += 1
  elif uf.find(p[i]) == uf.find(i):
    ans += 1

print(ans)


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

using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }

  if (N == 1) {
    cout << "Yes" << endl;
    return 0;
  }
  if (N == 2) {
    if (vec.at(1) - vec.at(0) >= 2) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
    return 0;
  }


  vector<int> newVec;
  newVec.push_back(vec.at(0));
  int last = vec.at(N-1);
  for (int i = 1; i < N-1; i++) {
    if (vec.at(i) != vec.at(i+1)) {
      newVec.push_back(vec.at(i));
    }
  }
  newVec.push_back(last);

  for (int i = newVec.size() - 1; i > 1; i--) {
    if (newVec.at(i-1) - newVec.at(i) >= 2 || newVec.at(i-2) - newVec.at(i) >= 2) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using ll = long long;
// #define int ll
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, int(n) + 1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
// const int MOD = 1000000007;

template <typename T>
void __print__(std::ostream &os, const char *, const char *tail, const T &fst) {
    os << fst << tail;
}
template <typename Fst, typename... Rst>
void __print__(std::ostream &os, const char *del, const char *tail, const Fst &fst,
               const Rst &... rst) {
    os << fst << del;
    __print__(os, del, tail, rst...);
}

#ifdef LOCAL
#define dump(...)                                         \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; \
        __print__(os, ", ", "\n", __VA_ARGS__);           \
        std::cerr << os.str();                            \
    } while (0)
#else
#define dump(...)
#endif

template <typename Fst, typename... Rst>
void println(const Fst &fst, const Rst &... rst) {
    __print__(std::cout, "\n", "\n", fst, rst...);
}
template <typename Fst, typename... Rst>
void print(const Fst &fst, const Rst &... rst) {
    __print__(std::cout, " ", "\n", fst, rst...);
}

template <typename iter>
void println_(iter bgn, iter end) {
    while (bgn != end) println(*bgn++);
}

template <typename iter>
void print_(iter bgn, iter end) {
    while (bgn != end) {
        std::cout << *bgn++;
        std::cout << (bgn == end ? "\n" : " ");
    }
}

int _ = (std::cout.precision(10), std::cout.setf(std::ios::fixed), std::cin.tie(0),
         std::ios::sync_with_stdio(0), 0);

template <typename T>
std::vector<T> ndarray(int n, T v) {
    return std::vector<T>(n, v);
}
template <typename... Args>
auto ndarray(int n, Args... args) {
    auto val = ndarray(args...);
    return std::vector<decltype(val)>(n, move(val));
}

template <typename T>
bool umax(T &a, const T &b) {
    return a < b ? a = b, true : false;
}

template <typename T>
bool umin(T &a, const T &b) {
    return a > b ? a = b, true : false;
}

using namespace std;

int main() {
    int n;
    while (cin >> n) {
        ll a[200010];
        ll s = 0;
        rep(i, n) {
            cin >> a[i];
            s += a[i];
        }
        ll opt = 1e18;
        ll c = 0;
        rep(i, n - 1) {
            c += a[i];
            ll diff = abs((s - c) - c);
            opt = min(opt, diff);
        }
        print(opt);
    }
}

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

#define rr(i, b)    for (int i = 0; i < int(b); i++)
#define vi(n, a) vector <int> a(n); rr(i, n) cin >> a[i]
#define pvec(a) rr(i, a.size()) cout << a[i] << " "; cout << endl
#define bug(x) cout << #x << " " << x << endl
#define ll long long
#define vii vector <int>

using namespace std;

void solve() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    
    cout << max({a*c, a*d, b*d, b*c}) << endl;
}
 
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 3616
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const n = parseInt(args[0][0], 10)
	const a = args.slice(1, n + 1).map(arg => parseInt(arg[0], 10))
	const sortedA = a.slice().sort((t1, t2) => t2 - t1)

	for (let i = 0; i < n; i++) {
		if (a[i] !== sortedA[0]) console.log(sortedA[0])
		else console.log(sortedA[1])
	}
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 72336
#include <bits/stdc++.h>
using namespace std;
int h[100011]  , dp[100011];
 
int main() {
	int n  , k ; 
	scanf("%d %d" , &n , &k) ; 
	for (int i =0 ; i<n ; ++i) {
		scanf("%d" , &h[i]) ; 

	}
	for (int i =0 ; i<n ; ++i)
		dp[i] = 1e9 ; 
	
	dp[0] = 0 ; 
	for (int i = 1 ; i<n ; ++i){
		for (int j = i-1 ; j>=max(0 , i-k) ; --j){
			int mn = abs(h[i]- h[j]) ;
			dp[i] = min(dp[i] , mn+dp[j]) ;  
		//		cout<<dp[i]<<" "<<mn<<" "<<dp[i-j]<<endl;
		}
	
		
	}
	printf("%d\n" , dp[n-1]) ; 
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
int f(int n, int *p){
    int cnt = 1, x[8];
    for(int i=0;i<n;i++) x[i] = i+1;
    do{
        bool flg = true;
        for(int i=0;i<n;i++){
            if(p[i] != x[i]) flg = false;
        }
        if(flg) return cnt;
        cnt++;
    }while(next_permutation(x, x+n));
    return -1;
}
int main(void){
    int n;
    int p[8], q[8];
    cin >> n;
    for(int i=0;i<n;i++) cin >> p[i];
    for(int i=0;i<n;i++) cin >> q[i];
    cout << abs(f(n, p) - f(n, q)) << endl;
    
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int ans = 0;
        int tmp = 0;
        int h1 = Integer.parseInt(sc.next());
        int h2 = 0;
        for(int i = 1;i<n;i++){
            h2 = Integer.parseInt(sc.next());
            if(h1 >= h2){
                tmp += 1;
            }else{
                ans = Math.max(tmp,ans);
                tmp = 0;
            }
            h1 = h2;
            if(i == n -1){
                ans = Math.max(tmp,ans);
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 44716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

const string YES = "Yes";
const string NO = "No";

void solve(long long N)
{
    for (int i = 1; i < 1000010; i++)
    {
        if ((i * (i - 1) / 2) == N)
        {
            cout << YES << endl;
            cout << i << endl;
            vector<vector<ll>> ans(i);
            ll cnt = 1;
            for (int j = 0; j < i; j++)
            {
                for (int k = j + 1; k < i; k++)
                {
                    ans[j].push_back(cnt);
                    ans[k].push_back(cnt);
                    cnt++;
                }
            }
            for (int j = 0; j < i; j++)
            {
                cout << ans[j].size() << " ";
                for (auto &&array : ans[j])
                {
                    cout << array << " ";
                }
                cout << endl;
            }
            return;
        }
        else
        {
            if ((i * (i - 1) / 2) > N)
            {
                break;
            }
        }
    }
    cout << NO << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
int main()
{
	int n,q;
	cin>>n>>q;
	vector<pair<ll,pair<ll,ll> > > p;
	for(ll i=0;i<n;i++)
	{
		ll s,t,x;
		cin>>s>>t>>x;
		p.pb(mp(x,mp(s-x,t-x-1)));
	}
	ll ans[q];
	multiset<pair<ll,ll> > s;
	for(ll i=0;i<q;i++)
	{
		ll d;
		cin>>d;
		s.insert(mp(d,i));
		ans[i]=-1;
	}
	sort(p.begin(),p.end());
	for(ll i=0;i<p.size();i++)
	{
		ll l=p[i].ss.ff;
		ll r=p[i].ss.ss;
		multiset<pair<ll,ll> >::iterator it;
		if(s.empty()) continue;
		it=s.lower_bound(mp(l,-1));
		while(s.size() && it!=s.end() && (*it).ff<=r)
		{
			ans[(*it).ss]=p[i].ff;
			s.erase(it++);
		}
	}
	for(ll i=0;i<q;i++)
	{
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 21868
def solve():
  N, K = [int(i) for i in input().split()]
  h = [int(i) for i in input().split()]

  minimumCost = [0] * N

  for currentIndex in range(1, N):
    minimumCost[currentIndex] = min(minimumCost[previousIndex] + abs(h[currentIndex] - h[previousIndex]) for previousIndex in range(max(currentIndex - K, 0), currentIndex))

  print(minimumCost[N - 1])

solve()


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

#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i = (int)(begin), i##_end = (int)(end); i < i##_end; ++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x

int main(void){
	int N, K;
	cin >> N >> K;

	int l[50];
	rep(i, N) cin >> l[i];
	sort(l, l + N);
	reverse(l, l + N);

	int ans = 0;
	rep(i, K){
		ans += l[i];
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
map<long long, int> cnt;
int n;
long long a[100005], b[100005];
int pp[2201], p[350], tot;
long long sqr(long long x) {return x * x;}
int main() {
	for (int i = 2; i <= 2200; i++) if (!pp[i]) {
		p[++tot] = i;
		for (int j = i + i; j <= 2200; j += i)
			pp[j] = 1;
	}
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		long long x;
		scanf("%lld", &x);
		for (int j = 1; j <= tot && 1ll * p[j] * p[j] * p[j] <= x; j++)
			while (x % (1ll * p[j] * p[j] * p[j]) == 0)
				x /= (1ll * p[j] * p[j] * p[j]);
		b[i] = 1;
		cnt[x]++;
		a[i] = x;
		for (int j = 1; j <= tot && 1ll * p[j] * p[j] * p[j] <= x; j++) if (x % p[j] == 0) {
			b[i] *= (x % (1ll * p[j] * p[j]) == 0 ? p[j] : 1ll * p[j] * p[j]);
			while (x % p[j] == 0) x /= p[j];
		}
		if (sqr((long long)(sqrt(x) + 0.5)) == x) b[i] *= (long long)(sqrt(x) + 0.5);
		else b[i] *= x * x;
	}
	int ans = 0;
	if (cnt[1]) ans++, cnt[1] = 0;
	for (int i = 1; i <= n; i++)
		ans += max(cnt[a[i]], cnt[b[i]]), cnt[a[i]] = cnt[b[i]] = 0;
	printf("%d\n", ans);
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n+1, 0), b(n, 0);
  for (int i = 0; i < n+1; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];

  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (b[i] == 0) continue;
    
    if (b[i] <= a[i]) {
      ans += b[i];
      continue;
    }

    if (b[i] <= a[i] + a[i+1]) {
      ans += b[i];
      b[i] -= a[i];
      a[i+1] -= b[i];
      continue;
    }
    // Ai, Ai+1を全て倒せる場合
    ans += a[i] + a[i+1];
    a[i+1] = 0;
  }
  cout << ans << endl;
  return 0;
}

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

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef std::pair<int,int> pii;

using namespace std;

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

    double n,m;
    cin >> n >> m;
    vector<int> a(n);
    double sum  = 0;
    REP(i,n){
        cin >> a[i];
        sum += a[i];
    }

    int c = 0;
    REP(i,n){
        if(a[i] >= sum/(4*m))c++;
    }

    string ans = "Yes";
    if(c < m)ans = "No";

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

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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x, y) make_pair(x, y)

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    string s; cin >> s;
    ll ans = 100;
    rep(i, 26) {
        char a = 'a'+i;
        vector<ll> l;
        l.PB(-1);
        rep(j, s.size()) {
            if(s[j] == a) {
                l.PB(j);
            }
        }
        l.PB(s.size());
        if(l.size() == 2) continue;

        ll tmp = 0;
        rep(j, l.size()-1) {
            if(tmp < l[j+1]-l[j]-1) tmp = l[j+1]-l[j]-1;
        }
        if(ans > tmp) ans = tmp;
    }
    cout << ans << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 3572
#include "bits/stdc++.h"

using namespace std;


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int N;
	cin >> N;
	vector<int>A, B, C;
	A.resize(N);
	B.resize(N);
	C.resize(N);
	int ans = 0;
	rep(i, N) {
		cin >> A[i];
	}
	rep(i, N) {
		cin >> B[i];
		ans += B[i];
	}
	rep(i, N-1) {
		cin >> C[i];
	}
	rep(i, N-1) {
		if (A[i + 1] - A[i] == 1) {
			ans += C[A[i]-1];
		}
	}
	print(ans);

}

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

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

const int MAX = 1e5 + 10;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int A, B, C;

int main(){
    cin >> A >> B >> C;
    int ans = max( { A * 10 + B + C, B * 10 + A + C, C * 10 + A + B } );

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
#define MOD 1000000007
#define INF 1000000001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv)
{
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}
#define pi 3.141592653589793238462643383279
int main(void) {
	double a,b,x; cin >> a >> b >> x;
	double h = x/a/a;
	double ans;
	if(h<b/2){
		ans = 90-atan(2*h*a/b/b)/pi*180;
	}else{
		ans = 90-atan(a/(b-h)/2)/pi*180;
	}
	out16(ans);
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
int mod = 1000000007;

int main()
{
    IOS
    int t = 1;
    //cin >> t;
    while (t--)
    {
        int H, W, K;
        cin >> H >> W >> K;
        vector<vector<char>> c(H, vector<char>(W));
        for (int i = 0; i < H; i++)
            for (int j = 0; j < W; j++)
                cin >> c[i][j];
        int res = 0;
        for (int maskR = 0; maskR < (1 << H); maskR++)
        {
            for (int maskC = 0; maskC < (1 << W); maskC++)
            {
                int b = 0;
                for (int i = 0; i < H; i++)
                {
                    for (int j = 0; j < W; j++)
                    {
                        if (((maskR >> i)&1) == 0 && ((maskC >> j)&1) == 0)
                        {
                            if (c[i][j] == '#')
                                b++;
                        }
                    }
                }
                if (b == K)
                    res++;
            }
        }
        cout << res << "\n";
    }
    return 0;
}

Measured memory_bytes: 3620
#

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop
import math

def main():
    n, d = map(int, input().split())
    x = [list(map(int, input().split())) for _ in range(n)]
    # print(x)

    ans = 0
    for i in range(n - 1):
        for j in range(i + 1, n):
            diff = 0
            for d1, d2 in zip(x[i], x[j]):
                diff += (d1 - d2) ** 2
            # print(diff)
            diff = math.sqrt(diff)
            if diff == int(diff):
                ans += 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)

bool is_second_is_second(double a, double b, double c) {
  if (a < c) {
    if (a < b && b < c) return true;
  } else {
    if (a > b && b > c) return true;
  }
  return false;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> p(n, 0);
  REP(i, n) cin >> p[i];
  int ans = 0;
  REP(i, n - 2) {
    if (is_second_is_second(p[i], p[i + 1], p[i + 2])) ++ans;
  }
  cout << ans << endl;
  return 0;
}


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

typedef struct _Node {
  int key;
  struct _Node *next, *prev;
} Node;

Node *nil;

Node* listSearch(int key) {
  Node *cur = nil->next;
  while(cur != nil && cur->key != key) {
    cur = cur->next;
  }
  return cur;
}

void init(void) {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(void) {
  Node *cur = nil->next;
  int isf = 0;
  while(1) {
    if(cur == nil) break;
    if(isf++>0) printf(" ");
    printf("%d",cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t) {
  if(t==nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(void) {
  deleteNode(nil->next);
}

void deleteLast(void) {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(void) {
  int key, n, i;
  int size = 0;
  int np = 0, nd = 0;
  char com[20];
  scanf("%d", &n);
  init();
  for(i=0;i<n;i++) {
    scanf("%s%d",com, &key);
    if (com[0] == 'i') {
      insert(key);
      np++;
      size++;
    } else if(com[0] == 'd') {
      if(strlen(com) > 6) {
        if(com[6] == 'F')
          deleteFirst();
        else if(com[6] == 'L')
          deleteLast();
      } else {
        deleteKey(key);
        nd++;
      }
      size--;
    }
  }
  printList();
  return 0;
}



Measured memory_bytes: 32936
#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
long long X, Y, Z, n, power[50], mod = 1000000007;
int M[42][262144], GO[262144][11];

string parse(int r, int bit) {
	int cnt = 1, c = -1; string Y = "";
	for (int i = 0; i < r; i++) {
		if ((bit & (1 << i)) != 0)c = i;
	}
	r = c + 1;
	for (int i = 0; i < r; i++) {
		if ((bit & (1 << i)) != 0) { Y += ('0' + cnt); cnt = 1; }
		else cnt++;
	}
	return Y;
}
int parse2(int r, string Y) {
	int cnt = 0, t = 0;
	for (int i = 0; i < Y.size(); i++) {
		t += (Y[i] - '0'); cnt += (1 << (t - 1));
	}
	return cnt;
}
long long solve(int depth, int bit) {
	if (M[depth][bit] >= 0)return M[depth][bit];
	string S = parse(X + Y + Z, bit);

	int G = 0, R = 0;
	for (int i = S.size() - 1; i >= 0; i--) {
		G += (S[i] - '0');
		if (G == X || G == X + Y || G == X + Y + Z)R++;
	}
	if (R == 3) {
		M[depth][bit] = power[n - depth];
		return power[n - depth];
	}
	if (depth == n) { M[depth][bit] = 0; return 0; }

	long long cnt = 0;
	for (int i = 1; i <= 10; i++) {
		int P = GO[bit][i];
		cnt += solve(depth + 1, P); cnt %= mod;
	}
	M[depth][bit] = cnt;
	return cnt;
}
int main() {
	cin >> n >> X >> Y >> Z;
	for (int i = 0; i <= n; i++) { for (int j = 0; j < (1 << (X + Y + Z)); j++) { M[i][j] = -1; } }
	for (int i = 0; i < (1 << (X + Y + Z)); i++) {
		for (int j = 1; j <= 10; j++) {
			string A = parse(X + Y + Z, i); A += ('0' + j);
			int V = 0, C = 0; for (int k = 0; k < A.size(); k++)V += (A[k] - '0');
			if (j >= 8) { V = 0; A = ""; }
			while (V > X + Y + Z) { V -= (A[C] - '0'); C++; }
			A = A.substr(C, A.size() - C);
			GO[i][j] = parse2(X + Y + Z, A);
		}
	}
	power[0] = 1; for (int i = 1; i < 50; i++)power[i] = power[i - 1] * 10 % mod;
	cout << solve(0, 0) << endl;
	return 0;
}

Measured memory_bytes: 27008
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K;cin>>N>>K;int H[N];
  for(int i=0;i<N;i++)cin>>H[i];
  sort(H,H+N);int M=H[K-1]-H[0];
  for(int i=1;i<=N-K;i++)M=min(M,H[i+K-1]-H[i]);
  cout<<M<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(false); cin.tie(0);
    string s;
    cin >> s;
    int n = s.length();
    int ans = 1;
    string prev = string(1, s[0]), current = "";
    for(int i=1;i<n;++i) {
        current += s[i];
        if(prev != current) {
            prev = current;
            current = "";
            ++ans;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  while(cin >> n >> m, n | m) {
    vector<int> sum = {0};
    for(int i = 0; i < n; ++i) {
      int K;
      cin >> K;
      sum.push_back((sum.back() + (K % m)) % m);
    }
    int answer = 0;
    set<int> used = {m};
    for(int j = 1; j < sum.size(); ++j) {
      answer = max(answer, (sum[j] - *used.lower_bound(sum[j]) + m + m) % m);
      used.insert(sum[j]);
      used.insert(sum[j] + m);
    }
    cout << answer << endl;
  }
}

Measured memory_bytes: 3712