akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
        string s;
         cin.tie(0);
        ios::sync_with_stdio(false);
         map<char,ll>array;
        ll n;
        ll mod=1000000007;
        cin>>n>>s;
       
        for(int i=0;i<n;i++){
            array[s[i]]++;
        }
        ll ans=1;
        //cout<<array[s[1]-'a']<<endl;
        for(char moji='a';moji<='z';moji++){
           
            ans=(ans*(1+array[moji]))%mod;
               
               //cout<<"aa";
           }
        

        cout<<(ans-1+mod)%mod<<endl;



    return 0;
}

Measured memory_bytes: 512
int main(void){
    char ch='0';
    
    while(1){
        
        ch = getchar();
        if('a' <= ch && ch <= 'z'){
            putchar(ch-32);
        }else if('A' <= ch && ch <= 'Z'){
            putchar(ch+32);
        }else{
            putchar(ch);
        }
        if(ch == '\n'){
            break;
        }
    }
}


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

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

    vector<int> A(N);
    rep(i, N) cin >> A.at(i);

    int bet, maxbet = 0;

    rep(i, N) {
        if(i<N-1){
            bet = A.at(i+1) - A.at(i);
            if(bet > maxbet){
                maxbet = bet;
            }else{
                bet = A.at(0) + K - A.at(N-1);
                if(bet > maxbet){
                    maxbet = bet;
                }
            }
        }
    }

    cout << K - maxbet << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  double x[n],s=0;
  string t[n];
  for(int i=0;i<n;i++){
    cin >> x[i] >> t[i];
    if(t[i]=="JPY")s+=x[i];
    else s+=x[i]*380000;
  }
  cout << fixed << setprecision(15) << s;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int cl(int a, int b) {
	return (a - (a%b)) / b;//b=0だと積む
}
int up(int a, int b) {
	return cl(a + b - 1, b);//b=0だと積む
}
int ord(int a, int p) {
	if (a%p == 0) {
		return ord(a / p, p) + 1;
	}
	else {
		return 0;
	}
}
long long ruin(int a, int n, long long  p) {
	if (n == 0) {
		return (1 % p);
	}
	else {
		long long x = ruin(a, (n - (n % 2)) / 2, p);
		if (n % 2 == 0) {
			return (x*x) % p;
		}
		else {
			return (((x*x) % p)*a) % p;

		}

	}

}
long long com(int n, int r, int p) {
	if (r == 0) {
		return (1 % p);
	}
	else {
		long long x = com(n, r - 1, p);
		return (x*(n - r) / r) % p;
	}
}
long long sum(long long n, long long p) {
	if (n == 0) {
		return 0;
	}
	else {
		long long x = (n%p) + sum((n - (n%p)) / p, p);
		return x;
	}
}
int main()
{
	int x;
	cin >> x;
	if (x == 7 or x == 5 or x == 3) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}


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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int n,l,sum;
vector<int> v;

main() {
    cin >> n;
    rep(i,n) cin >> l,sum+=l,v.pb(l)
    sort(all(v));
    if (v.back() < sum-v.back()) ct("Yes")
    else ct("No")
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  int N, prev, ans = 1, now;
  bool status = true;
  cin >> N;
  if (N <= 2) {
    cout << ans << endl;
    return 0;
  }

  N -= 2;
  cin >> prev >> now;
  while (prev == now) {
    cin >> now;
    N--;
  }
  if (prev > now) status = false;
  prev = now;

  while (N) {
    cin >> now;
   // cout << prev << " " << now << " " << status << endl;
    N--;
    if (prev == now) continue;
    if (status && prev > now) {
      ans++;
      prev = now;
      if (N <= 1) break;
      while (N && prev == now) {
        cin >> now;
        N--;
      }
      if (prev > now) status = false;
      prev = now;
      continue;
    } else if (!status && prev < now) {
      ans++;
      prev = now;
      if (N <= 1) break;
      while (N && prev == now) {
        cin >> now;
        N--;
      }
      if (prev < now) status = true;
      prev = now;
      continue;
    }
    prev = now;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end(),greater<ll>())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000007 //1000000000000000003
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

  int N;
  cin>>N;
  int M=pow(2,N);

  multiset<ll,greater<ll>> st;
  vector<ll> proded;

  //vector<ll> s;
  rep(i,M){
    ll a;
    cin>>a;
    st.insert(a);
  }

  //SORT(s);

  auto itr=st.begin();
  ll now=*itr;
  proded.emplace_back(now);
  st.erase(itr);

  rep(i,N){
    int x=pow(2,i);
    rep(j,x){
      itr=st.upper_bound(proded[j]);
      if(itr==st.end()){
        cout<< "No"<<"\n";
        return;
      }
      now=*itr;
      proded.emplace_back(now);
      st.erase(itr);
    }

  }

  cout<< "Yes"<<"\n";

}


