akhauriyash/Code-Regression huggingface dataset:
#include<cmath>
#include<cstdio>
#include<vector>
#include<numeric>

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

using namespace std;

const double EPS=1e-8;

const int M_MAX=1100,N_MAX=1100;

// minimize cx s.t. Ax<=b
enum{SOLVABLE,UNBOUNDED,INFEASIBLE};
int simplex(int m,int n,const double A_in[M_MAX][N_MAX],const double *b,const double *c,double *x){
	static double A[M_MAX+1][N_MAX+M_MAX+1];
	rep(j,n+m+1) A[0][j]=(j<n?c[j]:0);
	rep(i,m) rep(j,n+m) A[i+1][j]=(j<n?A_in[i][j]:i==j-n?1:0);
	rep(i,m) A[i+1][n+m]=b[i];

	int bas[M_MAX+1];
	rep(i,m) bas[i+1]=n+i;
	n+=m;

	while(1){
		int p,q;
		for(q=0;q< n;q++) if(A[0][q]<-EPS) break;
		for(p=1;p<=m;p++) if(A[p][q]> EPS) break;
		for(int i=p+1;i<=m;i++) if(A[i][q]>EPS){
			double ri=A[i][n]/A[i][q],rp=A[p][n]/A[p][q];
			if(ri<rp-EPS || abs(ri-rp)<EPS && bas[i]<bas[p]) p=i;
		}
		if(q>=n) break;
		if(p> m) return UNBOUNDED;

		// pivoting
		rep(i,m+1) if(i!=p) rep(j,n+1) if(j!=q) A[i][j]-=A[p][j]*A[i][q]/A[p][q];
		rep(i,m+1) if(i!=p) A[i][q]=0;
		rep(j,n+1) if(j!=q) A[p][j]/=A[p][q];
		A[p][q]=1;

		bas[p]=q;
	}

	n-=m;
	rep(i,n) x[i]=0;
	for(int i=1;i<=m;i++) if(bas[i]<n) x[bas[i]]=A[i][n+m];

	return SOLVABLE;
}

struct edge{ int v,cost,id; };

int main(){
	int n,m; scanf("%d%d",&n,&m);
	vector<edge> G[100];
	rep(i,m){
		int u,v,cost; scanf("%d%d%d",&u,&v,&cost);
		G[u].push_back((edge){v,cost,i});
	}

	int d[100]={};
	rep(u,n) rep(i,G[u].size()) {
		int v=G[u][i].v,cost=G[u][i].cost;
		d[v]=max(d[v],d[u]+cost);
	}

	static double A[M_MAX][N_MAX],b[M_MAX],c[N_MAX],x[N_MAX];
	rep(i,n){
		A[i][i]=1;
		b[i]=d[n-1]-d[i];
	}
	rep(u,n) rep(k,G[u].size()) {
		int v=G[u][k].v,cost=G[u][k].cost,i=G[u][k].id;
		A[n+i][n+i]=1;
		A[n+i][u]=1;
		A[n+i][v]=-1;
		b[n+i]=d[v]-d[u]-cost;
	}
	rep(i,m) c[n+i]=-1;

	simplex(n+m,n+m,A,b,c,x);

	printf("%.0f\n",-inner_product(c,c+n+m,x,0.0)+EPS);

	return 0;
}

Measured memory_bytes: 28884
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

ll ans, n, k;


long long gcd(long long a, long long b) {return b?gcd(b, a%b):a;}

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

    ans = n % k;
    ans = min(ans, abs(ans-k));
    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl '\n'
int M = 1e9 + 7;
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  int height[n];
  for (int i = 0; i < n; ++i)
  {
    cin >> height[i];
  }
  // int deg[n]={0};
  vector<int> v[n];
  for (int i = 0; i < m; ++i)
  {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    v[x].push_back(height[y]);
    v[y].push_back(height[x]);
    // deg[x]++;
    // deg[y]++;
  }
  int ans = 0;
  for (int i = 0; i < n; ++i)
  {
    if (v[i].size())
    {
      sort(v[i].rbegin(), v[i].rend());
      if (v[i][0] < height[i])
        ans++;
    }
    else
      ans++;
  }
  cout << ans;

}

Measured memory_bytes: 10280
h, w = map(int, input().split())
a = ['.' + input() + '.' for i in range(h)]
a = ['.' * (w + 2)] + a + ['.' * (w + 2)]

ans = True
for i in range(1, h + 1):
    for j in range(1, w + 1):
        if a[i][j] == '#' and a[i + 1][j] == '.' and a[i][j + 1] == '.'and a[i - 1][j] == '.' and a[i][j - 1] == '.':
            ans = False

print('Yes' if ans else 'No')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
int main()
{
	SPEED
	int n,m,b,c,temp;
	cin >> n >> m;
	priority_queue <int, vector<int>, greater<int> > pq; 
	for (int i = 0; i < n; ++i)
	{
		cin >> temp;
		pq.push(temp);
	}
	vector< pair<int, int> > v;
	for (int i = 0; i < m; ++i)
	{
		cin >> b >> c;
		v.pb(mp(b,c));
	}
	sort(v.begin(), v.end());
	for (int i = m-1; i >= 0; i--)
	{
		for (int j = 0; j < v[i].fi && pq.top() < v[i].se; j++)
		{
			pq.pop();
			pq.push(v[i].se);
		}
	}

	ll sum = 0;
	while (!pq.empty()) 
    { 
        sum += pq.top();
        pq.pop(); 
    } 
    cout << sum << '\n';
	return 0;
}


