akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ll,ll> pii;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=x;i>=y;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mes(a,b) memset(a,b,sizeof a)
#define mp make_pair
#define dd(x) cout<<#x<<"="<<x<<" "
#define de(x) cout<<#x<<"="<<x<<"\n"
#define debug() cout<<"I love Miyamizu Mitsuha forever.\n"
const int inf=0x3f3f3f3f;
const int mod=998244353;
const int maxn=3005;
ll dp[maxn][maxn];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int n=c-a+1;
	int m=d-b+1;
	dp[1][1]=1;
	rept(i,1,n)
	{
		rept(j,1,m)
		{
			if(i==1&&j==1) continue;
			else
			{
				dp[i][j]=(dp[i-1][j]*(j+b-1)+dp[i][j-1]*(i+a-1)-dp[i-1][j-1]*(j-1+b-1)%mod*(i-1+a-1)%mod+mod)%mod;
			}
		}
	}
	cout<<dp[n][m]<<"\n";
	return 0;
}

Measured memory_bytes: 74040
def main():
    S = input()
    n = len(S)
    i = 0
    res = []
    while i < len(S):
        countL, countR = 0, 0
        while i < n and S[i] == "R":
            countR += 1
            i += 1
        while i < n and S[i] == "L":
            countL += 1
            i += 1
        if (countL+countR) % 2 == 0:
            half = (countL+countR) // 2
            res += [0]*(countR-1) + [half]*2 + [0]*(countL-1)
        else:
            half1 = (countR+countL+1)//2
            half2 = (countR+countL) - half1
            if countR > countL:
                if (countR-1) % 2 == 0:
                    res += [0]*(countR-1) + [half1, half2] + [0]*(countL-1)
                else:
                    res += [0]*(countR-1) + [half2, half1] + [0]*(countL-1)
            else:
                if (countL-1) % 2 == 0:
                    res += [0]*(countR-1) + [half2, half1] + [0]*(countL-1)
                else:
                    res += [0]*(countR-1) + [half1, half2] + [0]*(countL-1)
    return res

if __name__ == '__main__':
    output = main()
    print(" ".join(map(str, output)))

Measured memory_bytes: 10564
import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

			while (scanner.hasNext()) {

				String[] arrays = input().split(" ");
				Double a = Double.parseDouble(arrays[0]);
				Double b = Double.parseDouble(arrays[1]);
				Double c = Double.parseDouble(arrays[2]);
				Double d = Double.parseDouble(arrays[3]);
				Double e = Double.parseDouble(arrays[4]);
				Double f = Double.parseDouble(arrays[5]);

				double x = (c * e - b * f) / (a * e - b * d);
				double y = (c * d - a * f) / (b * d - a * e);

				if (x == -0.0) {

					x = 0.0;

				}

				if (y == -0.0) {

					y = 0.0;

				}

				System.out.print(String.format("%.3f", x));
				System.out.print(" ");
				System.out.println(String.format("%.3f", y));

			}

		close();

	}

	public static String input() {

		return scanner.nextLine();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
}

Measured memory_bytes: 26640
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int n;
bool a[200000];
bool b[200000];
vi ans;

int main(){
  cin >> n;
  REP(i, n) cin >> a[i];
  int cnt = 0;
  for(int i = n; i >= 1; i--){
    bool t = a[i-1];
    for(int j = i * 2; j <= n; j+=i){
      if(b[j-1]) t = !t;
    }
    if(t) ans.pb(i);
    b[i-1] = t;
  }
  cout << ans.size() << endl;
  REP(i, ans.size()){
    cout << ans[i] << endl;
  }

}

