akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(int x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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

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

long double a, b, c, d;
int n;

long double calc(long double pos) {
	return a * pos * pos * pos + b * pos * pos + c * pos + d;
}

long double find_answer(long double L, long double R, bool ok) {
	long double p1 = calc(L), p2 = calc(R);
  if (p1 > p2) swap(p1, p2);
	if (!(p1 <= 1e-14 && -1e-14 <= p2)) return -1e9;

	long double M;
	for (int i = 0; i < 100; i++) {
		M = (L + R) / 2;
		long double ret = calc(M);
		bool res = false;

    if (ret > 0) res = true;
		if ((ok ^ res) == false) R = M;
		else L = M;
	}
	return M;
}

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a >> b >> c >> d;
		d /= a; c /= a; b /= a; a = 1;

		long double A = 3.0 * a, B = 2.0 * b, C = c; // 微分
		vector<tuple<long double, long double, bool>> T;
		if (B * B - 4.0 * A * C < -1e-5) {
			T.push_back(make_tuple(-10000, 10000, true));
		}
		else {
			long double V = sqrtl(B * B - 4.0 * A * C); // sqrtl long double用のsqrt
			long double W1 = (-B - V) / (2.0 * A);
			long double W2 = (-B + V) / (2.0 * A);
			T.push_back(make_tuple(-10000, W1, true));
			T.push_back(make_tuple(W1, W2, false));
			T.push_back(make_tuple(W2, 10000, true));
		}
		vector<long double>U;
		for (int j = 0; j < T.size(); j++) {
			long double V = find_answer(get<0>(T[j]), get<1>(T[j]), get<2>(T[j]));
			if (V >= -1e8) U.push_back(V);
		}
		sort(U.begin(), U.end());

		int t1 = 0, t2 = 0;
		for (int j = 0; j < U.size(); j++) {
			if (U[j] < -1e-5) t1++;
			else t2++;
		}
		if (fabs(d) < 1e-10) t2--;
		if (fabs(c) < 1e-10 && fabs(d) < 1e-10) t2--;
		if (fabs(b) < 1e-10 && fabs(c) < 1e-10 && fabs(d) < 1e-10) t2--;
		cout << t2 << " " << t1 << endl;
	}
	return 0;
}



Measured memory_bytes: 3244
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


template<typename T>
class Lagrange_polynomial{
private:
    typedef unsigned long ul;
    typedef pair<T,T> point;
    
public:
    vector<point> P;
    
    Lagrange_polynomial(vector<point> P={}):P(P){}
    
    void add_point(point a){P.push_back(a);}
    
    void add_point(vector<point> a){
        for(int i=0;i<a.size();i++){
            P.push_back(a[i]);
        }
    }
    
    T F(T x,const vector<point> &P){
        assert(P.size()>1);
        T ret=0;
        for(ul i=0;i<P.size();i++){
            T a=P[i].S;
            for(ul t=0;t<P.size();t++){
                if(i==t){continue;}
                a*=x-P[t].F;
                assert(P[i].F!=P[t].F);
                a/=P[i].F-P[t].F;
            }
            ret+=a;
        }
        return ret;
    }
    
    bool judge(T x,T y){
        return F(x)==y;
    }
};

double f(double a,double dist){
    ll k=a/dist;
    return a-=dist*k;
}


int main(){
    cout<<fixed<<setprecision(12);
    double d;
    ll n,b;
    cin>>d>>n>>b;
    vector<pd> A(n);
    Lagrange_polynomial<double> L;
    for(int i=0;i<n;i++){
        cin>>A[i].F>>A[i].S;
    }
    double mx=E;
    for(int i=0;i<=b;i++){
        vector<pd> P(3,{0,0});
        double dist=d;
        dist/=i+1;
        P[1]={dist,0};
        pd mi={dist/2,0};
        P[2]=mi;
        for(int t=0;t<n;t++){
            double where=f(A[t].F,dist);
            if(where==0 || where==dist){mi={dist/2,E}; break;}
            if(L.F(where,P)<A[t].S){
                mi={where,A[t].S};
                P[2]=mi;
            }
        }
        if(mi==pd(dist/2,E)){continue;}
        double h=L.F(dist/2,P);
        h=max(h,dist/4);
        //cout<<dist<<" "<<h<<endl;
        mx=min(mx,sqrt(h*2+dist*dist/(h*2)/4));
    }
    cout<<mx<<endl;
    
    return 0;
}




Measured memory_bytes: 3308
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int[] tmp = new int[101];
		while(stdIn.hasNext()) {
			tmp[stdIn.nextInt()]++;
		}
		int max = 0;
		for(int i = 0; i < 101; i++) {
			if(tmp[i] > max) {
				max = tmp[i];
			}
		}
		for(int i = 0; i < 101; i++) {
			if(tmp[i] == max) {
				System.out.println(i);
			}
		}
			
	}
}

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

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

using namespace std;


int main()
{
	string a;
	cin>>a;
	
	if(a=="ooo"){
		cout<<"1000"<<endl;
	}
	else
		if(a=="oox"){
		cout<<"900"<<endl;
	}
	else
		if(a=="oxo"){
		cout<<"900"<<endl;
	}
	else
		if(a=="xoo"){
		cout<<"900"<<endl;
	}
	else
		if(a=="oxx"){
		cout<<"800"<<endl;
	}
	else
		if(a=="xox"){
		cout<<"800"<<endl;
	}
	else
		if(a=="xxo"){
		cout<<"800"<<endl;
	}
	else
		if(a=="xxx"){
		cout<<"700"<<endl;
	}
}
	
	
	


