akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
int main() {
	int N; cin >> N;
	vector<int>as;
	int zero = 0;
	int one = 0;
	for (int i = 0; i < N; ++i) {
		int a; cin >> a;
		if (a == 0)zero++;
		else if (a == 1)one++;
		else as.push_back(a);
	}
	sort(as.begin(), as.end());
	vector<int>ans;
	if (!zero&&!one) {
		if (as.size() >= 2 && as[as.size() - 1] == 3 && as[as.size() - 2] == 2) {
			for (int i = 0; i < as.size() - 2; ++i) {
				ans.push_back(as[i]);
			}
			ans.push_back(3);
			ans.push_back(2);
		}
		else {
			for (int i = 0; i < as.size(); ++i) {
				ans.push_back(as[i]);
			}
		}
	}
	else if (!zero) {
		if (as.size() >= 2 && as[as.size() - 1] == 3 && as[as.size() - 2] == 2) {
			for (int i = 0; i < as.size() - 2; ++i) {
				ans.push_back(as[i]);
			}
			ans.push_back(3);
			ans.push_back(2);
		}
		else {
			for (int i = 0; i < as.size(); ++i) {
				ans.push_back(as[i]);
			}
		}
		for (int i = 0; i < one; ++i) {
			ans.push_back(1);
		}
		
	}
	else {
		if (zero%2 && one == 0) {
			if (!as.empty()) {
				int fst = as[0];
				as.erase(as.begin());
				if (as.size() >= 2 && as[as.size() - 1] == 3 && as[as.size() - 2] == 2) {
					for (int i = 0; i < as.size() - 2; ++i) {
						ans.push_back(as[i]);
					}
					ans.push_back(3);
					ans.push_back(2);
				}
				else {
					for (int i = 0; i < as.size(); ++i) {
						ans.push_back(as[i]);
					}
				}
				for (int i = 0; i < zero - 1; ++i) {
					ans.push_back(0);
				}
				ans.push_back(fst);
				ans.push_back(0);
			}
			else {
				for (int i = 0; i < zero; ++i) {
					ans.push_back(0);
				}
			}
			
		}
		else {
			if (as.size() >= 2 && as[as.size() - 1] == 3 && as[as.size() - 2] == 2) {
				for (int i = 0; i < as.size() - 2; ++i) {
					ans.push_back(as[i]);
				}
				ans.push_back(3);
				ans.push_back(2);
			}
			else {
				for (int i = 0; i < as.size(); ++i) {
					ans.push_back(as[i]);
				}
			}
			if (zero% 2 == 0) {
				for (int i = 0; i < zero; ++i) {
					ans.push_back(0);
				}
				for (int i = 0; i < one; ++i) {
					ans.push_back(1);
				}
			}
			else {
				for (int i = 0; i < zero-1; ++i) {
					ans.push_back(0);
				}
				ans.push_back(1);
				ans.push_back(0);
				for (int i = 0; i < one-1; ++i) {
					ans.push_back(1);
				}
			}
		}
	}
	assert(ans.size() == N);
	for (auto a : ans) {
		cout << a << endl;
	}
	return 0;
}

Measured memory_bytes: 3132
N = gets.chomp.to_i

def hoge(num, prime)
ans = 0
i = 0
begin
	i += 1
 	ans += num/(prime**i)
end while num/(prime**(i+1))>0
return ans
end



def primes(max)
arr=(2..max).to_a
(2..Math::sqrt(max)).each do |i|
arr.delete_if {|a|a % i == 0 && a!=i}
end
arr
end



ans = 1
primes(N).each{|i|
ans *= (hoge(N, i) + 1 % (10**9 + 7))
ans %= (10**9 + 7)
}

p ans