Measured memory_bytes: 2040
fun main(args:Array<String>?): Unit {
    val (n, q) = readLine()!!.trim().split(' ').map(String::toInt)
    val s = readLine()!!.trim()
    val ac = Array(n){i ->
        if (i == 0) 0
        else if (s[i - 1] == 'A' && s[i] == 'C') 1
        else 0
    }
    for (i in 1 until s.length) ac[i] += ac[i - 1]
    
    repeat(q){
        val (l, r) = readLine()!!.trim().split(' ').map(String::toInt)
        println(
                ac[r - 1] - ac[l - 1]
        )
    }
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
constexpr int INF = numeric_limits<int>::max()/2;

struct UF {
	vector<int> data;
	UF(int size) : data(size, -1) { }
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool find(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

typedef vector<vector<int>> Graph;
UF uf(700);
vector<P> ps;
vector<int> col(700,0);
bool f=true;
int cnt;

void dfs(const Graph& g, int node, int c){
  if(c==1) cnt++;
  col[node]=c;
  for(int i=0;i<(int)g[node].size();i++){
    int next=g[node][i];
    if(col[next]!=0){
      if(col[node]==col[next]){
        f=false;
        return ;
      }
      else{
        continue;
      }
    }
    dfs(g,next,-c);
  }
  return ;
}

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

    int n,m;cin>>n>>m;
    Graph v(n,vector<int>(n,0)),g(n);
    for(int i=0;i<m;i++){
      int a,b;cin>>a>>b;a--;b--;
      v[a][b]=v[b][a]=1;
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        if(i==j) continue;
        if(v[i][j]) continue;
        g[i].push_back(j);
        uf.unite(i,j);
      }
    }
    for(int i=0;i<n;i++){
      if(col[i]!=0) continue;
      cnt=0;
      dfs(g,i,1);
      ps.push_back(P(uf.size(i)-cnt,cnt));
    }
    if(!f){
      cout<<-1<<endl;
      return 0;
    }
    vector<vector<bool>> dp(ps.size()+1,vector<bool>(n+1,false));
    dp[0][0]=true;
    for(int i=0;i<(int)ps.size();i++){
      int a=ps[i].first,b=ps[i].second;
      for(int j=n;j>=0;j--){
        if(j-a<0) break;
        dp[i+1][j] = dp[i+1][j] || dp[i][j-a];
      }
      for(int j=n;j>=0;j--){
        if(j-b<0) break;
        dp[i+1][j] = dp[i+1][j] || dp[i][j-b];
      }
    }
    int res=INF;
    for(int i=0;i<=n;i++){
      if(!dp[(int)ps.size()][i]) continue;
      int b=n-i,tmp=i*(i-1)/2+b*(b-1)/2;
      res=min(res,tmp);
    }
    cout<<res<<endl;
}


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

int main(){

int N,X;
  cin >> N >> X;
  int min=10000;
  int m[N];
  int count=N;
  for(int i=0;i<N;i++){
  cin >> m[i];
   int t= m[i];
    X-=m[i];
    if(min>m[i])min = t;
  
  }
  cout << N + X/min << endl;

}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> H(N);
	int res = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> H[i];
	}
	int flag = 0;
	int flag1 = 0;
	for (int i = 0; i < N - 1; i++)
	{
		//for (int j = i; j < N;j++){
		if (flag1 == 1)
		{
			if (H.at(i + 1) < H.at(i))
			{
				flag = 1;
				cout << "No" << endl;
				break;
			}
			if (H.at(i + 1)-1 >= H.at(i))
			{
				flag1 = 0;
			}
		}
		else
		{
			if (H.at(i + 1) < H.at(i) - 1)
			{
				flag = 1;
				cout << "No" << endl;
				break;
			}
			else if (H.at(i + 1) == H.at(i) - 1)
			{
				flag1 = 1;
			}
		}
		//}
		//if(flag==1){
		//	break;
		//}
	}
	if (flag == 0)
	{
		cout << "Yes" << endl;
	}
}


Measured memory_bytes: 1024
/*****************************************************

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

#include<bits/stdc++.h>
#define MAX 9223372036854775807
#define endl "\n"
#define ll long long
#define int long long
#define pb push_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define ip pair<int, int>

#define loop(i,n) for(int i=0;i<n;i++)
#define fast ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
using namespace std;

const ll MOD = 1e9+7;
const ll SZ = 107;
const ll N = 2e5+7;
const ll inf = 1e17;

int pwr(int x, int y)
{
    ll r = 1LL;
    while(y)
    {
        if(y&1)
            r = (r * x) % MOD;
        y >>= 1;
        x = (x * x) % MOD;
    }
    return r % MOD;
}

int inv(int x)
{
    return pow(x, MOD-2);
}

void solve()
{
    int n, k; 
    cin>>n>>k; 
    if(k>(n-2)*(n-1)/2)
    {
        cout<<"-1";
        return;
    }
    
    vector<ip> v;
    for(int i=2;i<=n;i++)
        v.pb({1, i});
    int x = (n-2)*(n-1)/2;
    int j = 2;
    while(x != k)
    {
        for(int i=j+1;i<=n;i++)
        {
            v.pb({j, i});
            x--;
            if(x==k)
                break;
        }
        j++;
    }
    cout<<v.size()<<endl;
    for(auto i: v)
        cout<<i.first<<" "<<i.second<<endl;
}

signed main()
{
    int t=1;
    // cin >>t;
    while(t--){
        solve();
    }
    return 0;
}

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


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

Measured memory_bytes: 512
#include<stdio.h>

int sw=0,n,a[100];

void bubbleSort(){
    for(int i=0;i<n;i++){
        for(int j=n-1;j>i;j--){
            if(a[j]<a[j-1]){
                int temp=a[j];
                a[j]=a[j-1];
                a[j-1]=temp;
                sw++;
            }
        }
    }
}

int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    bubbleSort();
    for(int i=0;i<n;i++){
        if(i)printf(" ");
        printf("%d",a[i]);
    }
    printf("\n%d\n",sw);
    return 0;
}


Measured memory_bytes: 2704
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,f=0;
    int x,y;
    cin>>x>>y;
    for(a=0;a<=x;a++)
    {
    b=x-a;
    if(2*a+4*b==y)
    cout<<"Yes"<<"\n",f=1;
    }
    if(f==0)
    cout<<"No";
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (ll i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL) 
const int mod = 1e9 + 7, mxn = 1e5 + 1;

int solve(){
	ll c;
	cin>> c;
	string ans;
	string fin = "";
	while(c){
		ll val = c%26ll;
		if(val == 0)
			val = 26;
		char dig = ('a' + val - 1);
		fin.pb(dig);
		c /= 26;
		if(val == 26)
			c--;
	}
	reverse(all(fin));
	cout<< fin;
	return 0;
}
 
int main()
{
    fast;
    int t = 1;
    //cin>> t;
    while(t--){  
        solve();
    }
    return 0;
}
//v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1);
 
/*  inv[1] = 1; // inv is ll
    for(int i=2; i<=mxn; ++i)
        inv[i]=mod-mod/i*inv[mod%i]%mod;*/
        
