akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <functional>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
using namespace std;
// #define int long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = (((1<<30)-1)<<1)+1;
const int nINF = 1<<31;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, int> pci;

/////////////////////////////////////////////////////////////////////

int a[2];
char c;

signed main() {
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(7);
    while(cin >> c) ++a[c-'0'];
    cout << 2*min(a[0], a[1]) << endl;

    return 0;
}

// Easy things to check:
// - LONG LONGS (WA)
// - const int N is correct (WA, RTE)
// - .size()-k underflow (WA, RTE, TLE)
// - small n edge cases (WA)

// Rare mistakes made in the past:
// - division by 0 (WA)
// - integer division (WA)
// - setprecision (WA)
// - INF not big enough using ll (WA)
// - setting max to 0 instead of -INF/min to 0 instead of INF (WA)
// - outputting debug (WA)
// - allocating too much memory (locRTE, MLE)
// - stack size (locRTE)
// - round announcements (WA)
// - multiset::erase (WA)



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
int main() {
   long long a,b,k;
   cin >> a >> b >> k;
   if(k <= a){
       cout << a - k << " " << b << endl;
   }else if(k <= a + b){
       cout << 0 << " " << b - (k - a) << endl;
   }else{
       cout << 0 << " " << 0 << endl;
   }
   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793



int main(){
  string S; cin >> S; bool ans = false;
  rep(i, 3){
    if(S[i]=='7') ans = true;
  }
  if(ans){
    cout << "Yes" << endl; return 0;
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(void){
ios_base::sync_with_stdio(false);
cin.tie(NULL);

int a,b,c,d;    cin>>a>>b>>c>>d;

while(a>0 && c>0)
{
   c=c-b; if (c<=0) {cout<<"Yes"<<endl; break;}
   a=a-d; if (a<=0) {cout<<"No"<<endl; break;}

}










return 0;}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

typedef long long ll;

using namespace std;

int main(int argc , char *argv[]) {
    int r, d, x2000;

    cin >> r >> d >> x2000;

    for(int i = 0 ; i < 10 ; i++) {
        x2000 *= r;
        x2000 -= d;
        cout << x2000 << endl;
    }
    return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << endl;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, pair<vector<T>&, int> v) {
	while (v.second--) {
		T a;
		v.first.push_back(is >> a, a);
	}
	return (is);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

int main() {
	int H, W, K;
	int dp[105][8] = {};

	cin >> H >> W >> K;
	dp[0][0] = 1;

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			for (int bit = 0; bit < (1 << (W - 1)); bit++) {
				bool flag = false;
				for (int k = 0; k < W - 2; k++) {
					if (((bit >> k) & 1) && (bit >> (k + 1)) & 1) flag = true;
				}
				if (flag) continue;
				if (j > 0 && ((bit >> (j - 1)) & 1)) {
					(dp[i + 1][j - 1] += dp[i][j]) %= mod;
				} else if (j < W - 1 && ((bit >> j) & 1)) {
					(dp[i + 1][j + 1] += dp[i][j]) %= mod;
				} else {
					(dp[i + 1][j] += dp[i][j]) %= mod;
				}
			}
		}
	}

	cout << dp[H][K - 1] << endl;
	return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep_1(i, n) for (int(i) = 0; (i) <= (n); (i)++)
#define rep_2(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  ll sum = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      sum += d[i] * d[j];
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
# https://beta.atcoder.jp/contests/abc101/tasks/abc101_a
# A - Eating Symbols Easy

# A_Eating_Symbols_Easy.py

num = 0
S = input()
for i in range(4):
    if S[i] == "+":
        num += 1
    else:
        num -= 1
print(num)


Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var abx = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            Console.WriteLine(abx[0] <= abx[2] && abx[0] + abx[1] >= abx[2] ? "YES" : "NO");
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)
#define add(x,y)(x=((ll)y+x)%mo)
#define ll long long
using namespace std;
const int N=105,mo=1e9+7;
int n,nn,v,ans;
int h[N],w[N],h2[N],f[N][N];
int ksm(int x,int y){
	int t=1;
	for(;y;y>>=1,x=(ll)x*x%mo)if(y&1)t=(ll)t*x%mo;
	return t;
}
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	fo(i,1,n)cin>>h[i],h2[i]=h[i];
	sort(h2+1,h2+n+1);
	nn=unique(h2+1,h2+n+1)-h2-1;
	f[0][0]=1;
	fo(i,1,n){
		w[i]=lower_bound(h2+1,h2+nn+1,h[i])-h2;
		if(v=f[i-1][0]){
			f[i][0]=(ll)v*2%mo;
			if(h[i-1]<h[i]){
				fo(j,w[i-1]+1,w[i]){
					if(j==1)f[i][j]=(ll)2*ksm(2,h[i]-h2[1])%mo*(ksm(2,h2[1]-1)-1)%mo;
					else f[i][j]=(ll)v*2*ksm(2,h[i]-h2[j])%mo*(ksm(2,h2[j]-h2[j-1])-1)%mo;
				}
			}	
		}
		int p;
		if(h[i-1]<h[i])p=ksm(2,h[i]-h[i-1]);
		fo(j,1,nn)if(v=f[i-1][j]){
			if(h[i-1]>=h[i]){
				if(j<=w[i])add(f[i][j],v);
				else add(f[i][0],v*2);
			}else{
				add(f[i][j],v*p);
			}
		}
	}
	fo(i,0,nn)add(ans,f[n][i]);
	cout<<ans;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
using namespace std;
const int maxn=2000+10;
char s[maxn];
int a[maxn],b[maxn],c[maxn],L[maxn],R[maxn];
bool bz[maxn];
int i,j,k,l,t,n,m,ans,num,sum,cnt,mx,mi,top;
bool czy,gjx;
bool cmpL(int x,int y){
    return L[x]<L[y];
}
bool cmpR(int x,int y){
    return R[x]<R[y];
}
int main(){
    scanf("%s",s+1);
    n=strlen(s+1);
    czy=1;
    fo(i,1,n){
        a[i]=s[i]-'0';
        if (a[i]) czy=0;
    }
    scanf("%s",s+1);
    gjx=1;
    fo(i,1,n){
        b[i]=s[i]-'0';
        if (b[i]) gjx=0;
    }
    if (gjx){
        if (czy) printf("0\n");else printf("-1\n");
        return 0;
    }
    fo(i,1,n){
        j=i;
        while (!b[j]){
            L[i]++;
            if (j==1) j=n;
            else j--;
        }
        j=i;
        while (!b[j]){
            R[i]++;
            if (j==n) j=1;
            else j++;
        }
    }
    ans=1000000000;
    fo(i,1,n){
        fo(j,1,n) bz[j]=0;
        sum=0;
        j=i;
        fo(k,1,n){
            if (a[j]!=b[k]) bz[j]=1,sum++;
            if (j==n) j=1;else j++;
        }
        cnt=(i==1?0:n-i+1);
        top=0;
        fo(j,1,n)
            if (bz[j]&&R[j]>cnt) c[++top]=j;
        sort(c+1,c+top+1,cmpL);
        mx=0;mi=5*n;
        if (top) mi=min(mi,L[c[top]]*2+cnt);
        fd(j,top,1){
            mx=max(mx,R[c[j]]);
            if (j>1) mi=min(mi,L[c[j-1]]*2+mx*2-cnt);
        }
        if (top) mi=min(mi,mx*2-cnt);
        if (!top) mi=cnt;
        num=mi;
        ans=min(ans,num+sum);
        cnt=i-1;
        top=0;
        fo(j,1,n)
            if (bz[j]&&L[j]>cnt) c[++top]=j;
        sort(c+1,c+top+1,cmpR);
        mx=0;mi=5*n;
        if (top) mi=min(mi,R[c[top]]*2+cnt);
        fd(j,top,1){
            mx=max(mx,L[c[j]]);
            if (j>1) mi=min(mi,R[c[j-1]]*2+mx*2-cnt);
        }
        if (top) mi=min(mi,mx*2-cnt);
        if (!top) mi=cnt;
        num=mi;
        ans=min(ans,num+sum);
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 256
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define int ll

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

const int N = 1e5 + 20 , inf = 3e18 ;
int n , x , y , z , a[N] , b[N] , c[N] ;
int ord[N] , l[N] , r[N] ;

inline bool cmp (int x , int y) {
	return c[x] - b[x] < c[y] - b[y] ;
}

int32_t main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;

	cin >> x >> y >> z ;
	n = x + y + z ;

	for (int i = 0 ; i < n ; i ++) cin >> a[i] >> b[i] >> c[i] ;

	iota(ord , ord + n , 0) ;
	sort(ord , ord + n , cmp) ;

	set <pii> st ;
	int sum = 0 ;

	for (int t = 0 ; t < n ; t ++) {
		int i = ord[t] ;

		sum += b[i] - a[i] ;
		st.insert({b[i] - a[i] , i}) ;

		if (_sz(st) > y) {
			pii p = *st.begin() ;
			st.erase(p) ;
			sum -= p.F ;
		}

		if (_sz(st) < y) l[t] = -inf ;
		else l[t] = sum ;
	}

	st.clear() ;
	sum = 0 ;

	for (int t = n - 1 ; t >= 0 ; t --) {
		int i = ord[t] ;

		if (t < n - 1) r[t] = r[t + 1] ;

		sum += c[i] - a[i] ;
		st.insert({c[i] - a[i] , i}) ;

		if (_sz(st) > z) {
			pii p = *st.begin() ;
			st.erase(p) ;
			sum -= p.F ;
		}

		if (_sz(st) < z) r[t] = -inf ;
		else r[t] = sum ;
	}

	int ans = -inf ;

	for (int i = 0 ; i < n - 1 ; i ++) ans = max(ans , l[i] + r[i + 1]) ;

	for (int i = 0 ; i < n ; i ++) ans += a[i] ;

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


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

int main() {
    int n;
    cin >> n;
    vector<int> vec(100000, 0);
    for(int i=1; i<=100; i++){
        for(int j=1; j<=100; j++){
            for(int k=1; k<=100; k++){
                vec[i*i+j*j+k*k+i*j+j*k+k*i]++;
            }
        }
    }
    for(int i=1; i<=n; i++) cout << vec[i] << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll N;
    cin >> N;
    ll AC=0,WA=0,TLE=0,RE=0;
    REP(i,N){
        string S;
        cin >> S;
        if(S == "WA"){
            WA++;
        }else if(S == "AC"){
            AC++;
        }else if(S == "TLE"){
            TLE++;
        }else{
            RE++;
        }
    }
    cout << "AC x " << AC << "\n";
    cout << "WA x " << WA << "\n";
    cout << "TLE x " << TLE << "\n";
    cout << "RE x " << RE << "\n";
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define fillarray(array, value, begin, end) fill((array) + (begin), (array) + (end) + 1, value)
#define fillvector(v, value) fill((v).begin(), (v).end(), value)
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
#define vecfirst (*vec.begin())
#define veclast (*vec.rbegin())
#define vecall(v) (v).begin(), (v).end()
#define vecupsort(v) (sort((v).begin(), (v).end()))
#define vecdownsort(v, type) (sort(vecall(v), greater<type>()))
#define veccmpsort(v, cmp) (sort(vecall(v), cmp))
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
clock_t TIME__START, TIME__END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME__END - TIME__START) / 1000);
    system("pause");
#endif
}
char s[1005], t[1005];
int n, m, ans = inf;

inline void solve()
{
    scanf("%s%s", s + 1, t + 1);
    n = strlen(s + 1), m = strlen(t + 1);
    for (int i = 1; i <= n - m + 1; ++i)
    {
        int tmp = m;
        for (int j = 1; j <= m; ++j)
        {
            if (s[i + j - 1] == t[j])
                tmp--;
        }
        ans = min(ans, tmp);
    }
    printf("%d\n", ans);
}

int main()
{
    TIME__START = clock();
    int Test = 1;
    // scanf("%d", &Test);
    while (Test--)
        solve();
    TIME__END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 3812
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#define mem(u, v) memset(u, v, sizeof(u))
#define INF 0x3f3f3f3f
#define pii pair<int, int >
#define LL long long
#define mid (l + r) / 2
#define lowbit(x) x & -x
using namespace std;
const int MAXN = 1e6 + 7,  MAXM = 1e6 + 7, MAXK = 1e6 + 7;

int a[MAXN], b[MAXN], sum[MAXN], c[MAXN], n;
LL ans0;

void add(int x){
	while (x <= 5 * n){
		c[x] += 1;
		x += lowbit(x);
	}
}

int get(int x){
	int y = 0;
	while (x > 0){
		y += c[x];
		x -= lowbit(x);
	}
	return y;
}

bool judge(int x){
	sum[0] = 0;
	for (int i = 1; i <= n; i++){
		if (a[i] >= x) sum[i] = sum[i - 1] + 1;
		else sum[i] = sum[i - 1];
	}
	for (int i = 0; i <= n; i++) sum[i] = 2 * sum[i] - i + n + 1;
	LL ans1 = 0;
	mem(c, 0);
	for (int i = 0; i <= n; i++){
		ans1 += get(sum[i]);
		add(sum[i]);
	}
	if (ans1 >= ans0) return true;
	return false;
}

int main(){
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]), b[i] = a[i];
	sort(b + 1, b + n + 1);
	int l = 1, r = n, ans = 0;
	ans0 = (1LL * n * (n - 1) / 2 + n + 1) / 2LL;
	while (l <= r){
		if (judge(b[mid])) ans = mid, l = mid + 1;
		else r = mid - 1;
	}
	printf("%d\n", b[ans]);
	return 0;
}


Measured memory_bytes: 12544
#include<stdio.h>
#include<string.h>
#include<stdbool.h>

int main(void){
  struct boxball{
  	int ball;
    bool red;
  }box[100001];
  int n,m,i,c=0;
  int x,y;
  scanf("%d%d",&n,&m);
  for(i=0;i<n;i++){
  	box[i]=(struct boxball){1,false};
  }
  box[0]=(struct boxball){1,true};
  for(i=0;i<m;i++){
  	scanf("%d%d",&x,&y);
    box[x-1].ball--;
    box[y-1].ball++;
    if(box[x-1].red){
    	box[y-1].red=true;
      if(box[x-1].ball==0) box[x-1].red=false;
    }
  }
  for(i=0;i<n;i++){
  	c+=box[i].red;
  }
  printf("%d\n",c);
  return 0;
}

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

int main() {
  int N, D;
  cin >> N >> D;
  vector<vector<int>> X(N, vector<int>(D));
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < D; ++j) {
      cin >> X.at(i).at(j);
    }
  }
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      int dist = 0;
      for (int k = 0; k < D; ++k) {
        dist +=
            (X.at(i).at(k) - X.at(j).at(k)) * (X.at(i).at(k) - X.at(j).at(k));
      }
      for (int k = 0; k <= dist; ++k) {
        if (k * k == dist) {
          ++ans;
        }
      }
    }
  }
  cout << ans << endl;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> X(N);
  vector<int> Y(N);
  for(int i=0; i<N; i++){
    cin >> X.at(i);
    Y.at(i)=X.at(i);
  }
  sort(Y.begin(), Y.end());
  int medb=Y.at(N/2);
  for(int i=0; i<N; i++){
    if(X.at(i)<medb) cout << medb << endl;
    else cout << Y.at(N/2-1) << endl;
  }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC omodtimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
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>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long ,long long> ii; 	
typedef complex<long double> com;
 
