akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
int dp[3005][3005],t[3005][3005];
char s1[3005],s2[3005],s[3005];
int main(){
	scanf("%s%s",s1+1,s2+1);
	int n=strlen(s1+1),m=strlen(s2+1);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++){
			if (s1[i]==s2[j] && dp[i-1][j-1]+1>dp[i][j])
				dp[i][j]=dp[i-1][j-1]+1,t[i][j]=0;
			if (dp[i-1][j]>dp[i][j]) dp[i][j]=dp[i-1][j],t[i][j]=1;
			if (dp[i][j-1]>dp[i][j]) dp[i][j]=dp[i][j-1],t[i][j]=2;
		}
	int ans=dp[n][m];
	if (!ans) return 0;
	int i=n,j=m;
	while (i && j){
		if (!t[i][j]) {
			s[ans--]=s1[i];
			i--,j--;
		}else if (t[i][j]==1) i--;
		else j--;
	}
	printf("%s\n",s+1); 
}

Measured memory_bytes: 70784
//16-3
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while (true)

int main(){
    int E,Y;
    cin >> E >> Y;
    if(E == 0){
        if(Y < 1912){
            cout << "M" << Y - 1868 + 1 << endl;
        }
        else if(Y < 1926){
            cout << "T" << Y - 1912 + 1 << endl;
        }
        else if(Y < 1989){
            cout << "S" << Y - 1926 + 1 << endl;
        }
        else{
            cout << "H" << Y - 1989 + 1 << endl;
        }
    }
    if(E == 1){
        cout << Y + 1868 - 1 << endl;
    }
    if(E == 2){
        cout << Y + 1912 - 1 << endl;
    }
    if(E == 3){
        cout << Y + 1926 - 1 << endl;
    }
    if(E == 4){
        cout << Y + 1989 - 1 << endl;
    }

    return 0;
}



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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

vector<vector<int>> G;
vector<vector<int>> D;

void dfs(int cur, int pre, int depth, int who) {
	D[cur][who] = depth;

	for (auto to : G[cur]) {
		if (to != pre) {
			dfs(to, cur, depth + 1, who);
		}
	}
}

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

	int n, u, v;
	cin >> n >> u >> v;
	u--; v--;

	G.resize(n);
	D.resize(n, vector<int>(2, 0));

	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	dfs(u, u, 0, 0);
	dfs(v, v, 0, 1);

	int ans = 0;
	rep(i, n) {
		if (D[i][0] < D[i][1]) {
			chmax(ans, D[i][1] - 1);
		}
	}

	out(ans);

	return 0;
}

Measured memory_bytes: 16384
#include<bits/stdc++.h>
using namespace std;
// g++ Main.cpp -std=gnu++1y -O2 -I/opt/boost/gcc/include -o main && ./main
// g++ Main.cpp -std=gnu++1y -O2 -I/opt/boost/gcc/include -o main && ./main

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vll = vector<vl>;
using vii = vector<vi>;
using pii = pair<int, int>;

using vc = vector<char>;
using vcc = vector<vc>;
using vb = vector<bool>;
using vbb = vector<vb>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using vd = vector<double>;
using vdd = vector<vd>;

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i, a, b) for(int (i) = a; (i) < (b);(i)++)
#define MAX(a, b) ((a > b) ? a : b)
#define MIN(a, b) ((a > b) ? b : a)

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


const int MOD = 1e9 + 7;

vector<pii> prime_factorization(int n){ // 素因数分解をしたvector<素数, 指数>を返す
  vector<pii> res;
  int tmp, root_n = floor(sqrt(n));
  if(n % 2 == 0){
    tmp = 1;
    n /= 2;
    while(n % 2 == 0){
      n /= 2;
      tmp++;
    }
    res.push_back(make_pair(2, tmp));
  }
  ll i = 3;
  while(i <= root_n && i <= n){
    if(n % i == 0){
      tmp = 1;
      n /= i;
      while(n % i == 0){
        n /= i;
        tmp++;
      }
      res.push_back(make_pair(i, tmp));
    }
    i += 2;
  }
  if(n != 1) res.push_back(make_pair(n, 1));
  return res;
}
vector<pli> prime_factorization(ll n){ // 素因数分解をしたvector<素数, 指数>を返す
  vector<pli> res;
  int tmp, root_n = floor(sqrt(n));
  if(n % 2 == 0){
    tmp = 1;
    n /= 2;
    while(n % 2 == 0){
      n /= 2;
      tmp++;
    }
    res.push_back(make_pair(2, tmp));
  }
  ll i = 3;
  while(i <= root_n && i <= n){
    if(n % i == 0){
      tmp = 1;
      n /= i;
      while(n % i == 0){
        n /= i;
        tmp++;
      }
      res.push_back(make_pair(i, tmp));
    }
    i += 2;
  }
  if(n != 1) res.push_back(make_pair(n, 1));
  return res;
}

// n は 2以上の素数表を返す
vb Primes(int n){
  vector<bool> res(n + 1, true);
  res.at(0) = false; res.at(1) = false;
  for(int i = 2; i <= sqrt(n); i++){
    if(res.at(i)){
      for(int j = 2 * i; j <= n; j += i){
        res.at(j) = false;
      }
    }
  }
  return res;
}
// ===================================================

ll power_mod(ll k, int n, int mod){
  if(n == 0) return 1;
  ll tmp = power_mod(k, n / 2, mod);
  tmp = (tmp * tmp) % mod;
  if(n % 2 == 0) return tmp;
  return (k * tmp) % mod;
}