// lower bound   >=  
// upper bound   >
// vector<int>().swap(vec); //free memory from vec


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
struct UnionFind {
	vector<int> data;
	UnionFind(int n) : data(n, -1) {}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	bool merge(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (data[y] < data[x]) swap(x, y);
		data[x] += data[y];
		data[y] = x;
		return true;
	}
};
int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>> L(M);
	for (int i = 0; i < N; ++ i) {
		int K;
		cin >> K;
		for (int j = 0; j < K; ++ j) {
			int x;
			cin >> x;
			L[x-1].push_back(i);
		}
	}
	UnionFind uf(N);
	for (auto& a : L) {
		for (int i = 1; i < a.size(); ++ i) {
			uf.merge(a[i-1], a[i]);
		}
	}
	if (N == -uf.data[uf.root(0)]) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j) for(int i=0;i<j;i++)
#define print(a) cout<<a<<endl
typedef long long ll;
typedef string str;
typedef unsigned long long ul;
#define vint vector<int>

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if((b+c)-a<0){
		print(0);
	}else{
		print(b+c-a);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _C ios::sync_with_stdio(false);cin.tie(0);
#define PI 3.1415926535897932384626433832795028841971693993751058209749445923078164
#define xx first
#define yy second
#define ERR 0.00000001
#define INF (ll)1<<62
#define nSize 1000000
#define For(o,n) for(int i = 0 ; i < n ; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef long double ld;

int main()
{_C
	ll n;
	cin >> n;
	ll i = 2;
	vpll v;
	for(int i = 1 ; 2*i <= n ; i++)
	{
		v.push_back(pll(i,n-i));
	}
	ll mn = INF , a;
	string s1 , s2;

	for(int i = 0 ; i < v.size() ; i++)
	{
		a = 0;
		s1 = to_string(v[i].xx);
		s2 = to_string(v[i].yy);
		for(int j = 0 ; j < s1.size() ; j++)
			a += (s1[j]-'0');
		for(int j = 0 ; j < s2.size() ; j++)
			a += (s2[j]-'0');
		mn = min(a,mn);
	}
	cout << mn << '\n';

	#ifdef LOCAL
	//	cout << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << endl;
	#endif
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;
const double btc2jpy = 380000.0;

int main() {
  int n;
  cin >> n;
  string u;
  double x;
  double jpy, btc;
  rep(i, n) {
    cin >> x >> u;
    if (u == "JPY")
      jpy += x;
    else
      btc += x;
  }

  double ans = (double)jpy + btc * btc2jpy;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
c=input("").split(" ")
a=int(c[0])

e=100*int(c[1][0])+10*int(c[1][2])+int(c[1][3])

d=int(a*e)
s=str(d)
if (len(s)<3):
    f="0"
else:
    f=s[:len(s)-2]

print(f)


Measured memory_bytes: 9004
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll maxn=300+10;
ll d[maxn][maxn];
int main(){
	ll n;
	scanf("%lld",&n);
	for(ll i=1;i<=n;i++)
		for(ll j=1;j<=n;j++)
			scanf("%lld",&d[i][j]);
	ll ans=0ll;
	for(ll i=1;i<=n;i++)
		for(ll j=1;j<=n;j++)
			if(d[i][j]!=d[j][i]){
				printf("-1");
				return 0;
			}
	for(ll i=1;i<n;i++)
		for(ll j=i+1;j<=n;j++){
			bool b=0;
			for(ll k=1;k<=n;k++){
				if(k==i || k==j) continue;
				if(d[i][k]+d[k][j]<d[i][j]){
					printf("-1");
					return 0;
				}
				else if(d[i][k]+d[k][j]==d[i][j]){
					b=1;
				}
			}
			if(!b) ans+=d[i][j];
		}
	printf("%lld",ans);
	return 0;
}

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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll e;
  ll x = 0;
  VLL three;
  map <ll,ll>tIdx;
  while(x*x*x <= 1000000){
    three.push_back(x*x*x);
    tIdx[x*x*x] = x;
    x++;
  }
  x = 0;
  VLL second;
  map <ll,ll>sIdx;
  while(x*x <= 1000000){
    second.push_back(x*x);
    sIdx[x*x] = x;
    x++;
  }
  while(true){
    cin >> e;
    if(e== 0) break;
    ll ans = 1e9;
    for(ll xx:three){
      for(ll yy:second){
        ll zz = e-xx-yy;
        if(zz < 0) continue;
        else ans = min(ans,sIdx[yy]+tIdx[xx]+zz);
      }
    }
    cout << ans << endl;
  }
  return 0;
}



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

using namespace std;

#define ll long long
#define ld long double
#define ull unsigned long long
#define __ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int maxn = 1e5 + 10;
int n, a[maxn];
set<int> s;
map<int, int> mp;
vector<int> v1, v2;

int main() {
    __;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        int x;
        cin >> x;
        a[i] = x;
        s.insert(x);
    }
    int ct = 1;
    for (auto i:s) {
        mp[i] = ct;
        ++ct;
    }
    int cnt = 0;
    for (int i = 1; i <= n; ++i) {
        if (i & 1) {
            v1.push_back(mp[a[i]]);
            if (mp[a[i]] & 1); else cnt++;
        } else {
            v2.push_back(mp[a[i]]);
        }
    }
    cout << cnt << endl;
    return 0;
}

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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define pli pair<long long,int>
#define pil pair<int,long long>
#define ll long long
#define el '\n'

using namespace std;

ll h;
ll tot;

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

    cin >> h;
    ll cur = 1;
    while (h>0){
        tot+=cur;
        cur*=2;
        h/=2;
    }   
    cout << tot << el;

    return 0;
}

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

