akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<sstream>
using namespace std;
long long int inf = 1e18;

int n, m, s, t;
vector<int> u, v, a, b;

vector< vector< pair<int, pair<int, int> > > > x;


vector<long long int> func(int z, int ss){
  queue<int> q;
  q.push(ss);

  vector<long long int> y;
  y.resize(n+1, inf);
  y[ss] = 0;
  while(!q.empty()) {
    int p = q.front();
    q.pop();

    for(int i=0; i<x[p].size(); i++){
      int vv = x[p][i].first;
      pair<int, int> pp = x[p][i].second;

      if( z == 1 ){
        if( y[vv] > y[p] + pp.first ){
          y[vv] = y[p] + pp.first;
          q.push(vv);
        }
      }else {
        if( y[vv] > y[p] + pp.second ){
          y[vv] = y[p] + pp.second;
          q.push(vv);
        }
      }
    }
  }
  return y;
}

int main(){

  cin >> n >> m >> s >> t;
  u.resize(m);
  v.resize(m);
  a.resize(m);
  b.resize(m);
  x.resize(n+1);
  for(int i=0; i<m; i++){
    cin >> u[i] >> v[i] >> a[i] >> b[i];
    x[u[i]].push_back({v[i], {a[i], b[i]}});
    x[v[i]].push_back({u[i], {a[i], b[i]}});
  }
  long long int money = 1e15;
  vector<long long int> y = func(1, s);
  vector<long long int> snk = func(0, t);
  for(int i=1; i<=n; i++) {
    cerr << y[i] << " " << snk[i] << endl;
  }

  vector<long long int> ans(n+1, money);
  long long int mn = inf;
  for(int i=0; i<n; i++){
    mn = min(mn, y[n-i] + snk[n-i]);
    ans[n-1-i] -= mn;
  }
  for(int i=0; i<n; i++){
    cout << ans[i] << endl;
  }


  return 0;
}


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

int main(){
    int N, D, X;
    cin >> N >> D >> X;

    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }

    int n = 0;
    for(int i=0;i<N;i++){
        int x = 0;
        while(x*A[i]+1 <= D){
            n++;
            x++;
        }
    }
    cout << n+X << endl;
    return 0;
}


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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	while(true){
		int W=in(),H=in();
		if(!W && !H) break;
		vector<vector<int>> HW(H+1,vector<int>(W,1)),VW(H,vector<int>(W+1,1)),D(H,vector<int>(W,1<<30));

		REP(i,2*H-1){
			if(!(i%2)){
				REP(j,W-1){
					VW[i/2][j+1] = in();
				}
			}
			else{
				REP(j,W){
					HW[(i/2)+1][j] = in();
				}
			}
		}
		HW[0][0]=0,HW[H][W-1]=0;
		D[0][0]=1;
		queue<int> Q;
		Q.push(0);
		while(!Q.empty()){
			int V=Q.front();
			Q.pop();
			int u=V%W,v=V/W;
			if(u>0 && D[v][u-1]>=1<<30 && VW[v][u]==0){
				D[v][u-1]=D[v][u]+1;
				Q.push(u-1+v*W);
			}
			if(u<W-1 && D[v][u+1]>=1<<30 && VW[v][u+1]==0){
				D[v][u+1]=D[v][u]+1;
				Q.push(u+1+v*W);
			}
			if(v>0 && D[v-1][u]>=1<<30 && HW[v][u]==0){
				D[v-1][u]=D[v][u]+1;
				Q.push(u+(v-1)*W);
			}
			if(v<H-1 && D[v+1][u]>=1<<30 && HW[v+1][u]==0){
				D[v+1][u]=D[v][u]+1;
				Q.push(u+(v+1)*W);
			}
		}
		out(D[H-1][W-1]>=1<<30 ? 0 : D[H-1][W-1]);
	}
	return 0;
}



Measured memory_bytes: 3132
#include <stdio.h>