Measured memory_bytes: 384
// Created by Kshitij Anand NSIT
#include <bits/stdc++.h>


using namespace std;


#define int long long
#define pb push_back
#define P pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define vc vector<char>
#define vb vector<bool>
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define mp(a, b) make_pair(a, b)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
#define fill(arr,val) memset(arr,val,sizeof(arr))
#define db(x)  cout<<#x<<" : "<<x<<endl


const int N = 1000000007;

void solve(){

    int n,k,b,c, ans=0, count=0, sum=0;
    cin>>n>>k;


    
    if(k&1){
    	cout<<"No\n";
    	return;
    }

    if(k/2 < n || k/4 > n|| (k%4 !=0 && k/4 >=n)){
    	cout<<"No\n";
    	return;
    }

    cout<<"Yes\n";

    // cout<<ans<<endl; 
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    
  //  int t; cin>>t; while(t--)
    {     
      solve();
    }

  return 0;
}


Measured memory_bytes: 3648
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int main(){
	ll w,h,x,y;
	cin >> w >> h >> x >> y;
	
	printf("%.10Lf", (long double)w/2.0 * h);
	if(2*x==w && 2*y==h) printf(" 1\n");
	else  printf(" 0\n");
	
	return 0;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    if(H%h == 0 && W%w == 0){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
        if(W%w != 0){
            rep(i, H){
                rep(j, W){
                    if(j%w == 0) cout << 1000*(w-1)-1;
                    else cout << -1000;
                    cout << " ";
                }
                cout << endl;
            }
        }
        else{
            rep(i, H){
                rep(j, W){
                    if(i%h == 0) cout << 1000*(h-1)-1;
                    else cout << -1000;
                    cout << " ";
                }
                cout << endl;
            }
        }
    }
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    double sum = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        sum += 1.0 / a;
    }

    cout << 1 / sum;

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
using namespace std;

int main(void){
	
	string s;
	cin>>s;
	if(s.length()==2){
		cout<<s<<endl;
	}
	else{
		cout<<s[2]<<s[1]<<s[0]<<endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 764
program c174

implicit none
integer(16) :: k, i, a, b, m, f

i = 1

read *, k

if (mod(k, 2) == 0) then
 print *, -1
 stop
else if (k == 7) then
 print *, 1
 stop
end if

f = mod(7, k)
a = mod(7, k)

do while(f > 0)
 i = i + 1
 b = a * 10
 a = mod(b, k)
 m =  f + a
 f = mod(m, k)
 !print '(4(I3))', i, a, b, f
 
 if(i > 1919810) then
 print *, -1
 stop
 end if
 
end do

print *, i

end program c174

Measured memory_bytes: 2776
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n, k; cin >> n >> k;
	cout << max(0, n-k+1) << endl;
	return 0;
}



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

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  int l;
  cin >> l;

  vector<int> a(l + 1, 0);
  for (int i = 1; i <= l; ++i) {
    cin >> a[i];
  }

  vector<vector<long long>> f(2, vector<long long> (l + 1, 0)), r = f;
  long long sum = 0, ans = l;
  for (int i = 1; i <= l; ++i) {
    sum += a[i];
    f[0][i] = min(sum, f[0][i - 1] + (a[i] & 1) + 2 * (a[i] == 0));
    f[1][i] = min(sum, min(f[0][i - 1], f[1][i - 1]) + !(a[i] & 1));
  }

  sum = 0;
  for (int i = l - 1; i >= 0; --i) {
    sum += a[i + 1];
    r[0][i] = min(sum, r[0][i + 1] + (a[i + 1] & 1) + 2 * (a[i + 1] == 0));
    r[1][i] = min(sum, min(r[0][i + 1], r[1][i + 1]) + !(a[i + 1] & 1));
    ans = min({ans, f[0][i] + r[0][i], f[0][i] + r[1][i], f[1][i] + r[0][i]});
  }

  cout << ans << '\n';
}




Measured memory_bytes: 7268
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n; cin >> n;
  int x = n;
  int sum = 0;
  while(n > 0) {
    sum += n%10;
    n/=10;
  }
  COUT(x%sum ? "No" : "Yes");
  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a int
	fmt.Scan(&a)

	if a < 10 {
		fmt.Println(a)
	} else if a < 100 {
		fmt.Println(9)
	} else if a < 1000 {
		fmt.Println(9 + a - 99)
	} else if a < 10000 {
		fmt.Println(909)
	} else if a < 100000 {
		fmt.Println(909 + a - 9999)
	} else if a < 1000000 {
		fmt.Println(90909)
	}
}


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

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	long long n, sum = 0;
	cin >> n;
	vector<long long> seq(n);
	vector<vector<long long>> table(n, vector<long long> (n, 0));
	for (int i = 0; i < n; i++) {
		cin >> seq[i];
		sum += seq[i];
	}

	int gap, i, j; //for filling table diagonally
	for (gap = 0; gap < n; gap++)
		for (i = 0, j = gap; j < n; i++, j++) {
			long long x = ((i + 2) <= j) ? table[i + 2][j] : 0;
			long long y = ((i + 1) <= j - 1) ? table[i + 1][j - 1] : 0;
			long long z = (i <= j - 2) ? table[i][j - 2] : 0;

			table[i][j] = max(seq[i] + min(x, y), seq[j] + min(y, z));
		}

	cout << 2 * table[0][n - 1] - sum << endl;
}