int main() {
    int N;
    cin >> N;
    string num;
    cin >> num;
    int hum;
    cin >> hum;

    vector<int> used(N);
    int c = 0;
    for (int i = 0; i < N && c < hum; i++) {
        if (num[i] == '0') {
            num[i] = '1';
            c++;
            used[i] = true;
        }
    }

    int j = N-1;
    while (c < hum) {
        if (!used[j]) {
            c++;
            num[j] = '0';
        }
        j--;
    }

    cout << num << endl;

    return 0;
}

Measured memory_bytes: 3204
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int h, w, dy[4] = {0, 1, 0, -1}, dx[4] = {1, 0, -1, 0};
    vector<string> s;
    cin >> h >> w;
    s.assign(h, "");
    for(int i=0;i<h;i++) cin >> s[i];
    vector< vector<int> > dst(h*w, vector<int>(h*w, 1e9));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j] == '#') continue;
            for(int k=0;k<4;k++){
                int y = i + dy[k];
                int x = j + dx[k];
                if(y < 0 || y >= h || x < 0 || x >= w) continue;
                if(s[y][x] == '#') continue;
                dst[i*w+j][y*w+x] = 1;
            }
        }
    }

    for(int i=0;i<h*w;i++){
        dst[i][i] = 0;
    }

    for(int k=0;k<h*w;k++){
        for(int i=0;i<h*w;i++){
            for(int j=0;j<h*w;j++){
                dst[i][j] = min(dst[i][j], dst[i][k] + dst[k][j]);
            }
        }
    }
    int ans = 0;
    for(int i=0;i<h*w;i++){
        if(s[i/w][i%w] == '#') continue;
        for(int j=0;j<h*w;j++){
            if(s[j/w][j%w] == '#') continue;
            if(ans < dst[i][j]){
                ans = dst[i][j];
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(a) (a).begin(), (a).end()
#define ALLR(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EMP emplace
#define EMPB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
#define Bit(n) (1LL << (n))
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

int c[4];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  REP(i, 3) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    c[a]++;
    c[b]++;
  }
  sort(c, c+4);
  if (c[0] == 1 && c[1] == 1 && c[2] == 2 && c[3] == 2) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX1  1000
#define MAX2 10000


int n, a[MAX1], s;
int b[MAX1], T[MAX2 + 1];


int partition(int [], int , int );
void quickSort(int [], int , int );
int solve();
 

int main(){
  int i;

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

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

  return 0;
}

int partition(int a[], int p, int r){
  int i, j;
  int t, x;
  x = a[r];
  i = p - 1;

  for( j = p ; j < r ; j++ ){
    if(a[j] <= x){
      i++;
      t = a[i];
      a[i] = a[j];
      a[j] = t;
    }
  }

  t = a[i + 1];
  a[i + 1] = a[r];
  a[r] = t;

  return i + 1;
}
void quickSort(int a[], int p, int r){
  int q;
  if(p < r){
    q = partition(a, p, r);
    quickSort(a, p, q - 1);
    quickSort(a, q + 1, r);
  }
}


int solve(){
  int i, cur, S, m, an, v,   ans = 0 ;

  int V[MAX1];
  for(i = 0 ; i < n ; i++){
    b[i] = a[i];
    V[i] = 0;
  }

  quickSort(b, 0, n - 1);

  for(i = 0 ; i < n ; i++) T[b[i]] = i;
  for(i = 0 ; i < n ; i++){
    if(V[i]) continue;
    cur = i;
    S = 0;
    m = MAX2;
    an = 0;
    while(1){
      V[cur] = 1;
      an++;
      v = a[cur];

      if(v < m) m = v;

      S += v;
      cur = T[v];
      if(V[cur]) break;
    }
    if(S + (an -2) * m < m + S + (an + 1) * s) ans += S + (an -2) * m;
    else ans +=  m + S + (an + 1) * s;
  }
  return ans;
}





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

#define int long long
#define rep(i, a) for (int i = 0; i < (a); i++)
#define repd(i, a) for (int i = (a)-1; i >= 0; i--)
#define reps(i, a, j) for (int i = (j); i < (a); i++)
#define deb(x) cout << #x << " " << x << endl;
#define debs(x) cout << #x << " " << x << " ";
#define deba(x) for (auto _i:x) cout << _i << " "; cout << endl;
#define ms(a) memset(a,0,sizeof(a));
#define mp make_pair
#define eb emplace_back
#define pii pair < int , int >
#define all(a) a.begin(),a.end()

void solve() {
    string s,t; cin >> s >> t;
    int n = s.length(),m = t.length(),res = n;
    reps (i,n,m-1) {
        int cur = 0;
        repd(j,m) {
            if (t[j] != s[i-(m-1-j)]) cur++;
        }
        res = min(res,cur);
    }
    cout << res << endl;

}

signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t; t=1;
    while (t--) solve();
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
ll ch[103][4][2];
int main() {
	string s;
	cin>>s;
	ll m;
	cin>>m;
	ch[0][0][0]=1;
	for(ll i=0;i<s.size();i++){
		for(ll j=0;j<=9;j++){
			ll now=s[i]-'0';
			if(j==0){
				for(ll k=0;k<=3;k++){
					ch[i+1][k][1]+=ch[i][k][1];
					if(now!=0){
						ch[i+1][k][1]+=ch[i][k][0];
					}
					else{
						ch[i+1][k][0]+=ch[i][k][0];
					}
				}
			}
			else{
				for(ll k=0;k<3;k++){
					ch[i+1][k+1][1]+=ch[i][k][1];
					if(j<now){
						ch[i+1][k+1][1]+=ch[i][k][0];
					}
					else if(j==now){
						ch[i+1][k+1][0]+=ch[i][k][0];
					}
				}
			}
		}
	}
	cout << ch[s.size()][m][0]+ch[s.size()][m][1];
	// your code goes here
	return 0;
}

Measured memory_bytes: 3592
import bisect
a,b,q=map(int,input().split())
s=[]
t=[]
for i in range(a):
  s.append(int(input()))
for i in range(b):
  t.append(int(input()))
s.sort()
t.sort()
INF=10**18
for i in range(q):
  x=int(input())
  if s[0]<x<s[-1]:
    s_left=s[bisect.bisect_left(s,x)-1]
    s_right=s[bisect.bisect_left(s,x)]
  elif x<s[0]:
    s_left=-INF
    s_right=s[bisect.bisect_left(s,x)]
  elif x>s[-1]:
    s_left=s[bisect.bisect_left(s,x)-1]
    s_right=INF
  if t[0]<x<t[-1]:
    t_left=t[bisect.bisect_left(t,x)-1]
    t_right=t[bisect.bisect_left(t,x)]
  elif x<t[0]:
    t_left=-INF
    t_right=t[bisect.bisect_left(t,x)]
  elif x>t[-1]:
    t_left=t[bisect.bisect_left(t,x)-1]
    t_right=INF
  v=x-min(s_left,t_left)
  w=max(s_right,t_right)-x
  u=min(min(x-s_left,s_right-x),min(x-t_left,t_right-x))*2+max(min(x-s_left,s_right-x),min(x-t_left,t_right-x))
  print(min(v,w,u))

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

using namespace std;

int main() {
  int n; cin >> n;
  int idx[n];
  for (int i = 0; i < n; i++) {
    int j; cin >> j;
    idx[j - 1] = i + 1;
  }
  for (int i = 0; i < n; i++)
    cout << idx[i] << " ";
  cout << endl;
  return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define int long long int
#define pp pair<int,int>
#define endl "\n"
#define PI 3.14159265
int MAX = INT_MAX;
const int mod=1e9+7;
const int INF =INT_MAX;
inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int pow(int a,int n,int mod){if(n==0)return 1;int p=pow(a,n/2,mod);p=(p%mod*p%mod)%mod;if(n%2) return (p%mod*a%mod)%mod;else return p;}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t=1;
    //cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        int x=0;
        for(int i=0;i<s.length();i++)
         x+=(s[i]-'0');
         if((x%9)==0)cout<<"Yes"<<endl;
         else cout<<"No"<<endl;

    }
}


Measured memory_bytes: 3764
n=int(input())
data=[list(map(int,input().split())) for i in range(n)]
data.sort(key=lambda tup:tup[0])
parent=[-1]*n

for i in range(n):
    if data[i][1]!=-1:
        parent[data[i][1]]=i
    if data[i][2]!=-1:
        parent[data[i][2]]=i

for i in range(n):
    if parent[i]==-1:
        root=i

def preorder(node):
    if node==-1:return
    print(' '+str(node),end='')
    preorder(data[node][1])
    preorder(data[node][2])

def inorder(node):
    if node==-1:return
    inorder(data[node][1])
    print(' '+str(node),end='')
    inorder(data[node][2])

def postorder(node):
    if node==-1:return
    postorder(data[node][1])
    postorder(data[node][2])    
    print(' '+str(node),end='')

print('Preorder')
preorder(root)
print()
print('Inorder')
inorder(root)
print()
print('Postorder')
postorder(root)
print()




        


Measured memory_bytes: 5620
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (n,m) = get!(usize, usize);
    let mut a = Vec::new();
    for _ in 0..n {
        a.push(get!([usize]).into_iter().collect::<VecDeque<_>>());
    }
    let mut list = HashSet::new();
    let mut mn = n;
    for _ in 0..m {
        let mut nums = vec![0; m+1];
        for i in 0..n {
            while list.contains(a[i].front().unwrap()) {
                a[i].pop_front();
            }
            nums[*a[i].front().unwrap()] += 1;
        }
        let mut mx = 0;
        let mut mxm = 0;
        for i in 1..m+1 {
            if nums[i] > mx {
                mx = nums[i];
                mxm = i;
            }
        }
        mn = min!(mn, mx);
        list.insert(mxm);
    }
    println!("{}", mn);
}


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