ll v_p(int n, int p){
  int res = 0;
  while(n >= p){
    res += (n / p);
    n /= p;
  }
  return res;
}



int main(){
  ll n; cin >> n;
  ll res = 2 * (n / 11); n %= 11;
  if(n != 0) res++;
  if(n > 6) res++; 
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        DistributeNumbers solver = new DistributeNumbers();
        solver.solve(1, in, out);
        out.close();
    }

    static class DistributeNumbers {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = 37;
            out.println((n * n + n + 1) + " " + (n + 1));
            for (int i = 1; i <= n + 1; i++) {
                if (i != 1) out.print(" ");
                out.print(i);
            }
            out.println();
            for (int j = 2; j <= n + 1; j++) {
                out.print(1);
                for (int k = 1; k <= n; k++) {
                    out.print(" " + (k + 1 + (j - 1) * n));
                }
                out.println();
            }
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= n; j++) {
                    out.print(i + 1);
                    for (int k = 1; k <= n; k++) {
                        out.print(" " + (k * n + 2 + (j + i * k) % n));
                    }
                    out.println();
                }

            }
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void println() {
            writer.println();
        }

        public void println(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

        public void print(int i) {
            writer.print(i);
        }

    }

    static class InputReader {
        private InputStream stream;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

    }
}



Measured memory_bytes: 29704
#include <iostream>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
using ll = long long;

using namespace std;



int main() {
    int a,b;
    cin>>a>>b;
    cout<<max({a+b,a-b,a*b})<<endl;

    return 0;
}


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

import sys

def main():
    args = input().split()
    a, b = int(args[0]) ,int(args[1])
    result = 'Even' if ( a * b ) % 2 == 0 else 'Odd'
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
a, b, c, d = gets.chomp.chars.map(&:to_i)

[a, b, c, d].permutation(4).each do |nums|
  ['+', '-'].repeated_permutation(3).each do |opes|
    expr = nums.zip(opes).join
    val = eval(expr)

    if val == 7
      puts expr + "=7"
      exit
    end
  end
end


Measured memory_bytes: 1788
n,k=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]
b=0
for i in range(n):
  for j in range(i):
    if a[j]>a[i]:
      b+=1
c=0
for i in range(n):
  for j in range(n):
    if a[j]>a[i]:
      c+=1
k=b*k+c*k*(k-1)//2
print(k%(10**9+7))

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>

int main(){
	std::string s;
	std::vector<unsigned int> a;
	std::vector<unsigned int> z;

	std::cin >> s;

	for(unsigned int i = 0; i < s.size(); ++i){
		if(s.substr(i, 1) == "A"){
			a.push_back(i);
		}
		
		if(s.substr(i, 1) == "Z"){
			z.push_back(i);
		}
	}

	std::cout << z.back() - a.front() + 1 << std::endl;

	return 0;
}


Measured memory_bytes: 1364
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
using namespace std;
int INF = 1001001001;
int main(){
	int n,l;
	cin >> n >> l;
	int ans = 0;
	int min = INF;
	for(int i=1; i<=n;i++){
		ans += l+i-1;
		if(abs(l+i-1) < abs(min)) min = l+i-1;
	}
	ans -= min;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 1000000002486618624LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int N;

  std::string S1, S2;

  std::cin >> N >> S1 >> S2;

  if (N == 1) {
    std::cout << 3 << std::endl;
  }
  else {
    std::vector<int> a;

    for (int i = 0; i < N; )
      if (S1[i] == S2[i]) {
        a.push_back(0);

        i ++;
      }
      else {
        a.push_back(1);
        
        i +=2;
      }

    long long c = a[0] == 0 ? 3 : 6;

    for (int i = 1, size = a.size(); i < size; i ++) {
      if (a[i] == 0) {
        if (a[i - 1] == 0)
          c *= 2;
      }
      else {
        if (a[i - 1] == 0) {
          c *= 2;
        }
        else {
          c *= 3;
        }
      }

      c %= MOD;
    }

    std::cout << c << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;++i)
#define END(x) (*(x.end()-1))
#define INF INT_MAX

using namespace std;
typedef long long ll;


template<typename T>
T gcd(T a, T b){
   if (a%b == 0){
       return(b);
   }
   else{
       return(gcd(b, a%b));
   }
}

template<typename T>
T lcm(T a,T b){
    return a/gcd(a,b)/b;
}

int main(void){
    int K;
    cin>>K;
    ll ans=0;
    for(int i=1;i<=K;++i){
        for(int j=1;j<=K;++j){
            for(int k=1;k<=K;++k){
                ans+=gcd(gcd(i,j),k);
            }
        }
    }
    cout<<ans;
}
/*

*/

Measured memory_bytes: 3620
/**************************************************************************
Coded by: Saba Karimi(_VINTAGE)
Institution: AIT PUNE
***************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
#define F first 
#define S second
/**************************************************************************/
signed main() 
{
    fast;
    int n,k;
    cin>>n>>k;
    int hash[k]={};
    for(int i=1;i<=n;i++)
    {
        hash[i%k]++;
    }
    int ans = 0;
    for(int a=0;a<k;a++)
    {
        int b = (k-a)%k;
        int c = (k-a)%k;
        if((b+c)%k!=0)
            continue;
        ans+=(hash[a]*hash[b]*hash[c]);
    }
    cout<<ans;
}

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

using namespace std;

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

	int n, notSorted = 0;
	cin>>n;

	for(int i = 1; i <= n; i++){
		int num;
		cin>>num;
		if(num != i)
			notSorted++;
	}

	string s = notSorted < 3?"YES\n":"NO\n";
	cout<<s;
}

