akhauriyash/Code-Regression huggingface dataset:
# coding=utf-8
from math import sqrt


def inner_product(vect1, vect2):
    return sum([(v1_el*v2_el) for v1_el, v2_el in zip(vect1, vect2)])


def vector_abs(vect):
    return sqrt(sum([element**2 for element in vect]))


def direction_unit_vector(p_from, p_to):
    d_vector = [(xt - xf) for xt, xf in zip(p_to, p_from)]
    d_u_vector = [element/vector_abs(d_vector) for element in d_vector]
    return d_u_vector


def projection(origin, line_from, line_to):
    direction_unit = direction_unit_vector(line_from, line_to)
    origin_d_vector = [(org-lf) for org, lf in zip(origin, line_from)]
    inject_dist = inner_product(direction_unit, origin_d_vector)
    on_line_vect = [inject_dist*element for element in direction_unit]
    return [olv_el + lf_el for olv_el, lf_el in zip(on_line_vect, line_from)]


if __name__ == '__main__':
    xy_list = list(map(int, input().split()))
    p1_list = xy_list[:2]
    p2_list = xy_list[2:]
    Q = int(input())

    for i in range(Q):
        p_list = list(map(int, input().split()))
        x_list = projection(p_list, p1_list, p2_list)
        print(' '.join(map(str, x_list)))



Measured memory_bytes: 5720
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define ll long long int

int main() {
	string s;
	cin >> s;
	
	if(s[s.length()-1] == 's'){
		cout << s + "es";
	}
	else{
		cout << s+"s";
	}
	
	
	return 0;
}

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

using namespace std;

using int64 = long long;

vector< pair< int, int > > beet(int x, int y) {
  vector< pair< int, int > > ret;
  ret.emplace_back(0, 0);
  ret.emplace_back(x, 1);
  ret.emplace_back(y, 2);
  ret.emplace_back(x & y, 3);
  ret.emplace_back(x | y, 4);
  ret.emplace_back(x ^ y, 5);
  ret.emplace_back(x ^ (x & y), 6);
  ret.emplace_back(y ^ (x & y), 7);
  return ret;
}


int N, M;
vector< int > g[100000];
map< vector< pair< int, bool > >, int > dp;
function< int(int, int, int) > fs[100000];

function< int(int, int, int) > getf(string s) {
  if(s == "T=T&X") return [](int t, int x, int y) { return t & x; };
  if(s == "T=T&Y") return [](int t, int x, int y) { return t & y; };
  if(s == "T=T|X") return [](int t, int x, int y) { return t | x; };
  if(s == "T=T|Y") return [](int t, int x, int y) { return t | y; };
  if(s == "T=T^X") return [](int t, int x, int y) { return t ^ x; };
  if(s == "T=T^Y") return [](int t, int x, int y) { return t ^ y; };
  throw 0;
}

int dfs(int idx, int par, int x, int y, int v, bool f) {
  bool leaf = true;
  for(auto &to : g[idx]) if(to != par) leaf = false;
  if(leaf) return v;
  if(f) {
    int ret = 1 << 30;
    for(auto &to : g[idx]) {
      if(to == par) continue;
      ret = min(ret, dfs(to, idx, x, y, fs[to](v, x, y), false));
    }
    return ret;
  } else {
    int ret = -1;
    for(auto &to : g[idx]) {
      if(to == par) continue;
      ret = max(ret, dfs(to, idx, x, y, fs[to](v, x, y), true));
    }
    return ret;
  }
}

int solve(int x, int y) {
  return dfs(0, -1, x, y, 0, false);
}

int main() {
  cin >> N >> M;
  for(int i = 1; i < N; i++) {
    string s;
    cin >> s;
    fs[i] = getf(s);
  }
  for(int i = 1; i < N; i++) {
    int x, y;
    cin >> x >> y;
    g[x].emplace_back(y);
    g[y].emplace_back(x);
  }
  while(M--) {
    int X, Y;
    cin >> X >> Y;
    auto uku = beet(X, Y);
    auto uku2 = uku;
    sort(begin(uku), end(uku));
    vector< pair< int, bool > > state;
    for(int i = 0; i < uku.size(); i++) {
      state.emplace_back(uku[i].second, i > 0 && uku[i - 1].first == uku[i].first);
    }
    if(!dp.count(state)) {
      int ret = solve(X, Y);
      for(int i = 0; i < uku.size(); i++) {
        if(ret == uku[i].first) {
          dp[state] = uku[i].second;
          break;
        }
      }
    }
    cout << uku2[dp[state]].first << endl;
  }
}



Measured memory_bytes: 22700
import scala.io.StdIn.readLine

object Main extends App {
  val Array(n, m) = readLine().split(' ').map(_.toInt)
  
  if (n == 1)
    println(m)
  else {
    var i: Int = 1
    val divisors = scala.collection.mutable.ArrayBuffer.empty[Int]
    while (i * i <= m) {
      if (m % i == 0) {
        divisors += i
        if (i * i != m) divisors += (m / i)
      }
      i = i + 1
    }
    println(divisors.filter(_ <= m / n).max)
  }
}