int main() {
  string s;
  while(cin >> s, s!="0") {
    int a = count(s.begin()+1,s.end(),'A');
    int b = count(s.begin()+1,s.end(),'B');
    if(a>b) a++;
    else b++;
    cout << a << ' ' << b << endl;
  }
  return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <queue>
#include <sstream>
#include <unordered_map>
#include <cstring>
#include <iomanip>

using namespace std;

typedef long long ll;

const ll INF=1e9+7;

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define ranger(x,a) for(auto x: a)

int main(){
    int N;
    cin>>N;
    pair <pair <string,int>,int > p[110];
    rep(i,N){
        string S;
        int A;
        cin>>S>>A;
        p[i]=make_pair(make_pair(S,-A),i);
    }
    sort(p,p+N);
    rep(i,N)cout<<p[i].second+1<<endl;
    return 0;
}

//a=97,z=122

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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector< vector<int> > Matrix;


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

	cin >> a >> b;

	if (a > b) {
		c = a;
		a--;
	}
	else {
		c = b;
		b--;
	}

	c += max(a, b);

	cout << c;


	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <string>
#include <set>
#include <iomanip>
#include <unordered_map>
#include <cmath>
#define int long long
#define pii pair<int, int>
typedef long long ll;
using namespace std;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}

const int N = 1001;
int a[N], b[N];
int sa[N * N], sb[N * N]; 
int str[N], stb[N];
bool istr[N], istb[N];
const int mod = 1e9 + 7;

