akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <utility>
#include <vector>
#include <complex>
#include <cmath>
#include <algorithm>
#include <set>

using namespace std;

static const double EPS=1e-12;
static const double INF=1e24;

using Point=complex<double>;
using Plane=vector<Point>;
using Polygon=vector<Point>;

bool operator<(const Point &a, const Point &b) {
    return real(a)!=real(b)? real(a)<real(b) : imag(a)<imag(b);
}

double cross_prod(const Point &a, const Point &b) {
    return imag(conj(a)*b);
}

double dot_prod(const Point &a, const Point &b) {
    return real(conj(a)*b);
}

struct LineSeg: public pair<Point, Point> {
    LineSeg() {}
    LineSeg(const Point &a, const Point &b) {
        first = a;
        second = b;
    }
};

enum PointType {
    BOTTOM,
    LEFT,
    RIGHT,
    TOP,
};

struct EndPoint {
    Point p;
    size_t seg;
    PointType type;
    EndPoint() {}
    EndPoint(Point p, size_t s, PointType t): p(p), seg(s), type(t) {}
    bool operator<(const EndPoint &rhs) const {
        return imag(p)!=imag(rhs.p)? imag(p)<imag(rhs.p) : type<rhs.type;
    }
};

size_t num_mintersect(vector<LineSeg> g) {
    size_t V=g.size();

    vector<EndPoint> h;
    for (size_t i=0; i<V; ++i) {
        if (imag(g[i].first) == imag(g[i].second)) {
            if (real(g[i].first) > real(g[i].second))
                swap(g[i].first, g[i].second);
        } else if (imag(g[i].first) > imag(g[i].second)) {
            swap(g[i].first, g[i].second);
        }

        if (imag(g[i].first) == imag(g[i].second)) {
            h.push_back(EndPoint(g[i].first, i, LEFT));
            h.push_back(EndPoint(g[i].second, i, RIGHT));
        } else {
            h.push_back(EndPoint(g[i].first, i, BOTTOM));
            h.push_back(EndPoint(g[i].second, i, TOP));
        }
    }
    sort(h.begin(), h.end());

    set<double> vlines;
    vlines.insert(INF);

    size_t count=0;
    for (size_t i=0; i<(V<<1); ++i) {
        if (h[i].type == TOP) {
            vlines.erase(real(h[i].p));
        } else if (h[i].type == BOTTOM) {
            vlines.insert(real(h[i].p));
        } else if (h[i].type == LEFT) {
            set<double>::iterator lb=lower_bound(
                vlines.begin(), vlines.end(), real(g[h[i].seg].first)
            );
            set<double>::iterator ub=upper_bound(
                vlines.begin(), vlines.end(), real(g[h[i].seg].second)
            );
            count += distance(lb, ub);
        }
    }

    return count;
}

int main() {
    size_t n;
    scanf("%zu", &n);

    vector<LineSeg> g(n);
    for (size_t i=0; i<n; ++i) {
        double x, y;
        scanf("%lf %lf", &x, &y);
        Point p1(x, y);

        scanf("%lf %lf", &x, &y);
        Point p2(x, y);

        g[i] = LineSeg(p1, p2);
    }

    printf("%zu\n", num_mintersect(g));
    return 0;
}

Measured memory_bytes: 17384
import java.math.*;
import java.util.*;

public class Main {
    static double deg(double t, double h) {
        return t - (h * 0.006);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double n = sc.nextDouble();
        double t = sc.nextDouble();
        double a = sc.nextDouble();
        double gap = 0;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            double tmp = sc.nextDouble();
            if (i == 0) {
                ans = i + 1;
                gap = Math.abs(a -deg(t, tmp));
            }
            if (Math.abs(a - deg(t, tmp)) < gap) {
                gap = Math.abs(a - deg(t, tmp));
                ans = i + 1;
            }
        }
        System.out.println(ans);
    }
}


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