Measured memory_bytes: 1784
#pragma GCC optimize("O3")

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz(x) (int)x.size()
#define f first
#define s second

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int a;
    cin >> a;
    string s;
    cin >> s;
    if(a<3200)
        cout << "red";
    else
        cout << s;

    return 0;
}


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

using namespace std;
using ll = long long;

ll n, cnt = 0;

void dfs(string s) {
	if(s.size()) {
		ll cur = stol(s);
		if(cur > n)return;
		int f = 0;
		for(auto i : s) {
			if(i -'0' == 7)f |= (1);
			if(i -'0' == 5)f |= (1<<1);
			if(i -'0' == 3)f |= (1<<2);
			//cout << s << " : " << f << endl;
		}
		if(f == 7)cnt++;
	}
	if((int)s.size() == 9)return;

	s.push_back('3');
	dfs(s);
	s.pop_back();
	s.push_back('5');
	dfs(s);
	s.pop_back();
	s.push_back('7');
	dfs(s);
	s.pop_back();
}

int main()
{
	cin >> n;
	dfs("");
	cout << cnt << endl;
}

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

const long MOD=998244353;
const long INF=100000000000000000;
int main(){
    string S;
    cin>>S;
    
    bool ans=true;
    
    if(S.at(0)!='A') ans=false;
    
    long count=0,place;
    for(int i=2;i<S.size()-1;i++){
        if(S.at(i)=='C') {
            count++;
            place=i;
        }
    }
    if(count!=1) ans=false;
    
    for(int i=1;i<S.size();i++){
        if(i!=place && S.at(i)<'a') ans=false;
    }
    
    if(ans) cout<<"AC"<<endl;
    else cout<<"WA"<<endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    int n; cin >> n;
    vector<int> a(n+1);
    rep1(i,n+1){
        cin >> a[i];
    }
    ll cnt1 = 0;
    ll cnt2 = 0;
    
    ll now1 = 0;
    ll now2 = 0;

    rep1(i,n+1){
        now1 += a[i];
        if(i % 2 != 0){
            if(now1 >= 0){
                cnt1 += now1 + 1;
                now1 = -1;
            }   
        }else{
            if(now1 <= 0){
                cnt1 += 1 - now1;
                now1 = 1;
            }
        }
    }
    rep1(i,n+1){
        now2 += a[i];
        if(i % 2 != 0){
            if(now2 <= 0){
                cnt2 += 1 -now2;
                now2 = 1;
            }   
        }else{
            if(now2 >= 0){
                cnt2 += 1 + now2;
                now2 = -1;
            }
        }
    }

    ll ans = min(cnt1,cnt2);
    cout << ans << endl;
}

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

// GCD, LCM
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main()
{
    int N,cnt0=0,cnt1=0;
    string S;
    cin>>S;

    for(int i=0;i<S.length();i++){
        if(S[i]=='1')cnt1++;
        if(S[i]=='0')cnt0++;
    }

    int ans = min(cnt0,cnt1)*2;

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>

using namespace std;

int main(){
double a,b,c,d,r;
cin >>a>>b>>c>>d;
r=sqrt((a-c-0.0001)*(a-c)+(b-d)*(b-d));


printf("%.5f\n",r);
    return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
typedef long long ll; 
const ll mod = 1e9+7;
#define fo(i, n) for (int i = 0; i < n; i++)
#define sc(n) scanf("%d", &n) 
using namespace std;

void solve() {
    int n; sc(n);
    int a[n+1]; int b[n+1];
    fo(i, n) sc(a[i+1]);
    fo(i, n+1) b[i] = 0;
    for(int i = n; i >= 1; i--) {
        int count = 0;
        for(int j = 2*i; j <= n; j += i) if (b[j]) count++;
        if (count % 2 != a[i]) b[i] = 1; 
    }
    set<int> s;
    for(int i = 1; i <= n; i++) if (b[i]) s.insert(i);
    printf("%d\n", s.size());
    for (int x: s) printf("%d ", x);
}

int main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

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

int num(string a, string b){
    int as,bs;
    as = a.size();
    bs = b.size();
    set<char> sta, stb, result;
    rep(i,as){
        sta.insert(a[i]);
    }
    rep(i,bs){
        stb.insert(b[i]);
    }

    set_intersection(sta.begin(), sta.end(),
                        stb.begin(), stb.end(),
                        std::inserter(result, result.end()));
    return result.size();

}

void solve(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int m = 0;
    for(int i=0; i<n; i++){
        string t1,t2;
        t1 = s.substr(0,i+1);
        t2 = s.substr(i+1,n-1);
        //cout << t1 << " " << t2 << endl;
        m = max(m, num(t1,t2));
    }
    //cout << num("aab","bca") << endl;
    cout << m << endl;
}

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


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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int c[3][3];
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            cin >> c[i][j];
        }
    }
    bool isok = true;
    for(int i = 1; i < 3; i++) {
        int a = c[0][0] - c[i][0];
        for(int j = 1; j < 3; j++) {
            isok &= a == c[0][j] - c[i][j];
        }
    }
    cout << (isok ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
from functools import lru_cache

import sys
sys.setrecursionlimit(10 ** 7)

N = int(input())
h = list(map(int, input().split()))

@lru_cache(maxsize=None)
def rec(n):
  # print(n)
  if n == 1:
    return 0
  elif n == 2:
    return abs(h[1]-h[0])
  else:
    return min(rec(n-1)+abs(h[n-1]-h[n-2]), rec(n-2)+abs(h[n-1]-h[n-3]))

print(rec(N))

Measured memory_bytes: 265476
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int N, M, K, Q, W, H, R, C;
int dp[200][200];

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

    cin >> N;
    vector<int> a(N), b(N);
    REP(i, N) cin >> a.at(i) >> b.at(i);

    REP(i, N + 1) {
        REP(j, N + 1) {
            dp[i][j] = INF;
            if (i + 1 == j) dp[i][j] = 0;
        }
    }

    FOR(len, 1, N) {
        REP(l, N) {
            int r = l + len + 1;
            if (r <= N) {
                FOR(h, l + 1, r) { chmin(dp[l][r], dp[l][h] + dp[h][r] + a[l] * b[h - 1] * b[r - 1]); }
            }
        }
    }

    cout << dp[0][N] << endl;

    return 0;
}