signed main() {
	fast();
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n * m; i++) {
		sa[i] = sb[i] = -1;
	}
	for (int i = 0; i < n; i++)  {
		cin >> a[i];
		sa[a[i]] = i;
		str[i] = 0;
	}
	for (int i = 0; i < m; i++) {
		cin >> b[i];
		sb[b[i]] = i;
		stb[i] = 0;
	}
	int pos = 0;
	int ustr = 0, ustb = 0;
	int answ = 1;
	for (int i = n * m; i >= 1; i--) {
		if (sa[i] != -1 && sb[i] != -1) {
			//cout << 1;
			pos += ustr + ustb;
			ustr++;
			ustb++;
		} else if (sa[i] != -1) {
			//cout << 2;
			int x = sa[i];
			answ *= ustb;
			answ %= mod;
			pos += ustb - 1;
			ustr++;
		} else if (sb[i] != -1) {
			//cout << 3;
			answ *= ustr;
			answ %= mod;
			pos += ustr - 1;
			ustb++;
		} else {
			//cout << 4;
			answ *= pos;
			answ %= mod;
			pos--;
		}
	}
	cout << answ;
	return 0;
}

Measured memory_bytes: 16000
U = 2 * 10 ** 5
mod = 10 ** 9 + 7


class Combination:
    """
    SIZEが10^6程度以下の二項係数を何回も呼び出したいときに使う
    使い方:
    comb = Combination(SIZE, MOD)
    comb(10, 3) => 120
    """

    def __init__(self, N, MOD=10 ** 9 + 7):
        self.MOD = MOD
        self.fact, self.inv = self._make_factorial_list(N)

    def __call__(self, n, k):
        if k < 0 or k > n:
            return 0
        res = self.fact[n] * self.inv[k] % self.MOD
        res = res * self.inv[n - k] % self.MOD
        return res

    def _make_factorial_list(self, N):
        fact = [1] * (N + 1)
        inv = [1] * (N + 1)
        MOD = self.MOD
        for i in range(1, N + 1):
            fact[i] = (fact[i - 1] * i) % MOD
        inv[N] = pow(fact[N], MOD - 2, MOD)
        for i in range(N, 0, -1):
            inv[i - 1] = (inv[i] * i) % MOD
        return fact, inv