int gcd(int a, int b){
    if (a%b==0){
        return b;
    }
    return gcd(b, a%b);
}
int main() {
    int N;
    cin >> N;
    int ans=0;
    for (int i=1; i<=N; i++){
        for (int j=1; j<=N; j++){
            for (int l=1; l<=N; l++){
                int x=gcd(i,gcd(j,l));
                ans+=x;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
n = int(input())
l = []
for i in range(n):
    l.append(i+1)
N = sum(l)

l3 = []
for i in range(n//3):
    l3.append(i+1)
s_3 = 3 * sum(l3)

l5 = []
for i in range(n//5):
    l5.append(i+1)
s_5 = 5 * sum(l5)

l15 = []
for i in range(n//15):
    l15.append(i+1)
s_15 = 15 * sum(l15)

ans = N - (s_3 + s_5 - s_15)
print(ans)

Measured memory_bytes: 72188
#include <bits/stdc++.h>
using namespace std;
const int P = 998244353;
const int inf = 2e9;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vector<pair<int, int> > x;
	x.resize(n);
	for(int i = 0; i < n; ++i) {
		cin >> x[i].first >> x[i].second;
	}
	sort(x.begin(), x.end());
	vector<int> p;
	p.resize(n);
	for(int i = 0; i < n; ++i) {
		p[i] = x[i].first;
	}
	vector<int> dp;
	dp.resize(n + 1);
	dp[n] = 1;
	vector<pair<int, int> > st;
	st.emplace_back(inf, n);
	for(int i = n - 1; i >= 0; --i) {
		while(x[i].first + x[i].second > st.back().first) {
			st.pop_back();
		}
		dp[i] = (dp[i + 1] + dp[st.back().second]) % P;
		st.emplace_back(x[i].first, i);
	}
	cout << dp[0] << '\n';
	return 0;
}



Measured memory_bytes: 4600
import java.util.*

fun main(args: Array<String>) {
    val sc=Scanner(System.`in`)
    val (a,b)=sc.nextLine().split(" ").map{it.trim().toLong()}
    var count=0
    for(i in 1..a)
    {
        val (x,y)=sc.nextLine().split(" ").map{it.trim().toLong()}.toTypedArray()
        var z=(Math.sqrt(((x*x)+(y*y)).toDouble()))
        if(z<=b.toDouble())
        {
            count++;
        }
    }
    println(count)
}



Measured memory_bytes: 62596
/*betaでやろう*/
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <iterator>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define PB push_back
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define mp make_pair
#define INT int_64
const ll INF = (ll)(1<<30)*10000;
const ll NEGA=-INF*10000; 


ll ans = 0;
int cnt=0;

ll a[200000];
int used[1001];
ll dp[1001][1001];
ll sumx,sumy,sumz;
ll sx,sy,sz;
int main() 
{
 
 ll a,b;
 cin>>a>>b;
 if(a+b==15) cout<<'+'<<endl;
 else if(a*b==15) cout<<'*'<<endl;
 else cout<<'x'<<endl;
}



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

int main() {
  int A, B;
  cin >> A >> B;

  int ans = 0;
  for (int i = A; i <= B; i++) {
    string s = to_string(i), t = s;
    reverse(t.begin(), t.end());
    if (s == t)
      ans++;
  }

  cout << ans << endl;
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

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

    rep(i,n){
        double x;cin>>x;
        string u;cin>>u;
        if(u=="JPY"){
            ans+=x;
        }
        else {
            ans+=380000*x;
        }
    }
    cout<<fixed<<setprecision(5)<<ans<<endl;
}


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

int main()
{

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

        long long asum;
        long long bsum;
        long long min = 0;
        long long temp = 0;
        long long asum_bck = 0;
        long long bsum_bck = 0;
        for (int i = 1; i < N; ++i) {
                bsum_bck += a[i];
        }
        for (int i = 0; i < N-1; ++i) {

                asum = asum_bck + a[i];
                if (i != 0) {
                        bsum = bsum_bck - a[i];
                }
                else {
                        bsum = bsum_bck;
                }
                temp = abs(asum - bsum);
                if (i == 0) {
                        min = temp;
                }
                else if (temp < min) {
                        min = temp;
                }

                asum_bck = asum;
                bsum_bck = bsum;

        }

        cout << min << endl;






}


Measured memory_bytes: 1792
function main(input) {
  const args = input.split(' ');
    const n= parseInt(args[0], 10);
    const d = parseInt(args[1], 10);
  if(n%(2*d+1)==0){
    console.log(Math.floor(n/(2*d+1)));
  }else{
    console.log(Math.floor(n/(2*d+1))+1);
  } 
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
//package atCoder;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		if(a <= 12 && a >=6)
			b = b/2;
		else if(a<6)
			b = 0;

		System.out.println(b);

	}
}


Measured memory_bytes: 21076
// Create by JJL
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <set>
#include <queue>
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;

//const int N=300010,Mod=1e9+7;

int main(){
    IOS;
    /* START CODE */
    bool su=0;
    int n;
    cin>>n;
    long long cnt=0;
    for(int i=1;i<=n;++i){
        cnt+=(n-1)/i;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3224
#include <stdio.h>

#define MAX 100
#define INFTY 10000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int prim();

int n;
int M[MAX][MAX];


int main(){
  int i,j;
  int e;
scanf("%d",&n);

for(i=0;i<n;i++){
  for(j=0;j<n;j++){
    int e; scanf("%d",&e);
    if(e== -1){
      e = INFTY;
    }
      M[i][j]=e;

  }
}

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

  return 0;
}

int prim(){
  int v,i;
  int u,minv;
  int d[MAX],p[MAX],color[MAX];

  for(i=0;i<n;i++){
    d[i]=INFTY;
    p[i]=-1;
    color[i]=WHITE;
  }

  d[0]=0;

  while(1){
    minv=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(minv>d[i] && color[i] != BLACK){
        u=i;
        minv=d[i];
      }
    }
    if(u==-1)break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if( color[v] != BLACK && M[u][v] != INFTY){
        if( d[v]>M[u][v]){
          d[v]=M[u][v];
          p[v] = u;
          color[v] = GRAY;
        }
      }
  }
}
int sum = 0;
for(i=0;i<n;i++){
  if( p[i] != -1){
    sum += M[i][p[i]];
  }
}

return sum;

}



Measured memory_bytes: 2056
a,b=map(int,input().split())
tmp_min=min(-(-(a*100)//8),b*10)
tmp_max=max(-(-(a*100)//8),b*10)
ans="-1"
for i in range(tmp_max-tmp_min+1):
    tmp=tmp_min+i
    if tmp*0.08//1==a and tmp*0.1//1==b:
        ans=tmp
        break
    if tmp*0.08//1>a or tmp*0.1//1>b:
        break
print(ans)

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define multis          multiset <int, greater <int> > gquiz1;
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

void ayushmehta651()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
	ayushmehta651();
	int n; cin >> n;
	int a[n];
	vector<int> freq(100069, 0);
	int sum = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		freq[a[i]]++;
		sum += a[i];
	}

	int q; cin >> q;

	while (q--)
	{
		int b, c; cin >> b >> c;

		sum -= (freq[b] * b);
		sum += (freq[b] * c);

		freq[c] += freq[b];
		freq[b] = 0;

		cout << sum << '\n';
	}
	return 0;
}


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

using namespace std;

const int mod = 1e9 + 7;

inline int add(int a, int b, int mod = mod) {
  a += b;
  if(a >= mod) a -= mod;
  if(a < 0) a += mod;
  return a;
}

inline int mul(int a, int b, int mod = mod) {
  return (long long) a * b % mod;
}

struct Matrix{
  int** arr;
  int r, c;
  Matrix(int a, int b){
    r=a; c=b;
    arr=new int*[r];
    for(int i=0; i<r; ++i){
      arr[i]=new int[c];
    }
    for(int i=0; i<r; ++i){
      for(int j=0; j<c; ++j){
        arr[i][j]=0;
      }
    }
  }
  void print(){
    for(int i=0; i<r; ++i){
      for(int j=0; j<c; ++j){
        printf("%d ", arr[i][j]);
      }
      printf("\n");
    }
  }
  Matrix operator*(Matrix other){
    if(c!=other.r){
      printf("Error: Dimension mismatch\n");
      exit(0);
    }
    Matrix res(r, other.c);
    for(int i=0; i<res.r; ++i){
      for(int j=0; j<res.c; ++j){
        for(int k=0; k<c; ++k){
          res.arr[i][j] = add(res.arr[i][j], mul(arr[i][k], other.arr[k][j]));
        }
      }
    }
    return res;
  }
};

int powm(Matrix M, long long n, long long k){
  Matrix res(M.r, M.c);
  for(int i = 0; i < M.r; ++i) {
    for(int j = 0; j < M.c; ++j) {
      if(i == j) res.arr[i][j] = 1;
    }
  }
  while(n){
    if(n&1) res = (res*M);
    n >>= 1;
    M = (M*M);
  }
  int ret = 0;
  for(int i = 0; i < res.r; ++i) {
    for(int j = 0; j < res.c; ++j) {
      ret = add(ret, res.arr[i][j]);
    }
  }
  return ret;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  int n; cin >> n;
  long long p; cin >> p;
  Matrix M(n, n);
  for(int i = 0; i < n; ++i) {
    for(int j = 0; j < n; ++j) {
      cin >> M.arr[i][j];
    }
  }
  cout << powm(M, p, p) << "\n";
}

Measured memory_bytes: 1536
#include <algorithm>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define cerr                                                                   \
  if (false)                                                                   \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

void solve(long long a_I, long long a_O, long long a_T, long long a_J,
           long long a_L, long long a_S, long long a_Z) {
  ll ans = a_O;
  ll no = 0;
  ll use = 0;
  no += a_I / 2 * 2;
  no += a_J / 2 * 2;
  no += a_L / 2 * 2;

  if (a_I && a_J && a_L) {
    a_I--;
    a_J--;
    a_L--;
    use += a_I / 2 * 2;
    use += a_J / 2 * 2;
    use += a_L / 2 * 2;
    use += 3;
  }

  cout << ans + max(no, use) << endl;
}

int main() {
  ios::sync_with_stdio(false);
  long long a_Z;
  long long a_S;
  long long a_T;
  long long a_I;
  long long a_L;
  long long a_O;
  long long a_J;
  cin >> a_I;
  cin >> a_O;
  cin >> a_T;
  cin >> a_J;
  cin >> a_L;
  cin >> a_S;
  cin >> a_Z;
  solve(a_I, a_O, a_T, a_J, a_L, a_S, a_Z);
  return 0;
}


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

int main(){
  int H, W;
  cin >> H >> W;
  vector<vector<char>> M(H, vector<char>(W));

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> M.at(i).at(j);
    }
  }
  vector<int> s(H,0);
  for (int i = 0; i < H; i++) {
    bool flag=false;
    for (int j = 0; j < W-1; j++) {
      if(M.at(i).at(j)=='.'&&M.at(i).at(j+1)=='.') flag=true;
      else{
        flag=false;
        break;
      }
    }
    if(flag) s.at(i)=1;
  }

  vector<int> t(W,0);
  for (int i = 0; i < W; i++) {
    bool flag=false;
    for (int j = 0; j < H-1; j++) {
      if(M.at(j).at(i)=='.'&&M.at(j+1).at(i)=='.') flag=true;
      else{
        flag=false;
        break;
      }
    }
    if(flag) t.at(i)=1;
  }

  for (int i = 0; i < H; i++) {
    if(s.at(i)==0){
      for (int j = 0; j < W; j++) {
        if(t.at(j)==0) cout << M.at(i).at(j);
      }
      cout << endl;
    }
  }
}


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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

struct UnionFind{
	vi data;
	UnionFind(int n):data(n,-1){}
	int Find(int i){
		return data[i]<0?i:(data[i]=Find(data[i]));
	}
	bool Unite(int a,int b){
		a=Find(a),b=Find(b);
		if(a==b) return false;
		if(-data[a]<-data[b]) swap(a,b);
		data[a]+=data[b];
		data[b]=a;
		return true;
	}
	int Size(int i){
		return -data[Find(i)];
	}
};

int main()
{
	for(int n,k,l;cin>>n>>k>>l&&n|k|l;){
		UnionFind uf[2]={n,n};
		rep(i,k){
			int u,v; cin>>u>>v; u--,v--;
			uf[0].Unite(u,v);
		}
		rep(i,l){
			int u,v; cin>>u>>v; u--,v--;
			uf[1].Unite(u,v);
		}
		map<tuple<int,int>,int> f;
		rep(i,n) f[mt(uf[0].Find(i),uf[1].Find(i))]++;
		rep(i,n) cout<<f[mt(uf[0].Find(i),uf[1].Find(i))]<<" \n"[i+1==n];
	}
}


Measured memory_bytes: 13568
import java.util.*;

public class Main{
    
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        String s = sc.next();
        int l = s.length();
        
        if(l<=k){
            System.out.println(s);
        }
        else{
            String s1 = s.substring(0,k);
            System.out.println(s1+"...");
        }
        
    }
    
}

Measured memory_bytes: 38620
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        int len = (A < B) ? A : B;
        List r = new ArrayList<Integer>();
        for (int i = 1; i <= len; i++) {
            if (A % i == 0 && B % i == 0) r.add(i);
        }
        System.out.println(r.get(r.size()-K));
    }
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    int n=s.size()-1;
    ll ans=0;
    for(int bit=0;bit<(1<<n);++bit){
        ll res=0;
        for(int i=0;i<=n;++i){
            res*=10;
            res+=stoi(s.substr(i,1));
            if(bit&(1<<i)){
                ans+=res;
                res=0;
            }
        }
        ans+=res;
    }
    
    cout << ans << "\n";
    return 0;
}   

Measured memory_bytes: 3640
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
using pll = pair<ll,ll>;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main(){
int H,W;
cin>>H>>W;
mint dp[H+1][W+1];
rep3(i,H)rep3(j,W)dp[i][j]=0;
dp[1][1]=1;

char map_[H+1][W+1];
rep3(i,H)rep3(j,W)cin>>map_[i][j];
rep3(i,H)rep3(j,W){
    if((i+1<=H)&&(map_[i+1][j]=='.')){
        dp[i+1][j]+=dp[i][j];
    }
    if((j+1<=W)&&(map_[i][j+1]=='.')){
        dp[i][j+1]+=dp[i][j];
    }
}

   
cout<<dp[H][W]<<endl;
return 0;
}

Measured memory_bytes: 12352
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int cnt = sc.nextInt();
        double power = 1;
        for (int i = 1; i <= cnt; i++) {
            power = (power*i)%(Math.pow(10, 9) + 7);
        }
        System.out.println((int)power);
    }
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

/* -----  2019/05/19  Problem: ABC 126 A / Link: http://abc126.contest.atcoder.jp/tasks/abc126_a  ----- */


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

	LL N; cin >> N;
	int K; cin >> K;
	string s; cin >> s;
	K--;
	FOR(i, 0, N) {
		if (K == i)s[i] = tolower(s[i]);
	}
	cout << s << endl;


	return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <map>
using namespace std;
typedef long long LL;
int main(int argc, char* argv[])
{
	int N;
	cin>>N;
	LL a;
	map<LL,int> aMap;
	map<LL,int>::iterator mit;
	int i;
	for (i=0;i<N;i++){
		cin>>a;
		mit=aMap.find(a);
		if (mit==aMap.end()){
			aMap[a]=1;
		}else{
			(*mit).second++;
		}
	}
	int aw=0;
	for (mit=aMap.begin();mit!=aMap.end();mit++){
		int f=(*mit).first;
		int s=(*mit).second;
		if (f==s){
		}else if (f<s){
			aw+=s-f;
		}else{//f>s
			aw+=s;
		}
	}
	cout<<aw<<endl;
	return 0;
}

Measured memory_bytes: 6272
#include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>
#define PI 3.1415926535897932
using namespace std;

string data[3000];
int c;

bool search(string);
void input(string);
void swap(char *,char *);

int main(){
	string str;
	string str1,str2; //1gariba-su
	int m,size,size1,size2;
	cin >> m;
	while(m--){
		c=0;
		cin >> str;
		size=str.size();
		for(int i=1;i<size;i++){	//1bunkatu
			str1.assign(str,0,i);
			str2.assign(str,i,size-i);
			size1=str1.size();
			size2=str2.size();
			if(search(str1+str2)) input(str1+str2); //12??????
			if(search(str2+str1)) input(str2+str1);	//21??????
			for(int j=0;j<size1/2;j++) swap(&str1[j],&str1[size1-j-1]);//1?????¢
			if(search(str1+str2)) input(str1+str2); //12??????
			if(search(str2+str1)) input(str2+str1); //21??????
			for(int j=0;j<size2/2;j++) swap(&str2[j],&str2[size2-j-1]);//2?????¢
			if(search(str1+str2)) input(str1+str2); //12??????
			if(search(str2+str1)) input(str2+str1); //21??????
			for(int j=0;j<size1/2;j++) swap(&str1[j],&str1[size1-j-1]);//1?????¢
			if(search(str1+str2)) input(str1+str2); //12??????
			if(search(str2+str1)) input(str2+str1); //21??????
		}
		cout << c << endl;
	}
	return 0;
}

bool search(string str){
	for(int i=0;i<c;i++){
		if(str==data[i]) return false;	//??????????????°
	}
	return true;	//??????????????°
}

void input(string str){
	data[c]=str;
	c++;
}

void swap(char *a,char *b){
	char w;
	w=*a;
	*a=*b;
	*b=w;
}

Measured memory_bytes: 1300
#include <iostream>

using namespace std;

int main()
{
    int w,h,x,y,r;
    cin>>w>>h>>x>>y>>r;
    if (x-r>=0 && x+r<=w && y+r<=h && y-r>=0) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}



Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define fastio     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define debug(x)   cerr<<#x<<": "<<x<<endl;
#define all(x)     (x).begin() , (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl       '\n'
#define MAX        1000000
typedef long long int ll;
using namespace std;


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


vector<pair<int,vector<int>>>arr;
int n,m,x;

bool check(vector<int>res) {
    for(int i:res)if(i<x)return false;
    return true;
}

int recur(int ind,int ans,vector<int>res) {
    if(ind==n && check(res))return ans;
    else if(ind==n)return INT_MAX;

    int fin;
    vector<int>res1(m,0);
    for(int i=0;i<m;i++)res1[i] = (res[i]+arr[ind].second[i]);
    int first=recur(ind+1,ans+arr[ind].first,res1);  //using ind
    int second=recur(ind+1,ans,res); //without using ind
    fin=min(first,second);
    return fin;
}


void solve(){
    cin>>n>>m>>x;
    arr.resize(n);
    for(int i=0;i<n;++i) {
        cin>>arr[i].first;
        arr[i].second = vector<int>(m,0);
        for(int j=0;j<m;++j)cin>>arr[i].second[j];
    }
    vector<int>res(m,0);
    int ans = recur(0,0,res);
    if(ans==INT_MAX)cout<<-1;
    else cout<<ans;
}





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


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int W,H,N;
  cin >> W >> H >> N;
  vector<vector<bool>> v(W,vector<bool>(H));
  vector<vector<int>> p(N,vector<int>(3));
  for (int i=0;i<N;i++){
    cin >> p.at(i).at(0) >> p.at(i).at(1) >> p.at(i).at(2);
  }
  for (int j=0;j<W;j++){
    for (int k=0;k<H;k++){
      v.at(j).at(k)=true;
    }
  }
  for (int i=0;i<N;i++){
    if (p.at(i).at(2)==1){
      for (int j=0;j<p.at(i).at(0);j++){
        for (int k=0;k<H;k++){
          v.at(j).at(k)=false;
        }
      }
    }
    if (p.at(i).at(2)==2){
      for (int j=p.at(i).at(0);j<W;j++){
        for (int k=0;k<H;k++){
          v.at(j).at(k)=false;
        }
      }
    }
    if (p.at(i).at(2)==3){
      for (int j=0;j<W;j++){
        for (int k=0;k<p.at(i).at(1);k++){
          v.at(j).at(k)=false;
        }
      }
    }
    if (p.at(i).at(2)==4){
      for (int j=0;j<W;j++){
        for (int k=p.at(i).at(1);k<H;k++){
          v.at(j).at(k)=false;
        }
      }
    }
  }
  int ans=0;
  for (int j=0;j<W;j++){
    for (int k=0;k<H;k++){
      if (v.at(j).at(k)){
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

int a,b,c;

int main(){
    cin>>a>>b>>c;
    cout<<min(a*b,c)<<endl;
}


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

using namespace std;

int main()
{
    map<long long ,int >ck;
    int n,s=0,a,b;
    cin>>n;
    while(n--){
        cin>>a;
        if(ck[a]==0){ck[a]=1;s++;}
        else{ck[a]=0;s--;}
    }
    cout<<s<<endl;
    return 0;
}



Measured memory_bytes: 6528
/* Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define foref(i, a, b) for (int i = b - 1, to = a; i >= to; i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  Long a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max({a * c, a * d, b * c, b * d}) << '\n';

  return 0;
}

Measured memory_bytes: 3644
def main():
    buf = input()
    N = int(buf)
    buf = input()
    H = int(buf)
    buf = input()
    W = int(buf)
    hspace = N - H + 1
    wspace = N - W + 1
    print(hspace * wspace)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import java.util.*;
        public class Main {
        	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int a[]=new int[n];
		int x=0;
		int aa=0;
		for(int i=0;i<n;i++){
			a[i] = sc.nextInt();
			aa+=a[i];
		}
		for(int i=0;i<n;i++){
			if(((double)aa/(4*m))<=a[i]){
				x++;
			}
		}
		if(m<=x){
			System.out.print("Yes");
		}else{
			System.out.print("No");
		}
	}
        }

Measured memory_bytes: 23764
N = int(input())
A = list(map(int, input().split()))

ans = 1

A = sorted(A, reverse=True)

if 0 not in A:
    for i in A:
        ans *= i
        if ans > 10 ** 18:
            break
else:
    ans = 0

if ans > 10 ** 18:
    print("-1")
else:
    print(ans)

Measured memory_bytes: 21660
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;cin>>n;
	vector<pair<string,int>> arrmv;
	for(int i=0;i<n;i++){
		string str;int minute;cin>>str>>minute;
		arrmv.push_back(make_pair(str,minute));
	}
	string tar; cin>>tar;
	int idx;
	for(int i=0;i<n;i++){
		if(arrmv[i].first==tar){
			idx=i+1;
			break;
		}
	}
	int sum=0;
	for(int i=idx;i<n;i++){
		sum+=arrmv[i].second;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
const int mod=1e9+7;
const double eps=1e-6;
const int inf=0x3f3f3f3f;
const double pi=acos(-1.0);
//LL powmod(LL a,LL b) {LL res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int a[100010];
int main(){
//    freopen("B-small-attempt1.in","r",stdin);
//    freopen("output.txt","w",stdout);
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int mx=*max_element(a,a+n);
    int mn=*min_element(a,a+n);
    if(mx-mn>1) return 0*puts("No");
    if(mn==mx){
        if(mn==n-1) puts("Yes");
        else if(mn<=n/2) puts("Yes");
        else puts("No");
    }
    else {
        int cnt=0;
        for(int i=0;i<n;i++){
            if(a[i]==mn) cnt++;
        }
        if(mx-cnt>=1&&mx-cnt<=(n-cnt)/2) puts("Yes");
        else puts("No");
    }
	return 0;
}
/*
*/


Measured memory_bytes: 640
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int

def divisor(n)
  result = SortedSet.new
  result.add(1); result.add(n)
  i = 1
  num = Math.sqrt(n)
  while i <= num do
    remainder = n % i
    if remainder == 0
      result.add(i)
      result.add(n/i)
    end
    i += 1
  end
  result.to_a
end

ans = N - 1
divisor(N).each do |x|
  y = N / x
  res = x - 1 + y - 1
  ans = res if res < ans
end

puts ans




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


int main()
{
    int n;
    cin>>n;
    vector<int> h(n,0);
    for(int i=0;i<n;i++)
        cin>>h[i];
    
    vector<int> dp(n,0);
    dp[n-1]=0;
    for(int i=n-2;i>=0;i--)
    {
        if(i==n-2)
            dp[i]=abs(h[i]-h[i+1])+dp[i+1];
        else
            dp[i]=min((abs(h[i]-h[i+1])+dp[i+1]),(abs(h[i]-h[i+2])+dp[i+2]));
    }
   cout<<dp[0]<<endl;
}

Measured memory_bytes: 4044
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<map>
#include<stack>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<sstream>


#define reps(i,f,n) for(int i = f; i < int(n); i++)
#define rep(i,n) reps(i,0,n)

#define PII pair<int,int>
#define PP pair< int,PII >


using namespace std;

int main(){
	
	int num;
	double w,h;
	
	while(scanf("%d,%lf,%lf", &num, &w, &h)!=EOF){
		if(25.0*h*h <= w){
			printf("%d\n", num);
		}
	}
	return 0;
}

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

#define MAX_N 100000

// int N = 3;
// struct edge { int to, cost; };

// vector<edge> G[MAX_N] = { 
//     { edge {1, 2} }, { edge { 2, 1 } } 
// }; // グラフ

int N;


int main() {
    cin >> N;
    vector<vector<int>> to(N), cost(N);
    for (int i = 0; i < N-1; i++) {
        int a, b, w;
        cin >> a >> b >> w;
        a--; b--;
        to[a].push_back(b); cost[a].push_back(w);
        to[b].push_back(a); cost[b].push_back(w);
    }

    vector<int> ans(N, -1);
    queue<int> q;
    ans[0] = 0;
    q.push(0);

    while (!q.empty())
    {
        int v = q.front();
        q.pop();
        for (int i = 0; i < to[v].size(); i++) {
            int u = to[v][i];
            int w = cost[v][i];
            if (ans[u] != -1) continue;
            ans[u] = (ans[v] + w) % 2;
            q.push(u);
        }
    }

    rep(i, N) {
        printf("%d\n", ans[i]);
    }
    

}

Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	int c,d,e,f,g;
	int h=0;
	for(int i=a;i<=b;i++){
		c=(i-i%10)/10;
		g=i%10;
		f=c%10;
		c=(c-c%10)/10;
		e=c%10;
		c=(c-c%10)/10;
		d=c%10;
		c=(c-c%10)/10;
		if(c==g&&d==f){
			h++;
		}
	}
	cout<<h<<endl;
}


Measured memory_bytes: 256
/* 十 聖イシドールスよ、迷えるプログラマを導き給え！ 十 */
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
#include <deque>
 
#define rep(i, n) for(int i = 0; i < n; i++)
 
//const long long INF = 1LL << 60;
const int INF = 1e9;
using ll = long long;

int main()
{
    double D, T, S;
    std::cin >> D >> T >> S;
    //printf("%f, %f\n", T, (D/S));

    if( T >= ( D / S ) )
    {
        std::cout << "Yes\n";
    }
    else
    {
        std::cout << "No\n";
    }


    
    return 0;
}

Measured memory_bytes: 3720
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np

def main():
	N, M = map(int, input().split(" "))
	ab = []
	
	for _ in range(M):
		a, b = map(int, input().split(" "))
		ab.append((a, b))
		
	ab = sorted(ab, key=lambda x:(x[1]))
	ans = 0
	otosu = -1
	for i, val in enumerate(ab):
		a, b = val
		if i == 0:
			ans += 1
			otosu = b
			continue
		if otosu <= a:
			ans += 1
			otosu = b
			continue
	
	print(ans)
	
if __name__ == "__main__":
	main()


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

int main(void){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0;i < n;i++)cin >> a[i];
    int min = 1000000;
    for(int i = -100;i <= 100;i++){
        int sum = 0;
        for(int j = 0;j < n;j++){
            sum += (a[j] - i)*(a[j] - i);
        }
        if(sum < min)min = sum;
    }
    cout << min;
}

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

map<long long, long long> mp;

long long MOD = 1000000000+7;

long long modpow(long long a, long long n) {
  long long res = 1;
  while (n > 0) {
  if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return res;
}

long long modinv(long long a) {
  return modpow(a, MOD - 2);
}

map<long long, long long> prime_factorize(long long N) {
  map<long long, long long> mp2;
  for (long long a = 2; a*a <= N; ++a) {
    if (N % a != 0) continue;
    long long ex = 0;
    while (N % a == 0) {
      ++ex;
      N /= a;
    }
    if (mp.count(a) == 0) {
      mp[a] = ex;
    } else {
      mp[a] = mp[a] > ex ? mp[a] : ex;
    }
    mp2[a] = ex;
  }
  if (N != 1) {
    if (mp.count(N) == 0) {
      mp[N] = 1;
    } else {
      mp[N] = mp[N] > 1 ? mp[N] : 1;
    }
    mp2[N] = 1;
  }
  return mp2;
}

int main() {
  long long N; cin >> N;
  vector<long long> A(N), B(N);
  vector<map<long long, long long>> mp2(N);
  for (long long i = 0; i < N; i++) {
    cin >> A[i];
    mp2[i] = prime_factorize(A[i]);
  }
  long long result = 0;
  
  long long lcm = 1;
  for (auto iter = mp.begin(); iter != mp.end(); iter++) {
    lcm = (lcm * modpow(iter->first, iter->second)) % MOD;
  }
  for (long long i = 0; i < N; i++) {
    long long tmp = lcm;
    for (auto iter = mp2[i].begin(); iter != mp2[i].end(); iter++) {
      tmp = (tmp * modinv(modpow(iter->first, iter->second))) % MOD;
    }
    result = (result + tmp) % MOD;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3968
m = 1000000000000000000

n = input()
a = [int(i) for i in input().split()]

# s = a.set()
if 0 in a:
    print(0)
else:


    o = 1

    for i in a:
        if o <= m:
            o = o * i
        else:
            o = -1
            break
        
    if o > m:
        o = -1

    print(o)

Measured memory_bytes: 21776
s=input()
count=0
n=int(len(s))
t1=s[:int((n-1)/2)]
t2=s[int((n+3)/2-1):]
result='No'
if s==s[::-1]:
    if t1==t1[::-1]:
        if t2==t2[::-1]:
            result='Yes'
print(result)


Measured memory_bytes: 8980
N = int(input())
a = [int(i) for i in input().split()]

counter=0
i=0
while i<N-1:
    if(i<N-2):
        if(a[i]==a[i+1]==a[i+2]):
            counter+=1
            i+=1
        elif(a[i]==a[i+1]):
            counter+=1
        i+=1
    else:
        if(a[i]==a[i+1]):
            counter+=1
        i+=1

print(counter)


Measured memory_bytes: 3064
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
int n,A,B,x[110000];
int main(){
	scanf("%d%d%d",&n,&A,&B);
	for (int i=1;i<=n;i++) scanf("%d",&x[i]);
	long long int ans=0;
	for (int i=1;i<n;i++)
		ans+=min((long long int)(x[i+1]-x[i])*A,(long long int)B);
	cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
int main(void)
{
	char s[200001];
	int a,z,i;
	scanf("%s",s);
	for(i=0; i<strlen(s); i++){
		if(s[i]=='A'){
			a=i;
			break;
		}
	}
	for(i=strlen(s)-1; i>=0; i--){
		if(s[i]=='Z'){
			z=i;
			break;
		}
	}
	printf("%d\n",z-a+1);
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int main(void){
	int a,i,max,mini,n;
	long long int sum;
	max=-1000000;
	mini=1000000;
	sum=0;
	scanf("%d",&n);

	for (i=1 ; i<=n ; i=i+1){
		scanf("%d",&a);
		if(mini>a) mini=a;
		if(max<a) max=a;
		sum=sum+a;
	}
	printf("%d %d %lld\n",mini,max,sum);
	return 0;
}

Measured memory_bytes: 600
// https://atcoder.jp/contests/abs/tasks/arc065_a
#include <iostream>
#include <stack>
using namespace std;

string s;
int goal;
string t[] = {"dream", "dreamer", "erase", "eraser"};
stack<int> st;
int l[] = {5, 7, 5, 6};

bool search(int point, int start = 0)
{
  if (point == goal)
    return true;

  for (size_t i = start; i < 4; i++)
  {
    if (t[i] == s.substr(point, l[i]))
    {
      st.push(i);
      return search(point + l[i]);
    }
  }

  if (st.empty())
    return false;
  else
  {
    int top = st.top();
    st.pop();
    return search(point - l[top], top + 1);
  }
}

int main()
{
  cin >> s;
  goal = s.length();

  bool result = search(0);

  if (result)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 4096
#include <stdio.h>

#define N 3

int main(void){
	char S[10];
	int k;

	scanf("%s", S);

	if (((S[0] =='A')&&(S[1]=='A')&&(S[2]=='A'))||((S[0]=='B')&&(S[1]=='B')&(S[2]=='B'))) {
			puts("No");
	} else {
			puts("Yes");
	}

	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;

inline ll read(){
    ll Hashimoto=0;
	bool Kanna=1;
    char I_Love=getchar();
    while(I_Love<'0'||I_Love>'9'){
        if(I_Love=='-')Kanna=0;
        I_Love=getchar();
    }
    while(I_Love>='0'&&I_Love<='9'){
        Hashimoto=Hashimoto*10+I_Love-'0';
        I_Love=getchar();
    }
    return (Kanna?Hashimoto:-Hashimoto);
}
template<typename T1,typename T2> inline void Umax(T1 &a,T2 b){
	if(a<b)a=b;
}
template<typename T1,typename T2> inline void Umin(T1 &a,T2 b){
	if(a>b)a=b;
}

#define I_Love_Hashimoto_Kanna main
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define filein(s) freopen(s,"r",stdin);
#define fileout(s) freopen(s,"w",stdout);
#define file freopen("I_Love_Hashimoto_Kanna.out","w",stdout);
#define RE cout<<"I_Love_Hashimoto_Kanna"<<endl;
#define Tone(Kanna) cout<<Kanna<<endl;
#define Tall(Hashimoto,Kanna) for(int I_Love=0;I_Love<(Kanna);++I_Love)cout<<Hashimoto[I_Love]<<(I_Love==(Kanna)-1?"\n":" ");
#define FOR(I_Love,Hashimoto,Kanna) for(int I_Love=Hashimoto;I_Love<(Kanna);++I_Love)
#define MP(Hashimoto,Kanna) make_pair(Hashimoto,Kanna)
#define REV(Kanna) reverse(Kanna.begin(),Kanna.end());
#define SORT(Kanna) sort(Kanna.begin(),Kanna.end());
#define UNIQUE(Kanna) Kanna.erase(unique(Kanna.begin(),Kanna.end()),Kanna.end());
#define inf (1000000000)
#define linf (1000000000000000000ll)
#define mod (1000000007)

int n;
int a[211111];
bool f[211111];

int I_Love_Hashimoto_Kanna() {
	//完全想清楚了再开始写。
	//写不顺、不知道怎么写、很乱的时候，停下来好好想想。
	//做得慢总比做不出好。
	fastio;
	n=read();
	FOR(i,0,n){
		a[i]=read();
	}
	sort(a,a+n);
	int ans=0;
	for(int k=30;k>=0;--k){
		int pw=1<<k;
		int j=n-1;
		FOR(i,0,n)if(!f[i]){
			while(j>=0&&(a[i]+a[j]>pw||f[j]||i==j))j--;
			if(j<0||a[i]+a[j]!=pw)continue;
			f[i]=f[j]=1;
			ans++;
		}
	}
	Tone(ans);
	
	return 0;
}


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

int dp[100002];
vector<vector<int>> G(100002, vector<int>());


int rec(int n){
    if(dp[n] != -1) return dp[n];
    int ret = 0;
    for(auto itr=G[n].begin();itr != G[n].end();itr++){
        ret = max(ret, rec(*itr) + 1);
    }
    return dp[n] = ret;
}

int main(){
    int N, M;
    int x, y;

    cin >> N >> M;
    for(int m=0;m<M;m++){
        cin >> x >> y;
        G[x].push_back(y);
    }
    for(int n=1;n<=N;n++) dp[n] = -1;
    int ans = 0;
    for(int n=1;n<=N;n++){
        ans = max(ans, rec(n));
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        ll a,b;
        cin>>a>>b;
        if(a>b)swap(a,b);
        ll ok=0,ng=b+1;
        while(ng-ok>1){
            ll mid=(ok+ng)/2;
            ll mx;
            ll c=(a+mid)/2;
            if(c>=mid){
                mx=(a+1)*(mid-1);
            }
            else{
                mx=c*(a+mid-c);
            }
            if(mx<a*b)ok=mid;
            else ng=mid;
        }
        cout<<a+ok-2<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n;
    int x=0;
    int b=0;
    cin>>n;
    char a[100000];
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]=='I'){
            x=x+1;
            
        }
        else if(a[i]=='D'){
            x=x-1;
        }
        b=max(b,x);
    }cout<<b;
    return 0;


}


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long N = sc.nextLong();
        long A = sc.nextLong();
        long B = sc.nextLong();

        System.out.println(solve(N, A, B));
    }

    private static long solve(long N, long A, long B) {
        long count = 0;

        if ((B-A)%2 == 0) {
            count = (B-A)/2;
        } else {
            count = Math.min(
                    A+(B-A-1)/2,
                    N-B+1+(B-A-1)/2
            );
        }

        return count;
    }
}

Measured memory_bytes: 22996
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
//const n = +input[0];
//const a = [];
//for(let i=0;i<n;i++){
//	a.push(input[i+1].split(" ").map((x:string):number=>+x));
//}

//const [n, m] = input[0].split(" ").map((x: string): number => +x);
//const a = input[1].split(" ").map((x: string): number => +x);

function compareFunc(a, b){
    return a-b;
}

const n: number = +input[0];

let tmp: number = 0;
for(let i = 1; i <= n; i++){
    if(i % 2 !== 0){
        tmp++
    }
}
console.log(tmp/n);

Measured memory_bytes: 7372
import sys
input = sys.stdin.readline

N, M = map(int, input().split())

broken= [False]*(N+1)
for i in range(M):
    broken[int(input())] = True

dp = [0]*(N+1)
dp[0] = 1
if not broken[1]:dp[1] = 1

         
for i in range(2, N+1):
    if broken[i]:continue
    dp[i] = dp[i-1] + dp[i-2]
    dp[i] %= (10**9 + 7)
print(dp[N])

Measured memory_bytes: 7668