Measured memory_bytes: 3536
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
#include <set>
#include <cassert>
using namespace std;
using ll = long long;
using plong = pair<ll,ll>;
ll MOD=998244353;

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

int main(){
    ll N,K;
    cin>>N>>K;
    map <ll,ll> mp;
    for(ll i=0;i<K;i++){
        ll d;
        cin>>d;
        for(ll j=0;j<d;j++){
            ll c;cin>>c;c--;
            mp[c]++;
        }
    }
    ll res=0;
    for(ll i=0;i<N;i++){
        if(mp[i]==0)res++;
    }
    cout<<res<<endl;
}


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

using namespace std;
 
 


//c++ templte for help............................................................................................................................................

typedef long long ll;

template<typename... T>
void print1(T... t){
	((cout<<t<<" "),...);
}

template<typename... T>
void print2(T... t){
		vector<vector<ll>> ans={t...};
		for(ll i=0;i<(ll)ans.size();i++){
			if(i!=0) cout<<"\t\t";
			else cout<<"\t";
			for(ll j=0;j<(ll)ans[i].size();j++){
				cout<<ans[i][j]<<" ";
			}
			if(i!=(ll)ans.size()-1)
			cout<<endl;
		}
}	
#define deb(...) {cout<<" [ "#__VA_ARGS__<<" : "; print1(__VA_ARGS__); cout<<"]"<<endl; }
#define vdeb(...) {cout<<" [ "#__VA_ARGS__<<" : "; print2(__VA_ARGS__); cout<<"]"<<endl;}

// to return everything in string
#define ret(...) {stringstream returnn;returnn<<__VA_ARGS__;return returnn.str();}

stringstream retvec;
template<typename... T>
void returnvector(T... t){
		vector<vector<ll>> ans={t...};
		for(ll i=0;i<(ll)ans.size();i++){
			for(ll j=0;j<(ll)ans[i].size();j++){
				retvec<<ans[i][j];
				if(j!=(ll)ans[i].size()-1)
					retvec<<" ";
			}
			if(i!=(ll)ans.size()-1)
				retvec<<endl;
		}
}
#define vret(...) {returnvector(__VA_ARGS__);return retvec.str();}
	


//for loop
#define fo(i,n) for(int i=0;i<(ll)n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
 
 
//to print vector element 
template<typename T>
void printV(T vec){
	fo(i,vec.size()) cout<<vec[i]<<" "<<flush;
	cout<<endl;
	}
	
 
#define M ll(1e9+7)
const ll INF=ll(1e9+5);
 
//iterate map
template<typename T>
void itR(T map){
	 for(auto itr=map.begin();itr!=map.end();itr++){
				deb(itr->first,itr->second);
			}
	cout<<endl;
}

//c++ template for help...........................................................................................................................................

string solve(){
	string s;
	cin>>s;
	
	if(s.back()=='s'){
		s+="es";
	}else{
		s+="s";
	}
	ret(s);
}

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

	//ll testCase;
	//cin>>testCase;
	//for(ll tt=0;tt<testCase;tt++){
		string ans1=solve();
		if(ans1!="")
			cout<<ans1<<endl;
	//}
	return 0;
}


Measured memory_bytes: 3664
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint(), C = getint();
	const int mod = 1e9 + 7;

	int AB[401][401];
	rep(j, C + 1) AB[0][j] = 0;

	rep1(i, 400) {
		AB[i][0] = i;
		rep1(j, C) {
			AB[i][j] = (AB[i - 1][j] + ll(AB[i][j - 1] - AB[i - 1][j - 1]) * i) % mod;
		}
	}

	ll dp[2][401] = {};
	dp[0][0] = 1;
	int a[400];
	rep(i, N) a[i] = getint();
	rep(i, N) {
		auto mae = dp[i & 1];
		auto tugi = dp[!(i & 1)];
		int b = getint();
		auto A = AB[a[i] - 1];
		auto B = AB[b];

		for (int j = C; j >= 0; j--) {
			tugi[j] = mae[j] * (b - a[i] + 1) % mod;
		}

		rep1(k, C) {
			int K = B[k] - A[k];
			rep(j, C - k + 1) {
				tugi[j + k] += mae[j] * K % mod;
			}
			tugi[k] %= mod;
		}
	}

	printf("%lld", (dp[N & 1][C] % mod + mod) % mod);

	Would you please return 0;
}

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

using namespace std;

template<typename T>
string toString(const T& x) {
  ostringstream os; os << x; return os.str();
}

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

  string s = "";
  for (int i = 0; i < n; i++) {
    string d;
    cin >> d;
    s += d;
  }

  for (int i = 0; i <= 1000; i++) {
    string t = toString(i);
    if (s.find(t) != string::npos) continue;
    cout << t << endl;
    break;
  }

  return 0;
}