Measured memory_bytes: 3176
using System;
using System.Linq;

namespace AOJ.Volume0
{
    public class HitAndBlow
    {
        public static void Main()
        {
            while (true)
            {
                string input1 = Console.ReadLine();
                if (string.IsNullOrEmpty(input1)) { break; }
                string input2 = Console.ReadLine();

                var a = input1.Split(' ');
                var b = input2.Split(' ');

                int hit = 0;
                int blow = 0;
                for (int i = 0; i < 4; i++)
                {
                    if (a[i] == b[i]) { hit++; }
                    else
                    {
                        if (a.Count(x => x == b[i]) == 1) { blow++; }
                    }
                }

                Console.WriteLine(hit + " " + blow);
            }
        }
    }
}

Measured memory_bytes: 5812
#include <stdio.h>
char S[100005], T[100005];
int sm[100005], tm[100005];
int sizeq;
int q[100005][4];
int main()
{
	int sizes, sizet;
	scanf("%s%s", S, T);
	scanf("%d", &sizeq);
	int i;
	for (i = 0; i < sizeq; i++)
	{
		scanf("%d%d%d%d", q[i], q[i] + 1, q[i] + 2, q[i] + 3);
	}
	sm[0] = tm[1] = 0;
	int m = 0;
	for (i = 0; S[i]; i++)
	{
		if (S[i] == 'A') m = (m + 1) % 3;
		else m = (m + 2) % 3;
		sm[i + 1] = m;
	}
	m = 0;
	for (i = 0; T[i]; i++)
	{
		if (T[i] == 'A') m = (m + 1) % 3;
		else m = (m + 2) % 3;
		tm[i + 1] = m;
	}
	for (i = 0; i < sizeq; i++)
	{
		if ((sm[q[i][1]] - sm[q[i][0] - 1] - tm[q[i][3]] + tm[q[i][2] - 1] + 6) % 3 == 0)
		{
			puts("YES");
		}
		else
		{
			puts("NO");
		}
	}

	return 0;
}

Measured memory_bytes: 3072
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
bool isPowerOfTwo(int n)
{
   if(n==0)
   return false;

   return (ceil(log2(n)) == floor(log2(n)));
}
int power(int x, unsigned int y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return power(x, y / 2) * power(x, y / 2);
    else
        return x * power(x, y / 2) * power(x, y / 2);
}
int findXor(int arr[], int n)
{

    // Calculate xor of all the elements
    int xoR = 0;
    for (int i = 0; i < n; i++) {
        xoR = xoR ^ arr[i];
    }

    // Return twice of xor value
    return xoR * 2;
}

signed main()
{
    string s;
    cin>>s;
    int a=0,b=0;
    for(int i=0;i<3;i++)
    {
        if(s[i]=='A')
            a++;
        else
            b++;
    }
    if(a==0||b==0)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
}





Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>
#include<bitset>