int main(void)
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if(a < b){
		if(b < c){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1008
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")

#include <iostream>
#include <string>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <tuple>
#include <queue>
#define PII pair<int, int>
#define T3I tuple<int, int, int>
using namespace std;

typedef long long ll;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;

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

    ll N, K;
    cin >> N >> K;
    int ans = 0;
    while(N) {
        N /= K;
        ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

const int mod = 1000000007;

struct mint {
    long long x;
    mint(long long x=0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
bool operator==(const mint& a, const mint& b) { return a.x == b.x;}

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

    int n;
    cin >> n;
    mint ans = 1;
    for (int i = 1; i <= n; ++i) {
        ans *= i;
    }
    cout << ans << endl;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=1; i<N; i++){
        cin >> A[i];
    }

    vector<int> cntS(N, 0);
    for(int i=1; i<N; i++){
        cntS[A[i]-1]++;
    }

    for(int i=0; i<cntS.size(); i++){
        cout << cntS[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 4844
from bisect import bisect_left, bisect_right
n = int(input())
al = sorted(list(map(int,input().split())))
bl = sorted(list(map(int,input().split())))
cl = sorted(list(map(int,input().split())))

ans = 0
for b in bl:
    # b未満の要素の個数
    a_cnt = bisect_left(al,b)
    # bより大きい要素の個数
    c_cnt = n - bisect_right(cl,b)
    ans += a_cnt*c_cnt

print(ans)

Measured memory_bytes: 106388
#include<stdio.h>

int main(){
  int n,n2=0;
  double ans;
  scanf("%d",&n);
  // printf("%d\n",n);
  if(n%2==1)
    {
      n2=n+1;
      double x =n2/2;
      ans = x/n;
    }
  else{
    double y =n/2;
    ans =y/n;
      }
      printf("%f\n",ans);
  
  return 0;
}


Measured memory_bytes: 128
def main():
    n,wmax = map(int,input().split())
    wv = [list(map(int,input().split())) for _ in range(n)]

    # min -> inf, max -> -1
    inf = 10**18
    vmax = sum(list(zip(*wv))[1])
    dp = [[inf]*(vmax+1) for _ in range(n+1)]

    # shoki joken
    dp[0][0] = 0
    for i in range(n):
        w,v = wv[i]
        for j in range(vmax+1):
            # i select or not select
            if j-v >= 0:
                dp[i+1][j] = min(dp[i][j],dp[i][j-v]+w)
            else:
                dp[i+1][j] = dp[i][j]

    res = 0
    for i in range(vmax+1):
        if wmax >= dp[-1][i]:
            res = max(res,i)
    print(res)

if __name__ == '__main__':
    main()


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

int main() {
  int64_t N, M, K;
  cin >> N >> M >> K;
  vector<int64_t> A(N + 1), B(M + 1);
  int64_t tmp;
  for (int64_t i = 1; i < N + 1; i++) {
    cin >> tmp;
    A[i] = A[i - 1] + tmp;
  }
  for (int64_t i = 1; i < M + 1; i++) {
    cin >> tmp;
    B[i] = B[i - 1] + tmp;
  }
  int64_t ans = 0;
  for (int i = 0; i < N + 1; i++) {
    
    tmp = K - A[i];
    if (tmp < 0) {
      break;
    }
    else {
      int64_t b = upper_bound(B.begin(), B.end(), tmp) - B.begin();
      ans = max(ans, i + b - 1);
    }
  }
  cout << ans;
}



Measured memory_bytes: 6428
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

namespace CSharpSpiral {
	class Program {
		static void Main(string[] args) {
			var sw = new StreamWriter(Console.OpenStandardOutput()) {
				AutoFlush=
#if DEBUG
			true
#else
			false
#endif
			};
			Console.SetOut(sw);
			new Program().Solve(new ConsoleInput(
#if DEBUG
			new StreamReader("../../../inputData.txt")
#else
			Console.In
#endif
			, ' '));
			Console.Out.Flush();
		}
		public void Solve(ConsoleInput cin) {
			var N = cin.ReadInt;
			var A = cin.ReadIntArray(N);
			var Dif = A.Select((x, i) => x-i);
			var count = new Dictionary<int, int>();
			var res = 0L;
			for(int j = 0; j<N; j++) {
				var query = A[j]-j;
				if(count.ContainsKey(query))
					res+=count[query];
				var target = -(j+A[j]);
				if(count.ContainsKey(target)) {
					count[target]++;
				} else{ count.Add(target, 1); }
			}
			Console.WriteLine(res);
		}
	}
	static class ExtendClass {
		public static string Join<T>(this IEnumerable<T> X, string separator = " ") => string.Join(separator, X);
	}
	class ConsoleInput {
		private readonly TextReader _stream;
		private readonly char _separator = ' ';
		private readonly Queue<string> inputStream;
		public ConsoleInput(TextReader stream, char separator = ' ') {
			this._separator=separator;
			this._stream=stream;
			inputStream=new Queue<string>();
		}
		public string Read {
			get {
				if(inputStream.Count!=0) return inputStream.Dequeue();
				string[] tmp = _stream.ReadLine().Split(_separator);
				for(int i = 0; i<tmp.Length; ++i)
					inputStream.Enqueue(tmp[i]);
				return inputStream.Dequeue();
			}
		}
		public string ReadLine { get { return _stream.ReadLine(); } }
		public int ReadInt { get { return int.Parse(Read); } }
		public long ReadLong { get { return long.Parse(Read); } }
		public double ReadDouble { get { return double.Parse(Read); } }
		public string[] ReadStrArray(long N) {
			var ret = new string[N];
			for(long i = 0; i<N; ++i)
				ret[i]=Read;
			return ret;
		}
		public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i<N; ++i) ret[i]=ReadInt; return ret; }
		public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i<N; ++i) ret[i]=ReadLong; return ret; }
		public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i<N; ++i) ret[i]=ReadDouble; return ret; }
		public bool isEOF {
			get { return _stream.Peek()==-1; }
		}
	}
}

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