//-----------------------------------
int main(){
  cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}
//-----------------------------------


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

int main()
{
    int n,a[4];
    scanf("%d",&n);
    for(int i = 0;i<4;i++){
        a[i] = n%10;
        n = n/10;
    }
    if(a[0]==a[1]){
        if(a[1]==a[2])
            printf("Yes\n");
        else
            printf("No\n");
    }
    else if(a[1]==a[2]){
        if(a[2]==a[3])
            printf("Yes\n");
        else
            printf("No\n");
    }
    else
        printf("No\n");
    return 0;
}


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

using namespace std;

int main() {
  string O, E;
  cin >> O >> E;
  for (int i = 0; i < O.size() + E.size(); ++i) {
    if (i % 2 == 0) cout << O[i / 2];
    else cout << E[i / 2];
  }
  cout << endl;
}

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

int main(){
    int n;
    cin >> n;
    int sum=0;
    int v[n],c[n];
    for(int i=0; i<n; i++){
        cin >> v[i];
    }
    for(int i=0; i<n; i++){
        cin >> c[i];
    }
    for(int i=0; i<n; i++){
        if(v[i]-c[i]>0)sum+=v[i]-c[i];
        //cout << sum << endl;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
import scala.annotation.tailrec
import scala.collection.{immutable, mutable}
import scala.io.StdIn._
object Main extends App {

  loop()
  @tailrec def loop(): Unit = {
    val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
    if (n == 0 && m == 0) return
    val map = Array.fill(n){readLine.trim.split(' ').map(_.toDouble)}
    val maxHeight = Array.fill(2){Array.fill(n){1d}}
    for (i ← 1 until m){
      for (j ← 0 until n){
        maxHeight(i % 2)(j) = 0d
      }
      for (g ← 0 until n; p ← 0 until n){
        maxHeight(i % 2)(g) = math.max(maxHeight(i % 2)(g), maxHeight((i + 1) % 2)(p) * map(p)(g))
      }
    }
    println(f"${maxHeight((m + 1) % 2).max}%.2f")
    loop()
  }
}




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

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

    int a = 0;
    int b = 0;
    int c = 0;

    for(int i = 0; i < 3; i++){
        if(S.substr(i,1) == "a"){
            a++;
        }else if(S.substr(i,1) == "b"){
            b++;
        }else if(S.substr(i,1) == "c"){
            c++;
        }
    }

    if(a == 1 && b == 1 && c == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
  int n,m;
  scanf("%d\n",&n);
  vector<int> a;
  while (scanf("%d",&m)!=EOF) {
    a.push_back(m);
  }
  sort(a.begin(), a.end(), greater<int>());
  int sum = 0;
  for (size_t i = 0; i < a.size(); i++) {
    if (i%2==0) {
      sum += a[i];
    }else{
      sum -= a[i];
    }
  }
  printf("%d\n",sum );
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        const int INF = 1000000007;
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = l[0], M = l[1], X = l[2];
            var A = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var min = A.Count(z => z < X);
            var max = M - min;

            Console.WriteLine(Math.Min(min, max));
        }
    }
}