Measured memory_bytes: 3200
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
const int INF = 1e9;
const int MOD = 1e9 + 7;
#define MAX_q 150
#define MAX_L 1000
string X, Y;
int dp[MAX_L + 1][MAX_L + 1];
void DP() {
    rep(i, X.size()) {
        rep(k, Y.size()) { dp[i][k] = 0; }
    }
    rep(i, X.size()) {
        rep(k, Y.size()) {
            if (X[i] == Y[k]) {
                dp[i + 1][k + 1] = dp[i][k] + 1;
            } else {
                dp[i + 1][k + 1] = max(dp[i][k + 1], dp[i + 1][k]);
            }
        }
    }
}
int main() {
    int q;
    cin >> q;
    rep(j, q) {
        cin >> X >> Y;
        DP();
        cout << dp[X.size()][Y.size()] << endl;
    }
    return 0;
}


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

typedef long long ll;
int main(){
	ll N, M; cin >> N >> M;
	vector<ll> a(M);
	vector<ll> s(N, 0);
	for(ll i = 0; i < M; ++i){ cin >> a[i]; }

	ll MOD = 1000000007;

	if(N == 1) { cout << 1 << endl; return 0; }

	s[0] = 1; s[1] = 1;
	for(ll i = 0; i < M; ++i){
		s[a[i]] = -1;
		if(a[i] == 1) s[a[i]] = 0;
	}

	for(ll i = 2; i < N; ++i){
		if(s[i] == -1) s[i] = 0;
		else s[i] = (s[i-1] % MOD + s[i-2] % MOD) % MOD;
	}

	// for(int i = 0; i < N; ++i){ cout << s[i] << endl; }

	cout << (s[N-1] % MOD + s[N-2] % MOD) % MOD << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	string s;
  	cin>>s;
  	ll n=s.size();
  	ll i,j,ans1=0,ans2=0;
  
  	for(i=0;i<n;i++){
		if(i%2==0){
			if(s[i]=='0'){
              ans1++;
            }
        }else{
			if(s[i]=='1'){
              ans1++;
            }
        }
    }
	  for(i=0;i<n;i++){
		if(i%2==0){
			if(s[i]=='1'){
              ans2++;
            }
        }else{
			if(s[i]=='0'){
              ans2++;
            }
        }
    }
  
  
  	cout<<min(ans1,ans2)<<endl;
  
}



Measured memory_bytes: 512
#include <bits/stdc++.h>                                      
using namespace std;                                          
const int dx[] = {1,0,-1,0,1,-1,-1,1};                        
const int dy[] = {0,1,0,-1,1,1,-1,-1};                        
const int INF = 1e9;                                          
const long long LINF = 1e18;                                  
const double EPS = 1e-8;                                      
#define pb emplace_back                                       
#define mk make_pair                                          
#define fr first                                              
#define sc second                                             
#define ll long long                                          
#define reps(i,j,k) for(int i=(j);i<(k);++i)                  
#define rep(i,j) reps(i,0,j)                                  
#define all(x) (x).begin() (x).end()                          
#define MOD 1000000007                                        
typedef pair<int,int> Pii;                                    
typedef pair<int, ll> Pil;                                    
typedef vector<int> vi;                                       
typedef vector<vi> vvi;                                       
int main(){                                                   
        int N;                                                
        cin >> N;                                             
        vi s;                                                 
        rep(i,N){                                             
                int tmp;                                      
                cin >> tmp;                                   
                s.pb(tmp);                                    
        }                                                     
        ll ans = LINF;                                        
//      sort( all(s) );                                       
        sort(s.begin(),s.end());                              
        reps(i,s[0],s[N-1]+1){                                
                ll sum = 0LL;                                 
                rep(j,N){                                     
                        sum += (ll)(s[j]-i)*(ll)(s[j]-i);     
                }                                             
                ans = min(ans, sum);                          
        }                                                     
        cout << ans << endl;                                  
        return 0;                                             
}                                                             

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