Measured memory_bytes: 73672
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,y,a,b;
	cin>>n>>y;
	for(a=0;a<=y/10000;a++)
	{
		for(b=0;b<=y/5000;b++)
		{
			if(a+b<=n)
			{
				if(a*10000+b*5000+(n-a-b)*1000==y)
				{
					cout<<a<<' '<<b<<' '<<(n-a-b);
					return 0; 
				}
			}
		}
	}
	cout<<-1<<' '<<-1<<' '<<-1;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

bool is_valid_parenthese(string s) {
    int cnt = 0;
    for(char c: s) {
        if (c == '(') cnt += 1;
        else cnt -= 1;
        if (cnt < 0) return false;
    }
    return cnt == 0;
}

int main() {
    //   BWBBWWWB
    //=> ((())())
    //=> 2*3*2*1 rev, x 4!
    int n;
    ll mod = 1e9 + 7;
    string s;
    cin >> n >> s;
    if (s[0] == 'W') {
        cout << "0" << endl;
        return 0;
    }
    string paren = "(";
    int cnt = 1;
    for(int i = 1; i < n*2; i++) {
        if (s[i] == 'W') {
            if (cnt % 2 == 1) {
                paren += '(';
                cnt += 1;
            } else {
                paren += ')';
                cnt -= 1;
            }
        } else {// s[i] == 'B';
            if (cnt % 2 == 1) {
                paren += ')';
                cnt -= 1;
            } else {
                paren += '(';
                cnt += 1;
            }
        }
    }
    // cout << ans << endl;
    if (!is_valid_parenthese(paren)) {
        cout << 0 << endl;
        return 0;
    } else {
        ll mul = 0;
        ll ans = 1;
        for(int i = n*2-1; i >= 0; i--) {
            if (paren[i] == ')') {
                mul += 1;
            } else {
                ans *= mul;
                ans %= mod;
                mul -= 1;
            }
        }
        for(int i = 1; i <= n; i++) {
            ans *= i;
            ans %= mod;
        }
        cout << ans << endl;
    }
    return 0;
}




Measured memory_bytes: 980
#include<cstdio>
typedef long long LL;
const int N=405,md=1e9+7;
int n,c,A[N],B[N],dp[N];
int pre[N][N],pw[N];
inline void upd(int&a){a+=a>>31&md;}
int main(){
	scanf("%d%d",&n,&c);
	for(int i=1;i<=n;++i)scanf("%d",A+i);
	for(int i=1;i<=n;++i)scanf("%d",B+i);
	dp[0]=1;
	for(int i=1;i<=400;++i)pw[i]=1;
	for(int i=0;i<=c;++i){
		int*P=pre[i];
		for(int j=1;j<=400;++j)upd(P[j]=P[j-1]+pw[j]-md),pw[j]=(LL)pw[j]*j%md;
	}
	for(int i=1;i<=n;++i){
		for(int C=c;~C;--C){
			int d=0;
			for(int j=0;j<=C;++j)
			d=(d+(LL)dp[C-j]*(pre[j][B[i]]-pre[j][A[i]-1]+md))%md;
			dp[C]=d;
		}
	}
	printf("%d\n",dp[c]);
	return 0;
}

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