using namespace std;
typedef long long int ll; typedef pair<int, int> P; typedef unsigned long long int ull;
const ll mod = 1000000007;
const int inf = 1e9 + 7;
const ll linf = 1LL << 60;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define REP(i,m,n) for(int i=(m);i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define vec vector<int>
#define vecb vector<bool>
#define vecd vector<double>
using str = string;
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
std::string sreverse(string str, int firstItr, int secondItr) {
	if (firstItr < 0 || secondItr>int(str.size() - 1))return str;
	while (firstItr < secondItr) {
		swap(str[firstItr], str[secondItr]);
		firstItr++; secondItr--;
	}
	return str;
}
std::string RunLengthEncoding(std::string str) {
	int itr = 0; std::string res;
	while (itr < int(str.size())) {
		char tmp = str[itr++];
		int length = 1;
		while (itr <int(str.size()) && str[itr] == tmp) { ++itr; ++length; }
		res.push_back(tmp);
		res += to_string(length);
	}
	return res;
}
std::string split(std::string str, size_t first_itr, bool isFront) {
	if (first_itr < 0 || first_itr > str.size()) {
		return str;
	}
	else {
		if (isFront) {
			std::string tmp;
			for (size_t i = 0; i < first_itr; i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
		else {
			std::string tmp;
			for (size_t i = first_itr; i < str.size(); i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
	}
}

int main() {
	int x; cin >> x;
	ll ans = 0;
	for (int i = 1; i <= x; i++) {
		for (int j = 1; j <= x; j++) {
			int s = gcd(i, j);
			for (int k = 1; k <= x; k++) {
				ans += gcd(s, k);
			}
		}
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 3636
A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
K = min(a)+min(b)
X = 10**9
for i in range(M):
    x,y,c = map(int,input().split())
    S = a[x-1]+b[y-1]-c
    if S<X:
        X = S
if X<K:
    print(X)
else:
    print(K)

Measured memory_bytes: 18736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define Y cout << "YES\n"
#define N cout << "NO\n"
#define REP(i, a, b) for (int i = a; i <= b; i++)
#define R(i, n) for (int i = 0; i < n; i++)
#define RE(i, a, b) for (int i = a; i >= b; i--)
int prime[1000010], p[100001][2];
int fun()
{
	int k = 0;
	for (int i = 2; i < 1000001; i++)
	{
		if (prime[i] == 0)
		{
			p[k][0] = i;
			k++;
			for (int j = i + i; j < 1000001; j += i)
			{
				prime[j] = 1;
			}
		}
	}
	return k;
}

int main()
{
	int k = fun();
	int flag = 0;
	ll n, ans = 0;
	cin >> n;
	if (n > 1)
	{
		for (int i = 0; i < k; i++)
		{
			if (n < p[i][0])
			{
				break;
			}
			while (1)
			{
				if (n % p[i][0] == 0)
				{
					flag = 1;
					p[i][1]++;
					n /= p[i][0];
				}
				else
				{
					break;
				}
			}
		}
		if (n > 1)
		{
			ans = 1;
		}
		for (int i = 0; i < k; i++)
		{
			int c = 1;
			while (1)
			{
				if (p[i][1] >= c)
				{
					p[i][1] -= c;
					ans++;
					c++;
				}
				else
				{
					break;
				}
			}
		}
		cout << ans << endl;
	}
	else
	{
		cout << ans << endl;
	}
}

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


int main()
{
	string S;
	char c;
	cin >> S;
	int count;
	int answer;
	int N;
	N = S.length();
	count = 0;
	for (int i=0;i<S.length();i++){
      	if (i%2==0)c = '0';
      	if (i%2==1)c = '1';
		if (S.at(i)==c){
			count += 1;
        }
	}
	answer = min(count,N-count);
	cout << answer << endl;

	return 0;
}

Measured memory_bytes: 512
mod=10**9+7
n=int(input())
arr1=list(map(int,input().split()))
arr2=list(map(int,input().split()))
a=[-1]*n
b=[-1]*n
c=[-1]*n
s=arr1[0]
a[0]=s
for i in range(n):
  if arr1[i]==1:
    a[i]=1
  else:
    if s!=arr1[i]:
      a[i]=arr1[i]
      s=arr1[i]
s=arr2[-1]
b[-1]=s
for i in range(1,n+1):
  if arr2[-i]==1:
    b[-i]=1
  else:
    if s!=arr2[-i]:
      b[-i]=arr2[-i]
      s=arr2[-i]
flag=False
for i in range(n):
  if a[i]==-1 and b[i]==-1:
    c[i]=-1
  elif a[i]==-1:
    if arr1[i]>=b[i]:
      c[i]=b[i]
    else:
      flag=True
  elif b[i]==-1:
    if arr2[i]>=a[i]:
      c[i]=a[i]
    else:
      flag=True
  else:
    if a[i]==b[i]:
      c[i]=a[i]
    else:
      flag=True
if flag==True:
  print(0)
else:
  l=0
  r=0
  ans=1
  cnt=0
  for i in range(n):
    if c[i]==-1:
      if cnt==0:
        l=c[i-1]
      cnt+=1
    else:
      if cnt!=0:
        r=c[i]
        for _ in range(cnt):
          ans=(ans*min(l,r))%mod
        cnt=0
  print(ans)

Measured memory_bytes: 18752
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: u32 = sc.cin();
    put!((n..1000).filter(|x| x/100 == x%10 && (x/10)%10 == x%10).next().unwrap());
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
//freopen("input.txt","r",stdin);
string s;
int i;
cin>>s;
for(i=0;i<s.length();i++)
{
if(s[i]=='?')
     s[i]='D';
}
cout<<s<<endl;


}


Measured memory_bytes: 3688
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

K = int(input())
ans = 0
for a in range(1, K+1):
  for b in range(1, K+1):
    ab = gcd(a,b)
    for c in range(1, K+1):
      ans += gcd(ab,c)

print(ans)

Measured memory_bytes: 68244
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    ll N; cin>>N;
    vector<ll>a(N);
    map<ll,ll>mp;
    rep(i,N){
        cin>>a[i];
        mp[a[i]]++;
    }

    bool oks =true;
    if(N%2!=0)oks=false;
    for(auto p:mp){
        if(oks){
            if(p.first%2==0||p.first>=N||p.second!=2){
                cout<<0<<endl;
                return 0;
            }
        }
        else{
                  if(p.first==0&&p.second!=1){
                    cout<<0<<endl;
                    return 0;
                }
            else if(p.first%2!=0||p.first>=N&&p.second!=2){
                cout<<0<<endl;
                return 0;
            }
        }
    }
    ll ans =1;
    rep(i,N/2){
        ans*=2;
        ans%=mod;
    }
    cout<<ans<<endl;
}




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

const int maxN=101;
const int maxK=1e5+2;

int n,k;
int v[maxN];
bool dp[maxK];

int main(){
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>v[i];
    }

    for(int i=0;i<=k;i++){
        if(dp[i]==false){
            for(int j=1;j<=n;j++){
                if(i+v[j]<=k){
                    dp[i+v[j]]=true;
                }
            }
        }
    }

    if(dp[k]==1){
        cout<<"First";
    } else {
        cout<<"Second";
    }

    return 0;
}

Measured memory_bytes: 384
def gcd(a,b)
    while b>0 do
        a,b = b,a%b
    end
    return a
end


ar = gets.chomp.split(" ").map{|i|i = i.to_i}
a=ar[0]
b=ar[1]
k=ar[2]

arr = []

s=gcd(a,b)
s.times do|i|
    if s % (i+1)==0 then
        arr << (i+1)
    end
end
l = arr.length
puts arr[(l-k)]

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEL 2e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}
template <class T>
inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template <class T>
inline T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

double culc(int xi, int xj, int yi, int yj){
    int bs = (xi - xj) * (xi - xj) + (yi - yj) * (yi - yj);
    double distance = sqrt(bs);
    return distance;
}

void alchemst(vector<double> &v){
    sort(v.begin(), v.end(), greater<double>());
    double a = v[v.size() - 1];
    v.pop_back();
    double b = v[v.size() - 1];
    v.pop_back();
    double c = (a + b) / 2.0;
    v.push_back(c);
}

int main(){
    int n;
    cin >> n;
    vector<double> v(n);
    rep(i, n) cin >> v[i];
    rep(i,n-1)
        alchemst(v);
    cout << v[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
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<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

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

//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 INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

int main() {
  int N,M;
  cin >> N >> M;
  if(N==M) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
b = list(map(int, input().split()))
ans = 0
for i in range(n):
  if i == 0:
    ans += b[i]
  elif i == n - 1:
    ans += b[i - 1]
  else:
    ans += min(b[i], b[i-1])
print(ans)

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

#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<int>()
#define MAX(a) *max_element(all(a))

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;

const int INF = 1001001001;
const int MOD = 1000000007;
const long long INFL = (1LL << 60);
const double EPS = 1e-9;

int main() {
  int N;
  cin >> N;
  vi d(N);
  rep(i, N) cin >> d[i];
  sort(all(d));

  int mid = N / 2;
  int res = d[mid] - d[mid - 1];

  cout << res << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<numeric>
using namespace std;
#define ll  long long
#define mp make_pair
#define fi first
#define se second
#define pii pair<ll,ll>
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// using ll = long long;
ll int dp[55][55][55*55];
ll int A[55];
int main()
{
    int n,a;
    cin >> n >> a;
    for(int i=0;i<n;i++)
    cin >> A[i];
    dp[0][0][0]=1;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            for(int k=0;k<=50*50;k++)
            {
                dp[i+1][j][k] += dp[i][j][k];
                dp[i+1][j+1][k+A[i]] += dp[i][j][k];
            }
        }
    }
    ll int total = 0;
    for(int i=1;i<=n;i++)
    {
        total += dp[n][i][i*a];
    }
    cout << total;
}

Measured memory_bytes: 66560
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

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

    int n, m;
    cin >> n >> m;

    string s;
    cin >> s;

    vector< vector<int> > g(n + 1);
    rep(i, n + 1){
        if(i + 1 <= n) g[i].emplace_back(i + 1);
        if(s[i] == '0') g[i].emplace_back(max(i - m, 0));
    }

    vector<int> cost(n + 1, IINF);
    cost[n] = 0;
    deque< P > que;
    que.push_back({0, n});
    while(!que.empty()){
        P now = que.front();
        que.pop_front();
        if(cost[now.second] < now.first){
            continue;
        }
        for(auto to : g[now.second]){
            if(to < now.second && chmin(cost[to], now.first + 1)){
                que.push_back({now.first + 1, to});
            }else if(to > now.second && chmin(cost[to], now.first)){
                que.push_front({now.first, to});
            }
        }
    }

    if(cost[0] >= IINF){
        cout << -1 << endl;
        return 0;
    }

    vector<int> ans;
    int cnt = 0;
    int v = 0;
    while(v < n){
        int nx = v;
        while(s[nx] == '1' || cnt + cost[nx] + 1 > cost[0]){
            ++nx;
        }
        ans.emplace_back(nx - v);
        v = nx;
        ++cnt;
    }

    rep(i, ans.size()){
        if(i) cout << ' ';
        cout << ans[i];
    }
    cout << endl;

    cout << flush;

    return 0;
}

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

#define fi first
#define se second
#define FO(x, n) for (int x = 0; x < n; ++x)
#define FOR(x, a, b) for (int x = a; x < b; ++x)
#define RFO(x, n) for (int x = n - 1; x >= 0; --x)
#define RFOR(x, a, b) for (int x = b - 1; x >= a; --x)
#define FOR_ITER(x, a) for(auto x = a.begin(); x != a.end(); ++x)
using namespace std;
typedef unsigned char byte;
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;
typedef pair<llong, llong> pll;
inline bool feq(const double& a, const double& b) { return fabs(a - b) < 1e-10; }

using namespace std;


int main(){
//    int n, l;
//    cin >> n >> k;
//    vector<bool> dislike(10, false);
//
//    FOR(i, 0, k) {
//        int t;
//        cin >> t;
//        dislike[t] = true;
//    }

    int n;
    cin >> n;


    cout << n * (n + 1) / 2 << endl;
    return 0;
}


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

#define ll long long int
#define mem(n) memset(n,0,sizeof(n))

#define tst int tst; scanf("%d",&tst) ; while(tst--)

#define LCM(a,b) (a / __gcd(a,b) ) * b

#define gcd(a,b) __gcd(a,b)

#define Case printf("Case %d: ",cs++);

#define for0(l,n) for(int l=0;l<n;l++)

#define for1(l,n) for(int l=1;l<=n;l++)

#define pool(n) for(int i=n-1;i>=0;i--)

#define bug(n) cout<<">> "<<n<<" <<";

#define szv(v) v.size()
#define sz(a) sizeof(a)

#define YES printf("YES\n")

#define NO printf("NO\n")

#define Yes printf("Yes\n")

#define No printf("No\n")
#define pb push_back

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

#define cl(v) v.clear;
#define maxall(V) *max_element(v.begin(),v.end())
#define minall(V) *min_element(v.begin(),v.end())
vector<ll>v;
ll n,m,q,a,b,c,sum=0,cnt=0;
ll arr[123456];
map<ll,bool>mp;

int main()
{
    cin>>a>>b>>c;

    cout<<(a+b)*(c/2)<<endl;

}




Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;


int main(){
  int n;
  double a,b,c,d,e,f;
  double x1,x2,x3,y1,y2,y3;
  double px,py;
  double r;

  cin >> n;

  for(int i=0;i<n;i++){
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    a = (x2-x1)*2.0;
    b = (y2-y1)*2.0;
    c = (x2*x2 + y2*y2 - x1*x1 - y1*y1);
    d = (x3-x1)*2.0;
    e = (y3-y1)*2.0;
    f = (x3*x3 + y3*y3 - x1*x1 - y1*y1);
    px = (c*e-b*f)/(a*e-b*d);
    py = (a*f-c*d)/(a*e-b*d);
    r = sqrt((px-x1)*(px-x1) + (py-y1)*(py-y1));
    //printf("%.3f %.3f %.3f\n",px,py,r);
    cout << fixed << setprecision(3) << px << " " << py << " " << r << endl;



  }

  return 0;
}

Measured memory_bytes: 1288
#include<bits/stdc++.h>
using namespace std;
int main(){
    while(1){
        int H,W;
        cin>>H>>W;
        if(H==0 && W==0) break;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                cout<<"#";
            }
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3084
///#pragma GCC optimize("Ofast")
///#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
///#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
///#include<ext/pb_ds/assoc_container.hpp>
///#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
///using namespace __gnu_pbds;
///template<typename T> using orderset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vii> vvii;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll N = 10001;
const ll MOD = 1000000007;
const ll INF = LLONG_MAX;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rev(a) reverse(all(a))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define yes cout<<"YES"<<nl
#define no cout<<"NO"<<nl
#define space ' '
#define nl '\n'
#define PI acos(-1)

#define coutv(v) for(auto it:v)cout<<it<<space;cout<<nl;
#define cinv(v) for(auto &it:v)cin>>it;

ll f(ll n)
{
    return (n*(n+1))/2;
}
int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int tc=1,cs=0;
    ///cin>>tc;
    while(tc--)
    {
        ll n,k,i,s=0,c=0,last;
        cin>>n>>k;
        last=n;
        for(i=1; i<=n+1; i++)
        {
            if(i>n)
            {
                s++;
                break;
            }
            ll st=f(i-1);
            if(i>=k)
            {
                s+=(last-st+1);
                s%=MOD;
            }
            last=last+(n-i);
        }
        cout<<s%MOD<<nl;
    }
}


Measured memory_bytes: 3648
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
      
        // k日まではx円
        // (n-k)日の間はy円
        // つまり、 (K * x) + (N - K) * y 
        // N > K の場合がある、この場合は処理を変えて単に N * K 
      
        int n = sc.nextInt();
        int k = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
      
        int price = 0;
     
        if (n > k) {
          price =  ((k * x) + ((n - k ) * y));
        } else {
          price = (n * x);
        }
        
      
        System.out.println(price);
	} 
}

Measured memory_bytes: 21716
#include <math.h>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

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

  string ans;

  ans = "2018" + S.substr(4, 6);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
var
n,s,w,e,i:Longint;
t:String;
begin
readln(t);
for i:=1 to length(t)do begin
if t[i]='W'then inc(w)else if t[i]='S'then inc(s)else if t[i]='E'then inc(e)else inc(n);
end;
if((w>0)=(e>0))and((s>0)=(n>0))then writeln('Yes')else writeln('No');
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
const ll mod=1000000007;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  int a,b,c; cin>>a>>b>>c;
  int k=max({a,b,c});
  int d=a+b+c-k;
  if(k==d)
  puts("Yes");
  else
  puts("No");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
void ABC110(void);
void ABC111(void);
void ABC112(void);
void ABC113(void);
void ABC114(void);
void ABC115(void);
void ABC116(void);
void ABC117(void);
void ABC118(void);
void ABC119(void);

int main(void){
    ABC119();
}

void ABC119(){
    string s;
    cin>>s;
    if(s[5]>='1'||s[6]>='5')cout<<"TBD"<<endl;
    else cout<<"Heisei"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
#include<string>
#include<map>
#include<queue>

using namespace std;

int main(void){

    int a, b;
    cin >> a >> b;

    cout << (a <= b ? a : a-1) << endl;

    return 0;
}

Measured memory_bytes: 256
N,*X=map(int,open(0).read().split());M,g,q,r=10**9+7,1,[1,1],0
for i in range(1,N):r,g=(r+q[-1]*(X[-1]-X[i-1]))%M,g*i%M;q+=[M//(-~i)*-q[M%(-~i)]%M]
print(r*g%M)

Measured memory_bytes: 14052
def P(s):
  L = [0] * 26
  R = P = 0
  for i in range(D):
    t = I[i + D][0] - 1
    R += I[i][t]
    P += s - (i + 1 - L[t]) * C[t]
    R -= P
    L[t] = i + 1
  return R
(D,), C, *I = [list(map(int, o.split())) for o in open(0)]
for d, q in I[2*D + 1:]:
  I[d - 1 + D][0] = q
  print(P(sum(C)))

Measured memory_bytes: 89908
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
	ll n,i,ma=0,mi=10000000000;
	cin>>n;
	ll a;
	for(i=0;i<n;i++){
		cin>>a;
		ma=max(a,ma);
		mi=min(a,mi);
	}
	cout<<ma-mi<<endl;

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
	char s[105],t[105];
	scanf("%s%s",s,t);
	int m=strlen(s);
	int n=strlen(t);
	if(m>n)printf("GREATER\n");
	else if(m<n)printf("LESS\n");
	else {
		if(strcmp(s,t)<0)printf("LESS\n");
		else if(strcmp(s,t)==0)printf("EQUAL\n");
		else printf("GREATER\n");
	}
	return 0;
}
	


Measured memory_bytes: 128
# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def MI() : return map(int, input().split())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def chkprint(*args) : names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}; print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

A = I()
B = I()

ans = [1, 2, 3]

ans.remove(A)
ans.remove(B)

print(ans[0])


Measured memory_bytes: 43504
def fibonacci(i, num_list):
    if i == 0 or i == 1:
        num_list[i] = 1
    else:
        num_list[i] = num_list[i-2] + num_list[i-1]

n = int(input()) + 1
num_list = [0 for i in range(n)]
for i in range(n):
    fibonacci(i, num_list)
print(num_list[-1])




Measured memory_bytes: 5604
#include<bits/stdc++.h>
#define N 41
#define D 14
using namespace std;
typedef pair<int,int> P;
int d,x,p,y,ans;
int dp[N][D];
string s;
vector<P> v;

int main(){
  cin>>d;
    cin>>x;
  for(int i=0;i<x;i++){
    cin>>s>>p;
    if(s=="D")v.push_back(P(1,p));
  }
  cin>>y;
  for(int i=0;i<y;i++){
    cin>>s>>p;
    if(s=="DD")v.push_back(P(2,p));
  }
  memset(dp,-1,sizeof(dp));
  dp[0][0]=ans=0;
  for(int i=0;i<(int)v.size();i++){
    int cost=v[i].first,point=v[i].second;
    for(int j=0;j<=d;j++){
      if(dp[i][j]<0)continue;
      if(j+cost<=d)dp[i+1][j+cost]=max(dp[i+1][j+cost],dp[i][j]+point);
      dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
    }
  }
  for(int i=0;i<=d;i++)ans=max(ans,dp[v.size()][i]);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define ll long long int
#define n 100005
using namespace std;
ll dp[n];
ll height[n];
ll solve(int N)
{
    dp[1] = 0;
    for (int i = 2; i <= N; i++) {
        ll opt1 = abs(height[i] - height[i - 1]) + dp[i - 1];
        ll opt2 = (i == 2) ? INT_MAX : abs(height[i] - height[i - 2]) + dp[i - 2];
        dp[i] = min(opt1, opt2);
    }
    return dp[N];
}
int main()
{
    memset(dp, 0, sizeof dp);
    memset(height, 0, sizeof height);
    int N;
    cin >> N;
    for (int i = 1; i <= N; i++) {
        cin >> height[i];
    }
    cout << solve(N);
}

Measured memory_bytes: 5172
s = raw_input()
N = len(s)

A, B = -1,-1

for i in range(N - 1):
  if s[i] == s[i+1]:
    A, B = i + 1, i + 2

for i in range(N - 2):
  if s[i] == s[i+2]:
    A, B = i + 1, i + 3

print A, B

Measured memory_bytes: 5892
//
//  main.cpp
//  HelloWorld
//
//  Created by purple on 2020/04/13.
//  Copyright © 2020 Purple. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <string>
#include <fstream>
#include <list>

using namespace std;

string Sort(string s, int opt){
    int i,j;
    char tmp;
 
    if(opt == 0){
        for(i=0; i<s.size(); i++){
            for(j=0; j<i; j++){
                if(s[i]<s[j]){
                    tmp = s[i];
                    s[i] = s[j];
                    s[j] = tmp;
                }
            }
        }
    }
    
    if(opt == 1){
        for(i=0; i<s.size(); i++){
            for(j=0; j<i; j++){
                if(s[i]>s[j]){
                    tmp = s[i];
                    s[i] = s[j];
                    s[j] = tmp;
                }
            }
        }
    }
    
    return s;
}


int main(int argc, const char * argv[]) {
    // insert code here...
 
    
    /////////////////////////////////////////////////////
    /////////input from txt （提出時にこの箇所は削除すること）
//    ifstream in("aaa.txt");
//    cin.rdbuf(in.rdbuf());
    ////////////////////////////////////////////////////////
    
    string s1,s2;

    //Input
    cin >> s1 >> s2;

    string ans1,ans2;
    
    ans1 = Sort(s1,0);
    ans2 = Sort(s2,1);
    
    if(ans1 < ans2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    //Output
//    cout << ans1 << endl;
    
    return 0;
    
}


Measured memory_bytes: 256
#include<stdio.h>
   int main(void)
   {
      int A,B,C,D;
      scanf("%d %d %d",&A,&B,&C);
      D=B/A;
     if(D<C){
              printf("%d\n",D);                                    
     }
    else{
              printf("%d\n",C);
    }
    return 0;
  }
  


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int h,w;cin>>h>>w;
    char a[h][w];
    rep(i,h)rep(j,w) cin>>a[i][j];
    vector<vector<int>> t(h,vector<int>(w,1e+8));
    int roty[4]={1,0,-1,0},rotx[4]={0,1,0,-1};
    queue<pair<int,int>> que;
    rep(i,h)rep(j,w){
        if(a[i][j]!='#')continue;
        que.push({i,j});
        t[i][j]=0;
    }
    while(que.size()){
        int y=que.front().first,x=que.front().second;que.pop();
        rep(k,4){
            int ny=y+roty[k],nx=x+rotx[k];
            if(0>ny||ny>=h||0>nx||nx>=w)continue;
            if(chmin(t[ny][nx],t[y][x]+1))que.push({ny,nx});
        }
    }
    int res=0;
    rep(i,h)rep(j,w) chmax(res,t[i][j]);
    cout<<res<<endl;
}

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

using namespace std;

int main()
{
	string str;
	int i,j;
	int ans=0;
	
	for(;cin >> str;)
	{
		for(i=0,j=str.size()-1;;)
		{
			if(i>j)
			{
				ans++;
				break;
			}
			if(str[i]==str[j])
			{
				i++;
				j--;
			}
			else
				break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+10;
const int p=1e9+7;
char s[N];
int edge[N][2],dp[N][8];
inline void init(){
	edge[0][0]=3; edge[0][1]=1;
	edge[1][0]=5; edge[1][1]=2;
	edge[2][0]=2; edge[2][1]=2;
	edge[3][0]=4; edge[3][1]=7;
	edge[4][0]=3; edge[4][1]=3;
	edge[5][0]=6; edge[5][1]=1;
	edge[6][0]=5; edge[6][1]=5;
	edge[7][0]=3; edge[7][1]=1;
}
int main(){
	scanf("%s",s); int len=strlen(s);
	init();
	dp[len][1]=dp[len][2]=1;
	for(int i=len-1; i>=0; --i)
		for(int j=0; j<8; ++j){
			if(s[i]!='0')dp[i][j]=(dp[i+1][edge[j][1]]+dp[i][j])%p;
			if(s[i]!='1')dp[i][j]=(dp[i+1][edge[j][0]]+dp[i][j])%p;
		}
	printf("%d",dp[0][0]);
	return 0;
}

Measured memory_bytes: 10752
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
  string o,e;
  cin>>o>>e;
  int n=o.size();
  for(int i=0;i<n;i++){    
    cout<<o[i];
    if(i<e.size())
      cout<<e[i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
import bisect

n = int(input())
#length = list(map(lambda x:int(x), input().split()))
length = list(map(int, input().split()))
length.sort()
ans = 0
for i in range(n-2):  
    a = length[i]
    for j in range(i+1,n-1):
        b = length[j]
        if i >= j:
            continue
        else:
            max_bar = bisect.bisect_left(length,a+b)
            ans += max_bar - j - 1
            
print(ans)

Measured memory_bytes: 3188