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

int main() {
	
	ll n; cin >> n;
	vector<ll> a(n);
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	const ll inf = 1000000000000000000LL;
	ll tmp = 1;
	for (int i = 0; i < n; i++) {
		if (a[i] == 0) {
			tmp = 0;
			break;
		}
		else if (tmp > inf / a[i]) {
			tmp = -1;
			break;
		}
		tmp *= a[i];
	}
	cout << tmp << endl;
	return 0;
}

Measured memory_bytes: 4028
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
int x[3100];
int y[3100];
int las[3100][3100];
int cur[3100];
int p[3100];
long long ks[3100];
long long dp[3100][4][3100];
int Q;
//map<pair<int,pair<int,int> >,long long >dp;
long long calc(int a,int b,int c){
	if(a==0){
		return p[b]>p[c];
	}
	int ty=-1;
	int rm=0;
	if(a<Q&&b==x[a]){ty=0;rm=c;}
	else if(a<Q&&b==y[a]){ty=1;rm=c;}
	else if(a<Q&&c==x[a]){ty=2;rm=b;}
	else if(a<Q&&c==y[a]){ty=3;rm=b;}
	if(ty!=-1&&~dp[a][ty][rm]){
		return dp[a][ty][rm];
	}
	//printf("%d %d %d %d %d\n",a,b,c,ty,rm);
	long long ret=0;
	int to=max(las[a][b],las[a][c]);
	if(to==-1){
		ret=calc(0,b,c);
	}else{
		ret=calc(to,b,c);
		if(x[to]==b&&y[to]==c)ret=(ret+calc(to,c,b))%mod;
		else if(x[to]==c&&y[to]==b)ret=(ret+calc(to,c,b))%mod;
		else if(x[to]==b)ret=(ret+calc(to,y[to],c))%mod;
		else if(x[to]==c)ret=(ret+calc(to,b,y[to]))%mod;
		else if(y[to]==b)ret=(ret+calc(to,x[to],c))%mod;
		else if(y[to]==c)ret=(ret+calc(to,b,x[to]))%mod;
	}
	ret=ret*ks[a-to-1]%mod;
	if(ty!=-1){
		dp[a][ty][rm]=ret;
	}
	return ret;
}
int main(){
	ks[0]=1;
	for(int i=1;i<3100;i++)ks[i]=ks[i-1]*2%mod;
	int a,b;scanf("%d%d",&a,&b);Q=b;
	for(int i=0;i<a;i++)scanf("%d",p+i);
	for(int i=0;i<b;i++){
		scanf("%d%d",x+i,y+i);x[i]--;y[i]--;
	}
	for(int i=0;i<=b;i++)for(int j=0;j<4;j++)for(int k=0;k<a;k++)
		dp[i][j][k]=-1;
	for(int i=0;i<a;i++)cur[i]=-1;
	for(int i=0;i<b;i++){
		cur[x[i]]=cur[y[i]]=i;
		for(int j=0;j<a;j++){
			las[i+1][j]=cur[j];
		}
	}
	long long ret=0;
	for(int i=0;i<a;i++){
		for(int j=i+1;j<a;j++){
			ret+=calc(b,i,j);
		}
	}
	ret%=mod;
	printf("%lld\n",ret);
}

Measured memory_bytes: 332160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod1=1000000007,mod2=998244353,MAX=1000005,INF=1<<30;

ll ru1[MAX],ru2[MAX];

struct Rollinghash{
    string S;
    int n;
    int base1;
    int base2;
    vector<ll> h1,h2;
    vector<int> bit;
    
    void make(string &T,int ba1,int ba2){
        S=T;
        n=S.size();
        h1.assign(n+1,0);
        h2.assign(n+1,0);
        bit.assign(n+1,0);
        base1=ba1;
        base2=ba2;
        
        for(int i=1;i<=n;i++){
            h1[i]=h1[i-1]*base1+ll(S[i-1]-'a');
            h1[i]%=mod1;
            
            h2[i]=h2[i-1]*base2+ll(S[i-1]-'a');
            h2[i]%=mod2;
        }
        
        for(int i=n-1;i>=0;i--){
            bit[i]=bit[i+1]|(1<<(S[i]-'a'));
        }
    }
    