int main(int argc, char const *argv[])
{
    string s, t;
    cin >> s >> t;
    rep(i, s.size())
    {
        bool ok = true;
        rep(j, s.size())
        {
            ok &= s[(i + j) % s.size()] == t[j];
        }
        if (ok)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
H,W = map(int,input().split())
c = []
dicta = {}
dicta[-1] = 0
for i in range(10):
    c.append(list(map(int,input().split())))
    dicta[i] = 0
c = [i for i in zip(*c)]
for i in range(H):
    a = list(map(int,input().split()))
    for i in a:
        dicta[i] += 1
dicta.pop(-1)
cost = [0 for i in range(10)]
def dijkstra(start,node,cost):
    d = [float('inf') for i in range(node)]
    used = [False for i in range(node)]
    d[start] = 0
    while True:
        flag = True
        for i in range(node):
            if (not used[i]) and flag:
                v = i
                flag = False
            elif (not used[i]) and d[i] < d[v]:
                v = i
        
        if flag:
            break
        used[v] = True
        for j in range(node):
            d[j] = min(d[j],d[v]+cost[v][j])
    return d

cost = dijkstra(1,10,c)
ans = 0
for k,v in dicta.items():
    ans += v*cost[k]
print(ans)



Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
vector<ll> xv,yv;
int main(){
  ll n,k;
  cin>>n>>k;
  vector<P> vec;
  for(int i=0;i<n;i++){
    ll x,y;
    cin>>x>>y;
    vec.push_back(P(x,y));
    xv.push_back(x);
    yv.push_back(y);
  }
  sort(xv.begin(),xv.end());
  sort(yv.begin(),yv.end());
  ll ans=((ll)1<<62);
  for(int a=0;a<n;a++){
    for(int b=a;b<n;b++){
      for(int c=0;c<n;c++){
        for(int d=c;d<n;d++){
          ll lx=xv[a],rx=xv[b],ly=yv[c],ry=yv[d];
          ll cnt=0;
          for(int i=0;i<n;i++){
            ll x=vec[i].first,y=vec[i].second;
            if(lx<=x&&x<=rx&&ly<=y&&y<=ry) cnt++;
          }
          if(cnt>=k){
            ans=min(ans,(rx-lx)*(ry-ly));
          }
        }
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
typedef long long ll;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int i,j,k;
char grid[1010][1010];
int memo[1010][1010];

int dfs(int col,int row){

    
    if(row < 0 || col < 0){
        return 0;
    }

    else if(row == 0 && col == 0){
        return 1;}

    

    if(memo[col][row]!=-1){
        return memo[col][row];
    }

    int sum = 0;

    
    if(grid[col-1][row] != '#'){
        sum += dfs(col-1,row);
    }
    sum = sum % (int(1e9)+7);

    if(grid[col][row-1] != '#'){
        sum += dfs(col,row-1);
    }

    return memo[col][row] = sum % (int(1e9)+7);
    
    
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
    int r,c;
    cin >> r >> c;
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            cin >> grid[j][i];
            memo[j][i]=-1;
        }
    }
    cout << dfs(c-1,r-1) << endl;
    
}

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

#define ll long long
#define ull unsigned ll

#define vi vector <int>
#define ii pair <int, int>
#define vii vector <ii>
#define INFLL 9e18
#define INF 2e9
#define EPS 1e-9
#define pb push_back
#define emp emplace_back
#define PI acos(-1.0)
#define endl "\n"
#define mp make_pair
#define DEBUG 0

int main ()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    
    string s, t;
    cin >> s >> t;
    t.pop_back();
    if (t == s) cout << "Yes" << endl;
    else cout << "No" << endl;
          

    return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int me = 0;

void sea(int *r,int m,int n,int k){
  if(n > 1){
    sea(r,m*2,n-1,k);
    sea(r,m+k,n-1,k);
  }
  if(n == 1){
    r[me]= m*2;
    me++;
    r[me] = m+k;
    me++;
  }
}

int main(){
  int n,k;
  scanf("%d %d",&n,&k);
  int m = 1;
  int r[(int)pow(2,n)];
  sea(r,m,n,k);
  int i;
  int min = 50000000;
  for(i=0;i<(int)pow(2,n);i++){
    if(r[i] < min){
      min = r[i];
    }
  }
  printf("%d\n",min);

}


Measured memory_bytes: 384
n,k,q=map(int,input().split())
l=[int(input()) for i in range(q)]
d=dict.fromkeys(range(n),k)

for i in l:
  d[i-1]+=1

for i in d.values():
  if i-q>0:
    print('Yes')
  else:
    print('No')





Measured memory_bytes: 19108
#include"stdio.h"
#include"stdlib.h"
int *A;
int *B;
int *C;
int n;
void CountingSort(int k)
{
  int i,j;
  for(i=0;i<k;i++)
    {
      C[i]=0;
    }
  for(j=0;j<n;j++)
    {
      C[A[j]]++;
    }
  for(i=1;i<k;i++)
    {
      C[i]+=C[i-1];
    }
  for(j=n-1;j>=0;j--)
    {
      B[C[A[j]]-1]=A[j];
      C[A[j]]--;
    }
}
int main()
{
  int i,j;
  int k;
  scanf("%d",&n);
  A=(int*)malloc(sizeof(int)*n);
  B=(int*)malloc(sizeof(int)*n);
  scanf("%d",&A[0]);
  k = A[0];
  for(i=1;i<n;i++)
    {
      scanf("%d",&A[i]);
      if(k<A[i])k=A[i];
    }
  k++;
  C=(int*)malloc(sizeof(int)*(k));
  CountingSort(k);
  printf("%d",B[0]);
  for(i=1;i<n;i++)
    {
      printf(" %d",B[i]);
    }
  printf("\n");
}


Measured memory_bytes: 17456
S = input()
gt = [0]
for i in range(len(S)):
    if S[i] == '<':
        gt.append(gt[i] + 1)
    else:
        gt.append(0)

lt = [0] * (len(S)+1)
for i in range(len(S)-1, -1, -1):
    if S[i] == '>':
        lt[i] = lt[i+1] + 1
    else:
        lt[i] = 0

# print(gt)
# print(lt)
print(sum([max(g, l) for g, l in zip(gt, lt)]))


Measured memory_bytes: 87956
/**Bismillahir Rahmanir Raheem
    Author:Refatul Fahad**/

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
#define IOS  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define sz(s)  (int)s.size()
#define all(s)  s.begin(),s.end()
const int N = 1e5 + 5;
const ll M = 1ll<<62;
const double pi=2*acos(0.0);
const double esp=1e-9;
int Set(int N,int pos) {
    return N=N | (1<<pos);
}
int reset(int N,int pos) {
    return N= N & ~(1<<pos);
}
bool check(int N,int pos) {
    return (bool)(N & (1<<pos));
}

int dx[]= {0,0,1,-1};
int dy[]= {1,-1,0,0};

ll ar[5005],br[5005];
int main() {

    IOS;
    /// freopen("input.txt","r",stdin);
    /// freopen("output.txt","w",stdout);

    int test=1;
    //cin>>test;
    for(int cs=1; cs<=test; ++cs) {
        ll n,k,ans,mx=-M;
        cin>>n>>k;

        for(int i=1; i<=n; ++i) {
            cin>>ar[i];
        }
        for(int i=1; i<=n; ++i) {
            cin>>br[i];
        }
        for(int i=1; i<=n; ++i) {
            ans=0ll;
            int in=ar[i],cnt=0;
            vector<ll> vt(n+5,0ll);
            vector<bool>vc(n+5,0);
            vc[i]=true;
            while(cnt+1<=k) {
                ans+=br[in];
                ++cnt;
                in=ar[in];
                vt[cnt]=ans;
                mx=max(mx,ans);
                if(vc[in]) {
                    if(cnt+1>k)break;
                    ans+=br[in];
                    ++cnt;
                    mx=max(mx,ans);
                    vt[cnt]=ans;
                    break;
                }
                vc[in]=true;//cout<<ans<<endl;
            }
//            ll di=k/cnt;
//            ans=ans*di;
//            if(ans>0ll)
//                mx=max(mx,ans);
//            ll md=k%cnt;
            for(int i=1; i<=cnt; ++i) {
                mx=max(mx,vt[i]+(max(0ll,ans)*((k-i)/cnt)));
            }
        }
        cout<<mx<<endl;
    }
    return 0;
}



Measured memory_bytes: 3744
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int A=sc.nextInt();
		int B=sc.nextInt();
		int C=sc.nextInt();
		int D=sc.nextInt();
		int sum=(A+B+C+D);
		pl(sum/60);
		pl(sum%60);
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}



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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)

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

	bool ans[1001];
	rep(i,1001) ans[i]=false;
	ans[1]=true;

	FOR(i,2,33){
		ll tmp=i*i;
		ans[tmp]=true;
		while(1){
			tmp*=i;
			if(tmp>1000) break;
			else ans[tmp]=true;
		}
	}
	rrep1(i,X){
		if(ans[i]){
			cout<<i;
			return 0;
		}
	}
}

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

int main() {
	int n;
	cin >> n;
	int a[100010];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	int count = 0;
	int ans = 0;
	for (int i = 1; i < n; i++) {
		if (a[i - 1] == a[i]) {
			count++;
		}
		else {
			if ((count + 1) % 2 == 1) {
				ans++;
			}
			count = 0;
		}
		if (i == n - 1) {
			if ((count + 1) % 2 == 1) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
    }
    let n = s.len();
    let mut count = 0;
    for i in 0..n {
        if i % 2 == 0 {
            if s[i] == '0' {
                count += 1;
            }
        } else {
            if s[i] == '1' {
                count += 1;
            }
        }
    }

    let mut count2 = 0;
    for i in 0..n {
        if i % 2 == 0 {
            if s[i] == '1' {
                count2 += 1;
            }
        } else {
            if s[i] == '0' {
                count2 += 1;
            }
        }
    }

    let ans = std::cmp::min(count, count2);
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define sz(x)  ((int)x.size ())
#define all(x) (x).begin(), (x).end()
#define re return
#define mp make_pair
#define sqrt(x) sqrt (abs(x))
#define y0 y3451
#define y1 y4562
#define j0 j25624
#define j1 j45624
#define makeunique(x) sort(all(x)), (x).resize (unique(all(x)) - (x).begin())
 
typedef pair <int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef double D;
typedef long double ld;
typedef unsigned int uint;
typedef vector <string> vs;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <vi> vvi;
 
template <class T> using _tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> T abs (T x) { re x > 0 ? x : -x; }
template <class T> T sqr (T x) { re x * x; }
template <class T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }
template <class T> int sgn (T x) { re x > 0 ? 1 : (x < 0 ? -1 : 0); }
 
#define filename ""
 
const D pi = acos(-1.);
const int N = 2e5 + 20;
const int inf = 1e9 + 7;
 
int mod = inf;
ii a[N];
ll dp[3010];
 
inline ll power(ll x, ll y = mod - 2) {
	ll ans = 1;
	while (y) {
		if (y & 1) ans = ans * x % mod;
		y /= 2;
		x = x * x % mod;
	}
	re ans;
}
ll f[N], rev[N];
int w, h;
 
inline ll cnk(int n, int k) {
    ll ans = f[n] * rev[k] % mod;
    re ans * rev[n - k] % mod;
}
int n, m;
 
int main() {
	cin >> w >> h >> n;
	for (int i = 0; i < n; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		a[i] = {x - 1, y - 1};
	}
	a[n] = {w - 1, h - 1};
	n++;
	sort(a, a + n);
	f[0] = rev[0] = 1;
	for (int i = 1; i <= w + h; i++) {
		f[i] = f[i - 1] * i % mod;
		rev[i] = power(f[i]);
	}
	for (int i = 0; i < n; i++) {
		dp[i] = cnk(a[i].fi + a[i].se, a[i].fi);
		for (int j = 0; j < i; j++)
			if (a[i].fi >= a[j].fi && a[i].se >= a[j].se)
				dp[i] = (mod + dp[i] - cnk(a[i].fi - a[j].fi + a[i].se - a[j].se, a[i].fi - a[j].fi) * dp[j] % mod) % mod;
	}
	cout << dp[n - 1];
}


Measured memory_bytes: 4352
Scanf.scanf "%d" @@ fun n ->
let a = Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0)) in
let dp = Array.init (n+1) (fun _ -> Array.make (n+1) 0) in
for w = 1 to n do
  for i = 0 to n-w do
    dp.(i).(i+w) <-
      max (a.(i) - dp.(i+1).(i+w)) (a.(i+w-1) - dp.(i).(i+w-1))
  done;