Measured memory_bytes: 1788
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<pair<int,int>> stu(n), che(m);
  REP(i,n) cin >> stu[i].first >> stu[i].second;
  REP(j,m) cin >> che[j].first >> che[j].second;

  REP(i,n) {
    int dist = 1000000000, ind;
    REP(j,m) {
      int cru = abs(stu[i].first - che[j].first) + abs(stu[i].second - che[j].second);
      if(dist > cru) { dist = cru; ind = j; }
    }
    ind++;
    cout << ind << endl;
  }
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
int main(){
    int n;
    cin>>n;
    int64_t sum=0;
    for(int i=1;i<=n;i++){
        if(i%3!=0 && i%5!=0){
            sum += i;
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string s;
    int64_t c0=0, c1=0;
    cin >> s;
    rep(i,s.size()){
        if(s.at(i) == '0') c0++;
        if(s.at(i) == '1') c1++;
    }
    cout << 2*min(c0,c1) << endl;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = n; i < 10000; i++) {
    string s = to_string(i);
    if (s[0] == s[1] && s[1] == s[2]) {
      cout << s << endl;
      return 0;
    }
  }
  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    string str;
    cin>>str;
    ll ct=0,ans=0;
    fr(i,0,3)
    {
        if(str[i]=='R')
        {
            ct++;
            ans=max(ans,ct);
        }
        else
        {
            ans=max(ans,ct);
            ct=0;

        }
    }
    cout<<ans<<endl;
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        //cout<<"Case #"<<pp-t<<":\n";
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
/*
recursion - matrix exponential

*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

Measured memory_bytes: 3652
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=3005,MOD=1000000007;

int PowMod(int a,int b)
{
	int ret=1;
	while(b)
	{
		if(b&1)
			ret=(1LL*a*ret)%MOD;
		b>>=1;
		a=(1LL*a*a)%MOD;
	}
	return ret;
}

int N,M;
int fac[MAXN],ifac[MAXN];
int sum[MAXN],A[MAXN],l[MAXN],r[MAXN],len[MAXN],cnt1[MAXN];
pair<int,int> seg[MAXN];
int dp[MAXN][MAXN];

int F(int a,int b)
{
	if(a<b)
		return 0;
	return 1LL*fac[a]*ifac[b]%MOD*ifac[a-b]%MOD;
}

int main()
{
	scanf("%d%d",&N,&M);
	
	fac[0]=1;
	for(int i=1;i<=N;i++)
		fac[i]=(1LL*fac[i-1]*i)%MOD;
	ifac[N]=PowMod(fac[N],MOD-2);
	for(int i=N-1;i>=0;i--)
		ifac[i]=(1LL*ifac[i+1]*(i+1))%MOD;
	
	for(int i=1;i<=N;i++)
	{
		scanf("%1d",&A[i]);
		sum[i]=sum[i-1]+A[i];
	}
	for(int i=1;i<=M;i++)
	{
		scanf("%d%d",&l[i],&r[i]);
		seg[i]=make_pair(l[i],r[i]);
	}
	sort(seg+1,seg+M+1);
	int tmp=0;
	for(int i=2;i<=M+1;i++)
		if(seg[i].first!=seg[i-1].first&&seg[i-1].second>r[tmp])
		{
			l[++tmp]=seg[i-1].first;
			r[tmp]=seg[i-1].second;
		}
	M=tmp;
	for(int i=1;i<=M;i++)
	{
		len[i]=r[i]-l[i]+1;
		cnt1[i]=sum[r[i]]-sum[l[i]-1];
	}
	M++;
	l[M]=r[M]=N+1;
	len[M]=1;cnt1[M]=0;
	
	dp[1][sum[r[1]]-sum[l[1]-1]]=1;
	for(int i=2;i<=M;i++)
	{
		if(l[i]>r[i-1])
			for(int j=0;j<=len[i-1];j++)
				(dp[i][cnt1[i]]+=(1LL*dp[i-1][j]*F(len[i-1],j)%MOD))%=MOD;
		else
			for(int j=0;j<=r[i-1]-l[i]+1;j++)
				for(int k=j;k<=len[i-1];k++)
					(dp[i][j+sum[r[i]]-sum[r[i-1]]]+=(1LL*dp[i-1][k]*F(l[i]-l[i-1],k-j)%MOD))%=MOD;
	}
	
	printf("%d\n",dp[M][0]);
	
	return 0;
}


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

// #define int ll
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using si = set<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define fastio    ios::sync_with_stdio(0); cin.tie(0)
#define rep(i, n) for (int i = 0; i < n; i++)
#define dotc()    int tcs; if (cin >> tcs) rep(tc, tcs)
#define sz(x)     (int)x.size()
#define eb        emplace_back
#define pb        push_back
#define mp        make_pair
#define all(x)    x.begin(), x.end()
#define rall(x)   x.rbegin(), x.rend()
#define fi        first
#define se        second

int inf(0x3fffffff);
int mod(1000000007);
double pi(acos(-1.0));

int32_t main() {
  fastio;
#ifdef LOCAL
  freopen("io\\in.txt", "r", stdin);
  freopen("io\\out.txt", "w", stdout);
#endif

  int n;
  cin >> n;
  vector<vii> v(n);
  rep(i, n) {
    int a;
    cin >> a;
    v[i].resize(a);
    rep(j, a) {
      cin >> v[i][j].fi >> v[i][j].se;
      v[i][j].fi--;
    }
  }

  int mx = 0;
  rep(i, 1 << n) {
    bool ok = true;

    rep(j, n) {
      if (i >> j & 1) {
        for (auto& k : v[j]) {
          if ((i >> k.fi & 1) != k.se) ok = false;
        }
      }
    }

    if (ok) mx = max(mx, __builtin_popcount(i));
  }
  cout << mx;

  return 0;
}


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

int main(void)
{
    while(true) {
        int h, w;
        cin >> h >> w;
        if (h==0 && w==0)
            break;
        for (int i = 0; i < h; ++i)
            cout << string(w, '#') << endl;
        cout << endl;
    }
    return 0;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) (a.begin(), a.end())

int main(){
    int n,m,l;
    cin >> n >> m >> l;
    long long a[n][m], b[m][l];
    rep(i,n)rep(j,m)cin >> a[i][j];
    rep(i,m)rep(j,l)cin >> b[i][j];

    //printf("\n");
    rep(i,n){
        rep(j,l){
            long long c_ij = 0;
            rep(k,m)c_ij += a[i][k] * b[k][j];
            cout << c_ij;
            if(j < l-1)printf(" ");
        }
        printf("\n");
    }

    return 0;
}



Measured memory_bytes: 3220
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
using namespace std;



int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; ++i) {
      int val;
      cin >> val;
      vec[i] = val;
    }

    int ans = 0;

    while (true) {
        bool odd = false;
        for (int i = 0; i < N; ++i) {
            if (vec[i] % 2 != 0) odd = true;
        }

        if (odd) break;

        for (int i = 0; i < N; ++i) {vec[i] /= 2;}
        ++ans;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class168
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            long[] A = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long[] B = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long sum = 0;
            for(int i = 0; i < N; i++)
            {
                if (B[i] >= A[i])
                {
                    sum += A[i];
                    B[i] -= A[i];
                    sum += Math.Min(B[i], A[i+1]);
                    A[i + 1] -= B[i];
                    if (A[i + 1] < 0) A[i + 1] = 0;
                }
                else
                {
                    sum += B[i];
                }
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 37808
n=int(input())
arr=[input() for _ in range(3)]
ans=0
for i in range(n):
  if arr[0][i]==arr[1][i] and arr[1][i]==arr[2][i]:
    tmp=0
  elif arr[0][i]==arr[1][i] or arr[1][i]==arr[2][i] or arr[2][i]==arr[0][i]:
    tmp=1
  else:
    tmp=2
  ans+=tmp
print(ans)

Measured memory_bytes: 3064
import sys
def input():
    return sys.stdin.readline()[:-1]
sys.setrecursionlimit(200000)
N=int(input())
S = [list(map(int, input().split()))+[i] for i in range(N-1)]
A=[None]*(N-1)
l=[[] for i in range(N+1)]
t=[0]*N
t[0]=1
for i in S:
    l[i[0]].append((i[1],i[2]))
    l[i[1]].append((i[0],i[2]))
def haba(o,c):
    p=1
    for i in l[o]:
        if t[i[0]-1]==0:
            if c==p:
                p+=1
            A[i[1]]=p
            t[i[0]-1]=1
            haba(i[0],p)
            p+=1
haba(1,0)
print(max(A))
print(*A,sep="\n")

Measured memory_bytes: 103516
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n, k;
        cin >> n >> k;
        if(n == 0)
            return 0;

        vector<int> blood(k);
        for(int i=0; i<k; ++i)
            cin >> blood[i];

        for(int i=0; i<n; ++i){
            for(int j=0; j<k; ++j){
                int tmp;
                cin >> tmp;
                blood[j] -= tmp;
            }
        }

        if(*(min_element(blood.begin(), blood.end())) < 0)
            cout << "No" << endl;
        else
            cout << "Yes" << endl;
    }
}

Measured memory_bytes: 892
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
int MOD = 1000000007;

int main() {
	int a, b; cin >> a >> b;
	if (a < b) cout << "a < b" << endl;
	if (a > b) cout << "a > b" << endl;
	if (a == b) cout << "a == b" << endl;
}

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

using namespace std;

bool DP[100005];
char S[100005];

int main() {
    string str;
    cin >> str;
    int n = str.size();
    for (int i = 1; i <= n; ++i) {
    	S[i] = str[i - 1];
    	DP[i] = false;
    }
    DP[0] = true;
    for (int i = 5; i <= n; ++i) {
    	if (DP[i - 5] && S[i - 4] == 'd' && S[i - 3] == 'r' && S[i - 2] == 'e' && S[i - 1] == 'a' && S[i] == 'm') DP[i] = true;
    	if (DP[i - 5] && S[i - 4] == 'e' && S[i - 3] == 'r' && S[i - 2] == 'a' && S[i - 1] == 's' && S[i] == 'e') DP[i] = true;
    	if (i >= 6) {
    		if (DP[i - 6] && S[i - 5] == 'e' && S[i - 4] == 'r' && S[i - 3] == 'a' && S[i - 2] == 's' && S[i - 1] == 'e' && S[i] == 'r') DP[i] = true;
    	}
    	if (i >= 7) {
    		if (DP[i - 7] && S[i - 6] == 'd' && S[i - 5] == 'r' && S[i - 4] == 'e' && S[i - 3] == 'a' && S[i - 2] == 'm' && S[i - 1] == 'e' && S[i] == 'r') DP[i] = true;
    	}
    }
    if (DP[n]) cout << "YES";
    else cout << "NO";	
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
    using namespace std;
    #define MAXN 400005
    #define MOD 998244353
    #define LL long long int
    LL ans,res,C[MAXN],fac[MAXN],revfac[MAXN];
    int n,m,k;
    LL qpow(LL a,int b)
    {
        LL tmp=1;
        while(b)
        {
            if(b&1)
            tmp=tmp*a%MOD;
            a=a*a%MOD;
            b>>=1;
        }
        return tmp;
    }
    void facrev()
    {
        C[0]=1;
        C[1]=(n-1);
        fac[1]=1;
        for(int i=2;i<=n;i++)
        {
            fac[i]=fac[i-1]*i%MOD;
            C[i]=C[i-1]*(n-i)%MOD;
        }
        revfac[n]=qpow(fac[n],MOD-2);
        for(int i=n-1;i>=1;i--)
        revfac[i]=revfac[i+1]*(i+1)%MOD,C[i]=C[i]*revfac[i]%MOD;
    }
    int main()
    {
        scanf("%d%d%d",&n,&m,&k);
        facrev();
        int p=n-k;
        res=m;
        for(int i=1;i<=p-1;i++)
        {
            res=res*(m-1)%MOD;
        }
        ans=res*C[p-1]%MOD;
        for(int j=p+1;j<=n;j++)
        {
            res=res*(m-1)%MOD;
            ans=(ans+res*C[j-1]%MOD)%MOD;
        }
        printf("%lld\n",ans);
        return 0;
    }

Measured memory_bytes: 8520
#include<cstdio>
#include<cctype>
using namespace std;

int main(){
  char ch;

  while(1){
    scanf("%c", &ch);
    if ( ch == '\n' ) break;
    if ( islower(ch) ) printf("%c", toupper(ch));
    if ( isupper(ch) ) printf("%c", tolower(ch));
    if ( !isalpha(ch) ) printf("%c", ch);
  }
  printf("\n");

  return 0;
}


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

int main() {
  int n, k;
  cin >> n >> k;
  long double sum = 0;
  long long score, cnt;
  for (int i = 0; i < n; i++) {
    score = i + 1;
    cnt = 0;
    while (score < k) {
      score *= 2;
      cnt++;
    }
    sum += pow(0.5, cnt) / n;
  }
  cout << fixed << setprecision(10) << sum << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		String [] a = new String[h];
		for(int n = 0;n < h;n++) {
			a[n] = sc.next();
		}
		for(int n = 0;n < w+2;n++) System.out.print("#");
			System.out.println("");
		for(int n = 0;n < h;n++) System.out.println("#" + a[n] + "#");
		for(int n = 0;n < w + 2;n++)System.out.print("#");
	}
}


Measured memory_bytes: 23124
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;

long long cnt;
int A[1000000];
int n;
vector<int> G;

    void insertionSort(int A[],int n,int g){
      for(int i = g;i < n;i++){
        int v = A[i];
        int j = i - g;
        while(j >= 0 && A[j] > v){
            A[j + g] = A[j];
            j -= g;
            cnt++;
        }
        A[j + g] = v;
      }
    }
    void shellSort(int A[],int n){
      for(int h = 1;;){
        if(h > n){
            break;
        }
        G.push_back(h);
        h = 3 * h + 1;
      }
      for(int i = G.size() - 1;i >= 0;i--){
        insertionSort(A,n,G[i]);
      }
    }
    int main(){
       cin >> n;
       for(int i = 0;i < n;i++){
          scanf("%d",&A[i]);
       }
       cnt = 0;
       shellSort(A,n);
       cout << G.size() << endl;
       for(int i = G.size() - 1;i >= 0;i--){
         printf("%d",G[i]);
         if(i)
            printf(" ");
      }
      printf("\n");
      printf("%d\n",cnt);
      for(int i = 0;i < n;i++){
        printf("%d\n",A[i]);
      }
       return 0;
}


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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int T, N;
int t[32];
int M[128];
int dp[32][128];

int dfs(int n, int d){
  if(d==100) return 0;
  int &res = dp[n][d];
  if(res >= 0) return res;
  //  if(d<=N) cout << n << " " << d << endl;
  res = INF;
  if(t[n] <= M[d]) res = min(res, dfs((n+1)%T, d+1));
  res = min(res, dfs(1, d+1)+1);
  return res;
}

int main(){
  while(scanf("%d", &T) && T){
    memset(dp, -1, sizeof(dp));
    fill(M, M+100, 24);
    rep(i,T) scanf("%d", t+i);
    scanf("%d",&N);
    rep(i,N){
      int t,m;
      scanf("%d%d", &t,&m); t--;
      M[t] = min(M[t],m);
    }

    printf("%d\n", dfs(0, 0));
  }
  return 0;
}

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

ll solve() {
    ll N, K, S, SMAX = 1e9;
    cin >> N >> K >> S;
    vector<ll> a;
    for ( int i = 0; i < N; i++ ) {
        if ( i < K ) a.push_back(S);
        else {
            if ( S == SMAX ) {
                a.push_back(S-1);
            } else {
                a.push_back(S+1);
            }
        }
    }
    for ( int i = 0; i < N; i++ ) {
        cout << (i != 0 ? " " : "") << a[i];
    }
    cout << "\n";
    return 0;
}

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

Measured memory_bytes: 2164
#include <cstdio>

typedef long long lint;

int abs(int num) { return num > 0 ? num : -num; }
int main()
{
	int n;
	scanf("%d", &n);

	int arr[200000];
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", arr + i);
		if (i && arr[i] - arr[i - 1] > 1) return !printf("-1");
	}

	if (arr[0] != 0) return !printf("-1");

	lint ans = 0;
	for (int i = 1; i < n; ++i)
	{
		if (arr[i] == arr[i - 1] + 1) ++ans;
		else ans += arr[i];
	}

	printf("%lld", ans);

	return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();sc.nextLine();
		while(t--!=0)System.out.println(sc.nextLine().replaceAll("Hoshino", "Hoshina"));
	}
}

Measured memory_bytes: 17304
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		string str = Console.ReadLine();
		string ans = "Yes";
		if(N%2==1){
			ans = "No";
		} else if(str.Substring(0,N/2)!=str.Substring(N/2,N/2)){
			ans = "No";
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13140
#include <iostream>
 
using namespace std;
 
int main(void) {
    string s;
    cin >> s;

    if(s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }
 
    return 0;
}

Measured memory_bytes: 3628
n = gets.to_i
table = []
table2 = []
exhausted = {}

n.times do |index|
  a = gets.chomp.split(" ").map(&:to_i)
  table << [a[0] + a[1], index, a[0]]
  table2 << [a[1] + a[0], index, a[1]]
end

table.sort_by!{|k| [-k[0], -k[2]]}
table2.sort_by!{|k| [-k[0], -k[2]]}
#table2.reverse!
total = 0

table_idx = 0
table2_idx = 0

#p table
#p table2

for i in 0..n-1
  if i.even?
    while exhausted[table[table_idx][1]]
      table_idx += 1
    end
    exhausted[table[table_idx][1]] = 1
    total += table[table_idx][2]
  else
    while exhausted[table2[table2_idx][1]]
      table2_idx += 1
    end
    exhausted[table2[table2_idx][1]] = 1
    total -= table2[table2_idx][2]
  end
  #p [table_idx, table2_idx]
  #p exhausted
end

puts total

Measured memory_bytes: 26416
#include <stdio.h>

int main(void) {

  int nocolor=0,dark=0;

  int map[10][10];

  int x,y,size;
  int nx,ny;
  int dx[12]={1,0,-1,0,1,-1,-1,1,2,0,-2,0};
  int dy[12]={0,1,0,-1,1,1,-1,-1,0,2,0,-2};

  int i;

  for(x=0;x<10;x++) for(y=0;y<10;y++) map[x][y]=0;

  //for(x=0;x<10;x++) for(y=0;y<10;y++) printf("%d ",map[x][y]);
  
  while(scanf("%d,%d,%d",&x,&y,&size)!=EOF) {

    switch(size) {

    case 1:
      
      map[x][y]++;

      for(i=0;i<4;i++) {

	nx=x+dx[i];
	ny=y+dy[i];

	if(nx>=0 && nx<10 && ny>=0 && ny<10) map[nx][ny]++;

      }

      break;

    case 2:

      map[x][y]++;

      for(i=0;i<8;i++) {

	nx=x+dx[i];
	ny=y+dy[i];

	if(nx>=0 && nx<10 && ny>=0 && ny<10) map[nx][ny]++;

      }

      break;

    case 3:

      map[x][y]++;

      for(i=0;i<12;i++) {

	nx=x+dx[i];
	ny=y+dy[i];

	if(nx>=0 && nx<10 && ny>=0 && ny<10) map[nx][ny]++;

      }

      break;

    }

  }

  for(x=0;x<10;x++) {

    for(y=0;y<10;y++) {

      if(map[x][y]==0) nocolor++;

      if(dark<map[x][y]) dark=map[x][y];

    }

  }

  printf("%d\n%d\n",nocolor,dark);

  return 0;

}

Measured memory_bytes: 0
#include<iostream>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

struct st{
  double v,w;
  bool operator<(const st & a)const{
    return v/w < a.v/a.w;
  }
  bool operator>(const st & a)const{
    return v/w > a.v/a.w;
  }
};

double solve(double w,vector<st> & pos,vector<st> & neg){
  double posx=0;/*ppが指しているものweight*/
  double negx=1;
  double ret = 0;
  int pp = 0,np = 0;
  while(pp < pos.size() && w > 0){
    double tx = min(1.0,w/pos[pp].w);
    ret += pos[pp].v * tx;
    w -= tx * pos[pp].w;
    if (w < 1e-10){
      posx = 1-tx;
      break;
    }
    else pp++;
  }
  if (posx < 1e-10)pp++,posx = 1;
  //cout << "pp : " << ret <<" "<< posx << endl;

  while(pp < pos.size() && np < neg.size()){
    /*posxを詰め込むために必要なw。*/
    double pw = posx * pos[pp].w;
    /*negxによって、開けることができるw。*/
    double gw = negx * -neg[np].w;
    double used = min(pw,gw);
    double px = used/pos[pp].w;
    double gx = used/-neg[np].w;
    if (px * pos[pp].v < gx * -neg[np].v)break;/*これ以上は、負/負のものを使っても価値が増えることはない。*/
    ret += px * pos[pp].v;
    ret += gx * neg[np].v;

    posx -= px;
    negx -= gx;

    if (posx < 1e-10)pp++,posx = 1;
    if (negx < 1e-10)np++,negx = 1;
  }
  return ret;
}

main(){
  int n,w;
  while(cin>>n>>w && n){
    double ans=0,wlim = w;
    vector<st> pos,neg;
    rep(i,n){
      double tw,tv;
      cin>>tw>>tv;
      if (tw <= 0 && tv >= 0){//全部使って良い
	w -= tw;
	ans += tv;
      }else if (0 < tw && tv <= 0){//一つも使わない。
      }else if (tw >= 0 && tv > 0){//
	pos.push_back((st){tv,tw});
      }else if (tw < 0 && tv <= 0){
	neg.push_back((st){tv,tw});
      }
    }
    sort(pos.begin(),pos.end(),greater<st>());
    sort(neg.begin(),neg.end());
    //rep(i,pos.size())cout << pos[i].w <<" " << pos[i].v << endl;
    double tmp = solve(w,pos,neg);
    printf("%.10lf\n",tmp+ans);
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

template <typename S>
vector<int64_t> prekmp(const S& w) {
    int64_t m = w.size();

    // t[k] = max_{t<k} w[k-t:k] == w[0:t]
    vector<int64_t> t(m + 1, -1);

    t[1] = 0;
    int64_t i = 1, j = 1;
    while (j < m) {
        assert(i <= j);
        // assert(w.substr(i, j - i) == w.substr(0, j - i));
        if (w[j] == w[j - i]) {
            ++j;
            // assert(w[i:j] == w[0:j-i])
            t[j] = j - i;
        } else if (i == j) {
            ++i;
            ++j;
            t[j] = 0;
        } else {
            // w[j-t[j-i]:j] == w[j-i-t[j-i]:j-i] ==w[0:t[j-i]]
            i = j - t[j - i];  // > i
        }
    }

    return t;
}

template <typename S>
int64_t kmp(const S& s, const S& w, const vector<int64_t>& t, int64_t i,
            int64_t j) {
    int64_t n = s.size(), m = w.size();

    while (i < n) {
        assert(i <= j);
        assert(j - i < m);
        // assert(s.substr(i, j - i) == w.substr(0, j - i));
        if (s[j % n] == w[j - i]) {
            ++j;
            if (j - i == m) {
                return i;
            }
        } else if (i == j) {
            ++i;
            ++j;
        } else {
            // s[j-t[j-i]:j] == w[j-i-t[j-i]:j-i] ==w[0:t[j-i]]
            i = j - t[j - i];  // > i
        }
    }

    return -1;
}

template <typename S>
int64_t kmp(const S& s, const S& w, const vector<int64_t>& t, int64_t i) {
    if (i == -1) {
        return kmp(s, w, t, 0, 0);
    } else {
        int64_t m = w.size();
        return kmp(s, w, t, i + m - t[m], i + m);
    }
}

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

    vector<uint64_t> a(n), b(n);
    for (auto i : irange(0L, n)) {
        cin >> a[i];
    }
    for (auto i : irange(0L, n)) {
        cin >> b[i];
    }

    vector<uint64_t> c(n), d(n);
    for (auto i : irange(0L, n)) {
        c[i] = (a[i] ^ a[(i + 1) % n]);
        d[i] = (b[i] ^ b[(i + 1) % n]);
    }

    vector<int64_t> k;
    int64_t idx = -1;
    const auto& t = prekmp(d);
    while ((idx = kmp(c, d, t, idx)) >= 0) {
        k.push_back(idx);
    }

    for (auto kk : k) {
        cout << kk << " " << (a[kk] ^ b[0]) << "\n";
    }
}

Measured memory_bytes: 12912
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
int a[maxn];
int dp[maxn];		//dp[i]:´ÓÆðµãµ½iµÄ×îÐ¡·ÑÓÃ 

int main() {
	int n,k;cin>>n>>k;
	for(int i = 1;i <= n;i++) cin>>a[i];
	dp[1] = 0;
	dp[2] = abs(a[2] - a[1]);
	for(int i = 3;i <= n;i++) {
		dp[i] = 1e9;		//ÐèÒª½«dp[i]¶¨ÒåÎªÒ»¸öºÜ´óµÄÖµ£¬ÀàËÆÓÚÇóMin,minÒªÉèÖÃÎªºÜ´ó 
		for(int j = 1;j <= k;j++) {
			if(i - j >= 1) {
				dp[i] = min(dp[i],dp[i-j] + abs(a[i] - a[i-j]));
			} else 
				break;
		}
	}
	cout<<dp[n];
	return 0;
}

Measured memory_bytes: 1024
def main(input = STDIN)
  while (args = input.gets.split(" ").map(&:to_i)) != [-1, -1, -1]
    remain = 120 * 60 - hms_to_sec(*args)
    puts sec_to_str(remain), sec_to_str(remain * 3)
  end
end
def hms_to_sec(h, m, s)
  return (h * 60 + m) * 60 + s
end
def sec_to_str(second)
  output = []
  3.times do
    output << (second % 60).to_s.rjust(2, "0")
    second /= 60
  end
  return output.reverse.join(":")
end
main

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> G[N];
    map<pair<ll, ll>, ll> eColor;
    vector<pair<ll, ll>> edge;
    REP(i, N - 1)
    {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
        edge.push_back(make_pair(a, b));
    }

    ll maxV = 0;
    REP(i, N) maxV = max(maxV, (ll)G[i].size());
    vector<ll> vColor(N, -1);
    queue<ll> q;
    vector<bool> visited(N, false);
    q.push(0);
    while(!q.empty())
    {
        ll v = q.front();
        q.pop();
        visited[v] = true;
        ll paintColor;
        if (vColor[v] != -1)
        {
            paintColor = (vColor[v] + 1) % maxV;
        }
        else
        {
            paintColor = 0;
        }
        REPV(iter, G[v])
        {
            if (!visited[*iter])
            {
                q.push(*iter);
                pair<ll, ll> e = make_pair(min(v, *iter), max(v, *iter));
                eColor[e] = paintColor;
                vColor[*iter] = paintColor;
                paintColor = (paintColor + 1) % maxV;
            }
        }
    }

    cout << maxV << endl;
    REP(i, N - 1) cout << eColor[edge[i]] + 1 << endl;
}


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

enum value{
    A = 10,
    B = 11,
    C = 12,
    D = 13,
    E = 14,
    F = 15
};

value number(char a){
    if(a == 'A'){
        return A;
    } else if(a =='B'){
        return B;
    } else if(a == 'C'){
        return C;
    } else if(a == 'D'){
        return D;
    } else if(a == 'E'){
        return E;
    } else {
        return F;
    }
}

int main(){
    char x, y;
    cin >> x >> y;

    int num_x = number(x);
    int num_y = number(y);

    if(num_x == num_y){
        cout << '=' << endl;
    } else if(num_x > num_y){
        cout << '>' << endl;
    } else {
        cout << '<' << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#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 order_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll         long long int
#define endl       '\n'
#define pii        pair <int, int>
#define mk         make_pair

static const int maxn = 3e5 + 5;
static const int logn = 19;

signed main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(nullptr);
      int n, q;
      cin >> n >> q;
      set <int> st;
      while (q--) {
            int d;
            cin >> d;
            for (int i = 0; i < d; i++) {
                  int x;
                  cin >> x;
                  st.insert(x);
            }
      }
      cout << n - st.size() << endl;
}


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

const ll infll=9223372036854775806;
const int inf=2147483646;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int i,j,n,k,ans=0;
	string a;
	cin>>n>>k>>a;
	vector<pair<int,int>> g;
	g.push_back(make_pair(0,0));
	for (i=0;i<a.size();i++){
		if (a[i]=='0'){
			j=i;
			while (a[j]=='0'&&j<a.size()){
				j++;
			}
			g.push_back(make_pair(i,j));
			i=j;
		}
	}
	g.push_back(make_pair(a.size(),a.size()));
	if (g.size()-1<=k){
		cout<<a.size();
	}
	else {
		for (i=k+1;i<g.size();i++){
			ans=max(ans,g[i].first-g[i-k-1].second);
		}
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 1020
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
const int mod = 1000000007;
#define ll long long

struct UnionFind {
	vector<int> par;
	UnionFind(int x) : par(x, -1) {}
	void init(int x) { par.assign(x, -1); }
	int root(int x) {
		if (par[x] <= -1) return x;
		else return root(par[x]);
	}
	bool issame(int x, int y) {
		return root(x) == root(y);
	}
	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}
	int size(int x) {
		return -par[root(x)];
	}
};
int A[100010], B[100010];
ll ans[100010];

int main()
{
	int N, M;
	cin >> N >> M;
	UnionFind G(N);
	G.init(N);
	for (int i = 0; i < M; i++) {
		cin >> A[i] >> B[i];
		A[i]--; B[i]--;
	}
	ans[M - 1] = (ll)N * (N - 1) / 2;
	for (int i = M - 1; i > 0; i--) {
		int down = 0;
		if (!G.issame(A[i],B[i])) {
			down = (ll)G.size(A[i]) * G.size(B[i]);
		}
		G.merge(A[i], B[i]);
		ans[i - 1] = ans[i] - down;
	}
	for (int i = 0; i < M; i++) {
		cout << ans[i] << endl;
	}
}


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

template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set
    
    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

int main() {
    int N,Q; cin >> N >> Q;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];
    vector<int> lefts(Q), rights(Q), ids(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> lefts[i] >> rights[i];
        --lefts[i];
        ids[i] = i;
    }
    sort(ids.begin(), ids.end(), [&](int i, int j) {
            return rights[i] < rights[j];});

    BIT<int> bit(N+5);
    vector<int> prev(1100000, -1);
    vector<int> res(Q, 0);
    int r = 0;
    for (auto i : ids) {
        for (; r < rights[i]; ++r) {
            bit.add(prev[a[r]]+2, r+2, 1);
            prev[a[r]] = r;
        }
        int tmp = bit.sum(lefts[i]+1, lefts[i]+2);
        res[i] = max(res[i], tmp);
    }
    for (int i = 0; i < Q; ++i) cout << res[i] << endl;
}

Measured memory_bytes: 21728
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
using namespace std;
using ll = long long;
const int INF = 999999999;

int main() {
    int A, B, C; cin >> A >> B >> C;
    cout << B * (C / A);
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <queue>
#include <stack>
#include <set>
#include <cmath>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<#a<<':'<<a<<endl

const ll INF = 1e9+7;

template<typename T>inline T digit(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n;cin>>n;
  vector<int> d(n);rep(i,n)cin>>d[i];
  ll ans = 0;
  rep(i,n){
    for(int j = i + 1;j < n;++j){
      ans += d[i] * d[j];
    }
  }
  print(ans);
  return 0;
} 

Measured memory_bytes: 256
n=int(input())
hi=[int(i) for i in input().split(" ")]
pre=hi[0]
flag=0
if n==0:
    print("Yes")
for i in range(n-1):
    if hi[i+1] < pre-1:
        flag = 1
        break
    if hi[i+1] == pre-1:
        pre = hi[i+1]+1
    else:
        pre = hi[i+1]
if flag==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

i64 dp[101][5][5][5];

int main() {
	int n; scanf("%d", &n);
	
	dp[0][0][0][0] = 1;
	const int MOD = 1e9 + 7;
	for(int i = 0; i < n; i++) {
		for(int A = 0; A < 5; A++) {
			for(int B = 0; B < 5; B++) {
				for(int C = 0; C < 5; C++) {
					for(int D = 1; D < 5; D++) {
						if(A == 1 and B == 3 and D == 2) continue;
						if(A == 1 and C == 3 and D == 2) continue;
						
						if(B == 1 and C == 3 and D == 2) continue;
						if(B == 3 and C == 1 and D == 2) continue;
						if(B == 1 and C == 2 and D == 3) continue;
						
						dp[i + 1][B][C][D] += dp[i][A][B][C];
						dp[i + 1][B][C][D] %= MOD;
					}
				}
			}
		}
	}
	
	i64 ans = 0;
	for(int A = 0; A < 5; A++) {
		for(int B = 0; B < 5; B++) {
			for(int C = 0; C < 5; C++) {
				ans += dp[n][A][B][C];
				ans %= MOD;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 384
N, Q = map(int, input().split())
s = input()
a = [0] * (N + 1)

for i in range(N):
	a[i + 1] = a[i] + (1 if s[i : i + 2] == "AC" else 0)
for i in range(Q):
	l, r = map(int, input().split())
	print(a[r - 1] - a[l - 1])



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,A,B;
const ll mo=1000000007;

ll modpow(ll a, ll n=mo-2) {
	ll r=1;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

ll comb(int P_,int Q_) {
	if(P_<0 || Q_<0 || Q_>P_) return 0;
	ll p=1,q=1;
	Q_=min(Q_,P_-Q_);
	for(int i=1;i<=Q_;i++) p=p*P_%mo, q=q*i%mo,P_--;
	
	return p*modpow(q,mo-2)%mo;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>A>>B;
	
	ll ret=modpow(2,N) - comb(N,A) - comb(N,B) - 1;
	cout<<(ret%mo+mo)%mo<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

using namespace std;

int main() {
    long long int n;
    cin >> n;
    long long int ans = 1000000000000;
    for(long long int i = 1; i <= sqrt(n); i++) {
        if(n % i == 0){
            if((i - 1) + ((n / i) - 1) < ans) {
                ans = (i - 1) + ((n / i) - 1);
            }
        }
    }
    cout<<ans << endl;
}


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

using namespace std;
#define int long long int
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define vi vector <int>
#define sz(s) (int)s.size()
#define pii pair<int,int>
#define piii pair< int,pair<int,int> >
#define tiii tuple <int,int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define rall(v) v.rbegin(),v.rend()
#define endl '\n'
#define matrix vector <vector <int> >
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define NAYAN freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define N 500006
#define mod 1000000007
#define mod2 998244353
#define inf 1e18

int dp[102][100001];


int32_t main()  
{
    boost
    // #ifndef ONLINE_JUDGE 
    // NAYAN
    // #endif
    
    int n,W;

    cin >> n >> W;

    
    memset(dp,0,sizeof dp);
    int i,j;
    int w[n+1],v[n+1];
    for(i=1;i<=n;i++)
    {
        cin >> w[i] >> v[i];
    }

    

    for(i=1;i<=n;i++)
    {
        for(j=1;j<=W;j++)
        {
            if(j>=w[i])
            {
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
            }
            else
            {
                dp[i][j]=dp[i-1][j];
            }
        }
    }

    cout << dp[n][W] << endl;


}

Measured memory_bytes: 80000
import numpy as np

N = int(input())
a = [int(_) for _ in input().split()]
List = np.array([])
tmp = 0
cnt = 0

for i in a:
    if i == tmp:
        cnt += 1
    else:
        List = np.append(List,cnt)
        cnt = 1
        tmp = i
List = np.append(List,cnt)

print(int(sum(List//2)))

Measured memory_bytes: 22048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,-1,sizeof(x))
const int INF = 1000000001;

int main(){
  int a, b, x;
  cin >> a >> b >> x;
  if(a<=x && x<=a+b) cout << "YES" <<endl;
  else cout << "NO"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  long A, B, C, D;
  cin >> A >> B >> C >> D;
  long lc = (C / __gcd(C, D))* D;
  A--;
  cout << B - A - (B / C - A / C + B / D - A / D - (B / lc - A / lc)) << endl;
  return 0;
}

Measured memory_bytes: 256
/*
 * ITP1_6_D.cpp
 *
 *  Created on: 2016/05/19
 *      Author: suna
 */

#include <iostream>

using namespace std;

int main(void)
{
	int row;		//???
	int column;		//???
	int vector_A[100][100] = {};
	int vector_B[100] = {};
	int vector_C[100] = {};

	cin >> row >> column;

	//Initialization
	for(int i = 0; i < row; i++)
	{
		for(int j = 0; j < column; j++)
		{
			cin >> vector_A[i][j];
		}
	}

	for(int j = 0; j < column; j++)
	{
		cin >> vector_B[j];
	}

	//Multiplication
	for(int i = 0; i < row; i++)
	{
		for(int j = 0; j < column; j++)
		{
			vector_C[i] += vector_A[i][j] * vector_B[j];
		}
	}

	//Output
	for(int i = 0; i < row; i++)
	{
		cout << vector_C[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1208
X = list(map(int,input().split()))

X.sort()
fir = (X[2]-X[1])%2
sec = (X[2]-X[0])%2
if (fir == 0 and sec == 0):
	ans = (X[2]-X[1])//2+(X[2]-X[0])//2
elif (fir == 1 and sec == 1):
	ans = (X[2]-X[1])//2+(X[2]-X[0])//2+1
else:
	ans = (X[2]-X[1])//2+(X[2]-X[0])//2+2

print(ans)

Measured memory_bytes: 3064
from math import sqrt
def main():
    n,d = map(int,input().split())
    XY = [list(map(int,input().split())) for _ in range(n)]

    ans = 0
    for x,y in XY:
        if sqrt(x**2 + y**2) <= d:
            ans += 1
    print(ans)
    return 

if __name__ == "__main__":
    main()

Measured memory_bytes: 45384
N = int(input())
C = [0] * N
S = [0] * N
F = [0] * N
for i in range(N-1):
	C[i], S[i], F[i] = map(int, input().split())

def calc_time(i,t):
	global C,S,F

	res = 0
	if t < S[i]:
		res = S[i]
	elif t % F[i] == 0:
		res = t
	else:
		res = (t + F[i]) - (t % F[i])
	res += C[i]

	return res

ans = [[0 for i in range(N)] for _ in range(N)]
for i in range(N-1):
	for j in range(i,N-1):
		if j == 0:
			ans[i][j] = calc_time(j, 0)
		else:
			ans[i][j] = calc_time(j, ans[i][j-1])

for i in range(N):
	print(ans[i][N-2])

Measured memory_bytes: 9204
use proconio::input;
use proconio::marker::Usize1;
use std::collections::BTreeSet;

fn main() {
   input! {
      dn: usize,
      c: [i64; 26],
      s: [[i64;26]; dn],
      mut t: [Usize1; dn],
      m: usize,
      dq: [(Usize1, Usize1); m]
   }

   let mut score = 0;
   let mut last = vec![BTreeSet::new(); 26];
   for i in 0..26 {
      last[i].insert(0);
      last[i].insert(dn + 1);
   }
   for (d, &t) in t.iter().enumerate() {
      score += s[d][t];
      last[t].insert(d + 1);
      for i in 0..26 {
         if i != t {
            score -= c[i] * (d + 1 - last[i].range(..=d + 1).rev().next().unwrap()) as i64;
         }
      }
   }
   for &(d, q) in dq.iter() {
      if t[d] == q {
         continue;
      }
      let p = t[d];
      t[d] = q;
      score -= s[d][p];
      score += s[d][q];
      last[p].remove(&(d + 1));
      last[q].insert(d + 1);
      let f1 = last[p].range(..=d).rev().next().unwrap();
      let b1 = last[p].range(d + 2..).next().unwrap();
      let f2 = last[q].range(..=d).rev().next().unwrap();
      let b2 = last[q].range(d + 2..).next().unwrap();
      score -= c[p] * (d + 1 - f1) as i64 * (b1 - (d + 1)) as i64;
      score += c[q] * (d + 1 - f2) as i64 * (b2 - (d + 1)) as i64;
      println!("{}", score);
   }
}


Measured memory_bytes: 4500