int main() {
  string s;cin>>s;
  int ans=s.size(),n=s.size();
  rep(i,2){
    int cnt=0;
    rep(j,n){
      if(j%2==0&&s[j]!=(char)(i+'0'))cnt++;
      if(j%2==1&&s[j]==(char)(i+'0'))cnt++;
    }
    ans=min(ans,cnt);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3700
import sys
from bisect import bisect_left

input = sys.stdin.readline


def main():
    N = int(input())
    L = list(map(int, input().split()))

    L.sort()
    ans = 0
    for a in range(N - 2):
        for b in range(a + 1, N - 1):
            x = bisect_left(L, L[a] + L[b], lo=b)
            ans += (x - 1 - b)

    print(ans)


if __name__ == "__main__":
    main()


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

int main() {
  string n;
  cin >> n;
  string ans = "ABC" + n;
  cout << ans << endl; 
  
}

Measured memory_bytes: 3640
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from collections import deque
from collections import Counter
import bisect
from collections import defaultdict
import itertools

def main():
    N, Q = MI()
    #i行の一番右をline_right[i],　j列目の一番下をcolumn_under[j]とする。
    line_right = deque([(N, N)])
    line_right_keys = deque([N])
    column_under = deque([(N, N)])
    column_under_keys = deque([N])
    bla = pow(N - 2, 2)
    x_min = N
    y_min = N
    for i in range(Q):
        query = LI()
        if query[0] == 1:
            w = query[1]
            x = bisect.bisect_left(column_under_keys, w)
            bla -= column_under[x][1] - 2
            if w < x_min:
                line_right.appendleft((column_under[x][1], w))
                line_right_keys.appendleft(column_under[x][1])
                x_min = w
        else:
            y = query[1]
            z = bisect.bisect_left(line_right_keys, y)
            bla -= line_right[z][1] - 2
            if y < y_min:
                column_under.appendleft((line_right[z][1], y))
                column_under_keys.appendleft(line_right[z][1])
                y_min = y
    print(bla)
if __name__ == "__main__":
    main()

Measured memory_bytes: 86716
using System;
class ProgramA
    {
        static void Main(string[] args)
        {
            //入力
            string s = Console.ReadLine();

            //偶数同士の組み合わせと奇数同士の組み合わせなので、mC2とnC2を求める
            if(s[2] == s[3] && s[4] == s[5])
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }

Measured memory_bytes: 13140
def upper_bound(arr, v)
  l = -1
  r = arr.size
  while l + 1 < r
    m = (l + r) / 2
    if arr[m] <= v then l = m
    else r = m
    end
  end
  r
end

EPS = 1e-9
Factorial = (1..50).each_with_object([1]) { |i, arr| arr << arr[-1] * i }

n, m, l = gets.split.map(&:to_i)
p, t, v = n.times.map{ gets.split.map(&:to_i) }.transpose
time_set = n.times.map{ [0] * (m + 1) }
prob_set = n.times.map{ [0] * (m + 1) }
n.times do |i|
  s = v[i] == 0 ? Float::INFINITY : l / v[i].to_f
  (m + 1).times do |j|
    time_set[i][j] = s + t[i] * j
    prob_set[i][j] = (p[i] / 100.0) ** j * (1 - p[i] / 100.0) ** (m - j) * Factorial[m] / Factorial[m - j] / Factorial[j]
  end
end

n.times do |i|
  ret = 0
  (m + 1).times do |j|
    prob = prob_set[i][j]
    n.times do |k|
      next if i == k
      idx = upper_bound(time_set[k], time_set[i][j] + EPS)
      if idx == m + 1
        prob = 0
        break
      end
      prob *= prob_set[k][idx..-1].reduce(:+)
    end
    ret += prob
  end
  puts '%.8f' % ret
end

Measured memory_bytes: 9204
// Problem : E - Red and Green Apples
// Contest : AtCoder - AtCoder Beginner Contest 160
// URL : https://atcoder.jp/contests/abc160/tasks/abc160_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db long double
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define mi map<int,int>
#define ml map<ll,ll>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define MAX 4294967295
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MAXN 15000005
#define inf 1e10
#define PI acos(-1.0)
#define int long long

int x,y,A,B,C;
vi a,b,c;

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    cin>>x>>y>>A>>B>>C;
    a.resize(A), b.resize(B), c.resize(C);
    for(int i=0;i<A;i++) cin>>a[i];
    for(int i=0;i<B;i++) cin>>b[i];
    for(int i=0;i<C;i++) cin>>c[i];
    priority_queue<int,vi,greater<int>> pq;
    sort(all(a),greater<int>());
    sort(all(b),greater<int>());
    sort(all(c),greater<int>());
    int sum = 0;
    for(int i=0;i<x;i++) pq.push(a[i]), sum += a[i];
    for(int i=0;i<y;i++) pq.push(b[i]), sum += b[i];
    for(int i=0;i<C;i++){
        int val = pq.top();
        if(val >= c[i]) break;
        sum += c[i]-val;
        pq.pop();
        if(pq.empty()) break;
    } 
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 4852
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <cmath>
#include <set>
#include <map>
#include <stack>
#define SIZE 1000005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

char S[SIZE];
char T[SIZE];
P L[SIZE];
int n;

bool check(int X)
{
	if(S[0]!=T[0]) return false;
	if(X==0)
	{
		for(int i=0;i<n;i++) if(S[i]!=T[i]) return false;
		return true;
	}
	if(X==1)
	{
		int p=0;
		for(int i=0;i<n;i++)
		{
			if(T[i]!=S[i])
			{
				if(i==0||T[i]!=T[i-1]) return false;
			}
		}
		return true;
	}
	int s=0,e=0;
	L[e++]=P(X,0);
	int add=0;
	int p=0;
	for(int i=1;i<n;i++)
	{
		if(T[i]!=T[i-1])
		{
			L[s].first--;
			if(L[s].first==0) s++;
			p=max(p,L[s].second+add+1);
			while(p<n&&S[p]!=T[i]) p++;
			if(p>i) return false;
			int sum=0;
			while(s<e&&L[s].second+add<p)
			{
				sum+=L[s].first;
				s++;
			}
			add++;
			L[--s]=P(sum,p-add);
			L[e++]=P(1,i-add);
			//for(int j=s;j<e;j++) printf("[%d %d] ",L[j].first,L[j].second+add);puts("");
		}
	}
	return true;
}
int main()
{
	scanf("%d",&n);
	scanf("%s",&S);
	scanf("%s",&T);
	//check(3);
	//return 0;
	int l=-1,r=n+1;
	while(r-l>1)
	{
		int d=(l+r)/2;
		if(check(d)) r=d;
		else l=d;
	}
	if(r>n) puts("-1");
	else printf("%d\n",r);
	return 0;
}


Measured memory_bytes: 9984
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <queue>
#include <math.h>
#include <set>
#include <stack>
#include <deque>
#include <bitset>
using namespace std;

int main()
{
	int r;
	cin >> r;
	cout << 3 * r * r << endl;
}


Measured memory_bytes: 764
#include<iostream>
 
using namespace std;
 
int main(){
    int n;
    cin >> n;
    if(n%2!=0)
    {
        cout << (double)(n/2+1)/(double)n << endl;
    }
    else
    {
        cout << 0.5 << endl;
    }
    return 0;
}

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

const int N=1e5+30;
typedef long long ll;
int n,arr[N];
int dp[N];
ll solve(int i){
    if(i>=n)return 1e15;
    if(i==n-1){
        return 0;
    }

    if(dp[i]!=-1)return dp[i];

    ll path1=abs(arr[i]-arr[i+1])+solve(i+1);
    ll path2=abs(arr[i]-arr[i+2])+solve(i+2);
    return dp[i]= min(path1,path2);
}
int main()
{
    memset(dp,-1,sizeof dp);
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",arr+i);
    cout<<solve(0)<<endl;
}



Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;


ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = (ans*x) % MOD;
        x = (x*x) % MOD;
        n = n >> 1;
    }
    return ans;
}

ll cnt[100] = {};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll N, ans = 0; cin >> N;
  vector<ll> A(N);
  REP(i,N){
    cin >> A[i];
    REP(j,60) cnt[j] += (A[i] >> j) & 1;
  }
  REP(j,60){
    ans += ((cnt[j] * (N-cnt[j])) % MOD) * mpow(2, j);
    ans %= MOD;
  }
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 2560
def judge(s1, s2)
    if s1.size != s2.size
        return false
    end
    s1.size.times do |i|
        if s1[i] != ?? && s1[i] != s2[i]
            return false
        end
    end
    return true
end

s,t=$<.map(&:chomp)
ans = -1
s.size.times do |i|
    if judge(s[i, t.size], t)
        tmp = String.new(s)
        tmp[i, t.size] = t
        s.size.times do |j|
            if tmp[j] == ??
                tmp[j] = ?a
            end
        end
        if ans == -1
            ans = tmp
        else
            ans = [ans, tmp].min
        end
    end
end
puts (ans == -1 ? "UNRESTORABLE" : ans)

Measured memory_bytes: 1788
n = int(input())
h = list(map(int,input().split()))
i= int()
m= int()

count = 0
for i in range(n):
  m=0
  while m < i:
    if h[m] <= h[i]:
      m += 1
    else:
      break
  if m == i:
    count += 1
   
      
print(count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
 
using namespace std;
 
long long a,b,c,d;
 
int main() {
  scanf ("%lld %lld %lld %lld", &a, &b, &c, &d);
  
  printf ("%lld", max(a * c, max(a * d, max(b * c, b * d))));
  
  return 0;
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
#define ll long long
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define f(i,s,e) for(ll i=s;i<e;i++)
#define pb(x) push_back(x)
#define mp make_pair
#define mod 1000000007
#define all(x) x.begin(),x.end()
using namespace std;
vector<int> v[200005];
int vis[200005];

void dfs(int node){
    vis[node]=1;
    for(auto it:v[node]){
        if(vis[it]==0){
            dfs(it);
        }
    }
}

int main(){
    fast;

    int n,m,x,y,z,ans=0;
    cin>>n>>m;

    f(i,0,m){
        cin>>x>>y>>z;
        v[x].pb(y);
        v[y].pb(x);
    }

    f(i,1,n+1){
        if(vis[i]==0){
            ans++;
            dfs(i);
        }
    }
    cout<<ans;
}


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

int main() {
  int N;
  int sum = 0;
  cin >> N;
  
  for (int i = 0; i < N; i++){
    int l, r;
    cin >> l >> r;
    sum += r - l + 1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<array>
#include<cstdlib>

using namespace std;

typedef array<array<signed char,3>,3> Die;

int main(){
  for(int x,y;cin>>x>>y,x;){
    char g[3][3];
    bool nz=false;
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
	cin>>g[i][j];
	if(g[i][j]=='E'){
	  nz|=i!=y-1||j!=x-1;
	}else{
	  nz|=g[i][j]!='W';
	}
      }
    }
    if(!nz){
      cout<<0<<endl;
    }else{
      set<Die> s[32];
      Die d{};
      d[y-1][x-1]=-1;
      s[0].insert(d);
      for(int i=0;i<=30;i++){
	//	cout<<"c = "<<s[i].size()<<endl;
	for(auto e:s[i]){
	  int ey,ex;
	  for(int k=0;k<3;k++){
	    for(int j=0;j<3;j++){
	      if(e[k][j]==-1){
		ey=k;
		ex=j;
	      }
	    }
	  }
	  if(i<30){
	    static int dy[]={-1,0,1,0};
	    static int dx[]={0,1,0,-1};
	    for(int j=0;j<4;j++){
	      int ny=ey+dy[j];
	      int nx=ex+dx[j];
	      if(0<=ny&&ny<3&&0<=nx&&nx<3){
		auto n=e;
		n[ny][nx]=-1;
		n[ey][ex]=(e[ny][nx]+((e[ny][nx]%2^j%2)?1:5))%6;
	      
		bool f=false;
		int c=0;
		int gy,gx;
		for(int jj=0;jj<3;jj++){
		  for(int k=0;k<3;k++){
		    if(n[jj][k]==-1){
		      f|=g[jj][k]!='E';
		    }else{
		      f|=g[jj][k]!="WBRWBR"[n[jj][k]];
		    }
		    c+=g[jj][k]!='E'&&(n[jj][k]==-1||g[jj][k]!="WBRWBR"[n[jj][k]]);
		    if(g[jj][k]=='E'){
		      gy=jj;
		      gx=k;
		    }
		  }
		}
		if(!f){
		  cout<<i+1<<endl;
		  goto next;
		}
		if(max(c,abs(ny-gy)+abs(nx-gx))+i+1>30)continue;
		s[i+1].insert(n);
	      }
	    }
	  }
	}
	s[i].clear();
      }
      cout<<-1<<endl;
    next:
      ;
    }
  }
}

Measured memory_bytes: 37152
#include<stdio.h>

int main(){
  int N, ans;
  
  scanf("%d", &N);
  
  if(N < 105){
    ans = 0;
  } else if(N < 135){
    ans = 1;
  } else if(N < 165){
    ans = 2;
  } else if(N < 189){
    ans = 3;
  } else if(N < 195){
    ans = 4;
  } else {
    ans = 5;
  }
  
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
c=0
while 1:
 a=input()
 if a.isdigit():
  if c>0:c+=int(a)
  else:c=1
 else:
  if c!=0:print((s*2)[c%l-1:][:l])
  if'-'==a:break
  s=a;l=len(s);c=0

Measured memory_bytes: 5592
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);
function main(){
  var n = o.a();
  var p = o.l();
  var mn = 1e9, ans = 0;
  for(var i = 0; i < n; i++){
    if(p[i] < mn)ans++, mn = p[i];
  }
  return ans;
}

Measured memory_bytes: 22224
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
const ll N=1e6+5;
ll spf[N],n;
map< ll , ll > mp;
void init(){
    for(ll i=2;i<N;i+=2)spf[i]=2;
    for(ll i=3;i<N;i+=2)spf[i]=i;
    for(ll i=3;i*i<N;i+=2){
        if(spf[i]!=i)continue;
        for(ll j=i*i;j<N;j+=i)if(spf[j]==j)spf[j]=i;
    }
}
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    init();
    ll g=0;
    cin>>n;
    for(ll i=1;i<=n;i++){
        ll x;cin>>x;
        g = __gcd(g,x);
        ll prv=-1;
        while(x>1){
            if(spf[x]!=prv)mp[spf[x]]++;
            prv=spf[x];
            x/=spf[x];
        }
    }

    bool f=1;
    for(auto &ele:mp)if(ele.second>1)f=0;
    //for(auto &ele:mp)cout<<ele.first<<" "<<ele.second<<endl;
    if(f)return cout<<"pairwise coprime" , 0;

    if(g==1)cout<<"setwise coprime";
    else cout<<"not coprime";
}





Measured memory_bytes: 11224
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;


typedef long long i64;
const int inf = (int)1.05e9;


int main()
{
	int h, w;
	vector<vector<int>> dist;
	queue<pair<pair<int,int>,int>> q;

	scanf("%d%d", &h, &w);
	dist.resize(h);
	for(auto& d : dist) {
		d.resize(w, inf);
	}

	for(int i = 0; i < h; i++) {
		char buffer[1024];
		scanf("%s", buffer);
		for(int j = 0; j < w; j++) {
			if(buffer[j] == '#') {
				q.push({{i, j}, 0});
			}
		}
	}

	while(!q.empty()) {

		int x = q.front().first.first;
		int y = q.front().first.second;
		int d = q.front().second;
		q.pop();

		if(d >= dist[x][y]) {
			continue;
		}
		dist[x][y] = d;

		int dxs[] = {-1, 0, 0, 1};
		int dys[] = {0, -1, 1, 0};

		for(int dir = 0; dir < 4; dir++) {
			int nx = x + dxs[dir];
			int ny = y + dys[dir];
			if(nx < 0 || ny < 0 || nx >= h || ny >= w) {
				continue;
			}
			q.push({{nx, ny}, d + 1});
		}
	}

	int ans = 0;

	for(auto& d : dist) {
		for(auto& v : d) {
			ans = max(ans, v);
		}
	}

	printf("%d\n", ans);

	return 0;
}

/* waffle */


Measured memory_bytes: 52552
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <climits>

using namespace std;

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

//???
class Point {
public:
    double x, y;
    
    Point (double x = 0, double y = 0):x(x), y(y){}
    Point operator + (Point p){return Point(x + p.x, y + p.y);}
    Point operator - (Point p){return Point(x - p.x, y - p.y);}
    Point operator * (double a){return Point(a * x, a * y);}
    Point operator / (double a){return Point(x / a, y / a);}
    
    double norm(){return x*x + y*y;};
    double absolute(){return sqrt(norm());};
    
    bool operator < (const Point &p) const{
        return x != p.x ? x < p.x : y < p.y;
    }
    
    bool operator == (const Point &p) const{
        return equals(x, p.x) && equals(y, p.y);
    }
    
};
typedef Point Vector;                               //????????????
typedef struct Segment{Point p1, p2;}Segment;       //??????
//????????????a????????????
double norm(Vector a){
    return a.x * a.x + a.y * a.y;
}
//????????????a?????§??????
double absolute(Vector a){
    return sqrt(norm(a));
}

//????????????a,b?????????
double dot(Vector a, Vector b){
    return a.x * b.x + a.y * b.y;
}
//????????????a,b?????????
double cross(Vector a, Vector b){
    return a.x * b.y - a.y * b.x;
}

//????????????a??¨b?????´?????????
//a??¨b?????´????????´??????????????????0?????????
bool isOrthogonal(Vector a, Vector b){
    return equals(dot(a,b), 0.0);
}

//????????????a??¨b???????????????
//a??¨b?????´????????´??????????????????0?????????
bool isParallel(Vector a , Vector b){
    return equals(cross(a,b), 0.0);
}

int main(){
    
    int x0, y0, x1, y1, x2, y2, x3, y3;
    
    int q;
    
    cin >> q;
    
    for (int i = 0; i < q; i++) {
        cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
        Vector a = Point(x1, y1) - Point(x0, y0);
        Vector b = Point(x3, y3) - Point(x2, y2);
        
        if(isParallel(a, b)) cout << 2 << endl;
        else if(isOrthogonal(a, b)) cout << 1 << endl;
        else cout << 0 << endl;
    }


    return 0;
}

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


using namespace std;

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

    if(N[0]==N[1] && N[1]==N[2]){
        cout <<"Yes"<<endl;
    }
    else if(N[1]==N[2] && N[2]==N[3]){
        cout<<"Yes"<<endl;

    }
 
    else{
        cout <<"No"<<endl;
    }
    
}


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

int main(){
	int n;
	cin >> n;
	vector<int>data(n);
	for(auto &a:data) cin >> a;
	int count = 0;
	for(int i = 0; i < n; i++){
		int mini = i;
		for(int j = i; j < n; j++){
			if(data[j] < data[mini]) mini = j;
		}
		if(i != mini){
			count++;
			swap(data[i],data[mini]);
		}
	}
	for(int i = 0; i < n; i++){
		if(i!=0) cout << " ";
		cout << data[i];
	}
	cout << endl;
	cout << count << endl;
	return 0;
}	

Measured memory_bytes: 3084
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  sm=0
  for i,x in enumerate(l):
    for j,y in enumerate(l[i+1:]):
      sm+=x*y
  return sm

# main()
print(main())


Measured memory_bytes: 5552
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    sort(All(A));
    cout << A[N - 1] - A[0] << endl;
    return 0;
}

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

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

    int ans = 0;
    for (ll i = 2; i * i <= n; i++) {
        int cnt = 0;
        while (n % i == 0) n /= i, cnt++;
        for (int j = 1; j <= cnt; j++) cnt -= j, ans++;
    }

    if (n != 1) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<queue>