    pair<ll,ll> ha(int l,int r){
        pair<ll,ll> res;
        res.fi=(h1[r]-h1[l]*ru1[r-l]%mod1+mod1)%mod1;
        res.se=(h2[r]-h2[l]*ru2[r-l]%mod2+mod2)%mod2;
        
        return res;
    }//開区間
};

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    mt19937_64 rng(58);
    ll ha1=rng()%mod1,ha2=rng()%mod2;
    
    ru1[0]=1;
    ru2[0]=1;
    
    for(int i=1;i<MAX;i++){
        ru1[i]=ru1[i-1]*ha1%mod1;
        ru2[i]=ru2[i-1]*ha2%mod2;
    }
    int N;cin>>N;
    ll ans=0;
    vector<string> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
        reverse(all(A[i]));
    }
    sort(all(A),[](auto a,auto b){
        if(si(a)==si(b)) return a<b;
        return si(a)<si(b);
    });
    
    vector<Rollinghash> S(N);
    for(int i=0;i<N;i++){
        S[i].make(A[i],ha1,ha2);
    }
    
    int i=0;
    while(i<N){
        int j=i;
        while(j<N&&si(A[i])==si(A[j])) j++;
        
        map<pair<ll,ll>,int> MA;
        
        for(int k=i;k<j;k++){
            MA[S[k].ha(0,si(A[k])-1)]|=(1<<(A[k].back()-'a'));
        }
        
        for(int k=j;k<N;k++){
            if(MA.count(S[k].ha(0,si(A[i])-1))){
                ans+=__builtin_popcount(MA[S[k].ha(0,si(A[i])-1)]&S[k].bit[si(A[i])-1]);
            }
        }
        
        i=j;
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 82292
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;
const double PI = 3.1415926535898;

int a, b, x;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> a >> b >> x;
	setprecision(20);
	double ans;
	if (a*a*b < 2*x) {
		ans = atan2(2*(a*a*b - x), a*a*a);
	}
	else {
		ans = atan2((double)a*b*b, 2 * x);
	}
	ans *= 180;
	ans /= PI;
	
	printf("%.10f", ans);
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include "bits/stdc++.h"
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
char S[2004][2004]={};
int u[2004][2004],d[2004][2004],l[2004][2004],r[2004][2004];
int main(){
	int H,W;
	scan(H>>W);
	rep(i,H){
		scanf("%s",S[i]);
	}
	rep(i,H){
		int sum=0;
		rep(j,W){
			if(S[i][j]=='.'){
				sum++;
				l[i][j]=sum;
			}
			else sum=0;
		}
	}
	rep(i,H){
		int sum=0;
		for(int j=W-1;j>=0;j--){
			if(S[i][j]=='.'){
				sum++;
				r[i][j]=sum;
			}
			else sum=0;
		}
	}
	rep(j,W){
		int sum=0;
		rep(i,H){
			if(S[i][j]=='.'){
				sum++;
				u[i][j]=sum;
			}
			else sum=0;
		}
	}
	rep(j,W){
		int sum=0;
		for(int i=H-1;i>=0;i--){
			if(S[i][j]=='.'){
				sum++;
				d[i][j]=sum;
			}
			else sum=0;
		}
	}
	int ans=0;
	/*rep(i,H){
		rep(j,W){
			printf("%c",S[i][j]);
		}
		kaigyo;
	}
	rep(i,H){
		rep(j,W){
			printf("%d",l[i][j]+r[i][j]+u[i][j]+d[i][j]-3);
		}
		kaigyo;
	}*/
	rep(i,H) rep(j,W) if(S[i][j]=='.') ans=max(ans,l[i][j]+r[i][j]+u[i][j]+d[i][j]-3);
	prin(ans);
	return 0;
}


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

int main(){
	int a,b;
	cin >> a >> b;
	if(a <= b){
		swap(a,b);
	}
	if((a+b) % 2 == 1){
		cout << "IMPOSSIBLE";
	}else{
		cout << (a+b)/2;
	}
}

Measured memory_bytes: 256
H, N = map(int, input().split())
magiclist = [0]*N
dp = [0] * (N+1)
for s in range(N+1):
    dp[s] = [10**9] * (H + 1)
    dp[s][0] = 0
for i in range(N):
    magiclist[i] = [0]*2
    damage, mp = map(int, input().split())
    magiclist[i][0], magiclist[i][1] = damage, mp
    for j in range(H + 1):
        if j - damage < 0:
            dp[i + 1][j] = dp[i][j]
        else:
            dp[i + 1][j] = min(dp[i][j], (mp + dp[i + 1][j - damage]))
kouho = dp[N][H]
for h in range(N):
    kouho = min(kouho, min(dp[N][H-magiclist[h][0]:H])+magiclist[h][1])
print(kouho)


Measured memory_bytes: 121564
k,t=map(int,input().split())
a=list(map(int,input().split()))
num=sum(a)-max(a)
if max(a)<=num+1:
    print(0)
else:
    if max(a)<=(num+1)*2:
        print(max(a)-(num+1))
    else:
        print(num+max(a)-num-1)


Measured memory_bytes: 3060
from copy import deepcopy as cp

H,W,K = map(int,input().split())
src = [input() for i in range(H)]

panels = []
for cols in zip(*src):
    panels.append(list(reversed(cols)))

ans = 0
for r0 in range(H):
    for c0 in range(W):
        ps = cp(panels)
        del ps[c0][r0]
        tmp = 0
        bonus = 1
        chaining = True
        while chaining:
            chaining = False
            for r in reversed(range(H)):
                seq = 0
                prev = None
                for c in range(W):
                    if r >= len(ps[c]) or (prev and prev != ps[c][r]) or c == 0:
                        if seq >= K:
                            tmp += bonus * seq * int(prev)
                            chaining = True
                            for i in range(seq):
                                del ps[c-i-1][r]
                        if r >= len(ps[c]):
                            seq,prev = 0,None
                        else:
                            seq,prev = 1,ps[c][r]
                    elif prev:
                        seq += 1
                    else:
                        seq = 1
                        prev = ps[c][r]
                if seq >= K:
                    tmp += bonus * seq * int(prev)
                    chaining = True
                    for i in range(seq):
                        del ps[W-i-1][r]
            bonus *= 2
        ans = max(ans, tmp)
print(ans)

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

int main(){ 
	int card[52] ={0};
	int total, number;
	char type;
	cin >> total;
	for (int i=0; i<total; i++){
		cin >> type >> number;
		if (type == 'S'){
			card[number-1] = {1};
		}
		if (type == 'H'){
			card[number+12] = {1};
		}
		if (type == 'C'){
			card[number+25] = {1};
		}
		if (type == 'D'){
			card[number+38] = {1};
		}
	}
	for (int i=0; i<52; i++){
		if(card[i]==0){
			if (i<13){
				cout << "S" << " " << i+1 << endl;
			}
			if (i>=13 && i<26){
				cout << "H" << " " << i-12 << endl;
			}
			if (i>=26 && i<39){
				cout << "C" << " " << i-25 << endl;
			}
			if (i>=39 && i<52){
				cout << "D" << " " << i-38 << endl;
			}
		}
	}
}


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

int main() {
	int c[3][3];
	for(int i=0; i<3; ++i) for(int j=0; j<3; ++j) cin >> c[i][j];
	bool flag=true;
	int sa[3];
	for(int i=1; i<3; ++i){
	    for(int j=0; j<3; ++j) sa[j]=c[i][j]-c[i-1][j];
	    if(sa[0]!=sa[1] || sa[0]!=sa[2]){
	        flag=false;
	        break;
	    }
	}
	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

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

    ll N; cin >> N;
    vector<ll> A(N); cin >> A;
    sort(all(A), greater<ll>());

    ll stick[2] = {0,0};
    int c = 0;
    int i;
    for (i = 1; i < N; i++) {
        if (A[i] == A[i - 1]) {
            stick[c++] = A[i];
            if (c == 2) break;
            i++;
        }
    }
    cout << stick[0] * stick[1] << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;
int main(){
    long A,B;
    cin>>A>>B;
    vector<long> a,b;
    for(long i=ceil(A/0.08);i<(A+1)/0.08;i++){
        a.push_back(i);
    }
    for(long i=ceil(B/0.10);i<(B+1)/0.10;i++){
        b.push_back(i);
    }
    
    for(int i=0;i<a.size();i++){
        for(int j=0;j<b.size();j++){
            if(a[i]==b[j]){
                cout <<a[i]<<endl;
                return 0;
            }
        }
    }
    cout <<-1<<endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int n, t, a;
    int h[1999]={};
    double tmp=1999999999;
    double tmpx=0;
    int ans=0;
    
    cin >> n;
    cin >> t >> a;
    
    for(int i=1; i<=n; i++){
        
        cin >> h[i];
        
        tmpx = abs((t-h[i]*0.006)-a);
        
        if(tmpx<tmp){
            
            ans = i;
            tmp = tmpx;
            
        }
        
    }
    
    cout << ans << endl;
    
    return 0;
    
}

Measured memory_bytes: 256
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define INF 1e18
#define N 100100
#define PI 3.141592653589793238
typedef pair<ll,ll> pll;
ll power(ll a,ll b)
{
    if(b==1)return a;
    if(b==0)return 1;
    ll temp=power(a,b/2);
    ll ans=temp*temp;
    if(b&1)
        ans*=a;
    return ans;
}
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%p;
    if(b&1)
        ans=(a*ans)%p;
    return ans%p;
}
ll inv(ll a,ll m)
{
    return power(a,m-2,m);
}
//code begins
void solve(){
    ll n;cin>>n;
    ll prev=n,len=0,d=1;
    while(n>0)
    {
        len++;
        prev=n;
        d=d*26;
        n-=d;
    }
    string ans="";
    n=prev;
    n--;
    for(ll i=1;i<=len;i++){
        ans+=('a'+n%26);
        n/=26;
    }
    reverse(all(ans));
    cout<<ans<<endl;
}
signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

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

//    ll t;cin>>t;while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <complex>
#include <cmath>
#define EPS 1e-9
using namespace std;
typedef complex<double> xy_t;
int n;
xy_t points[301];
int count_in(xy_t center)
{
  int ans=0;
  for(int i=0;i<n;i++)
  {
    if (abs(center-points[i])<1.0+EPS)
      ans++;
  }
  return ans;
}
/*xy_t ppdcl(xy_t a)
{
  return xy_t(a.imag(),-a.real());
}
xy_t delta_v(xy_t C1,xy_t C2)
{
  xy_t half=(C1-C2)*0.5;
  double l=abs(half);
  return ppdcl(half)*sqrt(1-l*l)*(1.0/l);
}*/
int main()
{
  while(1)
  {
    cin>>n;
    if (n==0) break;
    double x,y;
    for(int i=0;i<n;i++)
    {
      cin>>x>>y;
      points[i]=xy_t(x,y);
    }
    int maxn=1;
    for(int i=0;i<n;i++)
    {
      for(int j=i;j<n;j++)
      {
        /*if(abs(points[i]-points[j])<2.0)
        {
          xy_t mid_p=(points[i]+points[j])*0.5;
          maxn=max(maxn,count_in(mid_p+delta_v(points[i],points[j])));
          maxn=max(maxn,count_in(mid_p-delta_v(points[i],points[j])));
        }*/
        double d=abs(points[j]-points[i])/2;
        xy_t v=(points[j]-points[i])/(2*d);
        if(d<1)
        {
            maxn=max(maxn,count_in(points[i]+d*v+sqrt(1-d*d)*v*xy_t(0,+1)));
            maxn=max(maxn,count_in(points[i]+d*v+sqrt(1-d*d)*v*xy_t(0,-1)));
        }
      }
    }
    cout<<maxn<<endl;
  }

}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    int n, mx = -1e18;
    string s;
    map<string, int> m;
    cin>>n;
    while(n--) {
        cin>>s;
        mx = max(mx, ++m[s]);
    }
    for (auto&& p: m) {
        if (p.second == mx) cout<<p.first<<endl;
    }
}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<string, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 100 + 10;