const ll INF = 1LL << 60;

ll N;
vector<ll> A;
ll ans = 0;

void dfs(int i, vector<ll> v) {
    if (i >= N) {
        rep(j, v.size()) {
            if (v[j] % 2 == 0) {
                ans++;
                return;
            }
        }
        return;
    }

    v[i] = A[i];
    dfs(i + 1, v);


    v[i] = A[i] - 1;
    dfs(i + 1, v);

    v[i] = A[i] + 1;
    dfs(i + 1, v);
}

int main() {
    cin >> N;
    A.resize(N);
    rep(i, N) cin >> A[i];
    vector<ll> tmp(N);
    dfs(0, tmp);

    cout << ans << endl;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
lsd = []
for i in range(N):
    lsd.append(list(map(int,input().split())))
lsd.sort(key=lambda x:x[0])
ans = 0
i = 0
while M != 0:
    if M >= lsd[i][1]:
        ans += lsd[i][0]*lsd[i][1]
        M -= lsd[i][1]
    else:
        ans += lsd[i][0]*M
        M = 0
    i += 1
print(ans)

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

int main()
{
    int a,b;
    cin >> a >> b;
    int n = max(a, b);

    for(int i=n;i<=1000;i++){
        int A = i * 0.08;
        int B = i * 0.1;
        if (A == a && B == b)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(x)     (x).begin() , (x).end()
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
typedef long long int ll;
using namespace std;

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

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


const ll mod = 1e9+7;
const double eps = 1e-9;


const int N=2e5+10;
int n,k;
ll a[N];

void comp() {
    map<ll,ll>res;
    vector<ll>ar;
    for(int i=0;i<n;++i)
        ar.push_back(a[i]);
    sort(all(ar));
    ll cur=20;
    for(int i=0;i<n;++i) {
        if(res[ar[i]]==0) {
            res[ar[i]]=cur , cur++;
        }
    }
    for(int i=0;i<n;++i)
        a[i] = res[a[i]];
}

void solve(){
    cin >> n >> k;
    for(int i=0;i<n;++i)
        cin >> a[i];
    //comp();
    int j=0;    
    ll cur=a[j];
    for(int i=k;i<n;++i) {
        if(a[i] > cur)
            cout << "Yes\n";
        else cout << "No\n";
        cur=a[++j];
    }
}



int main(){
    fastio 
    int test=1;
    while(test--)
        solve();
    return 0;
}


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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define I_1000000007 (1000000007)
#define I_998244353   (998244353)
#define I_INF             (1<<28)
#define L_INF           (1LL<<60)
#define rep(i, n)      REP(i, 0, (n))
#define repc(i, n)     REPC(i, 0, (n))
#define REP(i, n, m)   for (int i = (int)(n); i <  (int)(m); i++)
#define REPC(i, n, m)  for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define yesno(cond)       YESNO((cond), "Yes", "No")
#define YESNO(cond, a, b) cout << ((cond) ? (a) : (b)) << "\n"
template<class T> inline bool chmin(T& a, const T& b) {
  if (a > b) { a = b; return true; } else return false;
}
template<class T> inline bool chmax(T& a, const T& b) {
  if (a < b) { a = b; return true; } else return false;
}

namespace solver {
  using namespace std;
  using ll = long long;

  int H, W, K, sum[15][1010];
  bool S[15][1010];

  void init() {
    cin >> H >> W >> K;
    string s;
    rep(i, H) {
      cin >> s;
      rep(j, W) {
        S[i][j] = s[j] - '0';
      }
    }
  }

  void solve() {
    rep(i, H) rep(j, W) {
      sum[i+1][j+1] = sum[i+1][j] + sum[i][j+1] - sum[i][j] + S[i][j];
    }
    int minv = I_INF;
    rep(k_, 1<<(H-1)) {
      int k = k_ << 1;
      vector<int> his;
      his.push_back(0);
      REPC(i, 1, H-1) if((k>>i)&1) his.push_back(i);
      his.push_back(H);
      int l = 0;
      int ans = his.size() - 2;
      bool invalid = false;
      REPC(r, 1, W) if(!invalid) {
        bool over = false;
        rep(hi, his.size()-1) {
          int white = sum[his[hi+1]][r] - sum[his[hi+1]][l] - sum[his[hi]][r] + sum[his[hi]][l];
          if(white > K) over = true;
        }
        if(over && l == r-1) invalid = true;
        else if(over) ans++, l = r-1;
      }
      if(!invalid) {
        chmin(minv, ans);
      }
    }
    cout << minv << "\n";
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solver::init();
  solver::solve();
  return 0;
}

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

// const int INF = 1001001001;
// long long max => LLONG_MAX

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n, k; cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.rbegin(), a.rend());
    int ans = 0;
    for(int i = 0; i < k; i++) ans += a[i];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;

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

Measured memory_bytes: 1160
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef unsigned long ll;

int N;
vector<int> w;

int solve(){
	vector<vector<int>> dp(N+1,vector<int>(N+1,-N));
	for(int i = 0; i <= N; i++){
		dp[i][i] = 0;
		if( i < N) dp[i][i+1] = 0;
	}
	for(int bet = 2; bet <= N; bet++){
		for(int i = 0; i + bet <= N; i++){
			int j = i + bet;
			if( dp[i+1][j-1] == j- i -2){
				if( abs(w[i] - w[j-1]) <= 1) dp[i][j] = max(dp[i][j],j-i);
				else dp[i][j] = max(dp[i][j],j-i-2);
			}
			for(int k = i + 1; k <= j-1; k++){
				dp[i][j] = max(dp[i][j],dp[i][k] + dp[k][j]);
			}
		}
	}
	return dp[0][N];
}

int main()
{
	while(cin>>N,N){
		w.resize(N);
		for(int i = 0; i < N; i++) cin>>w[i];
		cout<<solve()<<endl;
	}
	return 0;
}




Measured memory_bytes: 3284
#include <bits/stdc++.h>//coded by Nurstan ^_^

#define ll long long
#define pb push_back
#define mp make_pair

#define all(x) x.begin(), x.end()

#define F first
#define S second

// fixed << setprecision
// next_permutation(a, a + n)
// set <int> :: iterator it = x.begin(); it != x.end(); it ++

using namespace std;

const ll INF = int(1e9) + 123;
const int UNF = int(1e5) * 2;

inline void boost(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}

int main(){
	boost();
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	if(n % 7 == 0) {
		cout << "Yes";
		return 0;
	}
	if(n % 4 == 0) {
		cout << "Yes";
		return 0;
	}
	if(n % 11 == 0) {
		cout << "Yes";
		return 0;
	}
	if(n < 11) {
		cout << "No";
		return 0;
	}
	bool t = 0;
	int sum = 11;
	while(n >= sum) {
		if((n - sum) % 4 == 0) {
			cout << "Yes";
			return 0;
		}
		sum += 11;
	} 
	sum = 11;
	while(n >= sum) {
		if((n - sum) % 7 == 0) {
			cout << "Yes";
			return 0;
		}
		sum += 11;
	}
	cout << "No";
	return 0;	
	exit(0);
}


Measured memory_bytes: 256
f=->b,x{x<b ?x: f[b,x/b]+x%b};n,s=$<.map &:to_i;m=(n**0.5).to_i;p n<s ?-1:n>s ?(2..m).find{|b|f[b,n]==s}||m.downto(1).find{|b|(n-s)%b==0&&f[z=(n-s)/b+1,n]==s&&(break z)}||-1:n+1

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

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

    for (int i=1;i<=n;i++){
        if ( i%3 == 0 ) {
            cout << " " << i;
        } else {
            for (int x=i;x>0;x=x/10){
                if ( x%10==3 ) {
                    cout << " " << i;
                    break;
                }
            }
        }
    }
    cout << endl;
}



Measured memory_bytes: 3084
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let S: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };

    let mut dp = vec![vec![vec![false; 11]; 11]; 11];
    dp[10][10][10] = true;
    for &c in &S {
        let x = c.to_digit(10).unwrap() as usize;
        for i in 0..10 {
            for j in 0..10 {
                dp[i][j][x] |= dp[i][j][10];
            }
            dp[i][x][10] |= dp[i][10][10];
        }
        dp[x][10][10] = true;
    }
    let mut ans = 0;
    for i in 0..10 {
        for j in 0..10 {
            for k in 0..10 {
                ans += if dp[i][j][k] { 1 } else { 0 };
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=200010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
    int n=read();
    printf("%lld\n",n/3);
    return 0;
}

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

using namespace std;

using ll = long long;

int main(void) {
    int n, q; 
    scanf("%d\n%d", &n, &q);
    vector<int> arr(n);
    iota(arr.begin(), arr.end(), 1);
    while (q--) {
        int l, r;
        scanf("%d,%d", &l, &r);
        --l, --r;
        swap(arr[l], arr[r]);
    }
    for (int i = 0; i < n; i++) 
        printf("%d\n", arr[i]);
    return 0;
}


Measured memory_bytes: 3184
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C: Five Transportations
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int N = 5;
const long long LINF = 1LL << 62;

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

int main() {
  ll n;
  scanf("%lld", &n);

  ll mina = LINF;
  for (int i = 0; i < N; i++) {
    ll ai;
    scanf("%lld", &ai);
    if (mina > ai) mina = ai;
  }

  printf("%lld\n", (n + mina - 1) / mina + N - 1);
  return 0;
}


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

int main(){
	int N;
  	cin >> N;
  	vector<int> A(N);
  	rep(i, N) cin >> A[i];
  	
  	string ans = "APPROVED";
  	rep(i, N){
    	if(A[i] % 2 == 0){
        	if(A[i] % 3 == 0 || A[i] % 5 == 0){
            	ans = "APPROVED";
            }else{
             	ans = "DENIED";
              	break;
            }
        }
    }
  
  	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL<<60;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int sum =0;
  for(int i=0; i<4; i++){
    int x;
    cin >> x;
    sum += x;
  }
  cout << sum << endl;
  return 0;
}



Measured memory_bytes: 3108
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <set>

typedef long long ll;

#define rep(i,n) for(int i = 0; i < n; i++)
#define debug(x) cerr << #x << ": " << x << "\n";

using namespace std;
 
const ll INF = ll(1e18)+1;
const double PI=3.14159265358979323846;

int main(){
  int N;
  cin >> N;
  set<string> se;
  rep(i,N){
    string s;
    cin >> s;
    se.insert(s);
  }
  cout << se.size() << endl;
}


Measured memory_bytes: 19224
#include <iostream>
#include<time.h>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include<cassert>
#include<cctype>
#include<iterator>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
using Edge=pair<int,ll>;
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// g++ -o a a.cpp -Wall -lm -std=c++14

int main(){
    char a;
    cin>>a;
    if(isupper(a))cout<<'A'<<endl;
    else cout<<'a'<<endl;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int a, b, c, i, n, I=0;
	scanf("%d %d %d", &a, &b, &c);
	for(i = a ; i <= b ; i++)
	{
		n = c % i;
		if(n == 0)
		{
			I++;
		}
	}
	printf("%d\n",I);
	return 0;
}


Measured memory_bytes: 2144
use std::io::{self, Stdin};
use std::str::{self, FromStr};
use std::error::Error;

fn exec() {
    let mut sc = Scanner::new();
    let n: usize = sc.ne();
    let (a, b): (i64, i64) = (sc.ne(), sc.ne());
    let ab = a - b;
    let h: Vec<i64> = (0..n).map(|_| sc.ne()).collect();
    const INF: i64 = 1e10 as i64;
    let (mut lb, mut ub) = (0i64, INF);
    while (ub - lb) > 1 {
        let mid = (ub + lb) / 2;
        let mut cnt_a = 0;
        for &x in &h {
            let rest = x - b * mid;
            if rest > 0 {
                cnt_a += (rest - 1) / ab + 1;
            }
        }
        if cnt_a <= mid {
            ub = mid;
        } else {
            lb = mid;
        }
    }
    println!("{}", ub);
}

fn main() {
    const STACK: usize = 16 * 1024 * 1024;
    let _ = std::thread::Builder::new()
        .stack_size(STACK)
        .spawn(|| { exec(); })
        .unwrap()
        .join()
        .unwrap();
}

#[allow(dead_code)]
struct Scanner {
    stdin: Stdin,
    id: usize,
    buf: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            id: 0,
            buf: Vec::new(),
        }
    }
    fn next_line(&mut self) -> Option<String> {
        let mut res = String::new();
        match self.stdin.read_line(&mut res) {
            Ok(0) => None,
            Ok(_) => Some(res),
            Err(why) => panic!("error in read_line: {}", why.description()),
        }
    }
    fn next<T: FromStr>(&mut self) -> Option<T> {
        while self.buf.len() == 0 {
            self.buf = match self.next_line() {
                Some(r) => {
                    self.id = 0;
                    r.trim().as_bytes().to_owned()
                }
                None => return None,
            };
        }
        let l = self.id;
        assert!(self.buf[l] != b' ');
        let n = self.buf.len();
        let mut r = l;
        while r < n && self.buf[r] != b' ' {
            r += 1;
        }
        let res = match str::from_utf8(&self.buf[l..r])
                  .ok()
                  .unwrap()
                  .parse::<T>() {
            Ok(s) => Some(s),
            Err(_) => {
                panic!("parse error, {:?}",
                       String::from_utf8(self.buf[l..r].to_owned()))
            }
        };
        while r < n && self.buf[r] == b' ' {
            r += 1;
        }
        if r == n {
            self.buf.clear();
        } else {
            self.id = r;
        }
        res
    }
    fn ne<T: FromStr>(&mut self) -> T {
        self.next::<T>().unwrap()
    }
}


Measured memory_bytes: 8572
N, W = map(int, input().split())
WV = [list(map(int, input().split())) for _ in range(N)]

dp = [[0]*(W+1) for _ in range(N+1)]

for i in range(1, N+1):
    weight = WV[i-1][0]
    value = WV[i-1][1]
    for w in range(W+1):
        if w-weight<0:
            dp[i][w] = dp[i-1][w]
        else:
            dp[i][w] = max(dp[i-1][w-weight]+value, dp[i-1][w])
print(dp[N][W])


Measured memory_bytes: 119916
#include<stdio.h>

int x;

int gcd(int a,int b){
  while(a>1){
    if(a%b==0) return b;
    int tmp=b;
    b = a%b;
    a = tmp;}
  return 1;
}

int main(){
  scanf("%d",&x);
  int ans=360/gcd(360,x);
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 1696
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};

 


int main()
{
  double xa,xb,xc,xd,ya,yb,yc,yd;
  while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd)!=EOF){
    double td =(xa-xc)*(yd-ya)+(ya-yc)*(xa-xd);
    double tb =(xa-xc)*(yb-ya)+(ya-yc)*(xa-xb);
    double ta =(xb-xd)*(ya-yb)+(yb-yd)*(xb-xa);
    double tc =(xb-xd)*(yc-yb)+(yb-yd)*(xb-xc);

    if(td*tb >0.0||ta*tc>0.0)
      cout <<"NO"<<endl;
    else
      cout <<"YES"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1224
# coding: utf-8
# Your code here!
from heapq import *
n,k=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]