if __name__ == "__main__":
    N, K = map(int, input().split())
    comb = Combination(U + 5, mod)

    ans = 1
    for i in range(1, min(K + 1, N)):
        vacant = comb(N, i)
        person = comb(N - 1, i)
        ans = (ans + vacant * person % mod) % mod
    print(ans)

Measured memory_bytes: 18804
n, a = map(int, input().split())
X = list(map(int, input().split()))

# dp[i][j][k] i枚までj枚えらんで合計k
# 答えはdp[n][1..n][a..ak]
dp = [[[0] * 2700 for _ in range(52)]
      for __ in range(52)]

dp[0][0][0] = 1
for i in range(0, n):
    for j in range(0, n + 1):
        for k in range(n * max(X) + 1):
            dp[i + 1][j][k] += dp[i][j][k]  # 選ぶ
            dp[i + 1][j + 1][k + X[i]] += dp[i][j][k]  # 選ばない

ans = 0
for i in range(1, n+1):
    for j in range(a, 2501):
        if i * a == j:
            ans += dp[n][i][j]
print(ans)


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

	vector<int> dx = {0, 1, 1, 1, 0, -1, -1, -1};
	vector<int> dy = {-1, -1, 0, 1, 1, 1, 0, -1};

	vector<string> mass(h);
	rep(i, h) cin >> mass[i];

	rep(i, h)
	{
		rep(j, w)
		{
			int cnt = 0;
			rep(k, 8)
			{
				int y = i + dy[k], x = j + dx[k];
				if (0 <= x && x < w && 0 <= y && y < h && mass[y][x] == '#')
				{
					cnt++;
				}
			}
			if (mass[i][j] == '.')
			{
				cout << cnt;
			}
			else
			{
				cout << '#';
			}
		}
		cout << '\n';
	}
	cout << '\n';
	return 0;
}


Measured memory_bytes: 3596
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>


int main(){
	int a, b, c, t;
	scanf("%d %d %d", &a, &b ,&c);
	if (a > b) {
		t = b;
		b = a;
		a = t;
	}
	if (a > c) {
		t = c;
		c = a;
		a = t;
	}
	if (b > c) {
		t = b;
		b = c;
		c = t;
	}
	printf("%d %d %d\n", a, b, c);
	return 0;
}


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

int main()
{
  int n;
  cin>>n;
  vector<double> dp(n+1),ip(n);
  //dp[i]->i heads
  for(double &x: ip)
  cin>>x;

  dp[0]=1;
  for(int i=0;i<n;i++)
  {
    for(int j=i+1;j>=0;j--)
    {
      dp[j]=dp[j]*(1-ip[i])+(j==0?0:dp[j-1]*ip[i]);
    }
  }
  double sum=0;
  for(int i=0;i<=n;i++)
  {
    int t=n-i;
    if(i>t)
    sum+=dp[i];
  }
  printf("%.10lf\n",sum);

  return 0;
}


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

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        for line in sys.stdin:
            lines.append(line.strip())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (n, ) = [int(e) for e in lines[0].split(' ')]
    l = [int(e) for e in lines[1].split(' ')]

    return (n, l)


def solve(n, l):

    count = 0    
    for i in range(n):
        for j in range(i+1, n):
            for k in range(j+1, n):
                if l[i] != l[j] and l[j] != l[k] and l[k] != l[i]:
                    if l[i] + l[j] > l[k] and l[j] + l[k] > l[i] and l[k] + l[i] > l[j]:
                        count = count + 1
    
    return count


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 67996
#include <bits/stdc++.h>
using namespace std;
#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 ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