int n;
string s[N];
int p[N];
vector<P> v;
int per[N];

bool cp(int i, int j){
   if(s[i] != s[j]){
      return s[i] < s[j];
   }
   return p[i] > p[j];
}

int32_t main(){_

   cin>>n;

   for (int i = 0; i < n; ++i)
   {
      cin>>s[i]>>p[i];
      per[i] = i;
   }

   sort(per, per+n, cp);

   for (int i = 0; i < n; ++i)
   {
      cout<<per[i]+1<<endl;
   }

   return 0;
}

// Common sense: do smth instead of nothing
// Even a single second counts...
// If other's can do it, even I can do it. It wouldn't be that tough. Let me give it a try.
// Mistakes made in past
// -Ques. ask for max-min => think binary_search, DP, greedy
// -not reading question properly / skipping to read & understand all samples properly & wasting time in wrong direction.
// -Using wrong indexing in nested loops something like a[i], when it is supposed to be a[j](WA)
// -value of const int N is not correct (WA/RTE).
// -Did you memset dp to -1 ?
// -check for small edges cases and work on small test cases manually if WA
// -not deallocating memory to pointers can lead to MLE. Use delete :))
// -not reading problem statements of harder problems E,..., thinking it couldn't be solved, but it isn't the case.
// -Avoid using #define int long long as much as possible when it's dp problem and requires high memory say, O(N^2, N=5000) (MLE)
// -Check Bitwise Operator Precedence 
// -Use pragmas to optimize (by constant factor) when necessary..
// -Think before coding & starting to debug. Have patience to look inside code and actually see how it works

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, ans;
  cin >> a >> b;
  if((a + b) % 2 == 0){
    ans = (a+b)/2;
  } else {
    ans = (a+b+1)/2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <tuple>
#include <numeric>
#include <cstdio>
#include <cmath>
#include <cstdlib>
using namespace std;
using ll = long long;
const int INF = 1e9;

int main() {
    int k;
    string s;
    cin >> k >> s;
    if (s.length() <= k) {
        cout << s << endl;
    } else {
        string s_sub = s.substr(0, k);
        string dot = "...";
        cout << s_sub << dot << endl;
    }
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
int N; 
cin >> N; 
int A[10] = {};
for(int i = 0; i < N; i++){
  int K; 
  cin >> K; 
if(K < 3200){
A[K/400] ++; 
}
else{
A[8] ++; 
}
}
int T = min(A[0], 1) + min(A[1], 1) + min(A[2], 1) + min(A[3], 1)
  +min(A[4], 1) + min(A[5], 1) + min(A[6], 1) + min(A[7], 1); 
if(T > 0){
cout << T << " " << T + A[8] << endl;
}
else{
cout << 1 << " " << A[8] << endl; 
}
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define repp(i,j,k) for(int i=j;i>=k;i--)
#define llrep(i,j,k) for(long long int i=j;i<(long long int)k;i++)
#define Sort(x) sort(x.begin(),x.end()); 
#define vi vector<int>
#define vvi vector<vector<int>> 
#define ll long long
int mod=1e9+7;
const int INF = 100000000;

using namespace std;

void p(int x) {
	cout << x << endl;
}

void pp(string s) {
	cout << s << endl;
}




int main(void) {
	int n;
	cin >> n;
	vi  v(2 * n);
	rep(i, 0, 2 * n) cin >> v[i];
	Sort(v);

	int sum = 0;
	for(int i = 0; i < 2*n; i += 2) sum += v[i];

	cout << sum << endl;

	
	return 0;
}

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

int main(){
    string s;
    cin >> s;
    cout << s.substr(0, 3) << endl;
    return 0;
}


Measured memory_bytes: 3608
#include <stdio.h>
#include <string.h>
#define MAX 100
#define INT_MAX 1000000

int n;
void MatrixChainOrder(int p[]){
  int i,j,k,q,l;

  int m[n+1][n+1];
  for(i=1; i<=n; i++){
    m[i][i] = 0;
  }
  for(l=2; l<=n; l++){
    for(i=1; i<=n-l+1; i++){
      j = i+l-1;
      m[i][j] = INT_MAX;
      for(k=i; k<=j-1; k++){
	q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
	if(q < m[i][j])m[i][j] = q;
      }
    }
  }
  printf("%d\n",m[i-1][n]);
}


int main(){
  int p[MAX],i;

  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d %d",&p[i],&p[i+1]);
    
  } 
  /*for(i=0; i<=n; i++){
   printf(" %d",p[i]);
 }
 printf("\n");
  */
  MatrixChainOrder(p);

  return 0;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int n; cin >> n;
	vi p(n); rep(i,n) cin >> p[i];
	int ans = 0;
	rep(i,n-2){
		vi q(3);
		rep(j,3) q[j]=p[i+j];
		SORT(q);
		if(q[1]==p[i+1]) ans++;
	}
	cout << ans << endl;
}




Measured memory_bytes: 256
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
	int N, M;
	cin >> N >> M;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	int sum = 0;
	for (int i = 0; i < N; ++i) {
		sum += A[i];
	}
	int cnt = 0;
	for (int i = 0; i < N; ++i) {
		if (A[i] * 4 * M >= sum) {
			++cnt;
		}
	}
	cout << (cnt >= M ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define ll long long
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	ll N, K, L, R; cin >> N >> K >> L >> R;
	ll ans = 0;
	vector<ll> a(N + 1);
	vector<vector<ll>> sum(N / 2 + 1);
	for (int i = 0; i < N; i++) cin >> a[i];
	int n1 = N / 2;
	for (int i = 0; i < 1 << n1;i++) {
		int cnt = 0;
		ll a_sum = 0;
		for (int j = 0; j < n1; j++) {
			if (i >> j & 1) {
				cnt++; a_sum += a[j];
			}
		}
		sum[cnt].emplace_back(a_sum);
	}
	for (int i = 0; i < n1;i++) sort(sum[i].begin(), sum[i].end());

	int n2 = N - n1;
	for (int i = 0; i < 1 << n2;i++) {
		int cnt = 0;
		ll a_sum = 0;
		for (int j = 0; j < n2;j++) {
			if (i >> j & 1) {
				cnt++;	a_sum += a[n1 + j];
			}
		}

		if ( !(K - cnt >= 0) || n1 + cnt < K) continue;

		int it1 = upper_bound(sum[K - cnt].begin(), sum[K - cnt].end(), R - a_sum) - begin(sum[K - cnt]);
		int it2 = lower_bound(sum[K - cnt].begin(), sum[K - cnt].end(), L - a_sum) - begin(sum[K - cnt]);

		if (it1 - it2 <= 0) continue;
		ans += it1 - it2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 12256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i = 0; i < n; i++)
typedef long long ll;
// Welcome to my source code!

int main() {
    int n, l;
    cin >> n >> l;
    int L = l;
    int R = l+n-1;
    int eat;
    if (R <= 0) eat = R;
    else if (L >= 0) eat = L;
    else eat = 0;
    int ans = (R+L)*(R-l+1)/2-eat;
    cout << ans << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.insert(0, 0)
 
v = [-1] * (N + 1)
n = 1

for i in range(N):
  v[n] = i
  n = A[n]
  if v[n] != -1:
    s = n
    t = i
    l = t - v[s] + 1
    break

if t >= K:
  print(v.index(K))
else:
  K = (K - v[s]) % l
  print(v.index(K + v[s]))

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

using namespace std;
using ll = long long;
int main() {
    string s;
    cin>>s;
    int ans=0,tans=0;
    for(int i = 0;i < s.size();++i) {
        if(i%2==0){
            if(s[i]=='0')++ans;
            else ++tans;
        }
        else {
            if(s[i]!='0')++ans;
            else ++tans;
        }
    }
    cout<<min(ans,tans)<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(i, name)in(i)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(i,v) for(auto &i:(v))
#define all(v) (v).begin(),(v).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, A, B);
  int ans = 0;
  rep(i, A, B + 1) {
    if (i % 10 == i / 10000) {
      if ((i/10) % 10 == (i%10000) / 1000) {
        ans++;
      }
    }
  }
  print(ans);
}


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

int main(void) {
    int n;
    cin >> n;
    vector<int> v1, v2;
    int tmp;
    rep(i,n){
        cin >> tmp;
        v1.push_back(tmp);
    }
    rep(i,n){
        cin >> tmp;
        v2.push_back(tmp);
    }
    int res=0;
    int s;
    rep(i,n){
        s=0;
        rep(j,n){
            if(j<i)s += v1[j];
            else if(j==i)s += v1[j]+v2[j];
            else s+= v2[j];
        }
        res = max(res,s);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    int h, w;
    cin >> h >> w;
    string str = "";

    for(int i = 0; i < h; i++){
        string tmp;
        cin >> tmp;
        str += tmp;
    }

    map<char,int> mp;

    for(int i = 0; i < str.size(); i++){
        mp[str[i]]++;
    }

    int nec1;
    int nec2;
    int nec4;

  

    if(str.size() % 2 == 0){
        nec1 = 0;
    } else {
        nec1 = 1;
    }

    if(h % 2 != 0 && w % 2 != 0){
        nec2 = h / 2 + w / 2;
        nec4 = (h / 2) * (w / 2);
    } else {
        nec4 = (h / 2) * (w / 2);
        nec2 = (h % 2 == 0? h / 2 : w / 2);
    }

    if(w % 2 == 0 && h % 2 == 0){
        nec2 = 0;
        nec4 = (h / 2) * (w / 2);
    }

    for(int i = 0; i < nec1; i++){
        for(auto &i : mp){
            if(i.second % 4 == 1 || i.second % 4 == 3){
                i.second--;
                break;
            }
        }
    }

    int cnt = 0;

    for(int i = 0; i < nec2; i++){
        for(auto &i : mp){
            if(i.second % 4 == 2 && i.second >= 2){
                i.second -= 2;
                cnt++;
                break;
            }
        }
    }

    for(int i = 0; i < nec2 - cnt; i++){
        for(auto &i : mp){
            if(i.second % 2 == 0 && i.second >= 2){
                i.second -= 2;
                break;
            }
        }
    }

    for(int i = 0; i < nec4; i++){
        for(auto &i : mp){
            if(i.second % 4 == 0 && i.second >= 4){
                i.second -= 4;
                break;
            }
        }
    }

    bool ok = true;

    for(auto &i : mp){
        //cout << i.second << endl;
        if(i.second != 0){
            ok = false;
        }
    }

      //cout << nec1 << " " << nec2 << " " << nec4 << endl;

    if(ok){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W[] = new int[N+1];
        int T = 0,S1 = 0,S2 = 0,abs = 0,min = 100;

        for(int i = 1; i <= N; i++){
            W[i] = sc.nextInt();
        }

        for (int i = 1; i <= N; i++){
            T = W[i];//Tがi番目の時
            //System.out.println("T="+T);

            for(int j = 1; j <= i; j++){
                S1 += W[j]; 
                //System.out.println("S1="+S1);
            }

            for(int k = i+1; k < N+1; k++){
                if(N == i){
                    break;
                }
                S2 += W[k];
            }

            //System.out.println("S1="+S1);
            //System.out.println("S2="+S2);

            abs = S1-S2;
            if(abs < 0){
                abs = -1*abs;
            }

            //System.out.println("abs="+abs);
            if(abs < min){
                min = abs;
            }
            //System.out.println("min="+min);

            S1=0;
            S2=0;

        }


        System.out.println(min);
        

    }
}


Measured memory_bytes: 22996
#include<iostream>
#include<bits/stdc++.h>
#define MAXH 20
#define MAXW 20
#define INF 10000
using namespace std;
typedef long long ll;

int H,W;
char m[MAXH][MAXW];
int dd[MAXH][MAXW]; //コピー前
int d[MAXH][MAXW]; //コピー後
int ans;

void calc(int n, int h, int w) {
	if (h > 0) {
		if (m[h - 1][w] == '.' && d[h - 1][w] > n + 1) {
			d[h - 1][w] = n + 1;
			calc(n + 1, h - 1, w);
		}
	}
	if (h < H-1) {
		if (m[h + 1][w] == '.' && d[h + 1][w] > n + 1) {
			d[h + 1][w] = n + 1;
			calc(n + 1, h + 1, w);
		}
	}
	if (w > 0) {
		if (m[h][w - 1] == '.' && d[h][w - 1] > n + 1) {
			d[h][w - 1] = n + 1;
			calc(n + 1, h, w - 1);
		}
	}
	if (w < W-1) {
		if (m[h][w + 1] == '.' && d[h][w + 1] > n + 1) {
			d[h][w + 1] = n + 1;
			calc(n + 1, h, w + 1);
		}
	}
}

int maxd() {
	int r = 0;
	for (int i = 0; i<H; i++) {
		for (int j = 0; j < W; j++) {
			if (d[i][j]!=INF && d[i][j] > r) {
				r = d[i][j];
			}
		}
	}
	return r;
}

int main() {
	ans = 0;

	cin >> H >> W;
	for (int i = 0; i<H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> m[i][j];
			dd[i][j] = INF;
		}
	}
	
	for (int i = 0; i<H; i++) {
		for (int j = 0; j < W; j++) {
			if (m[i][j] == '.') {
				memcpy(d, dd, sizeof(dd));
				calc(0, i, j);
				if (maxd() > ans) {
					d[i][j] = 0;
					ans = maxd();
				}
			}			
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn._

object Main  {
  def main(args: Array[String]): Unit = {
    val Array(n,m) = readLine.split(" ").map(_.toLong)
    println(f"${solve(n,m)}")
  }

  def solve(n: Long, m: Long): Long = {
    def pow(m: Long, acc: Long): Long = {
      m match {
        case 0 => acc
        case _ => pow(m-1,2*acc)
      }
    }
    val a = pow(m,1)

     (100*(n-m) + 1900*m)*a
  }
}


Measured memory_bytes: 25416
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back

ll func(ll num){
	if(num % 2 == 0)return num / 2;
	else return 3 * num + 1;
}
int main(){

	ll s;
	cin >> s;
	vector<ll> A;
	A.pb(s);
	ll cnt = 1;
	while(true){
		A.pb(func(A[cnt - 1]));
		for(ll i = 0; i < cnt; i ++){
			if(A[cnt] == A[i]){
				cout << cnt + 1 << endl;
				return 0;
			}
		}
		cnt ++;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
  string s;
  cin >> s;
  map<char, int> mp;
  for (int i = 0; i < s.size(); i++){
    if (mp.find(s[i]) == mp.end()){
      mp[s[i]] = 1;
    }else{
      mp[s[i]] += 1;
    }
  }
  bool ans = true;
  for (auto it = mp.begin(); it != mp.end(); it++){
    if (it->second % 2 == 0) continue;
    ans = false;
    break;
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

int main()
{
  int n,d,x;
  cin >> n >> d >> x;
  vector<int> a(n);
  int i;
  for(i = 0;i < n;++i){
    cin >> a.at(i);
  }
  vector<int> b(n);
  for(i = 0; i < n;++i){
    b.at(i) = (d-1)/a.at(i) + 1;
  }
  for(i = 0;i < n;++i){
    x += b.at(i);
  }
  cout << x << endl;
  return 0;
}

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

int solve(string S)
{
    long long Ssize = S.size();
    long long sum = 0;
    if (Ssize == 1)
    {
        int ss = S[0] - '0';
        cout << ss << endl;
        return 0;
    }

    for (long long bit = 0; bit < (1 << (Ssize - 1)); bit++)
    {
        string num = "";
        for (long long i = 0; i < Ssize; i++)
        //全体10桁だと, i→0 ~9箇所 Ssize-1と思ってしまっている。
        {
            num += S[i];
            //cout << Ssize << endl;

            if (bit & (1 << i)) //0:nasi 1:+  //i=9の時はここに入らず、下に抜ける。
            {
                sum += stoll(num);
                num = "";
            }
        }
        sum += stoll(num);
    }

    cout << sum << endl;
    return 0;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    string S;
    cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 100000 + 5;
// ------------------------------------

// ------------------------------------
// 1 is tru

int main() {
  int d, t, s;
  cin >> d >> t >> s;
  if (d <= s * t) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    vint a(n);
    rep(i,n) cin >> a[i];
    vint b(n,-1);
    rep(i,n) {
        if (i-a[i] < 0) {cout << -1 << endl; return 0;}
        chmax(b[i-a[i]],a[i]);
    }
    vint c(n,-1);
    rep(i,n) if (b[i] != -1) c[i] = i + b[i];
    rep(i,n-1) {
        if (c[i] == -1 || c[i+1] == -1) continue;
        if (c[i] > c[i+1]) {cout << -1 << endl; return 0;}
    }
    ll ans = 0;
    rep(i,n) if (b[i] != -1) ans += b[i];
    cout << ans << endl;
}

Measured memory_bytes: 5564
#include <map>
#include <cstdio>
#include <iostream>
typedef long long ll;

int W,H,N;
ll Cnt[15];
std::map<std::pair<int,int>,bool> G,P;

int main()
{
    scanf("%d%d%d",&W,&H,&N),Cnt[0]=ll(W-2)*(H-2);
    for(int i=1,x,y;i<=N;++i)
    {
        scanf("%d%d",&x,&y),G[std::make_pair(x,y)]=true;
        for(int xs=x-2;xs<=x;++xs)
            for(int ys=y-2;ys<=y;++ys)
                if(xs>=1&&xs+2<=W&&ys>=1&&ys+2<=H)
                    P[std::make_pair(xs,ys)]=true;
    }
    for(auto i:P)
    {
        int Nc=0;
        for(int j=0;j<=2;++j)
            for(int k=0;k<=2;++k)
                if(G.count(std::make_pair(i.first.first+j,i.first.second+k)))
                    ++Nc;
        ++Cnt[Nc],--Cnt[0];
    }
    for(int i=0;i<=9;++i)std::cout<<Cnt[i]<<std::endl;
    return 0;
}

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

using namespace std;
using ll = long long;

constexpr ll kMod = 1e9 + 7;

ll dp[6000][6000];

int main()
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  dp[0][0] = 1;
  for (int i = 1; i <= n; ++i)
  {
    for (int j = 0; j <= i; ++j)
    {
      if (j == 0)
      {
        dp[i][j] = dp[i - 1][j + 1] * 2 + dp[i - 1][j];
      }
      else
      {
        dp[i][j] = dp[i - 1][j + 1] * 2 + dp[i - 1][j - 1];
      }
      dp[i][j] %= kMod;
    }
  }
  cout << dp[n][s.length()] << endl;
}

Measured memory_bytes: 233856
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int C[N-1], S[N-1], F[N-1];
  for (int i = 0; i < N-1; i++) {
    cin >> C[i] >> S[i] >> F[i];
  }
  for (int i = 0; i < N-1; i++) {
    int answer = S[i]+C[i];
    for (int j = i+1; j < N-1; j++) {
      if (answer > S[j]) {
        answer += (F[j]-answer%F[j])%F[j]+C[j];
      } else {
        answer = S[j]+C[j];
      }
    }
    cout << answer << endl;
  }
  cout << 0;
}

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

//combination 二項係数

const long long MAX = 200010;
const long long MOD = 998244353;
long long fac[MAX],inv[MAX],finv[MAX];

void prepare(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i =2; i < MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - (MOD/i)*inv[MOD%i]%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}

long long comb(long long n , long long k){
    if(k>=0 && k<= n){
        return fac[n]*(finv[n - k]*finv[k]%MOD)%MOD;
    }
    else return 0;
}

long long power[MAX];

int main(){
    prepare();
    long long N, M, K;
    cin >> N >> M >> K;
    power[0] = 1;
    for(int i = 1; i < MAX; i++){
        power[i] = (M-1)*power[i-1]%MOD;
    }

    long long ans = 0;
    for(int seg = N-K; seg <= N; seg++){
        ans += (comb(N-1, seg -1)*M%MOD)*power[seg-1]%MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}

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

int main(){
    int n,k;
    string s;
    cin >>n>>k>>s;
    int kyo =0;
    int ans =0;
    for(int i=1;i<n;i++){
        if(s[i-1]==s[i]){
            ans++;            
        }else{
            kyo++;
        }
    }
    if(kyo%2==0){
        ans += min(2*k,kyo);
    }else{
        if(k<=kyo/2){
            ans += 2*k;
        }else{
            ans += kyo;
        }
    }
    
    cout << ans << endl;

}

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

#define endl '\n'

// #define int long long

typedef long long ll;
typedef long double ld;

typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1000000000;
const int MOD = 1000000007; // 998244353

int cnt[10][10];

signed main() {  
   ios::sync_with_stdio(false);
   cin.tie(nullptr);
   int n;
   cin >> n;
   for (int i = 1; i <= n; i++) {
      string str = to_string(i);
      int first = str[0] - '0';
      int last = str.back() - '0';
      cnt[last][first]++;
   }  
   int res = 0;
   for (int i = 1; i <= n; i++) {
      string str = to_string(i);
      int first = str[0] - '0';
      int last = str.back() - '0';
      res += cnt[first][last];
   }
   cout << res << endl;
   return 0;
}

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

typedef long long ll;

const ll        MOD=1000000007;  ///1e9+7

#define forn(i,n) for(i=0;i<n;i++)
#define mem(a,b) memset(a, b, sizeof(a))

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///
ll h,w,dp[1000][1000],dx[]={-1,0},dy[]={0,-1};
string a[1000];

ll rec(ll x,ll y)
{
    if(x<0 or y<0) return 0;
    if(a[x][y]=='#') return 0;
    if(dp[x][y]>-1) return dp[x][y]%MOD;
    ll opt1=0;
    for(int i=0;i<2;i++){
        opt1+=rec(x+dx[i],y+dy[i]);
    }
    dp[x][y]=opt1;
    return dp[x][y]%MOD;
}

void _case()
{
    cin>>h>>w;
    ll i;
    forn(i,h) cin>>a[i];
    mem(dp,-1);
    dp[0][0]=1;
    cout<<rec(h-1,w-1)<<'\n';
}

main()
{
        fastio();
        _case();
}


///Thank you.


///Brainless_Loco Terminates Here!


Measured memory_bytes: 12588
n = int(input())
a = list(map(int, input().split()))

# import collections
# for i in range(1, n + 1):
#   print(collections.Counter(a)[i])

b = [0] * (n + 1)

for e in a:
  b[e] += 1

for i in range(1, n + 1):
  print(b[i])


Measured memory_bytes: 32296
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
int a,b,c,x,y;
int ans=2e9;
int main()
{
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	for(int i=0;i<=max(x,y);i++)
	{
		int rx=x-i,ry=y-i;
		if(rx<0)rx=0;
		if(ry<0)ry=0;
		ans=min(ans,i*2*c+rx*a+ry*b);
	}
	printf("%d",ans);
	return 0;
} 

Measured memory_bytes: 256
Max = 10**18
N = int(input())
array = list(map(int, input().split()))
for i in range(N):
	if array[i]==0:
		print(0)
		exit()

ans = 1
for i in range(N):
	ans *= array[i]
	if ans > Max:
		print(-1)
		exit()

print(ans)

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

static const int MAX=1e5+1;

int N;
vector<vector<int>> g(MAX); //有向グラフの隣接リスト
vector<int> out; 
bool used[MAX]={};
int ind[MAX];

void bfs(int s){
    queue<int> q;
    q.push(s);
    used[s]=true;
    while(!q.empty()){
        int u=q.front(); q.pop();
        out.push_back(u);
        for(auto it=g[u].begin();it!=g[u].end();it++){
            int v=*it;
            ind[v]--;
            if(ind[v]==0&&used[v]==false){ //入次数が0になったら追加
                used[v]=true; //再訪しない
                q.push(v);
            }
        }
    }
}

void tsort(){
    for(int i=0;i<N;i++){
        ind[i]=0;
    }
    for(int u=0;u<N;u++){
        for(auto it=g[u].begin();it!=g[u].end();it++){
            int v=*it;
            ind[v]++; //各頂点の次数を計算
        }
    }
    for(int u=0;u<N;u++){
        if(ind[u]==0&&used[u]==false) bfs(u);
    }
    //for(int i=0;i<out.size();i++){
        //cout << out[i] << endl;
    //}
}

int main(){
    cin >> N;
    int M;
    cin >> M;
    for(int i=0;i<M;i++){
        int x,y; cin >> x >> y;
        x--;y--;
        g[x].push_back(y);
    }
    tsort();
    int dp[N]={};
    int ans=0;
    for(auto u=out.begin();u!=out.end();u++){
        for(auto v=g[*u].begin();v!=g[*u].end();v++){
            dp[*v]=max(dp[*v],dp[*u]+1);
            ans=max(ans,dp[*v]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 7160
// Ivan Carvalho
// Problem N - Educational Dynamic Programming Contest - AtCoder
// Link : https://atcoder.jp/contests/dp
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int MAXN = 410;
const ll INF = 1e14;

ll dp[MAXN][MAXN],V[MAXN],pref[MAXN];
int N;

ll calc(ll a,ll b){
	if(a > b) return INF;
	return pref[b] - pref[a-1];
}

ll solve(int ini,int fim){
	if(dp[ini][fim] != -1) return dp[ini][fim];
	if(ini == fim) return dp[ini][fim] = 0;
	if(ini + 1 == fim) return dp[ini][fim] = V[ini] + V[fim];

	ll best = INF;

	for(int i = ini;i<fim;i++){
		ll cand = solve(ini,i) + solve(i+1,fim) + calc(ini,fim);
		best = min(best,cand);
	}

	return dp[ini][fim] = best;

}

int main(){

	memset(dp,-1,sizeof(dp));

	cin >> N;
	for(int i = 1;i<=N;i++) cin >> V[i];

	for(int i = 1;i<=N;i++) pref[i] = pref[i-1] + V[i];

	cout << solve(1,N) << endl;

	return 0;

}

Measured memory_bytes: 1536
#include<iostream>
 #include<string>
 
 using namespace std;
 
 int expression();
 int term();
 int factor();
 
 string exp;
 int p;
 
 int expression(){
     int value = term();
    while( exp[p] == '+' || exp[p] == '-' ){
        if ( exp[p] == '+' ) { p++; value += term(); }
        else { p++; value -= term(); }
     }
     return value;
 }
 
 int term(){
     int value = factor();
    while( exp[p] == '*' || exp[p] == '/' ){
        if ( exp[p] == '*' ) { p++; value *= factor(); }
         else { p++; value /= factor(); }
     }
     return value;
 }
 
 int factor(){
     int value = 0;
     if ( exp[p] == '(' ){
         p++; value = expression(); p++;
     } else {
         while( isdigit(exp[p]) ) { value = value*10 + exp[p++] - '0';}
     }
     return value;
 }
 
 int main(){
     int tcase; cin >> tcase;
     for ( int i = 0; i < tcase; i++ ){
         cin >> exp;
         p = 0;
         cout << expression() << endl;
     }
     return 0;
 }

Measured memory_bytes: 0