#print(n,k,a)
ans = 0
k=min(k,2*n)
for l in range(min(n,k)+1):
    for r in range(min(k-l,n-l)+1):
        for sute in range(min(k-l-r,l+r)+1):
            check = a[:l]+a[n-r:]
            heapify(check)
#            print(l,r,sute,check)
            c=0
            while(c < sute and check and check[0] < 0):
                heappop(check)
                c+=1
            ans = max(ans, sum(check))
print(ans)


Measured memory_bytes: 59484
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>

//エイリアス
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};



int main(){
    Stream io;

    int N, K;
    io.read(N, K);
    auto A = io.read_vec<ll>(N);
    for(int i = K; i < N; i++){
        int dec = A[i - K];
        int inc = A[i];
        if(dec < inc) cout << "Yes\n";
        else cout << "No\n";
    }
    
    return 0;
}


Measured memory_bytes: 4836
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <vector>

using namespace std;

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

#define INF 1000000000
#define F first
#define S second
#define forn(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)

using namespace std;

int a[123456];
int b[123456];
int main(){
	int n;
	scanf("%d", &n);
	rep(i,n) scanf("%d", &a[i]);
	rep(i,n) b[i] = a[i];

	int sum = 0;
	ll op1 = 0;
	rep(i,n){
		int tmp = sum+a[i];
		if(i % 2 == 0 && tmp <= 0){
			op1 += 1-tmp;
			sum = 1;
		}
		else if(i%2 == 1 && tmp >= 0){
			op1 += tmp+1;
			sum = -1;
		}
		else{
			sum = tmp;
		}
	}

	sum = 0;
	ll op2 = 0;
	rep(i,n){
		int tmp = sum+a[i];
		if(i % 2 == 1 && tmp <= 0){
			op2 += 1-tmp;
			sum = 1;
		}
		else if(i%2 == 0 && tmp >= 0){
			op2 += tmp+1;
			sum = -1;
		}
		else{
			sum = tmp;
		}
	}
	
	printf("%lld\n", min(op1,op2));

	return 0;
}