done;
Printf.printf "%d\n" dp.(0).(n)

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

typedef long long ll;
typedef pair<int, int> pii;
#define x first
#define y second

const int maxn = 2020, inf = 1e9;
int n;
int arr[maxn];
int dp[2][maxn][maxn];
bool bio[2][maxn][maxn];

int rek(bool f, int i, int j){
	if(bio[f][i][j])
		return dp[f][i][j];

	bio[f][i][j] = true;

	int ret = 0, k = max(i, j) + 1;

	if(k == n + 2){
		ret = abs(arr[i] - arr[j]);
	}else{
		if(f){
			ret = min(rek(true, i, k), rek(false, i, k));
		}else{
			ret = max(rek(false, k, j), rek(true, k, j));
		}
	}

	return dp[f][i][j] = ret;
}

int main(){
	ios_base::sync_with_stdio(false);

	cin >> n >> arr[0] >> arr[1];

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

	cout << rek(false, 0, 1) << endl;

	return 0;
}


Measured memory_bytes: 40192
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(a,b) for(int i=a;i<b;i++)
int m=62;
int main() {
    ll n,k;
    scanf("%lld%lld",&n,&k);
    vector<vector<ll>>a(m,vector<ll>(n,-1));
    rep(0,n)
    {
        scanf("%lld",&a[0][i]);
        a[0][i]--;
    }
    rep(1,m)
    {
        for(int j=0;j<n;j++)
        {
            a[i][j] = a[i-1][a[i-1][j]];
        }
    }
    ll now=0;
    rep(0,62)
    {
        if((k|(1LL<<i))==k)
        now = a[i][now];
    }
    printf("%lld",now+1);
}