Measured memory_bytes: 58604
#include<iostream>
#include<cstdio>
int main(void)
{
	int N=0,all=1,b=1;
	scanf("%d",&N);
	int A_i[N]={0};
	for(int i=0;i<N;i++)
	{
		scanf("%d",&A_i[i]);
		if(A_i[i]==1)
		{
			b++;
		}
		else
		{
			if(all<b){
				all=b;
			}
			b=1;
		}
	}
	if(all<b){all=b;}
	printf("%d\n",all);
	return 0;
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a) ? "Yes" : "No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}
const long long INFLL = 1LL << 60;
const int INF = 1 << 30;
const double PI = acos(-1);
int main()
{
	string s;
	int x, y;
	bool ans = true;
	cin >> s >> x >> y;
	x += 10000;
	y += 10000;
	VVi dis(2);
	int cnt = 0;
	int sw = 0;
	dis[0].push_back(0);
	dis[1].push_back(0);
	rep(i, s.size())
	{
		if (s[i] == 'T')
		{
			if (sw == 0)
			{
				x -= cnt;
			}
			else if (cnt != 0)
			{
				dis[sw % 2].push_back(cnt);
			}
			cnt = 0;
			sw++;
		}
		else
		{
			cnt++;
		}
	}
	if (sw == 0)
	{
		x -= cnt;
	}
	else if (cnt != 0)
	{
		dis[sw % 2].push_back(cnt);
	}
	
	vector<vector<bool>> dp(dis[0].size() + 1, vector<bool>(20000, false));
	dp[0][10000] = true;
	for (int i = 0; i < (int)dis[0].size(); i++)
	{
		for (int j = 0; j < 19999; j++)
		{
			if (dp[i][j] == false)
			{
				continue;
			}
			//	clog<<j<<" ";
			if (j + dis[0][i] < 20000)
			{
				dp[i + 1][j + dis[0][i]] = true;
			}
			if (j - dis[0][i] > 0)
			{
				dp[i + 1][j - dis[0][i]] = true;
			}
		}
		//	clog<<endl;
	}
	if(x<0 or x> 20000){
		ans=false;
	}else{
	ans &= dp[dis[0].size()][x];
	}vector<vector<bool>> dp2(dis[1].size() + 1, vector<bool>(20000, false));
	dp2[0][10000] = true;
	for (int i = 0; i < (int)dis[1].size(); i++)
	{
		for (int j = 0; j < 19999; j++)
		{
			if (dp2[i][j] == false)
			{
				continue;
			}
			if (j + dis[1][i] < 20000)
			{
				dp2[i + 1][j + dis[1][i]] = true;
			}
			if (j - dis[1][i] > 0)
			{
				dp2[i + 1][j - dis[1][i]] = true;
			}
		}
	}
		ans &= dp2[dis[1].size()][y];
		cout << solve(ans) << endl;
}