Measured memory_bytes: 896
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] d = new int[N];
		int ans = 0;
		for(int i = 0; i < N; i++)
			d[i] = sc.nextInt();
		for(int i = 0; i < N; i++)
			for(int j = i+1; j < N; j++)
				ans += d[i]*d[j];
		System.out.println(ans);

	}

}


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

int main() {
  
  string N;
  
  cin >> N;
  
  if(N.at(0)==N.at(1) && N.at(0)==N.at(2) && N.at(0)==N.at(3)) {
    
    cout << "Yes" << endl;
    
  } else if(N.at(0)==N.at(1) && N.at(0)==N.at(2) || N.at(1)==N.at(2) && N.at(1)==N.at(3)) {
    
    cout << "Yes" << endl;
    
  } else {
    
    cout << "No" << endl;
    
  }
  
  return 0;
  
}

Measured memory_bytes: 256
from sys import stdin
from itertools import permutations
def main():
    #入力
    readline=stdin.readline
    li=[int(readline()) for _ in range(5)]

    ans=float("inf")
    for i in permutations(li):
        tmp=0
        for j in range(5):
            if j!=4:
                if i[j]%10==0:
                    tmp+=i[j]
                else:
                    tmp+=i[j]+10-i[j]%10
            else:
                tmp+=i[j]

        ans=min(ans,tmp)

    print(ans)