using namespace std;

#define INF 999999999
#define REP(i,n) for(int i=0; i<(int)(n); i++)

int bi(int v){
	int r = 0;
	REP(i,20){
		if((1 << i) & v) r++;
	}
	//cout << r << endl;
	return r;
}

int main(){
	int n, m;
	double lab[20][3];
	double ans=0, now;
	cin >> n >> m;
	REP(i,n){
		cin >> lab[i][0] >> lab[i][1] >> lab[i][2];
	}
	if(m==1){
		cout << "0" <<endl;
		return 0;
	}
	REP(i,1<<n){
		if(bi(i) != m) continue;
		now = 0;
		REP(j,n){
			for(int k=j+1;k<n;k++){
				if((i&1<<j)&&(i&1<<k)){
					now += pow((lab[j][0] - lab[k][0]),2);
					now += pow((lab[j][1] - lab[k][1]),2);
					now += pow((lab[j][2] - lab[k][2]),2);
				}
			}
		}
		if(now > ans) ans = now;
	}
	printf("%.13f\n",ans);
	return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  float avg = 0;
  rep(i, N)
  {
    cin >> a[i];
    avg += (float)a[i] / N;
  }
  int score1 = 0;
  int score2 = 0;
  int average1 = (int)avg;
  int average2 = average1 + 1;
  rep(i, N)
  {
    score1 += pow(average1 - a[i], 2);
    score2 += pow(average2 - a[i], 2);
  }
  int ans = min(score1, score2);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
s=int(input())
a=s//100
b=s-a*100
res=0
wes=0
if a==0 or a>12:
    res=1
if b==0 or b>12:
    wes=1
if res==1 and wes==1:
    print("NA")
if res==0 and wes==1:
    print("MMYY")
if res==1 and wes==0:
    print("YYMM")
if res==0 and wes==0:
    print("AMBIGUOUS")

Measured memory_bytes: 3064
n = int(input())
h = list(map(int, input().split()))
h[0] -= 1
for i in range(1, len(h)):
    if h[i] - 1 >= h[i - 1]:
        h [i] -= 1

ans = 1
for i in range(1, len(h)):
    if h[i] < h[i - 1]:
        ans = 0
        break

if ans:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 63984
N,M=list(map(int,input().split()))
H=list(map(int,input().split()))
h=[]
for m in range(M):
    a,b=list(map(int,input().split()))
    if a-1<=N and b-1<=N:
        if H[a-1]<=H[b-1]:
            h.append(a-1)
        if H[a-1]>=H[b-1]:
            h.append(b-1)
h2=set(h)
ans=N-len(h2)
print(ans)


Measured memory_bytes: 19988
import java.util.Scanner;

class Main{
    public static void main(String[] args){
    	int residents[][][] = new int[4][3][10];
        int n,b, f, r, v;
        
		Scanner scanner = new Scanner(System.in);
		n = scanner.nextInt();
		
		for(int i = 0;i < n;i++){
			b = scanner.nextInt();
			f = scanner.nextInt();
			r = scanner.nextInt();
			v = scanner.nextInt();
			
			residents[b-1][f-1][r-1] += v;
		}
		
		for(int i = 0;i < 4;i++){
			for(int j = 0;j < 3;j++){
				for(int k = 0;k < 10;k++){
					System.out.print(" "+residents[i][j][k]);
				}
				System.out.println();
			}
			if(i != 3){
				System.out.println("####################");
			}						
		}		
    	scanner.close();
    }
}

Measured memory_bytes: 29880