Measured memory_bytes: 13216
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{   
    int N,X; cin>>N>>X;
    vint a(N);
    REP(i,N) cin>>a[i];

    sort(ALL(a));

    int ans=0;
    REP(i,N){
        if(X>=a[i]){
            X-=a[i];
            ans++;
        }
    }
    if(ans==N and X>0) ans--;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

class BPalace {
public:
	void solve(std::istream& in, std::ostream& out) {
	    ll n,t,a;
	    in>>n>>t>>a;
	    vector<double> h(n);
	    rep(i,n) {
	        ll tmp;
	        in>>tmp;

	        h.at(i)=t-tmp*0.006;
	    }
	    pair<double ,int > ans;
	    ans.first=pow(10,5);
	    rep(i,n){
	        if(abs(ans.first-a)>abs(h.at(i)-a)){
	            ans.first=h.at(i);
	            ans.second=i+1;
	        }
	    }
	    out<<ans.second<<endl;

	}
};


int main() {
	BPalace solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 504
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>

using namespace std;

int a[100001];
int n,k;

int main(){
  cin>>n>>k;
  for(int i=0;i<n;i++)cin>>a[i];
  if(k == 2){
    cout<<(n-1)<<endl;
    return 0;
  }
  int ans = n/(k-1);
  if((n%(k-1)) < 2) cout<<ans<<endl;
  else cout<<(ans+1)<<endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt(),b = scanner.nextInt(),c = scanner.nextInt();
		for(int i=0;i<b;i++){
			if((a*i) % b == c){
				System.out.println("YES");
				return;
			}
		}
		System.out.println("NO");
	}

}


Measured memory_bytes: 22612
#include <cstdio>

#define MAX_N 10000
#define MAX_Q 500


int lignerSearch(int *S, int &searchnum, int &n) {
	int i = 0;
	while (S[i] != searchnum) {
		if (i == n) {
			return false;
		}
		i++;
	}
	return true;
}

int main() {
// yomikomi
	int n;
	scanf("%d", &n);
	int S[MAX_N + 1];
	for (int i = 0; i < n; i++) {
		scanf("%d", &S[i]);
	}
	int q;
	scanf("%d", &q);
	int T[MAX_Q];
	for (int i = 0; i < q; i++) {
		scanf("%d", &T[i]);
	}

	int i = 0;
	int count = 0;
	while (i < q) {
		S[MAX_N] = T[i]; // search num banhei
		if (lignerSearch(S,T[i],n)) {
			count++;
		}
		i++;
	}
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

template<class T>
struct CompLeftGreater {
	bool operator() (T l, T r) { return l > r;} 
};

int main() {
	ll X, Y, Z, K;
	cin >> X >> Y >> Z >> K;
	vector<ll> A(X), B(Y), C(Z);
	for (ll i=0; i<X; ++i) cin >> A[i];
	for (ll i=0; i<Y; ++i) cin >> B[i];
	for (ll i=0; i<Z; ++i) cin >> C[i];

	CompLeftGreater<ll> cobj;
	sort(A.begin(), A.end(), cobj); 
	sort(B.begin(), B.end(), cobj); 
	// O(K^2 < 10^7)
	vector<ll> AB(K*K);
	ll idx = 0;
	for (ll i=0; i<X; ++i) {
		for (ll j=0; j<Y; ++j) {
			AB[idx++] = A[i]+B[j];
		}
	}
	sort(AB.begin(), AB.end(), cobj);

	vector<ll> ABC(K*Z);
	idx = 0;
	for (ll i=0; i<K; ++i) {
		for (ll j=0; j<Z; ++j) {
			ABC[idx++] = AB[i]+C[j];
		}
	}
	sort(ABC.begin(), ABC.end(), cobj);
	
	for (ll i=0; i<K; ++i) {
		cout << ABC[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 94080
#include "bits/stdc++.h"
using namespace std;


int main(int argc, char const *argv[])
{
  int n;
  cin >> n;
  // int sum = 0;
  set<int> s;
  while(n--){
   int x;
   cin >> x;
   if(s.find(x) ==s.end())
    s.insert(x);
  else
    s.erase(x);
  }
  cout << s.size();
  return 0;
}

Measured memory_bytes: 4864
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

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

const int N = 1010000;
const LL MOD = 1000000007;
LL fac[N];
LL sfac[N];
LL dp[N];

int main() {
	LL n, h, d;
	cin >> n >> h >> d;
	fac[0] = fac[1] = 1;
	FOR(i, 1, n + 1) {
		fac[i] = (fac[i - 1] * i) % MOD;
		sfac[i] = (sfac[i - 1] + fac[i]) % MOD;
	}
	dp[0] = fac[n];
	LL s = dp[0];
	FOR(i, 1, h) {
		dp[i] = (s * sfac[n])%MOD;
		s = (s + dp[i])%MOD;
		if (i >= d)s = (s - dp[i - d] + MOD) % MOD;
	}
	cout << s << endl;
	return 0;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int di2[] = {1, 1, -1, -1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2, -1};
const int dj2[] = {1, -1, 1, -1, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2, -1, 0, 1, 2, 2};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;


int main(){
  string s; cin >> s;
  set<string> st;
  string akiba = "AKIHABARA";
  for(auto bit = 0; bit < 1<<9; ++bit) {
    string add = "";
    rep(i, 9) {
      if(bit & 1<<i && akiba[i] == 'A') continue;
      add += akiba[i];
    }
    st.insert(add);
  }
  if(st.find(s) != st.end()) cout << "YES" << endl;
  else cout << "NO " << endl;
}

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

int main(){
  int A,B,C,X,Y;
  int ans;
  int N,M;
  int H=0,HA=0,HB=0;
  cin>>A>>B>>C>>X>>Y;
  if(A+B>2*C)H=1;
  if(A>2*C)HA=1;
  if(B>2*C)HB=1;

  if(H==1){
    ans+=min(X,Y)*C*2;
    N = X+Y-min(X,Y)*2;
    if(min(X,Y)==Y&&HA==1){
      ans+=N*C*2;
    }
    else if(min(X,Y)==Y&&HA==0){
      ans+=N*A;
    }
    else if(min(X,Y)==X&&HB==1){
      ans+=N*C*2;
    }
    else{
      ans+=N*B;
    }
  }
  else{
    ans+=X*A+Y*B;
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,j,n) for(int i=j;i<n;i++)
#define LL long long
#define pii pair<int,int>
#define fir first
#define sec second
#define MEM(i,j) memset(i,j,sizeof(i))
#define ALL(i) i.begin(),i.end()
#define VI vector<int>
#define VP vector<pii>
#define pb(a) push_back(a)
using namespace std;
int arr[100005];
bool vis[100005];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    FOR(i,1,n+1)
        cin >> arr[i];
    int cur  = 1 , ans = 1;
    bool flag = true;
    while(cur != 2)
    {
    	vis[cur] = true;
    	cur = arr[cur];
    	if(vis[cur])
    	{
    		flag = false;
    		break;
		}
		ans++;
	}
	if(flag)
	    cout << ans-1 << endl;
	else
	    cout << "-1" << endl;
    return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define db double
#define ld long double
#define rep(i,n) for(ll i=0;i<n;i++)
#define rev(i,n) for(ll i=n;i>=0;i--)
#define rep_a(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define debug(x) do { std::cerr << #x << ": " << x << std::endl; } while (0);
#define debugg(x,y) do { std::cerr << #x << ": " << x << "  "<< #y << ": " << y << std::endl; } while (0);
#define debugggg(i,j,k,ans) std::cerr << #i << ": " << i << "  "<< #j << ": " << j <<#k << ": " << k <<#ans << ": " << ans << std::endl;
const long long mod = 998244353;
const long long MOD = 1000000007;
typedef vector<ll>              vll;
typedef vector<string>          vstr;
typedef vector<char>            vchar;
typedef vector<pair<ll,ll> >    vpll;
typedef set<ll>                 sll;
typedef set<string>             sstr;
typedef set<pair<ll,ll> >       spll;
typedef map<ll,ll>              mllll;
typedef map<string,ll>          mstrll;
typedef queue<ll>               qll;
map<ll,ll>mp; 
int solve()
{
  int n;cin>>n;vector<vll> h(n+1,vll (3,INT_MAX));
  rep(i,n)rep(j,3)cin>>h[i+1][j];
  vector<vll> dp(n+1,vll (3,0));
  rep(j,3)dp[1][j] = h[1][j];
  rep_a(i,2,n+1)
  {
    rep(j,3)
    {
      rep_a(k,j+1,3)
      {
        int l = 3 - j - k;
        dp[i][l] = h[i][l]+max(dp[i-1][j],dp[i-1][k]);
      }
    }
  }
  cout<<max({dp[n][0],dp[n][1],dp[n][2]})<<endl;
  return 0;
}
 
int main()
{
  fast;
	/* #ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#else
	#endif */
	solve();
	/* #ifndef ONLINE_JUDGE
	cout<<"\nTime Elapsed: "<<1.0*clock()/ CLOCKS_PER_SEC <<" Sec\n";
	#endif */
	return 0;
}

Measured memory_bytes: 14156
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  string S;
  cin>>S;
  bool CAN=false;
  for(int i=0; i<S.size()-1; ++i){
    if(S.at(i)=='A' && S.at(i+1)=='C') CAN=true;
  }
  if(CAN) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> s(H);
  for(auto& i: s) cin >> i;

  auto sum=0;
  for(auto i: s) for(auto j: i) if(j=='#') ++sum;

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

  vector<vector<int>> d(H, vector<int>(W, -1));
  queue<pair<int,int>> q;
  q.emplace(0,0);
  d[0][0] = 1;
  while(!q.empty()) {
    auto y = q.front().first;
    auto x = q.front().second;
    q.pop();
    for(auto i=0; i<4; ++i) {
      auto ny = y+dy[i];
      auto nx = x+dx[i];
      if(ny<0||H<=ny) continue;
      if(nx<0||W<=nx) continue;
      if(d[ny][nx]!=-1) continue;
      if(s[ny][nx]=='#') continue;
      d[ny][nx] = d[y][x] + 1;
      q.emplace(ny, nx);
    }
  }
  if(d[H-1][W-1]==-1) cout << -1 << endl;
  else                cout << H*W - d[H-1][W-1] - sum << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int main(void)
{
    char a[8];
    char b[4];
    long c;
    long s;
    long i;
    scanf("%s %s",&(a[0]),&(b[0]));
    strcat(a,b);
    c = atol(a);
    s = sqrt(c);
    if(c == (s*s)){
        printf("Yes\n");
    }else{
        printf("No\n");
    };
    return 0;
}


Measured memory_bytes: 2088
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::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
 

#define M 200010


int main(){
	IOS;
	tihs;
	
	
	ll a[5],b[5];
	rep(i,0,5)cin>>a[i],b[i]=i;
	ll ans=inf;
	do{
		ll t=0;
		rep(i,0,5){
			t+=a[b[i]];
			if(t%10 and i!=4)t+=(10-(t%10));
		}
		ans=min(ans,t);
	}while(next_permutation(b,b+5));
	cout<<ans;
	return 0;
}

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

using namespace std;

#define ll long long

const int maxN = 100005;
const int INF = 1e9;

int arr[maxN];
int brr[maxN];
int crr[maxN];
int xrr[maxN];
int yrr[maxN];

int main() {
	//freopen("in.in", "r", stdin);

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

	int A, B, M;
	cin >> A >> B >> M;

	for (int i = 0; i < A; i++) cin >> arr[i];
	for (int i = 0; i < B; i++) cin >> brr[i];
	for (int i = 0; i < M; i++) {
		cin >> xrr[i] >> yrr[i] >> crr[i];
		xrr[i]--;
		yrr[i]--;
	}

	int ans = INF;
	for (int i = 0; i < M; i++) {
		int x = xrr[i];
		int y = yrr[i];
		ans = min(ans, arr[x] + brr[y] - crr[i]);
	}

	int m1 = INF, m2 = INF;
	for (int i = 0; i < A; i++) m1 = min(m1, arr[i]);
	for (int i = 0; i < B; i++) m2 = min(m2, brr[i]);

	ans = min(ans, m1 + m2);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define maxn 100100
char s[110];
int len;
int cal(int x)
{
    int las=0;
    int mx=0;
    for(int i=0;i<len;++i)
    {
        if(s[i]-'a'==x)
        {
            mx=max(mx,i-las);
            las=i+1;
        }
    }
    mx=max(mx,len-las);
    return mx;
}
int main()
{
    scanf("%s",s);
    len=strlen(s);
    int ans=len;
    for(int i=0;i<26;++i)
        ans=min(ans,cal(i));
    printf("%d\n",ans);
    return 0;
}


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

#define ll long long

const int mod = 1e9+7;

ll memo[100][5][5][5];
int n;
string s="AGCT";
map<char,int> hsh;

ll go(int pos,int oh,int ah,int oo){
    if(pos==n) return 1;
    if(memo[pos][oh][ah][oo]!=-1){
        return memo[pos][oh][ah][oo];
    }
    ll ans=0;
    for(auto it:s){
        if(oh==0){
            ans+=go(pos+1,hsh[it],ah,oo);
        }
        else if(ah==0){
            ans+=go(pos+1,oh,hsh[it],oo);
        }
        else if(oo==0){
            if(it!='C'&&it!='G'){
                ans+=go(pos+1,oh,ah,hsh[it]);
            }
            else{
                if(it=='C'){
                    if((oh==1&&ah==2)||(oh==2&&ah==1)) continue;
                    ans+=go(pos+1,oh,ah,hsh[it]);
                }
                else{
                    if(oh==1&&ah==3) continue;
                    ans+=go(pos+1,oh,ah,hsh[it]);
                }
            }
        }
        else{
            if(it!='C'&&it!='G'){
                ans+=go(pos+1,ah,oo,hsh[it]);
            }
            else{
                if(it=='G'){
                    if(ah==1&&oo==3) continue;
                    ans+=go(pos+1,ah,oo,hsh[it]);
                }
                else{
                    if((ah==1&&oo==2)||(ah==2&&oo==1)) continue;
                    if(oh==1&&ah==2&&(oo==2||oo==1||oo==4)) continue;
                    if(oh==1&&ah==4&&oo==2) continue;
                    ans+=go(pos+1,ah,oo,hsh[it]);
                }
            }

        }
        ans%=mod;
    }
    return memo[pos][oh][ah][oo]=ans;
}

int main(){

    hsh['A']=1;
    hsh['G']=2;
    hsh['C']=3;
    hsh['T']=4;
    memset(memo,-1,sizeof(memo));
    cin>>n;
    cout<<go(0,0,0,0);
    return 0;

}

Measured memory_bytes: 384
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]

def prime_fact(n):
    root = int(math.sqrt(n))
    prime_dict = {}
    for i in range(2, root+1):
        cnt = 0
        while n % i == 0:
            cnt += 1
            n = n // i
        if cnt:
            prime_dict[i] = cnt
    if n != 1:
        prime_dict[n] = 1
    return prime_dict


def main():
    N = NI()
    PD = {}
    for i in range(2, N+1):
        pd = prime_fact(i)
        for p, k in pd.items():
            PD.setdefault(p, 0)
            PD[p] += k
    X = {74: 0, 24: 0, 14: 0, 4: 0, 2: 0}
    for p, k in PD.items():
        for x in X.keys():
            if k >= x:
                X[x] += 1
    print(X[74] + X[24]*(X[2]-1) + X[14]*(X[4]-1) + X[4]*(X[4]-1)//2 * (X[2]-2))


if __name__ == "__main__":
    main()

Measured memory_bytes: 9452
Scanf.scanf "%d %d" (fun n m ->
    let balls = Array.make n 1 in
    let red   = Array.make n false in
    red.(0) <- true;
    for i = 1 to m do
        Scanf.scanf " %d %d" (fun x y ->
            let x = x - 1 in let y = y - 1 in
            if red.(x) then (
                if balls.(x) = 1 then red.(x) <- false;
                red.(y) <- true
            );
            balls.(x) <- balls.(x) - 1;
            balls.(y) <- balls.(y) + 1;
        )
    done;
    Array.fold_left (fun acc v -> if v then acc + 1 else acc) 0 red |> Printf.printf "%d\n"
)

Measured memory_bytes: 5888
def preorder(tree, index):
    print(" " + str(index), end="")
    if tree[index][1] != -1:
        preorder(tree, tree[index][1])
    if tree[index][2] != -1:
        preorder(tree, tree[index][2])


def inorder(tree, index):
    if tree[index][1] != -1:
        inorder(tree, tree[index][1])
    print(" " + str(index), end="")
    if tree[index][2] != -1:
        inorder(tree, tree[index][2])


def postorder(tree, index):
    if tree[index][1] != -1:
        postorder(tree, tree[index][1])
    if tree[index][2] != -1:
        postorder(tree, tree[index][2])
    print(" " + str(index), end="")



n = int(input())
a = [[-1 for i in range(3)] for j in range(n)]
for _ in range(n):
    i, l, r = [int(x) for x in input().split()]
    a[i][1] = l
    a[i][2] = r
    a[l][0] = i
    a[r][0] = i

root = 0
for i, v in enumerate(a):
    if v[0] == -1:
        root = i
        break

print("Preorder")
preorder(a, root)
print("")
print("Inorder")
inorder(a, root)
print("")
print("Postorder")
postorder(a, root)
print("")



Measured memory_bytes: 5616
''' بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ '''
gi = lambda : list(map(int,input().strip().split()))
n, = gi()
a = gi()
b = gi()
ans = 0
for k in range(n):
	if b[k] >= a[k]:
		ans += a[k]
		b[k] -= a[k]
	else:
		ans += b[k]
		a[k] -= b[k]
		b[k] = 0
	if b[k] > 0:
		temp = min(a[k + 1], b[k])
		a[k + 1] -= temp
		ans += temp
print(ans)

Measured memory_bytes: 18624
import java.util.*;

class Main{
	

	public static ArrayList<Log> logs = new ArrayList<>();


	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		
		int H = sc.nextInt();
		int W = sc.nextInt();

		boolean map[][] = new boolean[H][W];

		int rem = 0;

		for(int h=0;h<H;h++){
			for(int w=0;w<W;w++){
				int c = sc.nextInt();
				if(c%2==0) map[h][w] = true;
				else{
				 map[h][w] = false;
				 rem++;
				}
			}
		}

		int rem_x = -1;
		int rem_y = -1;
		int p_x = -1;
		int p_y = -1;

		for(int h=0;h<H;h++){
			if(rem < 2) break;
			if(h%2==0){
				for(int w=0;w<W;w++){

					if(!(rem_x == -1 && rem_y == -1)){
						logs.add(new Log(p_y,p_x,h,w));
					}
					if(!map[h][w]){
						if(rem_x == -1 && rem_y == -1){
							rem_x = w;
							rem_y = h;
							p_x = rem_x;
							p_y = rem_y;
						}else{
							map[rem_y][rem_x] = false;
							map[h][w] = false;
							rem -= 2;
							rem_x = -1;
							rem_y = -1;
						}
					}
					p_x = w;
					p_y = h;
				}

			}else{
				for(int w=W-1;w>=0;w--){

					if(!(rem_x == -1 && rem_y == -1)){
						logs.add(new Log(p_y,p_x,h,w));
					}
					if(!map[h][w]){
						if(rem_x == -1 && rem_y == -1){
							rem_x = w;
							rem_y = h;
							p_x = rem_x;
							p_y = rem_y;
						}else{
							map[rem_y][rem_x] = false;
							map[h][w] = false;
							rem -= 2;
							rem_x = -1;
							rem_y = -1;
						}
					}
					p_x = w;
					p_y = h;
				}

			}
		}

		System.out.println(logs.size());
		for(int n=0;n<logs.size();n++){
			System.out.println(logs.get(n).y+" "+logs.get(n).x+" "+logs.get(n)._y+" "+logs.get(n)._x);
		}


	}

	private static class Log{
		int y,x,_y,_x;
		Log(int y,int x,int _y,int _x){
			this.y = y+1;
			this.x = x+1;
			this._y = _y+1;
			this._x = _x+1;
		}
	}
}

Measured memory_bytes: 108860
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
	int w, h, n;
	cin >> w >> h >> n;
	int x[150], y[150], a[150];
	rep(i, n) cin >> x[i] >> y[i] >> a[i];
	int s = 0, t = w, u = 0, v = h;
	
	rep(i, n) {
		if (a[i] == 1) {
			s = max(s, x[i]);
		}
		else if (a[i] == 2) {
			t = min(t, x[i]);
		}
		else if (a[i] == 3) {
			u = max(u, y[i]);
		}
		else if (a[i] == 4) {
			v = min(v, y[i]);
		}
	}
	int ans = max(0,t-s)* max(0,v-u);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int w[2010];
int n, X, Y;
bool Pos(int K) {
	if (abs(w[n] - Y) >= K)return true;
	if (n>1 && abs(w[n - 1] - w[n]) >= K)return true;
	return false;
}
int main() {
	int i, j;
	scanf("%d%d%d", &n, &X, &Y);
	for (i = 1; i <= n; i++) {
		scanf("%d", &w[i]);
	}
	int b = 0, e = 1e9, mid, res = 0;
	while (b <= e) {
		mid = (b + e) >> 1;
		if (Pos(mid))res = mid, b = mid + 1;
		else e = mid - 1;
	}
	printf("%d\n", res);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int k;
int inque[100001],dis[100001];
struct node{
	int dis,i;
	node(int i,int dis):i(i),dis(dis){}
};
vector<node>v1[100001];
queue<int>q1;
int spfa(int s){
	memset(inque,0,sizeof(inque));
	memset(dis,127,sizeof(dis));
	dis[s]=0;
	inque[s]=1;
	q1.push(s);
	while(!q1.empty()){
		int k1=q1.front();q1.pop();
		inque[k1]=0;
		for(int i=0;i<v1[k1].size();i++){
			node w=v1[k1][i];
			//cout<<dis[w.i]<<' ';
			if(dis[w.i]>dis[k1]+w.dis){
				dis[w.i]=dis[k1]+w.dis;
				if(inque[w.i]==0){
					//cout<<w.i;
					inque[w.i]=1;
					q1.push(w.i);
				}
			}
		} 
		
	}
	//cout<<s<<' ';
	return s+dis[0];
}
int main(){
	cin>>k;
	for(int i=1;i<k;i++){
		for(int j=0;j<=9;j++){
			v1[i].push_back(node((i*10+j)%k,j));
		}
	}
	int minv=10000000;
	for(int s=1;s<=9;s++){
		//cout<<spfa(s)<<endl;
		minv=min(minv,spfa(s));
	}
	cout<<minv;
}

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

int main() {
	long a,n,i,j,k,l,x,y,z;
	cin >>a;
	int vol[a];
	for (i=0; i<a; i++) {
		cin >>n;
		vol[i]=n;
	}
	x=vol[0];
	for (j=0; j<a; j++) {
		if (vol[j] <= x) {
			x=x;
		} else if (x < vol[j]) {
			x=vol[j];
		}
	}
	y=vol[0];
	for (k=0; k<a; k++) {
		if (vol[k] < y) {
			y=vol[k];
		} else if (y <= vol[k]) {
			y=y;
		}
	}
	z=0;
	for (l=0; l<a; l++) {
		z=z+vol[l];
	}
	cout <<y<<" "<<x<<" "<<z<<endl;
}


Measured memory_bytes: 3116
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int main(){
  int N;
  double D;
  cin >> N;
  cin >> D;
  
  vector<double> X(N);
  vector<double> Y(N);
  
  for(int i=0; i<N; i++){
    cin >> X[i];
    cin >> Y[i];
  }
  
  int count=0;
  for(int i=0; i<N; i++){
    double d = X[i]*X[i]+Y[i]*Y[i];
    d = sqrt(d);
    if(d <= D){
      count++;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 6548
#include <iostream>
#include <vector>
#include <string>
using namespace std;
#define ll long long

int main(){
    ll N,M;
    // int a,b,c,d;
    int tmp = 0, ans = 0;
    vector<int> a(5);
    cin >> N >> M;
    if(N == 1 && M == 1){
        cout << 1 << endl;   
    }else if(N == 1){
        cout << M - 2 << endl;
    }else if(M == 1){
        cout << N - 2 << endl;
    }else{
        cout << (N-2) * (M-2) << endl;
    }
}

Measured memory_bytes: 256
n = int(input())
L=[]
for i in range(n):
	a = int(input())
	for j in range(a):
		x,y=map(int, input().split())
		L.append([i,x-1,y])
ans=0
import itertools
for i in itertools.product([1,0], repeat=n):
	s = sum(list(i))
	for l in L:
		if i[l[0]]==1 and i[l[1]]!=l[2]:
			s=0
			break
	ans= max(ans,s)
print(ans)

Measured memory_bytes: 3064
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

L = I()

N = math.floor(math.log2(L))+1
M = 0
edge = []
for i in range(N-1):
    edge.append([i,i+1,0])
    edge.append([i,i+1,2**i])
    M += 2
for i in range(N-1)[::-1]:
    if L-2**i >= 2**(N-1):
        edge.append([i,N-1,L-2**i])
        M += 1
        L -= 2**i

print(N,M)
for e in edge:
    print(e[0]+1, e[1]+1, e[2])

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

signed main() {
  int n; cin >> n;
  int sum = 0;
  int a[n], sumA[110];
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
    sumA[i] = sum;
  }
  sum = 0;
  int b[n], sumB[110];
  for(int i = 0; i < n; i++) {
    cin >> b[i];
    sum += b[i];
    sumB[i] = sum;
  }

  int maxS = 0;
  for(int i = 0; i < n; i++) {
    maxS = max(maxS, sumA[i] + (sumB[n-1] - sumB[i]) + b[i]);
  }
  cout << maxS << endl;
  return 0;
}


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

using namespace std;

int main(){
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    bool ans = true;
    for (int i = 1; i < s.length(); i++){
        if (s[i] == s[i-1]){
            ans = false;
            break;
        }else{
            continue;
        }
    }
    if (ans){
        cout << "yes";
    }else{
        cout << "no";
    }


    return 0;
}


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

int main()
{
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> ans(N);

  for (int i = 0; i < M; i++)
  {
    int p;
    string s;
    cin >> p >> s;
    if (s == "WA"s)
    {
      if (ans.at(p - 1).first == 0)
      {
        ans.at(p - 1).second++;
      }
    }
    else
    {
      ans.at(p - 1).first = 1;
    }
  }

  int ac = 0;
  int wa = 0;
  for (auto a : ans)
  {
    ac += a.first;
    if (a.first)
    {
      wa += a.second;
    }
  }
  cout << ac << ' ' << wa << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
/*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}

int main(){
    string s;
    cin >> s;
    char z;
    ll ans =0;
    vector<ll>che(s.size()+1,0);
    for(int i=0;i<s.size();i++){
        if(s.at(i)=='<'){
            che.at(i+1)=max(che.at(i+1),che.at(i)+1);
        }
    }
    reverse(s.begin(),s.end());
    reverse(che.begin(),che.end());
    for(int i=0;i<s.size();i++){
        if(s.at(i)=='>'){
            che.at(i+1)=max(che.at(i+1),che.at(i)+1);
        }
    }
    for(int i=0;i<=s.size();i++){
        ans+=che.at(i);
    }
   cout << ans<<endl;
}
    



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

#define int long long
#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define DESYNC ios::sync_with_stdio(0); cin.tie(0);
#define deb(x) cerr << ">> " << #x << " : " << x << "\n";
#define print(a) for(auto x : a) cout << x << " "; cout << "\n";

const int inf = 1e18 + 5;

// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

void solve()
{
    int n, m;
    cin >> n >> m;
    if(n == m) cout << "Yes\n";
    else cout << "No\n"; 
}

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

Measured memory_bytes: 3620
def main():
    import sys
    input = sys.stdin.readline
    class BIT:
        def __init__(self,n):
            self.tree = [0]*(n+1)
            self.size = n
        
        def add(self,i,x):
            while i <= self.size:
                self.tree[i] += x
                i += i&-i
        
        def sum(self,i):
            s = 0
            while i > 0:
                s += self.tree[i]
                i -= i&-i
            return s

    N,Q = map(int,input().split())
    bit = BIT(N)
    C = list(map(int,input().split()))
    query = []
    for i in range(Q):
        l,r = map(int,input().split())
        query.append([l,r,i])
    query.sort(key=lambda x: x[1])
    ans = [0]*Q
    #良い玉のindexを1-indexで管理する
    colorMemo = [0]*(N+1)
    cur = 1
    for q in query:
        l,r,j = q
        #良い玉の情報を更新する
        for i in range(cur,r+1):
            c = C[i-1]
            if colorMemo[c]:
                bit.add(colorMemo[c],-1)
            bit.add(i,1)
            colorMemo[c] = i
        cur = r + 1
        ans[j]=bit.sum(r)-bit.sum(l-1)

    print(*ans, sep="\n")
main()

Measured memory_bytes: 234208
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	string n;
	int x = 0;
	cin >> n;
	if (n.size() % 2 == 1){
		for (int i = 0; i < n.size()/2; i++){
			if (n[i] == n[n.size() - i - 1]){
				x++;
			}
		}
		if (x == n.size() / 2){
			cout << "Yes" << endl;
			return 0;
		}
		else{
			cout << "No" << endl;
			return 0;
		}
	}
	else{
		for (int i = 0; i < n.size() / 2; i++){
			if (n[i] == n[n.size() - i - 1]){
				x++;
			}
		}
		if (x == n.size()){
			cout << "Yes"<<endl;
			return 0;
		}
		else{
			cout << "No" << endl;
			return 0;
		}
	}
}

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

typedef long long ll;

#define rep(var,n) for(int var=0;var<(n);++var)

int main(){

  cin.tie(0);
  ios::sync_with_stdio(false);

  int n; cin >> n;

  cout << (double)(n/2+n%2)/n << endl;
  return 0;
}

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

const long long MOD = 1000000007;

void solve(long long N, long long M){
    if(N > M) swap(N, M);
    if(N+1 < M) {
        cout << 0 << endl;
        return;
    }
    ll res = 1;
    for(ll i=1; i<=N; i++){
        res *= i;
        res = res % MOD;
    }
    for(ll i=1; i<=M; i++){
        res *= i;
        res = res % MOD;
    }
    if(N==M) res = (res*2)%MOD;
    cout << res << endl;

}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
LL read() {
	int x = 0,f = 0;char ch = getchar();
	while(!isdigit(ch)) {if(ch=='-')f=1;ch=getchar();}
	while(isdigit(ch)) {x = x * 10 + ch - '0';ch = getchar();}
	return f?-x:x;
}

const int N = 1e6 + 10,inf = 0x3f3f3f3f;
LL a,b,c,d;
int main()
{
	a= read();b = read();c = read();d = read();
	cout << max(max(a*c,a*d),max(b*c,b*d));
	return 0;
}

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

int n,k;
int arr[9];

bool check(int n)
{
    int temp = n;
    while(temp != 0)
    {
        int x = temp%10;
        temp = temp/10;
        forn(i,k) if(arr[i] == x) return 1;
    }
    return 0;
}

int main()
{
    cin>>n>>k;
    forn(i,k) cin>>arr[i];

    while(check(n))
        n++;
    cout<<n;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
const long double EPS=1E-8;
////////////////////////////////////////


int main(){
    ll n[4];rep(i,0,3)cin>>n[i];
    sort(n,n+4);
    ll p[4]={1,4,7,9};
    rep(i,0,3){
        if(n[i]!=p[i]){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    
    
    return 0;
}






Measured memory_bytes: 256
using System;

namespace Project
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			while (true)
			{
				int H, W;
				string s = Console.ReadLine();
				string[] sar = s.Split(' ');
				H = int.Parse(sar[0]);
				W = int.Parse(sar[1]);
				if (H == 0 && W == 0) { break; }

				for (int i = 0; i < H; i++)
				{
					for (int j = 0; j < W; j++)
					{
						Console.Write("#");
					}
					Console.Write("\n");
				}
				Console.Write("\n");
			}
		}
	}
}

Measured memory_bytes: 8712
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func printBinary(n uint32) {
	fmt.Printf("%032b\n", n)
}

func main() {
	scanner.Split(bufio.ScanWords)

	n := uint32(nextInt())

	printBinary(n)
	printBinary(^n)
	printBinary(n << 1)
	printBinary(n >> 1)
}



Measured memory_bytes: 1132
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define ti3 tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
ll int MOD=1e9+7;
#define N 400000
 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    int n;
    cin>>n;
    ll int a[N];
    rep(i,3*n){
        cin>>a[i];
    }
    ll int b[N],c[N];
    pqg q;
    int i=0;
    ll int sum=0;
    while(i<n){
        q.push(a[i]);
        sum+=a[i];
        i++;
    }
    b[i]=sum;
    while(i<=2*n){
        ll int t=q.top();
        q.pop();
        sum+=(max(a[i],t)-t);
        q.push(max(a[i],t));
        i++;
        b[i]=sum;
    }
    i=3*n-1;
    pq p;
    sum=0;
    while(i>=2*n){
        p.push(a[i]);
        sum+=a[i];
        i--;
    }
    c[i+1]=sum;
    while(i>=n){
        ll int t=p.top();
        p.pop();
        sum+=(min(a[i],t)-t);
        p.push(min(a[i],t));
        i--;
        c[i+1]=sum;
    }
    ll int ans=-1e15;
    rep2(i,n,2*n){
        ans=max(ans,b[i]-c[i]);
    }
    cout<<ans;
    return 0;

}

Measured memory_bytes: 10232
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    long long n,a[200000],sum=0,s=0,ans=20000000000000000;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    for(int i=0;i<n-1;i++){
        s+=a[i];
        ans=min(abs((sum-s)-s),ans);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan, degrees
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
xy = [LIST() for _ in range(N)]
ans = INF
xy.sort()
for l in range(N-K+1):  # 長方形に含まれる最も左の点
    for r in range(l+K, N+1):  # 長方形に含まれる最も右の点
        y = sorted(xy[l:r], key = lambda x: x[1])  # lからrの中でのyのとりうる値をソート
        for i in range(r-l-K+1):
            sq = (xy[r-1][0] - xy[l][0]) * (y[i+K-1][1] - y[i][1])  # 下からKこ選んだときの面積
            ans = min(ans, sq)
print(ans)


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

int main (){
    double r;
    scanf("%lf", &r);
    
    double a = r * r * 3.141592653589;
    double b = 2 * r * 3.141592653589;
    
    printf("%f %f\n", a,b);
    
    return 0;
}


Measured memory_bytes: 3192
#include<stdio.h>
#include<cmath>

using namespace std;

int main(){

    double x1, y1, x2, y2;

    scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);

    printf("%.8lf\n", sqrt( (x2-x1) * (x2-x1) + (y2-y1) * (y2-y1) ) );

    return 0;

}


Measured memory_bytes: 2732
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
  input()
  vs = [(i + 1, v) for i, v in enumerate(map(int, input().split()))]
  vs.sort(key=lambda x: x[1])

  print(' '.join(str(i) for i, _ in vs))


if __name__ == '__main__':
  main()


Measured memory_bytes: 73132