if __name__=="__main__":
    main()

Measured memory_bytes: 9196
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0 ; i < n ; i++) a[i] = sc.nextInt();
		int[] sum = new int[9];
		for(int i = 0 ; i < n ; i++) {
			if(0 <= a[i] && a[i] < 400) sum[0]++;
			else if(400 <= a[i] && a[i] < 800) sum[1]++;
			else if(800 <= a[i] && a[i] < 1200) sum[2]++;
			else if(1200 <= a[i] && a[i] < 1600) sum[3]++;
			else if(1600 <= a[i] && a[i] < 2000) sum[4]++;
			else if(2000 <= a[i] && a[i] < 2400) sum[5]++;
			else if(2400 <= a[i] && a[i] < 2800) sum[6]++;
			else if(2800 <= a[i] && a[i] < 3200) sum[7]++;
			else if(3200 <= a[i]) sum[8]++;
		}
		int max = 0;
		int min = 0;
		int hatena = sum[8];
		for(int i = 0 ; i < 8 ; i++) {
			if(sum[i] >= 1) {
				max++;
				min++;
			}
		}
		if(min == 0) {
			System.out.println(1 + " " + hatena);
		} else {
			System.out.println(min + " " + (max + hatena));
		}
	}
}


Measured memory_bytes: 21972
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main()
{
  int n;
  while(cin>>n) {
    if(n == 0) return 0;
    bool up = true;
    bool r = false, l = false;
    int ans = 0;
    FOR(i,0,n) {
      string s; cin >> s;
      if(s[1] == 'u') {
        (s[0] == 'r' ? r : l) = true;
      }
      else {
        (s[0] == 'r' ? r : l) = false;
      }
      if(up) {
        if(l && r) {
          ans++;
          up = false;
        }
      } else {
        if(!l && !r) {
          ans++;
          up = true;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int n;
vector<int> g[210000];
bool used[210005];
ll cnt_x, cnt_y;

void dfs(int v) {
	if (v >= 100001) cnt_y++;
	else cnt_x++;
	used[v] = true;
	for (int c : g[v]) {
		if (used[c]) continue;
		dfs(c);
	}
	return;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	rep(i, n) {
		int a, b;
		cin >> a >> b;
		b += 100000;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	memset(used, 0, sizeof(used));
	ll ans = 0;
	rep(i, 200020) {
		if (g[i].size() && !used[i]) {
			cnt_x = 0, cnt_y = 0;
			dfs(i);
			ans += (cnt_x * cnt_y);
		}
	}
	ans -= n;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 10496
h,w = map(int,input().split())
l=[]

for i in range(h):
  s=[x for x in input()]
  l.append(s)

move=[[1,0],[-1,0],[0,1],[0,-1]]

def bfs(x,y):
  done=[[-1 for i in range(w)] for j in range(h)]
  ans,cnt = 0,0
  que=[[x,y,cnt]]
  done[y][x]=0

  while(que):
    nx,ny,cnt = que.pop(0)

    for dx,dy in move:
      mx=nx+dx
      my=ny+dy

      if 0<=mx<w and 0<=my<h and done[my][mx]==-1 and l[my][mx]==".":
        done[my][mx]=cnt+1
        que.append([mx,my,cnt+1])
        ans=max(ans,cnt+1)

  return ans


ans_r=0
for i in range(w):
  for j in range(h):
    if l[j][i]==".":
      now=bfs(i,j)
      ans_r=max(now,ans_r)
print(ans_r)


Measured memory_bytes: 9216
s = input()
t = input()
l = []
for i in range(len(s)-len(t)+1):
    s2 = s[i:]
    cnt = 0
    for j in range(len(t)):
        if s2[j] == t[j]:
            cnt += 1
    l.append(cnt)
print(len(t)-max(l))

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

int pan,ans;
string x;
char  pre;
int main(){
	scanf("%d",&pan);
	cin>>x;
	ans = 1;
	pre = x[0];
	for(int i = 0;i<pan;i++){
		if(x[i]!=pre){
			ans++;
		} 
		pre = x[i];
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <valarray>
#include <algorithm>
using namespace std;
int main() {
	int n, l;
	cin >> n;
	if (n % 2 == 0) {
		valarray<int>d(n);
		for (auto& i : d) {
			cin >> i;
		}
		sort(begin(d), end(d));
		l = (d.size() - 1) / 2;
		cout << d[l + 1] - d[l] << endl;
	}
	else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 640
n,m=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(m)]
p=list(map(int,input().split()))
c=0
for i in range(2**n):
    xi=format(i,'b').zfill(n)
    light_count=0
    for j in range(m):
        xl=[i+1 for i, x in enumerate(xi) if x == '1']
        c1=0
        for k in range(1,len(l[j])):
            if l[j][k] in xl:c1+=1
        if c1%2==p[j]:light_count+=1
    if light_count==m:c+=1
print(c)

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

int main()
{
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++)
		for(int j=i+1;j<s.length();j++)
		if(s[i]=='C'&&s[j]=='F')
		{
			cout<<"Yes";
			return 0;
		}
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using st = string;
using P = pair<int, int>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define chmax(x, y) { x = max(x, y); }
#define chmin(x, y) { x = min(x, y); }

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<st> s(h);
    rep(i, h) cin >> s.at(i);
    int ans = 0;
    rep(is, 1 << h){
        rep(js, 1 << w){
            int cnt = 0;
            rep(i, h){
                rep(j, w){
                    if(is >> i & 1) continue;
                    if(js >> j & 1) continue;
                    if(s.at(i).at(j) == '#') cnt++;
                }
            }
            if(cnt == k) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n;
int main() {
    cin >> n;
    int ansn = n;
    vector<int> ans;
    int limit = sqrt(n);
    for(int i = 2; i < limit+1; ++i) {
        if(n == 1) break;
        while(n % i == 0) {
            ans.push_back(i);
            n /= i;
        }
    }
    if(n != 1) ans.push_back(n);

    cout << ansn << ": ";
    for(int i = 0; i < ans.size(); ++i) {
        if(i == ans.size()-1) cout << ans.at(i) << endl;
        else cout << ans.at(i) << " ";
    }
}


Measured memory_bytes: 3168
#include <stdio.h>

static const int N = 100;

int Min(int a, int b){
  if(a < b)return a;
  else return b;
}

int main(){
  int i,j,l,k;
  int n;
  int p[N+1];
  int m[N+1][N+1];

  scanf("%d", &n);

  for(i=1; i<=n; i++)
    scanf("%d %d", &p[i-1],&p[i]);

  for(i=1; i<=n; i++)
    m[i][i] = 0;

  for(l=2; l<=n; l++){
    for(i=1; i<=n-l+1; i++){
      j = i + l - 1;
      m[i][j] = (1 << 21);
      for(k=i; k<=j-1; k++){
	m[i][j] = Min(m[i][j], m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j]);	
      }
    }
  }

  printf("%d\n",m[1][n]);
  
  return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

int main(int argc, char const *argv[])
{
    int q;
    cin >> q;
    priority_queue<int> pq1;
    priority_queue<int, vector<int>, greater<int>> pq2;
    ll c = 0;
    int med = 0;
    ll sum1 = 0;
    ll sum2 = 0;
    rep(i, q)
    {
        int type;
        cin >> type;
        if (type == 1)
        {
            int a, b;
            cin >> a >> b;
            c += b;
            if (pq1.size() > pq2.size())
            {
                if (a < med)
                {
                    pq2.push(pq1.top());
                    sum2 += pq1.top();
                    sum1 -= pq1.top();
                    pq1.pop();
                    pq1.push(a);
                    sum1 += a;
                }
                else
                {
                    pq2.push(a);
                    sum2 += a;
                }
                med = pq1.top();
            }
            else if (pq1.size() == pq2.size())
            {
                if (a < med)
                {
                    pq1.push(a);
                    sum1 += a;
                    med = pq1.top();
                }
                else
                {
                    pq2.push(a);
                    sum2 += a;
                    med = pq2.top();
                }
            }
            else
            {
                if (a > med)
                {
                    pq1.push(pq2.top());
                    sum1 += pq2.top();
                    sum2 -= pq2.top();
                    pq2.pop();
                    pq2.push(a);
                    sum2 += a;
                }
                else
                {
                    pq1.push(a);
                    sum1 += a;
                }
                med = pq1.top();
            }
        }
        else
        {
            ll value = c + (med * pq1.size() - sum1) + (sum2 - med * pq2.size());
            cout << med << " " << value << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3452
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
typedef long long ll;
using namespace std;
const int MOD=1e9+7;
ll N,M,cnt; int x[50][50];
int main(void) {
	cin >> N>>M;
	
		for (int i = 0; i < M; i++) {
			int a, b;
			cin >> a >> b;
			x[a - 1][b - 1] = 1;
			x[b - 1][a - 1] = 1;
		}
	for (int t = 0; t < N; t++) {
		for (int i = 0; i < N; i++) {
			int c = 0;
			for (int u = 0; u < N; u++) {
				if (x[i][u] == 1)c++;
			}
			if (c == 1) {
				cnt++;
				for (int k = 0; k < N; k++) {
					x[i][k] = 0; x[k][i] = 0;
				}
			}
		}
	}
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 256