const ll mod = 998244353;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll h,w;
	cin >> h >> w;
	vector <vector<ll>> dp(h,vector<ll>(w,LLONG_MAX));
	vector <vector<ll>> arr(h,vector<ll>(w));
	for (int z=0;z<h;z++){
		for (int x=0;x<w;x++){
			char lol;
			cin >> lol;
			arr[z][x] = lol == '.' ? 0 : 1;
 		}
	}
	dp[0][0] = arr[0][0];
	for (int z=0;z<h;z++){
		for (int x=0;x<w;x++){
			if (z > 0){
				ll c = arr[z][x];
				if (arr[z-1][x] == 1) c = 0;
				dp[z][x] = min(dp[z-1][x] + c,dp[z][x]);
			}
			if (x > 0){
				ll c = arr[z][x];
				if (arr[z][x-1] == 1) c = 0;
				dp[z][x] = min(dp[z][x-1] + c,dp[z][x]);
			}
		}
	}
	cout << dp[h-1][w-1] << endl;
}

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

int main() {
  int N; cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    long long a; cin >> a;
    A.at(i) = a - i - 1;
  }
  sort(A.begin(), A.end());
  long long b = A.at(A.size()/2);
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    ans += abs(A.at(i)-b);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
using System;

class AtCoderCS {
    static void Main(string[] args) {
        long X = long.Parse(Console.ReadLine());

        long t = 100, ans = 0;
        while (t < X) {
            ans++;
            t = (long)(t * 1.01);
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 27524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for(ll i = 0;i < n;i++)
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

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

  int n;
  cin >> n;
  vector<string> s(2);
  cin >> s[0] >> s[1];

  const ll MOD = 1000000007;
  ll ans = 1;
  rep(i, n) {
    if (i == 0) {
      if (s[0][i] == s[1][i]) {
        ans = ans*3%MOD;
      } else {
        ans = ans*6%MOD;
        i++;
      }
    } else {
      if (s[0][i] == s[1][i]) {
        if (s[0][i-1] == s[1][i-1]) {
          ans = ans*2%MOD;
        } else {
          //ans *= 1;
        }
      } else {
        if (s[0][i-1] == s[1][i-1]) {
          ans = ans*2%MOD;
        } else {
          ans = ans*3%MOD;
        }
        i++;
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
k = int(input())

if k == 0:
    a = [1, 1]
elif k == 1:
    a = [2, 0]
elif k <= 50:
    a = [i for i in range(1, k+1)]
else:
    a = [i for i in range(1, 51)]
    k -= 50
    d = k // 50
    for i in range(50):
        a[i] += d
    m = k % 50
    for i in range(-1, -m-1, -1):
        a[i] += 1
print(len(a))

# print(a)

a = [str(i) for i in a]
print(' '.join(a))



Measured memory_bytes: 9204
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    for(ll i=1; i<=3500; i++){
        for(ll j=1; j<=3500; j++){
            ll tmp = (4*i*j)-(n*j)-(n*i);
            if(tmp == 0) continue;
            double k = (1.0*n*i*j)/tmp;
            if(k == floor(k) && k >= 1){
                cout << i << " " << j << " " << (ll)k << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3660
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<vector>
#include<queue>
using namespace std;

vector<long long> num;
long long Q[int(1e7)];
int l=1,r=0;
inline void prepare() {
	for(register int i=1;i<10;i++)
		Q[++r]=i;
	while(r>l) {
		long long cur=Q[l++];
		if(cur>1e11) return;
		num.push_back(cur);
		int back=cur%10;
		
		Q[++r]=cur*10ll+back;
		if(back!=0) Q[++r]=cur*10ll+back-1;
		if(back!=9) Q[++r]=cur*10ll+back+1;
	}
}

signed main() {
	prepare();
	int k;
	cin>>k;
	sort(num.begin(),num.end()) ;
	cout<<num[k-1]<<endl;
}

Measured memory_bytes: 22764
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  s[k-1] += 'a' - 'A';
  cout<<s<<endl;
  return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
//const int mod = 100000;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

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

int main()
{
  vector<vector<int>> c(3, vector<int>(3));
  rep(i, 3) rep(j, 3) cin >> c[i][j];

  for(int a1 = 0; a1 <= 100; ++a1) {
    for(int a2 = 0; a2 <= 100; ++a2) {
      for(int a3 = 0; a3 <= 100; ++a3) {
        if(c[0][0]-a1 == c[0][1]-a2 && c[0][1]-a2 == c[0][2]-a3 && c[1][0]-a1 == c[1][1]-a2 && c[1][1]-a2 == c[1][2]-a3 && c[2][0]-a1 == c[2][1]-a2 && c[2][1]-a2 == c[2][2]-a3) {
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3612
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;

namespace AtCoder169
{
    class ProgramB
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var input = Console.ReadLine();
            var inputList = input.Split(" ").Select(long.Parse);

            if (inputList.Contains(0))
            {
                Console.WriteLine(0);
                return;
            }

            var result = new BigInteger(1);
            var judgeLine = new BigInteger(Math.Pow(10, 18));
            foreach (var d in inputList)
            {
                result *= d;
                if (judgeLine < result)
                {
                    Console.WriteLine(-1);
                    return;
                }
            }
            Console.WriteLine(result);

        }
    }
}


Measured memory_bytes: 41352
m, d = map(int, input().split())
ans = 0
for i in range(1, m + 1):
    for j in range(1, d + 1):
        if(i == ((j % 10) * ((j - (j % 10)) / 10)) and (j % 10) >= 2 and ((j - (j % 10)) / 10 >= 2)):
            ans += 1
print(ans)


Measured memory_bytes: 38640
#include <stdio.h>
int main()
{
	int a,b,c,d,result;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	{
		if(b<=c||d<=a)
			result=0;
		else
		{
			if(a>c)
			{
				if(b<d)
					result=b-a;
				else
					result=d-a;
			}
			else
			{
				if(b>d)
					result=d-c;
				else
					result=b-c;
			}
		}
		printf("%d\n",result);
	}
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1000000000 + 7;
const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

int n;
string s1, s2;
int dp[55][3][3];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    cin >> s1;
    cin >> s2;
    if (s1[0] == s2[0]) {
        rep(j, 3) dp[0][j][j] = 1;
    }
    else {
        rep(j, 3)rep(k, 3) {
            if (j == k) continue;
            dp[0][j][k] = 1;
        }
    }
    rep2(i, 1, n) {
        if (s1[i] == s2[i]) {
            rep(j, 3){
                (dp[i][j][j] += (dp[i - 1][(j + 1) % 3][(j + 1) % 3] + dp[i - 1][(j + 2) % 3][(j + 2) % 3])) %= mod;
            }
            rep(j, 3) {
                (dp[i][j][j] += (dp[i - 1][(j + 1) % 3][(j + 2) % 3] + dp[i - 1][(j + 2) % 3][(j + 1) % 3])) %= mod;
            }
        }
        else {
            if (s1[i] == s1[i - 1]) {
                rep(j, 3)rep(k, 3) {
                    if (j == k) continue;
                    (dp[i][j][k] += dp[i - 1][j][k]) %= mod;
                }
            }
            else {
                /*
                rep(j, 3)rep(k, 3) {
                    if (j == k) continue;
                    rep(l, 3) {
                        if (j != l && k != l) {
                            dp[i][j][k] = dp[i - 1][l][l] % mod;
                        }
                    }
                }
                */
                rep(j, 3)rep(k, 3) {
                    if (j == k) continue;
                    (dp[i][j][k] += dp[i - 1][(j + 1) % 3][(k + 1) % 3]) %= mod;
                    (dp[i][j][k] += dp[i - 1][(j + 1) % 3][(k + 2) % 3]) %= mod;
                    (dp[i][j][k] += dp[i - 1][(j + 2) % 3][(k + 1) % 3]) %= mod;
                    (dp[i][j][k] += dp[i - 1][(j + 2) % 3][(k + 2) % 3]) %= mod;
                }
            }
        }
    }
    int ans = 0;
    if (s1[n - 1] == s2[n - 1]) {
        rep(j, 3) (ans += dp[n - 1][j][j]) %= mod;
    }
    else {
        rep(j, 3)rep(k, 3) {
            if (j == k) continue;
            (ans += dp[n - 1][j][k]) %= mod;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N=int(input())
W1=input().split()
W2=[]
for i in range(N):
    W2.append(int(W1[i]))
for i in range(N):
    if i==0 or x>abs(sum(W2[i+1:])-sum(W2[:i+1])):
        x=abs(sum(W2[i+1:])-sum(W2[:i+1]))
    else:
        break
print(x)


Measured memory_bytes: 3060
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

void main(){
    long n, l;
    readlnTo(n, l);
    auto a = readLongs();
    long[] b;
    foreach(i; iota(n-1)) {
        b ~= a[i] + a[i+1];
    }
    if(reduce!((a,b) => a > b ? a: b)(0L, b) < l) {
        writeln("Impossible");
        return;
    }
    writeln("Possible");
    long idx = 0;
    while(b[idx] < l) {
        ++idx;
    }
    long[] ans;
    foreach(i; iota(idx, n-1)) {
        ans ~= i+1;
    }
    foreach_reverse(i; iota(idx)) {
        ans ~= i+1;
    }
    foreach_reverse(ai; ans) {
        writeln(ai);
    }
}



Measured memory_bytes: 6600
#include<bits/stdc++.h>
using namespace std;
struct pp{
	long long p; long long x;
};
pp a[100];
long long N, P;
long long Index = 0;
long long ans = 1;

void Nhap(){
	cin>>N>>P;
}

void Prime(long long n){
	for(long long i = 2; i<= sqrt(n); i++){
		bool kt = false;
		while(n%i == 0){
			a[Index].p = i;
			a[Index].x++;
			n/= i; 
			kt = true;
		}	
		if(kt== true) Index++;
	}
	if(n>1){
		a[Index].p = n;
		a[Index].x = 1;
		Index++;
	}
}

void Xuly(){
	for(long long i = 0; i< Index; i++){
		ans*= pow(a[i].p, (a[i].x / N));
	}
}

void Xuat(){
	cout<<ans;
}

int main(){
	Nhap();
	Prime(P);
//	cout<<Index<<endl;
//	for(int i = 0; i< Index; i++) cout<<a[i].p<<" "<<a[i].x<<endl;
	Xuly();
	Xuat();
}


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

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n;
	int h;
	int hmax = 0;
	int count = 0;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> h;
		if(h >= hmax){
			count++;
		}
		hmax = max(hmax, h);
	}
	cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define setDP(arr) memset(arr,-1,sizeof arr)
#define oo 2000000000
#define inf 1000000000000000LL
#define M 1000000007
typedef long long ll;
using namespace std;
const int N = 205001;
const double PI = acos(-1);

char gg[222][222];
int n;
vector<vector<int> > g;
int val[222];

void bfs(int node){
    queue<int> q;
    q.push(node);
    val[node]=1;
    while(!q.empty()){
        node=q.front();
        q.pop();
        for(int i = 0 ; i < g[node].size() ; i++){
            if(val[g[node][i]]){
                if(val[g[node][i]]%2==val[node]%2){
                    puts("-1");
                    exit(0);
                }
            }else{

                q.push(g[node][i]);
                val[g[node][i]]=val[node]+1;
            }
        }
    }
}

signed main(){
    cin >> n ;
    g.resize(n);
    for(int i = 0 ; i < n ; i++){
        scanf(" %s",gg[i]);
        for(int j = 0 ; j < n ; j++){
            if(gg[i][j]=='1')
                g[i].push_back(j);
        }
    }
    int ans = 0;
    set<int> st;
    for(int i = 0 ;i < n ; i++){
        bfs(i);
        st.clear();

        for(int h = 0 ; h < n ; h++){
            st.insert(val[h]);
            val[h]=0;
        }
        ans = max(ans,(int)st.size());
    }
    cout << ans << endl;

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main(){

  ll A, B;
  cin >> A;
  cin >> B;

  if(A>=13)
    cout << B << endl;
  else if((6<=A)and(A<=12))
    cout << B / 2 << endl;
  else
    cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 256
/*g++ file.cpp -o file.out*/
/*./file.out*/

#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define LL long long
#define Mod 1000000007
#define L_Mod 17100000013

int a[100001];

int main()
{
    LL sov=0;
    int n,x;
    scanf("%d%d",&n,&x);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    if(a[0]>x)
    {
        sov+=a[0]-x;
        a[0]=x;
    }
    for(int i=1;i<n;i++)
    {
        if(a[i]+a[i-1]>x)
        {
            sov+=a[i]+a[i-1]-x;
            a[i]=x-a[i-1];
        }
    }
    printf("%lld\n",sov);
    return 0;
}


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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int a[3],i;
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	cout<<a[2]*10+a[1]+a[0];
	return 0;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int i = a; i <= (n); ++i)
#define repD(i, a, n) for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a) memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	int A,B; cin >> A >> B;
	cout << 6 - A - B << endl;
	return 0;
}



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

// 小数点以下桁数
// fixed << setprecision(i)

int gcd(int a,int b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int a,int b){return (int64_t)a*b/gcd(a, b);}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//   for(auto x : v) cout << x << " "; cout << "\n";    // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }

int main()
{
  int n, p = 2;
  string s;
  vector<int> prime_num(26);
  int64_t count = 0, temp;

  n = 0;
  while (n < 26)
  {
    while (!is_prime(p))
      p++;
    prime_num[n] = p;
    n++;
    p++;
  }
  cin >> n;
  vector<int64_t> a(n, 1);
  for (int i = 0; i < n; i++)
  {
    cin >> s;
    for (int j = 0; j < 10; j++)
      a[i] *= prime_num[(int)(s[j] - 'a')];
  }
  sort(a.begin(), a.end());
  temp = 0;
  for (int i = 1; i < n; i++)
  {
    if (a[temp] != a[i])
    {
      temp = i - temp - 1;
      if (temp > 0)
        count += sigma(1, temp);
      temp = i;
    }
  }
  temp = n - 1 - temp;
  if (temp > 0)
    count += sigma(1, temp);
  // for (int i = 0; i < n; i++)
  //   cout << a[i] << endl;
  cout << count << endl;

}

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

using namespace std;
typedef long long ll;

int main() {
  ll H, W;
  cin >> H >> W;
  ll ret = H * W;

  for (int i = 1; i < H; i++) {
    ll s1 = i * W;
    ll w_mid = W / 2;
    ll s2 = (H - i) * w_mid;
    ll s3 = (H - i) * (W - w_mid);
    ll tmp = max(max(s1, s2), s3) - min(min(s1, s2), s3);
    if (tmp < ret) {
      ret = tmp;
    }
  }

  for (int i = 1; i < H; i++) {
    ll s1 = i * W;
    ll h_rem_mid = (H - i) / 2;
    ll s2 = h_rem_mid * W;
    ll s3 = (H - i - h_rem_mid) * W;
    ll tmp = max(max(s1, s2), s3) - min(min(s1, s2), s3);
    if (tmp < ret) {
      ret = tmp;
    }
  }

  for (int i = 1; i < W; i++) {
    ll s1 = i * H;
    ll h_mid = H / 2;
    ll s2 = (W - i) * h_mid;
    ll s3 = (W - i) * (H - h_mid);
    ll tmp = max(max(s1, s2), s3) - min(min(s1, s2), s3);
    if (tmp < ret) {
      ret = tmp;
    }
  }

  for (int i = 1; i < W; i++) {
    ll s1 = i * H;
    ll w_rem_mid = (W - i) / 2;
    ll s2 = w_rem_mid * H;
    ll s3 = (W - i - w_rem_mid) * H;
    ll tmp = max(max(s1, s2), s3) - min(min(s1, s2), s3);
    if (tmp < ret) {
      ret = tmp;
    }
  }

  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 256
use std::fmt;
use std::io::stdin;
use std::io::BufRead;
use std::str;
use std::str::FromStr;
use std::vec::Vec;
use std::collections::VecDeque;
use std::cmp;

fn main() {
    let stdin = stdin();
    let mut scan = InputScanner::new(stdin.lock(),256);

    let h:usize = scan.next();
    let w:usize = scan.next();

    let s:Vec<Vec<char>> = (0..h).map(|_| scan.next::<String>().chars().collect()).collect::<Vec<Vec<char>>>();

    let mut white_count = 0;

    for y in 0..h {
        for x in 0..w {
            if s[y][x] == '.' {
                white_count += 1;
            }
        }
    }

    let mut m:Vec<Vec<bool>> = (0..h).map(|_| (0..w).map(|_| false).collect::<Vec<bool>>()).collect::<Vec<Vec<bool>>>();

    m[0][0] = true;

    let mut answer = -1;

    let mut queue = VecDeque::new();

    queue.push_back((0,0));

    let mut count = 0;

    'outer: while queue.len() > 0 {
        let mut current = queue.drain(0..).collect::<VecDeque<(usize,usize)>>();

        count += 1;

        while let Some((x,y)) = current.pop_front() {
            if x == w - 1 && y == h - 1 {
                answer = cmp::max(answer,white_count - count);
                break 'outer;
            } else {
                let x = x as i64;
                let y = y as i64;

                for &(dx,dy) in &[(0,-1),(0,1),(-1,0),(1,0)] {
                    let x = x + dx;
                    let y = y + dy;

                    if x >= 0 && x < w as i64 && y >= 0 && y < h as i64 &&
                        s[y as usize][x as usize] == '.' && !m[y as usize][x as usize] {
                        let x = x as usize;
                        let y = y as usize;

                        m[y][x] = true;
                        
                        queue.push_back((x,y));
                    }
                }
            }
        }
    }

    println!("{}",answer);
}
struct InputScanner<R: BufRead> {
	reader: R,
	buf: Vec<u8>, // Should never be empty
	pos: usize,   // Should never be out of bounds as long as the input ends with '\n'
}
impl<R: BufRead> InputScanner<R> {
	fn new(reader: R, capacity: usize) -> Self {
		InputScanner {
			reader: reader,
			buf: Vec::with_capacity(capacity),
			pos: 0,
		}
	}

	#[inline]
	fn next<T: FromStr>(&mut self) -> T
	where
		T::Err: fmt::Debug,
	{
		if self.buf.is_empty() {
			self._read_next_line();
		}
		let mut start = None;
		loop {
			match (self.buf[self.pos], start.is_some()) {
				(b' ', true) | (b'\n', true) | (b'\r', true) => break,
				(_, true) | (b' ', false) => self.pos += 1,
				(b'\n', false) | (b'\r', false) => self._read_next_line(),
				(_, false) => start = Some(self.pos),
			}
		}
		let target = &self.buf[start.unwrap()..self.pos];
		unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
	}

	#[inline]
	fn _read_next_line(&mut self) {
		self.pos = 0;
		self.buf.clear();
		if self.reader.read_until(b'\n', &mut self.buf).unwrap() == 0 {
			panic!("Reached EOF");
		}
	}
}


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

int main(){
    int X, Y, A, B, C;
    long long sum;
    cin >> X >> Y >> A >> B >> C;
    sum = 0;
    vector<int> p;
    vector<int> q;
    vector<int> r;
    vector<int> v;
    for (int i = 0; i < A; i++) {
        int a;
        cin >> a;
        p.push_back(a);
    }
    for (int i = 0; i < B; i++) {
        int a;
        cin >> a;
        q.push_back(a);
    }
    for (int i = 0; i < C; i++) {
        int a;
        cin >> a;
        r.push_back(a);
    }
    sort(p.begin(), p.end(), greater<int>());
    sort(q.begin(), q.end(), greater<int>());
    sort(r.begin(), r.end(), greater<int>());    
    for (int i = 0; i < X; i++) {
        v.push_back(p[i]);
    }
    for (int i = 0; i < Y; i++) {
        v.push_back(q[i]);
    }
    for (int i = 0; i < C; i++) {
        v.push_back(r[i]);
    }
    sort(v.begin(), v.end(), greater<int>()); 
    for (int i = 0; i < X + Y; i ++) {
        sum += v[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 3572
import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] str = br.readLine().split(" ");
		Set<Integer> S = new TreeSet<Integer>();
		for(int i = 0; i < n; i++){
			S.add(Integer.parseInt(str[i]));
		}
		int m = Integer.parseInt(br.readLine());
		str = br.readLine().split(" ");
		for(int i = 0; i < m; i++){
			S.add(Integer.parseInt(str[i]));
		}
		for(Integer num : S) System.out.println(num);
	}
}



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

template <typename T>
class Queue {
private:
    vector<T> pulled, pushed;

public:
    void push(T a) {
        pushed.push_back(a);
    }

    T pop() {
        if (pulled.empty()) {
            reverse(pushed.begin(), pushed.end());
            pulled = pushed;
            pushed.clear();
        }
        T top = pulled.back();
        pulled.pop_back();
        return top;
    }

    T front() {
        return pulled.front();
    }

    int size() {
        return pulled.size() + pushed.size();
    }

    bool empty() {
        return size() == 0;
    }
};

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

int main() {
    int H, W;
    cin >> H >> W;

    string S[H];
    int bnum = 0;
    for (int h = 0; h < H; ++h) {
        cin >> S[h];
        for (int w = 0; w < W; ++w) {
            if (S[h][w] == '#') ++bnum;
        }
    }

    int d[H][W];
    fill(d[0], d[H], -1);

    Queue<pair<int, int>> que;
    que.push(make_pair(0, 0));
    d[0][0] = 1;

    while (!que.empty()) {
        int x, y;
        tie(x, y) = que.pop();

        for (int i = 0; i < 4; ++i) {
            int sx = x + dx[i];
            int sy = y + dy[i];
            if (0 <= sx && sx < H && 0 <= sy && sy < W && S[sx][sy] == '.' && d[sx][sy] < 0) {
                d[sx][sy] = d[x][y] + 1;
                que.push(make_pair(sx, sy));
            }
        }
    }

    cout << (d[H - 1][W - 1] < 0 ? -1 : H * W - bnum - d[H - 1][W - 1]) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=101;
long double W,H,x,y;
int main(){
    cin>>W>>H>>x>>y;
    printf("%.6Lf\n",1.0*W*H/2);
    if(x==W/2&&y==H/2)  puts("1");
    else    puts("0");
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String stra = input.readLine( );
		int a = Integer.parseInt(stra);
		String strb = input.readLine( );
		int b = Integer.parseInt(strb);
		String strh = input.readLine( );
		int h = Integer.parseInt(strh);

		int answer = (a + b) * h / 2;
		System.out.print(answer);

	}

}


Measured memory_bytes: 22996
#include <cassert>
#include <iostream>
using namespace std;
int n;

// warning: include *e
int getBackMaxSum(int* s, int *e) {
	int sum = 0, maxSum = 0x80000000;
	for (; s <= e; e--) {
		sum += *e;
		maxSum = max(sum, maxSum);
	}
	return maxSum;
}

int main () {
	while (cin >> n, n) {
		int a[n], maxSum = 0x80000000;
		for (int i = 0; i < n; i++) {
			cin >> a[i];
			maxSum = max(maxSum, getBackMaxSum(a, a + i));
			assert(a[i] <= maxSum);
		}
		cout << maxSum << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
int main(void)
{
	int n,a,b,c,d;
	scanf("%d %d",&n,&a);
	b=n/500;
	c=n-(500*b);
	d=a-c;
	if(d>=0){
	printf("Yes");
	}
	else{
	printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
	int arr[111]={}, sum=0, a, b, c, i;
	
	scanf("%d %d %d", &a, &b, &c);
	
	arr[a]++;
	arr[b]++;
	arr[c]++;
	
	for(i=1;i<=100;i++){
		if(arr[i]!=0)
		sum++;
	}
	
	printf("%d\n", sum);
	return 0;
}


Measured memory_bytes: 128