Measured memory_bytes: 13396
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((size_t *)a) < *((size_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

int main(void) {
	size_t A, B;

	scanf("%zu %zu", &A, &B);

	puts((A%2 == 1 & B%2 == 1 ? "Yes" : "No"));

	return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        var D = new Dictionary<int, int>();
        int N = cin.nextint;
        for (int i = 0; i < N; i++)
        {
            int a = cin.nextint;
            if (!D.ContainsKey(a))
            {
                D[a] = 1;
            }
            else
            {
                D[a]++;
            }
        }
        int ans = 0;
        foreach (var item in D)
        {
            int x = item.Key;
            int y = item.Value;
            if (x > y)
            {
                ans += y;
            }
            else if (x < y)
            {
                ans += y - x;
            }
        }
        WriteLine(ans);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

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

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

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

	int N, A, B; cin >> N >> A >> B;

	cout << min(N*A, B) << endl;

	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct UnionFind {
    vector< int > data;
    
    UnionFind(int sz) {
        data.assign(sz, -1);
    }
    
    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return (false);
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }
    
    int find(int k) {
        if(data[k] < 0) return (k);
        return (data[k] = find(data[k]));
    }
    
    int64_t size(int k) {
        return (-data[find(k)]);
    }
};

int main(void) {
    int64_t N, M;
    cin >> N >> M;
    vector<int> A(M), B(M);
    for(int i=0; i<M; i++) {
        cin >> A[i] >> B[i];
        --A[i];
        --B[i];
    }

    reverse(A.begin(), A.end());
    reverse(B.begin(), B.end());

    UnionFind uf(N);
    vector<int64_t> ans(M);
    ans[0] = N*(N-1) / 2L;
    for(int i=0; i<M-1; i++) {
        if(uf.find(A[i]) != uf.find(B[i])) {
            ans[i+1] = ans[i] - uf.size(A[i]) * uf.size(B[i]);
            uf.unite(A[i], B[i]);
        } else {
            ans[i+1] = ans[i];
        }
    }

    reverse(ans.begin(), ans.end());
    for(auto e: ans) {
        cout << e << endl;
    }
    return 0;
}


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

string a,b;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>a>>b;
	a += b;
	int n = stoi(a);
	int x = sqrt(n);
	if(x * x == n)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(998244353)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll a,ll b){if(!b)return a;else return gcd(b,a%b);}
int main()
{
	owo
   int n;
   cin>>n;
   vector<ll>p(n+2,-1);
   for(int i=1;i<=n;i++)cin>>p[i];
   ll ans = 0;
   for(int i=2;i<n;i++){   
      if((p[i+1]>p[i] && p[i] > p[i-1]) || (p[i-1] > p[i] && p[i] > p[i+1]))ans++;
   }
   cout<<ans;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<60;
const double eps=1e-9;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill_v(T& t,const V& v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill_v(T& t,const V& v){for(auto &e:t)fill_v(e,v);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
struct Segtree{
    int n,h;
    vector<int> dat,laz;
    Segtree(int n_){
        n=1;h=1;
        while(n<n_){
            n<<=1;
            h++;
        }
        dat.resize(2*n,INF);
        laz.resize(2*n,0);
    }
    int prop(int k){
        if(laz[k]==0)return dat[k];
        if(dat[k]<INF)dat[k]+=laz[k];
        if(k<n){
            laz[k<<1]+=laz[k];
            laz[k<<1|1]+=laz[k];
        }
        laz[k]=0;
        return dat[k];
    }
    void add(int a,int b,int x){
        int l=a+n,r=b+n;
        for(int i=h;i>0;i--)prop(l>>i),prop(r>>i);
        for(++r;l<r;l>>=1,r>>=1){
            if(l&1)laz[l++]+=x;
            if(r&1)laz[--r]+=x;
        }
        l=a+n,r=b+n;
        while(l>>=1)dat[l]=min(prop(l<<1),prop(l<<1|1));
        while(r>>=1)dat[r]=min(prop(r<<1),prop(r<<1|1));
    }
    void set(int k,int x){
        k+=n;
        for(int i=h;i>=0;i--)prop(k>>i);
        chmin(dat[k],x);
        while(k>>=1)dat[k]=min(prop(k<<1),prop(k<<1|1));
    }
    int getmin(int a,int b){
        int l=a+n,r=b+n;
        for(int i=h;i>0;i--)prop(l>>i),prop(r>>i);
        int res=INF;
        for(++r;l<r;l>>=1,r>>=1){
            if(l&1)chmin(res,prop(l++));
            if(r&1)chmin(res,prop(--r));
        }
        return res;
    }
};
int main(){
    int n;cin>>n;
    vector<int> b(n+10);
    for(int i=1;i<=n;i++)cin>>b[i];
    int q;cin>>q;
    vector<P> qs(q);
    for(int i=0;i<q;i++)cin>>qs[i].first>>qs[i].second;
    sort(all(qs));
    int id=0;
    Segtree tree(n+10);
    tree.set(0,0);
    for(int i=1;i<=n;i++){
        while(id<q&&qs[id].first==i){
            int r=qs[id].second;
            tree.set(r,tree.getmin(0,r));
            id++;
        }
        if(b[i]==1){
            tree.add(0,i-1,1);
        }else{
            tree.add(i,n,1);
        }
    }
    cout<<tree.getmin(0,n)<<endl;
}

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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class ATravelingBudget {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int a, b, c, d;
	    in >> a >> b >> c >> d;
	    out << min(a, b) + min(c, d) << endl;
	}
};


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


Measured memory_bytes: 256
#include <stdio.h> 
int main(void)
{ 
    int i,n,a[100]; 
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    for(i=1;i<=n;i++){
        printf("%d",a[n-i]);
        if(i==n) printf("\n");
        else printf(" ");
    }
    return 0;
} 


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


int main(void) {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  int ans = 0;
  int l = max(a, c);
  int r = min(b, d);

  ans = max(r - l, 0);

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

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

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    int C2 = max(C - A + B,0);
    cout << C2 << endl;
    return 0;
}

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

int n, a[101010];

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

#define VACANT_CHECK if(q=="Vacant") return 0;

int toColor(string q) {
  if(q=="Female")
    return 1;
  return 2;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  int n;
  cin>>n;
  vector<int> color(n);
  string q;
  cout << 0 << endl;
  cin>>q;
  VACANT_CHECK
  color[0]=toColor(q);
  cout << n-1 << endl;
  cin>>q;
  VACANT_CHECK
  color[n-1]=toColor(q);
  int l=0;
  int r=n-1;
  while(true) {
    int m=(l+r)/2;
    cout << m << endl;
    cin>>q;
    VACANT_CHECK
    color[m]=toColor(q);
    // [l,m]
    if(color[l]==color[m]&&(m-l+1)%2==0) {
      r=m;
      continue;
    }
    if(color[l]!=color[m]&&(m-l+1)%2==1) {
      r=m;
      continue;
    }
    if(color[r]==color[m]&&(r-m+1)%2==0) {
      l=m;
      continue;
    }
    if(color[r]!=color[m]&&(r-m+1)%2==1) {
      l=m;
      continue;
    }
  }
  return 0;
}


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

// auto mod int
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll 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 {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

// combination mod prime
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main() {
    int n, k;
    cin >> n >> k;
    k = min(k, n-1);
    combination c(n);
    mint ans;
    for(int i = 0; i <= k; i++) {
        ans += c(n, i) * c((n-i-1)+i, i);
    }
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 3328
#include<stdio.h>
#include<algorithm>
struct Team{
	int input;
	int wins;
	int loses;
	char name;
};
Team t[10];
inline bool operator<(const Team &a,const Team &b){
	if(a.wins!=b.wins)return a.wins>b.wins;
	if(a.loses!=b.loses)return a.loses<b.loses;
	return a.input<b.input;
}
int main(){
	int n;
	while(1){
		scanf(" %d ",&n);
		if(n==0)return 0;
		for(int i=0;i<n;i++){
			scanf(" %c ",&t[i].name);
			t[i].input=i;
			t[i].wins=0;
			t[i].loses=0;
			for(int j=0;j<n-1;j++){
				int val;
				scanf(" %d ",&val);
				if(val==0)t[i].wins++;
				else if(val==1)t[i].loses++;
			}
		}
		std::sort(t,t+n);
		for(int i=0;i<n;i++){
			printf("%c\n",t[i].name);
		}
	}
}

Measured memory_bytes: 0
#include <stdio.h>

int main(){
	unsigned int a,b,x,y,z;
	unsigned int r;
	while(scanf("%u %u", &a,&b) != EOF){
		if(a<b){
			z=a;
			a=b;
			b=z;
		}
		x = a;
		y = b;
		r = a % b;
		while(r != 0){
			x = y;
			y = r;
			r = x % y;
		}
		printf("%u %u\n", y, ((a/y)*b));
	}
	return 0;
}

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

using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;


int32_t main() {
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    
    
    ini(x);
    ini(x1);
    ini(x_);
    int ma = max({x,x1,x_});
    //out(ma);
    int  tmp = 0;
    if(x<ma){
        tmp +=(ma-x)/2;
        x+=((ma-x)/2)*2;
        //out(x,tmp);
    }
    if(x1<ma){
        tmp +=(ma-x1)/2;
        x1+=((ma-x1)/2)*2;
        //out(x1,tmp);
    }
    if(x_<ma){
        tmp +=(ma-x_)/2;
        x_+=((ma-x_)/2)*2;
        //out(x_,tmp);
    }
    if(x == x1 and x1 == x_)out(tmp);
    else{
        if(x+x1+x_ == 3*ma-1)out(tmp+2);
        else{
            out(tmp+1);
        }
    }


  
    
    
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vite ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tst lli T; cin>>T; while(T--)
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define lli long long int
#define vt vector
#define pb push_back
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    lli a, b, c, k, t = 0;
    cin >> a >> b >> c >> k;
    bool flag = true;
    if(b<=a)
    {
        while(b<=a)
        {
            b *= 2;
            t++;
        }
    }
    if(c<=b)
    {
        while(c<=b)
        {
            c *= 2;
            t++;
        }
    }

    if(t<=k)
        cout << "Yes";
    else
        cout << "No";
    cout<< endl;
    // cout<< fixed << 1.0 * clock() / CLOCKS_PER_SEC << setprecision(10);
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>

int f(int a)
{
 int i, j;
 for(i = 1; i <= 9; i++)
 {
  for(j = 1; j <= 9; j++)
   if(i * j == a)
    return 1;
 }
 return 0;
}

int main()
{
 int x;
 scanf("%d", &x);
 printf(f(x) ? "Yes\n" : "No\n");
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		String t = sc.next(); //big text
		String s = sc.next(); //small string
		
		//prepare kmp
		int[] kmp = new int[s.length()];
		{
			int i = 1, j = 0;
			while(i < s.length())
			{
//				System.out.println("i = " + i + ", j = " + j);
				if(s.charAt(i) == s.charAt(j))
				{
					kmp[i] = j+1; //i is the length of prefix that's also current suffix
					j++;
					i++;
				}
				else if(j == 0)
				{ //mismatch
					kmp[i] = 0;
					i++;
				}
				else
				{  //mismatch: try again with j rolled back
					//kmp[i] = j+1;
					j = kmp[j-1];
				}
			}
		}
		
//		System.out.println(Arrays.toString(kmp));
		
		StringBuilder sb = new StringBuilder();
		//begin search
		int j = 0;
		int i = 0;
		int c = 0;
		int mat = 0;
//		System.out.println("START");
		while(i < t.length())
		{
//			System.out.println(i + " " + j);
			if(t.charAt(i) == s.charAt(j))
			{
				if(j == s.length()-1)
				{ //whole pattern matched
					//MATCH!
					{
//						System.out.println("Match at " + (i-s.length()+1) + "~" + (i));
						sb.append((i-s.length()+1));
						sb.append('\n');
					}
					if(j > 0) //do the same as if mismatched, so that overlapped matches will all be found
						j = kmp[j-1];
					else
					{
						j = 0;
						i++;
					}
				}
				else
				{ //letter matched: go to next letter
					i++;
					j++;
				}
			}
			else
			{ //mismatch
				if(j > 0)
					j = kmp[j-1];
				else
				{
					j = 0;
					i++;
				}
			}
			
		}
		
		System.out.print(sb);
//		System.out.println(c);
		
		
	}
}



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

int main()
{
    ll n,ans=0;
    cin>>n;

    vector<ll>v(n+1,0);
    for(ll i=1;i<n+1;i++)
    {
       for(ll j=0;j<n+1;j+=i)
         v[j]++;
    }

    for(int f=1;f<=n;f++)
    {
        ans+=(f*(ll)v[f]);
    }
     cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 81384
from sys import stdin
from collections import deque
from itertools import repeat
def main():
    n = int(stdin.readline())
    a = map(int, stdin.readline().split(), repeat(10, n))
    ans = 0
    q = deque()
    p = 0
    for i, x in enumerate(a):
        while p & x:
            p ^= q.popleft()[1]
        q.append((i, x))
        ans += i - q[0][0] + 1
        p ^= x
    print ans
main()


Measured memory_bytes: 25104
#include <stdio.h>

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

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

int main() {
    int a, b;
    cin >> a >> b;
    
    double fa = a;
    double fb = b;
    
    int d = a / b;
    int r = a % b;
    double f = fa / fb;
    // cout << d << " " << r << " " << f << endl;
    printf("%d %d %.5f\n",(a/b),(a%b),(fa/fb));
}


Measured memory_bytes: 3220
# -*- coding: utf-8 -*-
source = (0,0)
def area(a, b, source):
    return (a[0]-source[0])*(b[1]-source[1]) - (b[0]-source[0])*(a[1]-source[1])

def div_con(coordinate):
    s = sorted(set(coordinate), key=lambda x: (x[1], x[0]))
    seq = []
    for i in range(len(s)):
        while len(seq) > 1 and area(seq[-2], s[i], seq[-1]) > 0:
            seq.pop()
        seq.append(s[i])
    t = len(seq)
    for i in range(len(s) - 2, -1, -1):
        while len(seq) > t and area(seq[-2], s[i], seq[-1]) > 0:
            seq.pop()
        seq.append(s[i])
        
    result = seq[:-1]
    return result

# input 
num = int(input())
# initialize
coordinate = []
# input 
for i in range(num):
  coordinate.append(tuple(map(int, input().split())))
result = div_con(coordinate)
# output 
print(len(result))
for item in result:
  print(item[0],item[1])


Measured memory_bytes: 31656
h1,s1,h2,s2 = map(int, input().split())

while h1 > 0 or h2 > 0:
  h2 -= s1
  if h2 <= 0:
    print("Yes")
    break
  h1 -= s2
  if h1 <= 0:
    print("No")
    break

Measured memory_bytes: 9176
#include <iostream>

using namespace std;

int main() {
    int n,a;
    int min = 1000000;
    int max = -1000000;
    long int sum = 0;

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> a;

        if (a < min)
            min = a;

        if (a > max)
            max = a;

        sum += a;
    }

    cout << min << " " << max << " " << sum << endl;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;
#define INF 1e9
typedef pair<int, int> P;

/* 　"assert"    assert(A：条件式)で　Aが真なら処理は続行、偽ならプログラムを終了する　*/

/*　　ラムダ式　　 auto a = [キャプチャ](パラメータ){ 処理 }  */

/* string型　メンバ関数　substr()    replace()  */

int main (){
    int n, k, s;
    cin >> n >> k >> s;
    vector<int> ans;
    rep(i,k){
        ans.push_back(s);
    }
    rep(i,n-k){
        if(s == 1e9){
            ans.push_back(1);
        }
        else{
            ans.push_back(s+1);
        }
    }
    rep(i,n) cout << ans[i]<< endl;
}


Measured memory_bytes: 1912
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    i64 n;
    cin >> n;
    i64 ans = n - 1;
    for (i64 i = 2; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ans = min(ans, i + n / i - 2);
        }
    }
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        char[][] map = new char[N][N];
        for (int i = 0; i < N; i++) {
            map[i] = scan.next().toCharArray();
        }
        long ans = 0;
        int A = 0;
        for (int B = 0; B < N; B++) {
            char[][] after = new char[N][N];
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < N; j++) {
                    after[i][j] = map[(i + A) % N][(j + B) % N];
                }
            }
            boolean ok = true;
            for (int i = 0; i < N && ok; i++) {
                for (int j = i + 1; j < N && ok; j++) {
                    if (after[i][j] != after[j][i]) {
                        ok = false;
                        break;
                    }
                }
            }
            if (ok) {
                ans += 1;
            }
        }
        System.out.println(ans * N);
    }
}


Measured memory_bytes: 56708
module Main where

import Data.List
import Control.Monad
import Debug.Trace
 
readTuple :: Read a  => IO (a, a)
readTuple = do
    [f, s] <- readLs
    pure (f, s)

readLs :: Read a => IO [a]
readLs = fmap read . words <$> getLine

solve :: Int -> Int -> Int
solve a b = first + second
    where
        first = max a b
        secondOne = first - 1
        secondTwo = min a b
        second = max secondOne secondTwo


main = do
    (a, b) <- readTuple
    print $ solve a b



Measured memory_bytes: 508
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }


int main(){
  int x, a, b;
  cin >> x >> a >> b;
  string ans = "dangerous";
  if(b-a <= 0)ans ="delicious";
  else if(b-a <= x)ans ="safe";
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
 
  int a,b,c,d,e,i;
  e = 0;
  scanf("%d %d %d",&a,&b,&c);
  for(i = a;i <= b;i++){
    d = c % i;
    if(d == 0){
      e++;
    }else(e == e);
        }
  printf("%d\n",e);
  return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
const int INF=(1<<21);
int n,M[101][101];
int d[101]; //最短距離を記録(到達不可な時はINF)
void bfs(int s){
  queue<int>q;
  q.push(s);//始点sをいれる(訪問)
  for(int i=0;i<n;i++) d[i]=INF;
  d[s]=0;
  while(!q.empty()){
    int u=q.front();
    q.pop();
    for(int v=0;v<n;v++){
      if(M[u][v]==0) continue; //辺がない
      if(d[v]!=INF) continue; //訪問したことがある
      d[v]=d[u]+1; //vは未訪問の頂点であり、隣接しているためd[u]に1を足す
      q.push(v); //vを始点に
    }
  }
  for(int i=0;i<n;i++){
    cout<<i+1<<" "<<( (d[i]==INF)?(-1):d[i] )<<endl;
  } //到達不可能か
}
int main(){
  int u,k,v;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(int j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }
  bfs(0);
  return 0;
}



Measured memory_bytes: 3284
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

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

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

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1000000007;

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

char c[60][60];

int bfs(int gx, int gy) {
	int sx = 1,sy = 1;
	queue<PII> q,pq;
	q.push(MP(sx,sy));
	c[sx][sy] = 'x';
	for (int i = 2; i < 2500; i++) {
		while (!q.empty()) {
			PII v = q.front();
			q.pop();
			int x = v.first;
			int y = v.second;
			if(c[x-1][y] == '.') {pq.push(MP(x-1,y)); c[x-1][y] = 'x'; }
			if(c[x+1][y] == '.') {pq.push(MP(x+1,y)); c[x+1][y] = 'x'; }
			if(c[x][y-1] == '.') {pq.push(MP(x,y-1)); c[x][y-1] = 'x'; }
			if(c[x][y+1] == '.') {pq.push(MP(x,y+1)); c[x][y+1] = 'x'; }
		}

		while (!pq.empty()) {
			q.push(pq.front());
			if (pq.front().first == gx && pq.front().second == gy) {
				return i;
			}
			pq.pop();
		}
	}
	return -1;
}

int main(int argc, char const* argv[])
{
	int h,w;
	cin >> h >> w;
	int nwhite = 0;
	for (int i = 0; i < h+2; i++) {
		for (int j = 0; j < w+2; j++) {
			if ((i == h+1 || i == 0) || (j == w+1 || j == 0)) {
				c[i][j] = '#';
			}
			else {
				cin >> c[i][j];
				if (c[i][j] == '.') {
					++nwhite;
				}
			}
		}
	}
	int ret;
	ret = bfs(h,w);
	if (ret == -1) {
		cout << -1 << endl;
	}
	else {
		cout << nwhite - ret << endl;
	}
	return 0;
}


Measured memory_bytes: 256
N = int(input())
li = input().split()
a = 1
sikataganai = False
try:
  h = li.index('0')
  print(0)
  sikataganai = True
except:
  for i in range(N):
    a *= int(li[i])
    if a > 10 ** 18:
      print(-1)
      exit()
  if not sikataganai :
    print(a)

Measured memory_bytes: 19428
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main(){
    double x1, y1, x2, y2, dist;
    cin >> x1 >> y1 >> x2 >> y2;
    if(x1 == x2){
        dist = abs(y1 - y2);
    } else if(y1 == y2){
        dist = abs(x1 - x2);
    } else {
        dist = sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
    }
    printf("%lf\n", dist);
    return 0;
}


Measured memory_bytes: 3264
#include <iostream>
#include <cstdio>
#include <numeric>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int x = 0;
    int y = 0;
    int N; cin >> N;
    string s, t; cin >> s >> t;


    for(int i = 0; i < N; i++){
      for(int j = 0; j < N; j++){
        int n=i, m=j;
        while(s[n] == t[m] && n < N){
          n++;
          m++;
        }
        x = max(x, n-i);
        y = max(y, m);
      }
    }
    //cout << x << " " << (N-y) << endl;

    if(x == N && y == N) cout << N << endl;
    else if (x == 0 && y == 0) cout << 2*N << endl;
    else cout << N + (N-x) << endl;


    return 0;
}


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

int main(){
    int N;
    string s;
    cin >> N >> s;
    int cntR = 0;
    int cntB = 0;
    for(int i = 0; i < N; i++) {
        if(s[i] == 'R') {
            cntR++;
        }
        else {
            cntB++;
        }
    }
    if(cntR > cntB) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 256
import numpy as np


def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod


mod = 10 ** 9 + 7  # 出力の制限
N = 10 ** 4
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)


def dist(x, y):
    ans = 0
    for i in range(len(x)):
        ans += (x[i] - y[i]) * (x[i] - y[i])
    return np.sqrt(ans)


n, d = map(int, input().split())
arr = []
for i in range(n):
    arr.append(list(map(int, input().split())))

ans = 0

for i in range(n):
    for j in range(i + 1, n):
        d = dist(arr[i], arr[j])
        if abs(d - int(d)) < 0.00001:
            ans += 1

print(ans)




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

using namespace std;

int main(){
  string s;
  cin >> s;
  int ans=0;
  for(int i=0;i<4;i++){
    if(s[i]=='+'){
      ans++;
    }
    else{
      ans--;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256