Measured memory_bytes: 101744
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

lli dx[]={0,0,-1,1,-1,-1,1,1};
lli dy[]={1,-1,0,0,1,-1,-1,1};

lli gcd(lli a , lli b) {
    if(b == 0) return a;
    a %= b;
    return gcd(b,a);
}

lli dp[MAXN];
void solve() {
    lli n, ans = 0;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        lli x;
        cin >> x;
        dp[x]++;
    }

    for (int i = 1; i < MAXN; ++i) {
        dp[i] += dp[i - 1];
        //cout << dp[i] << " ";
    }
    for (int i = 1; i < MAXN; ++i) {
        lli before = dp[i - 1];
        lli after = dp[MAXN - 1] - dp[i - 1];
        ans += (before == after);
    }
    cout << ans << "\n";
}

int main()
{
    IOS;
    lli t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        String s=sc.next();
        char[]ss=new char[s.length()];
        for(int i=0;i<s.length();i++){
            ss[i]=s.charAt(i);
        }
        for(int i=0;i<s.length();i++){
            if(i%2==0){
                System.out.print(ss[i]);
            }
        }

        
        
        
     
    }
}

Measured memory_bytes: 30364
from collections import defaultdict
from itertools import combinations

n = int(input())
d = defaultdict(int)

for _ in range(n):
    s = input()
    if s[0] == 'M':
        d['M'] += 1
    if s[0] == 'A':
        d['A'] += 1
    if s[0] == 'R':
        d['R'] += 1
    if s[0] == 'C':
        d['C'] += 1
    if s[0] == 'H':
        d['H'] += 1

ls = [dd for dd in d]

if len(ls) < 3:
    print(0)
    exit()

ans = 0
for v in combinations(ls, 3):
    cnt = 1
    for vv in v:
        cnt *= d[vv]
    ans += cnt

print(ans)


Measured memory_bytes: 3316
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#define ll long long int
#define MOD 1000000007LL
using namespace std;

int main() {
    char c[60][60]={};
    int h,w;
    cin>>h>>w;
    int d=0;
    for(int i=1;i<=h;i++){
        string s;
        cin>>s;
        for(int j=1;j<=w;j++){
            c[j][i]=s[j-1];
            if(s[j-1]=='.'){
                d++;
            }
        }
    }
    int ans[60][60]={};
    queue<int> xq;
    queue<int> yq;
    xq.push(1);
    yq.push(1);
    int vx[4]={1,0,-1,0};
	int vy[4]={0,1,0,-1};
    int co=0;
    while(1){
        int x=xq.front();
        int y=yq.front();
        for(int i=0;i<4;i++){
            int nx=x+vx[i];
            int ny=y+vy[i];
            if((nx<1)||(ny<1)){
                continue;
            }
            if(c[nx][ny]=='.'){
                if(ans[nx][ny]==0){
					ans[nx][ny]=ans[x][y]+1;
					xq.push(nx);
					yq.push(ny);
				}
				if((nx==w)&&(ny==h)){
					cout<<d-1-ans[nx][ny]<<endl;
					return 0;
				}
            }
        }
        xq.pop();
        yq.pop();
        if(xq.empty()){
          cout<<-1<<endl;
          return 0;
        }
    }
}


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