int main(){
    string s; cin >> s;
    ll n = s.size();
    
    VL mods(2019,0);
    ll rem = 0, tens = 1;

    rep(i,n){
        ll d = s[n-1-i] - '0';
        rem = (rem + tens*d) % 2019;
        tens = (tens*10) % 2019;
        mods[rem]++;
    }

    mods[0]++;

    ll ans = 0;
    rep(i, 2019){
        ll m = mods[i];
        ans += m*(m-1)/2;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int h,w;
    cin>>h>>w;
    std::vector<vector<char>> vec(h,vector<char>(w));
    char c;
    for (int i=0;i<h;i++) {
        int count_yoko=0;
        for (int j=0;j<w;j++) {
            cin>>c;
            if (c=='.') {
                count_yoko++;
            }
            vec.at(i).at(j)=c;
            if (count_yoko==w) {
                for (int k=0;k<w;k++) {
                    vec.at(i).at(k)='*';
                }
            }
        }
    }
    for (int l=0;l<w;l++) {
        int count_tate=0;
        for (int m=0;m<h;m++) {
            if (vec.at(m).at(l)=='.'||vec.at(m).at(l)=='*') {
                count_tate++;
            }
            if (count_tate==h) {
                for (int n=0;n<h;n++) {
                    vec.at(n).at(l)='*';
                }
            }
        }
    }
    for (int hoge=0;hoge<h;hoge++) {
        int count=0;
        for (int piyo=0;piyo<w;piyo++) {
            if (vec.at(hoge).at(piyo)!='*') {
                cout<<vec.at(hoge).at(piyo);
            } else {
                count++;
            }
        }
        if (count!=w) {
            cout<<endl;
        }
    }
}

Measured memory_bytes: 256
from collections import deque
n,m = map(int, input().strip().split())
to = [[] for _ in range(n)]

for _ in range(m):
    a,b = map(int, input().strip().split())
    to[a-1].append(b-1)
    to[b-1].append(a-1)

q=deque([0,])
ans=[None]*n
while q:
    cur=q.popleft()
    for nxt in to[cur]:
        if ans[nxt] is not None: # visited
            continue
        ans[nxt]=cur+1
        q.append(nxt)

if None in ans:
    print("No")
else:
    print("Yes")
    print(*ans[1:])

Measured memory_bytes: 38404
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define ld double
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define len length()
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect

void solve() {
    int h, a;
    cin >> h >> a;
    cout << (h + a - 1) / a;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin>>N;
    vll a(N);
    rep(i,N) cin>>a[i];
    sort(rall(a));
    priority_queue<ll> que;
    que.push(a[0]);
    ll ans=0;
    FOR(i,1,N-1){
        ll p = que.top(); que.pop();
        ans += p;
        que.push(a[i]);
        que.push(a[i]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6880
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
int iso_lower(vector<int> V, int x) {
    //ソートされたVの中から、V[i]>=xとなる最小のiを返す.存在しなければVの要素数を返す
    int s = V.size();
    //V.push_back(INF);
    int l = -1;
    int r = s;  //rが常にtrue
    while(r - l > 1) {
        int mid = (l + r) / 2;
        if(V[mid] < x)
            l = mid;
        else
            r = mid;
    }
    return r;
}
signed main(){
    int N;cin>>N;
    vector<int>V0,V1;
    rep(i,N){
        int x,y;cin>>x>>y;
        V0.push_back(x+y);
        V1.push_back(x-y);
    }
    sort(all(V0));
    sort(all(V1));
    int ans=-1;
    ans=max(ans,abs(V0[N-1]-V0[0]));
    ans=max(ans,abs(V1[N-1]-V1[0]));
    cout<<ans<<endl;
}


Measured memory_bytes: 6644
#include <stdio.h>
#include <string.h>
#define maxn 4010
#define LL long long
LL sum;
char s[maxn];
int r[maxn],g[maxn],b[maxn],n;
void count(char a,char b,char c,int *p){//abc
	int i,j,k;
	for(i=1;i<=n;i++)
		for(k=i+1;k<=n;k++)
			if(s[i]==a&&s[k]==c){
				if((i+k)%2==0){
					j=(i+k)/2;
					if(s[j]==b)sum+=p[k-1]-p[i]-1;
					else sum+=p[k-1]-p[i];
				}else sum+=p[k-1]-p[i];
			}
}
int main(){
	int i;
	scanf("%d%s",&n,s+1);
	for(i=1;i<=n;i++){
		r[i]=r[i-1],g[i]=g[i-1],b[i]=b[i-1];
		if(s[i]=='R')r[i]+=1;
		else if(s[i]=='G')g[i]+=1;
		else if(s[i]=='B')b[i]+=1;
	}
	count('R','G','B',g);
	count('B','G','R',g);
	count('R','B','G',b);
	count('G','B','R',b);
	count('B','R','G',r);
	count('G','R','B',r);
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 1752
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;
long long fac[510000],finv[510000],inv[510000];
void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<510000;i++){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}
long long COM(int n,int k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
long long facdiv(lint n,lint k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return (fac[n]*finv[k])%MOD;
}
multiset<lint> decomp(lint N){
    multiset<lint> res;
    for(int i=2;i<=1100000;i++){
        while(N%i==0) N/=i,res.insert(i);
        if(N==1) break;
        if(i==1100000) res.insert(N);
    }
    return res; 
}

int main(void){
    COMinit();
    lint N,M,ans=1;
    cin >> N >> M;
    multiset<lint> div=decomp(M);
    while(!div.empty()){
        auto itr=div.begin();
        lint count=div.count(*itr);
        ans*=COM(N+count-1,count);
        ans%=MOD;
        div.erase(*itr);
    }
    cout << ans << endl;
}

Measured memory_bytes: 12160
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
using static System.Globalization.CultureInfo;
 
class Program
{
    static void Main(string[] args)
    {
        var nk = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var ar = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        WriteLine((nk[0] - 1) / (nk[1] - 1) + ToInt32((nk[0] - 1) % (nk[1] - 1) != 0));
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}

Measured memory_bytes: 16864