namespace practice_csharp
{
    class Program
    {
        static void Main(string[] args)
        {
            var in1 = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var in2 = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var cal1 = new DateTime(2019,in1[0],in1[1]);
            var cal2 = new DateTime(2019,in2[0],in2[1]);
            var m = in1[0] < 12? in1[0]+1:12;
            var cal3 = new DateTime(2019,m,1);

            var add = cal1.AddDays(1.0);
            if(add.Equals(cal3) && add.Equals(cal2)){
                System.Console.WriteLine(1);
            }
            else{
                System.Console.WriteLine(0);
            }
        }
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
//#define ll __int64
#define ll long long

const ll INF=5000000000000000000;

int n,k;
int x[100],y[100];
ll ans=INF;

ll che(int a,int b,int c,int d){
	ll x1=x[a],x2=x[b],y1=y[c],y2=y[d];
	if(x1>x2||y1>y2)return -1;
	int cnt=0;

	rep(i,n){
		if(x1<=x[i]&&x[i]<=x2&&y1<=y[i]&&y[i]<=y2)cnt++;
	}
	if(cnt>=k)return (x2-x1)*(y2-y1);
	else return -1;
}

int main(){
cin>>n>>k;
rep(i,n)cin>>x[i]>>y[i];

rep(a,n){
	rep(b,n){
		rep(c,n){
			rep(d,n){
				ll tmp=che(a,b,c,d);
				if(tmp!=-1)ans=min(ans,tmp);
			}
		}
	}	
}

cout<<ans<<endl;



	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": # "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(string s;cin>>s;){
		vi a(allof(s));
		transform(allof(a),a.begin(),bind2nd(minus<int>(),'0'));
		rep(i,9)
			rep(j,9-i)
				a[j]=(a[j]+a[j+1])%10;
		cout<<a[0]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    int n,k;cin>>n>>k;
    int h[n];
    rep(i,n)cin>>h[i];
    sort(h,h+n);
    int ans = 1e9+1;
    rep(i,n-k+1){
        ans = min(ans,h[i+k-1]-h[i]);
    }
    co(ans);
}

Measured memory_bytes: 640
#include<stdio.h>
int main()
{
	int A,B,K;
	int Max,Min;
	
	scanf("%d%d%d",&A,&B,&K);
	
	if(B <= K || (A+K) > B) Max = B;
	else Max = A+K-1;
	
	if((A+K) > (B-K)) Min = A+K;
	else Min = B-K+1;
	
	for(int i=A; i <=Max; i++) printf("%d\n",i);
	for(int i=Min; i<=B;i++) printf("%d\n",i);
	
	return 0;
}

Measured memory_bytes: 128
from collections import defaultdict

n = int(input())
d = defaultdict(int)

for x in range(n+1):
    s = str(x)
    a = s[0]
    b = s[-1]
    if int(a) and int(b):
        d[(a, b)] += 1

num = '123456789'
res = 0
for i in num:
    for j in num:
        res += d[(i, j)] * d[(j, i)]

print(res)


Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>


using namespace std;

int main()
{
    int A[10],i;
    
    for(i=0; i<=9; i++)
    {
    cin >> A[i];         
    }
    
    sort(A,A+10);
    reverse(A,A+10);
    
    for(i=0; i<=2; i++)
    {
    cout<< A[i] << endl;         
    }
    
    return 0;
}

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

using namespace std;

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

vector<int> guy, sas;
int dp[101][1<<17];

int main(){
	int i, j, n, m, l, s, e, ins;
	int ans;
	while(1){
		cin >> n;
		if(!n)break;
		ans = 0;
		guy.clear();
		sas.clear();
		REP(i,n)REP(j,1<<17) dp[i][j]=0;
		REP(i,n){
			cin >> m >> l;
			sas.push_back(l);
			ins=0;
			REP(j,m){
				cin >> s >> e;
				for(int k=s;k<e;k++){
					ins+=1<<(k-6);
				}
			}
			//cout << ins << endl;
			guy.push_back(ins);
		}
		REP(i,n){
			REP(j,1<<17){
				dp[i+1][j] = dp[i][j];
			}
			REP(j,1<<17){
				if(!(guy[i]&j) && dp[i+1][j+guy[i]]<dp[i][j]+sas[i]){
					dp[i+1][j+guy[i]]=dp[i][j]+sas[i];
				}
			}
		}
		REP(j,1<<17) if(ans<dp[n][j])ans = dp[n][j];
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 52928
N = int(input())

if N < 105:
    print(0)
    exit()

ans = 0
for i in range(1, N+1, 2):
    count = 0
    for j in range(1, i+1):
        if i % j == 0:
            count += 1

    if count == 8:
        ans += 1

print(ans)

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[200005];
ll S[200005];
map<ll, ll> m;

int main()
{
    int N;
    cin >> N;
    memset(S, 0, sizeof(S));
    REP(i, N)
    {
        cin >> A[i];
        S[i] = A[i];
    }

    REP(i, N - 1)
    {
        S[i + 1] += S[i];
    }
    m[0]++;
    ll ans = 0;
    REP(i, N)
    {
        ans += m[S[i]];
        m[S[i]]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15872
package main

import (
	"fmt"
	"math"
)

type TPoint struct {
	T int
	X int
	Y int
}

func main() {
	var n int
	var steps []TPoint
	var match bool = true

	steps = append(steps, TPoint{T: 0, X: 0, Y: 0})

	fmt.Scan(&n)

	for i := 0; i < n; i++ {
		var time, x, y int
		fmt.Scan(&time)
		fmt.Scan(&x)
		fmt.Scan(&y)
		steps = append(steps, TPoint{T: time, X: x, Y: y})
	}

	for i := 0; i < n; i++ {
		dt := steps[i+1].T - steps[i].T
		dist := int(math.Abs(float64(steps[i+1].X - steps[i].X)) + math.Abs(float64(steps[i+1].Y - steps[i].Y)))
		if dt < dist {
			match = false
		}
		if dist%2 != dt%2 {
			match = false
		}
	}

	if match {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 9088
#include <iostream>
#include <vector>
#include <climits>
#include <functional>
using namespace std;

template<typename Monoid, typename OpMonoid = Monoid>
class LazySegmentTree{
private:
    using F = function<Monoid(Monoid, Monoid)>;
    using G = function<Monoid(Monoid,OpMonoid,int)>;
    using H = function<OpMonoid(OpMonoid,OpMonoid)>;
    int sz;
    vector<Monoid> data;
    vector<OpMonoid> lazy;
    const F func;
    const G op;
    const H mergeOp;
    const Monoid e;
    const OpMonoid op_e;
public:
    LazySegmentTree(int n, const F f, const G g, const H h,
    const Monoid &e, const OpMonoid op_e)
    :func(f), op(g), mergeOp(h), e(e), op_e(op_e){
        sz = 1;
        while(sz<n) sz <<= 1;
        data.assign(2*sz,e);
        lazy.assign(2*sz,op_e);
    }
    //初期化
    void set(int k, const Monoid &x){
        data[k+sz] = x;
    }
    //前計算
    void build(){
        for(int k=sz-1;k>0;k--){
            data[k] = func(data[2*k],data[2*k+1]);
        }
    }
    //kの子に長さlenの遅延を伝搬
    void propagate(int k, int len){
        if(lazy[k]!=op_e){
            if(k<sz){
                //遅延を下の段に伝搬、結果を分割する
                lazy[2*k] = mergeOp(lazy[2*k],lazy[k]);
                lazy[2*k+1] = mergeOp(lazy[2*k+1],lazy[k]);
            }
            data[k] = op(data[k],lazy[k],len);
            lazy[k] = op_e;
        }
    }
    //更新
    Monoid update(int a, int b, const OpMonoid &x, int k, int l, int r){
        propagate(k,r-l);
        if(r<=a || b<=l) return data[k];
        else if(a<=l && r<=b){
            lazy[k] = mergeOp(lazy[k],x);
            propagate(k,r-l);
            return data[k];
        }else{
            return data[k] = func(update(a,b,x,2*k,l,(l+r)>>1),update(a,b,x,2*k+1,(l+r)>>1,r));
        }
    }
    Monoid update(int a, int b, const OpMonoid &x){
        return update(a,b,x,1,0,sz);
    }
    //クエリ回答
    Monoid query(int a, int b, int k, int l, int r){
        propagate(k,r-l);
        if(r<=a || b<=l){
            return e;
        }else if(a<=l && r<=b){
            return data[k];
        }else{
            return func(query(a,b,2*k,l,(l+r)>>1),query(a,b,2*k+1,(l+r)>>1,r));
        }
    }
    Monoid query(int a, int b){
        return query(a,b,1,0,sz);
    }
    Monoid operator[](const int &k){
        return query(k,k+1);
    }
};


int main(){
    int N,Q;
    cin >> N >> Q;
    auto func = [](int a, int b){return min(a,b);};
    auto op = [](int a, int b, int l){return b!=-1? b:a;};
    auto mergeop = [](int a, int b){return b!=-1? b:a;};
    LazySegmentTree<int,int>
    seg(N,func,op,mergeop,INT_MAX,-1);
    for(int i=0;i<Q;i++){
        int c,s,t,x;
        cin >> c;
        if(c==0){
            cin >> s >> t >> x;
            seg.update(s,t+1,x);
        }else{
            cin >> s >> t;
            cout << seg.query(s,t+1) << endl;
        }
    }
}


Measured memory_bytes: 4932
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD=1e9+7;
template <class Q>
void clearQueue(Q & q) {
    q = Q();
}
void solve(){
    int n;cin>>n;
    int tot=0;
    vector<int>v(n);
 
  for(int i=0;i<n;i++){
    cin>>v[i];
    tot+= v[i];
  }
  int ans =0;
  for(int i=0;i<n;i++){
     tot-=v[i];
     ans = (ans%MOD + (tot %MOD *v[i] % MOD) %MOD)%MOD;
  }
  cout<<ans;
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL); 
	int T=1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 4728