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

#define vc vector
#define pb push_back
#define pf push_front
#define pr pair
#define mp make_pair
#define fi first
#define se second
#define uset unordered_set
#define umap unordered_map
#define str string
#define pq priority_queue
#define forn(i, a, b) for(int i = (a); i < (b); i++)
#define forr(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a) forn(i, 0, a)
#define all(x) x.begin(), x.end()
#define rev(x) x.rbegin(), x.end()
#define len(x) (int)x.size()
#define last(x) x[len(x)-1]
#define forall(i, x) for(auto &i : x)
#define endl '\n'

#define int long long
#define pii pr<int, int>
#define vi vc<int>

const int MAX = 1E6;
vc<vi> a(3, vi(3));

inline void fastio(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}


bool row(int n){
    return a[n][0] == 0 && 0 == a[n][2] && a[n][1] == 0;
}

bool col(int n){
    return a[0][n] == 0 && 0 == a[1][n] && a[2][n] == 0;
}


signed main()
{
    fastio();
    forall(i, a)
        forall(j, i)
            cin >> j;
    int n; cin >> n;
    rep(i, n){
        int x; cin >> x;
        forall(r, a)
        forall(c, r)
        if(c == x) c = 0;
    }
    if(row(0))
        cout << "Yes";
    else if(row(1))
        cout << "Yes";
    else if(row(2))
        cout << "Yes";
    else if(col(0))
        cout << "Yes";
    else if(col(1))
        cout << "Yes";
    else if(col(2))
        cout << "Yes";
    else if(a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0)
        cout << "Yes";
    else if(a[2][0] == 0 && a[1][1] == 0 && a[0][2] == 0)
        cout << "Yes";
    else
        cout << "No";
}


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

int main() {
	long long int n,i,j,k,w;
	cin >>n>>w;
	int a[n],b[n];
	for(i=0;i<n;i++)
	cin >>a[i]>>b[i];
	
	long long int dp[n+1][w+1];
	for(i=0;i<=n;i++)
	{
	    for(j=0;j<=w;j++)
	    {
	        if(i==0||j==0)
	        dp[i][j]=0;
	  else  if (a[i - 1] <= j) 
                dp[i][j] = max( b[i - 1] + dp[i - 1][j - a[i - 1]], dp[i - 1][j]); 
            else
                dp[i][j] = dp[i - 1][j];
	    }
	}
	cout<<dp[n][w];
}

Measured memory_bytes: 79104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int d=scan.nextInt();
		if(d==25) System.out.println("Christmas");
		else if (d==24 )System.out.println("Christmas Eve");
		else if(d==23) System.out.println("Christmas Eve Eve");
		else System.out.println("Christmas Eve Eve Eve");
	}

}


Measured memory_bytes: 26936
h, w = map(int, input().split())
S = [list(input().split()) for i in range(h)]

a = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

for i in range(h):
    for j in range(w):
        if S[i][j] == 'snuke':
            print(a[j]+str(i+1))
            break


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int a,i;
    if(n%2==0){
        a=n/2;
        int m=0;
        for(i=0;i<a;i++){
            if(s[i]!=s[i+a]){m++; break;}
        }
        if(m==0){cout<<"Yes";}
        else{cout<<"No";}
    }
    else{cout<<"No";}
}


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

public class Main{
    public static void main(String[] args){
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int hours = 0;
    int minutes = 0;
    int seconds = 0;
    
    
    try{
        int time = Integer.parseInt(br.readLine());
        
        hours = time / 3600;
        
        int x = time % 3600;
        minutes = x / 60;
        
        seconds = x % 60;
        
        
        
        System.out.println(hours+":"+minutes+":"+seconds);
        
        
    }catch(IOException e){}
    

    }
}

Measured memory_bytes: 24240
#include<iostream>
#include<queue>
#include<string>

using namespace std;




int main(){
    int n, q, w_time = 0;
    cin >>n >>q;
    //string name[n];
    //int time[n];
    class process{
    public:
        string name;
        int time;
    };
    //cout << n << ":" << q << endl;
    queue<process> qu;
    process p[100000];
    for(int i = 0; i < n; i++){
        cin >>p[i].name >>p[i].time;
        qu.push(p[i]);
    }
    while(qu.size() != 0){
        process pr = qu.front(); qu.pop();
        if(pr.time <= q){
            w_time += pr.time;
            cout << pr.name << " " << w_time << endl;
        }else{
            pr.time -= q;
            w_time += q;
            qu.push(pr);
        }
    }

}


Measured memory_bytes: 7920
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)

ll M;

template <typename T>
class Matrix {
public:
  vector<vector<T>> mat;
  Matrix(int h, int w) : mat(h, vector<T>(w)) {}
  vector<T>& operator[](int i) { return mat[i]; }
  const vector<T>& operator[](int i) const { return mat[i]; }
  const size_t height() const { return mat.size(); }
  const size_t width() const { return mat[0].size(); }

  // only square matrix
  static Matrix identity(int n) {
    Matrix E(n, n);
    for (int i = 0; i < n; ++i) E[i][i] = 1;
    return E;
  }

  // O(N^3)
  Matrix& operator*=(const Matrix& m) {
    int h = m.height(), w = m.width();
    vector<vector<T>> res(height(), vector<T>(w));
    for (int i = 0; i < height(); ++i)
      for (int k = 0; k < h; ++k)
        for (int j = 0; j < w; ++j) {
          if (i == 0)
            (res[i][j] += (*this)[i][k] % M * (m[k][j] % M)) %= M;
          else
            res[i][j] += (*this)[i][k] * m[k][j];
        }
    mat.swap(res);
    return *this;
  }

  Matrix& operator*(const Matrix& rhs) { return Matrix(*this) *= rhs; }

  // O(N^3logK)
  Matrix operator^(T exponent) {
    Matrix res = Matrix::identity(height());
    Matrix product = *this;

    while (exponent) {
      if (exponent & 1) res *= product;
      product *= product;
      exponent >>= 1;
    }
    return res;
  }

  friend ostream& operator<<(ostream& os, Matrix& m) {
    os << "---- Matrix ----" << endl;
    for (int i = 0; i < m.height(); ++i)
      for (int j = 0; j < m.width(); ++j)
        os << m[i][j] << " \n"[j == m.width() - 1];
    os << "---- Matrix end ----" << endl;
    return os;
  }
};

constexpr ll MOD = 1000000007;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;

int main() {
  ll L, A, B;
  cin >> L >> A >> B >> M;
  ll now = A;
  ll ten = 1;

  // 10^d 1 0   ans
  // 0    1 1   now
  // 0    0 1   b
  ll ans = 0;
  for (int i = 0; i < 18 && L > 0; ++i) {
    ten *= 10;
    ll l = max((ll)0, (ten - now + B - 1) / B);
    ll x = min(L, l);

    Matrix<ll> b(3, 3);
    Matrix<ll> c(3, 1);
    b[0][0] = ten % M;
    b[0][1] = 1;
    b[1][1] = 1;
    b[1][2] = 1;
    b[2][2] = 1;
    b = b ^ x;
    c[0][0] = ans;
    c[1][0] = now;
    c[2][0] = B;
    b *= c;
    ans = b[0][0];
    now = b[1][0];
    L -= x;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3192
#ifdef DBG1
  #define LOCAL
#endif

#ifdef LOCAL
  #define _GLIBCXX_DEBUG
#endif

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#ifdef DBG1
    #define dbg(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dbg(...)
#endif

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;

bool solve() {
  int n;
  if (scanf("%d", &n) != 1) { return false; }

  static char s[1000];
  scanf("%s", s);
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'B') {
      cnt++;
    } else {
      cnt--;
    }
  }
  printf("%s\n", cnt >= 0 ? "No" : "Yes");
  return true;
}

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

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

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }

  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }

  bool same(int x, int y) { return find(x) == find(y);}

  int size(int x) { return -d[find(x)];}
};

int f[100005];
vector<int> block[100005];

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    UnionFind uf(N);
    int a, b, c, d;
    for (int i = 0; i < M; ++i) {
        cin >> a >> b;
        --a;
        --b;
        f[a]++;
        f[b]++;
        uf.unite(a, b);
    }
    for (int i = 0; i < K; ++i) {
        cin >> c >> d;
        --c;
        --d;
        block[c].push_back(d);
        block[d].push_back(c);
    }
    for (int i = 0; i < N; ++i) {
        int s = uf.size(i) - 1 - f[i];
        for (int x : block[i]) {
            if (uf.same(i, x)) --s;
        }
        cout << s;
        if (i+1 == N) cout << endl;
        else cout << " ";
    }
    return 0;
}

Measured memory_bytes: 6784
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<deque>
using namespace std;
typedef long long ll;
ll dp[2][100001];
typedef pair<ll,ll>pii;
int main()
{
	int num,gen,kai;
	scanf("%d%d%d",&num,&gen,&kai);
	vector<ll>vec;
	vec.push_back(0);
	for(int i=0;i<num;i++)
	{
		int z;
		scanf("%d",&z);
		vec.push_back(z);
	}
	num++;
	int cur=0;
	for(int i=0;i<kai;i++)
	{
		deque<pii>deq;
		for(int j=0;j<num;j++)
		{
			if(!deq.empty())
			{
				if(deq[0].first==j-gen-1)deq.pop_front();
			}
			if(deq.empty())dp[1-cur][j]=-1000000000000000000LL;
			else dp[1-cur][j]=deq[0].second+vec[j]*(i+1);
			for(;;)
			{
				if(deq.empty())break;
				pii z=deq[deq.size()-1];
				if(z.second<dp[cur][j])deq.pop_back();
				else break;
			}
			deq.push_back(make_pair(j,dp[cur][j]));
		}
		for(int j=0;j<num;j++)dp[cur][j]=0;
		cur=1-cur;
	}
	ll maxi=0;
	for(int i=0;i<num;i++)maxi=max(maxi,dp[cur][i]);
	printf("%lld\n",maxi);
}

Measured memory_bytes: 4212
#1/i!でなく1/iだった
n = int(input())
x = list(map(int, input().split( )))
mod = 10**9+7
#rev_fact = []
rev = []
res = 1
for i in range(1,n):
     rev_i = pow(i,mod-2,mod)
     #res *= rev_i
     #res %= mod
     #rev_fact.append(res)
     rev.append(rev_i)

n_fact = 1

for i in range(1,n):
    n_fact*=i
    n_fact%=mod
#print(n_fact)
ans = 0
tmp = 0
for i in range(n-1):
    tmp += rev[i]
    ans += (x[i+1]-x[i])*tmp
    ans %= mod
ans*=n_fact
ans%=mod
print(ans)


Measured memory_bytes: 63640
#pragma comment(linker,"/stack:16777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=1;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int p[110];
int main(int argc,char** argv){
	int x,n;
	cin>>x>>n;
	rep(i,n){
		int pn;
		cin>>pn;
		p[pn]=1;
	}
	int mn=INF,ans=0;
	for(int i=-100;i<=300;i++){
		if(!p[i]&&abs(x-i)<mn){
			mn=abs(x-i);
			ans=i;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3596
a=list(input())
p=(a[0]=="R")
q=(a[1]=="R")
r=(a[2]=="R")

if (p and q and r):
  print(3)
elif (p and q) or (q and r):
  print(2)
elif (p or q or r):
  print(1)
else:
  print(0)

Measured memory_bytes: 9012
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define mk make_pair
#define pb push_back
#define eps 1e-12
#define sd(x) scanf("%d",&x)
#define sdl(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define pdl(x) printf("%lld\n",x)
#define MAXN 200009
using namespace std;
vector<int> g[MAXN];
int deg[MAXN];
vector<int> edge_list[MAXN];
pii edge[MAXN];
bool no_use[MAXN];
int new_deg[MAXN];
int dist[MAXN];
int par[MAXN];
int final_dist[MAXN];
inline void dfs(int pos,int prev)
{
	dist[pos]=dist[prev]+1;
	for(int i=0;i<g[pos].size();i++)
	{
		if(g[pos][i]!=prev)
		{
			dfs(g[pos][i],pos);
		}
	}
}
inline void dfs1(int pos,int prev)
{
	par[pos]=prev;
	final_dist[pos]=final_dist[prev]+1;
	for(int i=0;i<g[pos].size();i++)
	{
		if(g[pos][i]!=prev)
		{
			dfs1(g[pos][i],pos);
		}
	}
}
int main()
{
	int n;
	sd(n);
	for(int i=1;i<n;i++)
	{
		int x,y;
		sd(x);
		sd(y);
		g[x].pb(y);
		g[y].pb(x);
		deg[x]++;
		deg[y]++;
		edge[i]=mk(x,y);
		edge_list[x].pb(i);
		edge_list[y].pb(i);
	}
	for(int i=1;i<=n;i++)
	{
		if(deg[i]==1)
		{
			no_use[edge_list[i][0]]=true;
		}
	}
	for(int i=1;i<n;i++)
	{
		if(!no_use[i])
		{
			new_deg[edge[i].first]++;
			new_deg[edge[i].second]++;
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(new_deg[i]>=3)
		{
			printf("-1\n");
			return 0;
		}
	}
	dfs(1,0);
	int maxid=-1;
	int maxx=0;
	for(int i=1;i<=n;i++)
	{
		if(dist[i]>maxx)
		{
			maxx=dist[i];
			maxid=i;
		}
	}
	dfs1(maxid,0);
	maxx=0;
	maxid=-1;
	for(int i=1;i<=n;i++)
	{
		if(final_dist[i]>maxx)
		{
			maxx=final_dist[i];
			maxid=i;
		}
	}
	vector<int> v;
	int val=maxid;
	while(val)
	{
		v.pb(val);
		val=par[val];
	}
	vector<int> fans1,fans2;
	int next_num=1;
	for(int i=0;i<v.size();i++)
	{
		int req=deg[v[i]];
		if((i==0)||(i==(v.size()-1)))
		{
			req--;
		}
		else
		{
			req-=2;
		}
		for(int i=next_num+1;i<=next_num+req;i++)
		{
			fans1.pb(i);
		}
		fans1.pb(next_num);
		next_num=next_num+req+1;
	}
	reverse(v.begin(),v.end());
	next_num=1;
	for(int i=0;i<v.size();i++)
	{
		int req=deg[v[i]];
		if((i==0)||(i==(v.size()-1)))
		{
			req--;
		}
		else
		{
			req-=2;
		}
		for(int i=next_num+1;i<=next_num+req;i++)
		{
			fans2.pb(i);
		}
		fans2.pb(next_num);
		next_num=next_num+req+1;
	}
	vector<int> res;
	if(fans1<fans2)
	{
		res=fans1;
	}
	else
	{
		res=fans2;
	}
	for(int i=0;i<res.size();i++)
	{
		printf("%d ",res[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 26748
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define inf 100000000000005
#define mod 1000000007
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define R(i,a,b) for (int i=(a);i<(b);i++)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define pa pair<int,int>
#define pb push_back
#define be begin()
#define en end()
#define ret return puts("-1"),0;
#define int ll
#define N 5055
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,ans,A,B,sum[N][N],f[N],p[N];
inline void cm(int &x,int k){x=(k<x)?k:x;}
signed main(){
	n=read();A=read();B=read();
	F(i,1,n){
		p[i]=read();
		F(j,1,n) sum[i][j]=sum[i-1][j];F(j,p[i],n) sum[i][j]++;
	}
	ans=inf;
	F(i,1,n){
		f[p[i]]=(p[i]-1)*B;
		F(j,1,i-1){
			if (p[j]>p[i]) continue;
			int t=p[j],p1=(sum[j][p[i]]-sum[j][t]);
			cm(f[p[i]],f[t]+A*p1+B*(p[i]-t-p1-1));
		}
		int p1=sum[i][n]-sum[i][p[i]];
		cm(ans,f[p[i]]+A*p1+B*(n-p[i]-p1));
	}
	wrn(ans);
	return 0;
}

Measured memory_bytes: 198912
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>n;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int d,n;
  cin >> d >> n;
  int a;
  a = pow(100,d);
  if (n != 100) cout << n * a << endl;
  else cout << (n+1) * a << endl;
}

Measured memory_bytes: 512
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const int dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG	https://www.youtube.com/channel/UC6XdFs8T6Ei54O0FYl3PVVA


using namespace std;



int main() {
	int N;
	cin >> N;
	vector<double>x(N);
	vector<string>u(N);
	double ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> u[i];
		if (u[i] == "JPY") {
			ans += x[i];
		}
		else {
			ans += x[i] * 380000.0;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
class Arrow
  attr_reader :source, :sink, :label
   
  def initialize(source, sink, label)
    @source = source
    @sink = sink
    @label = label
  end
end
 
class Result
  attr_reader :target, :spell
 
  def initialize(target, spell)
    @target = target
    @spell = spell
  end
end
 
def advance(table, n, goes, arrows)
  next_table = [nil] * n
  (0...n).each do |node|
    best = table[node]
    goes[node].each do |arrow|
      result = table[arrow.sink]
      next unless result
      test = arrow.label + result.spell
      if !best || test < best.spell
        best = Result.new(arrow.sink, test)
      end
    end
    next_table[node] = best if best
  end
  next_table
end
 
def has_cycle(table, result, n)
  used = [false] * n
  loop do
    node = result.target
    return false unless node
    return true if used[node]
    used[node] = true
    result = table[node]
  end
end
 
def work(n, arrows, start, goal)
  goes = (0...n).map{[]}
  arrows.each do |arrow|
    goes[arrow.source] << arrow
  end
  table = [nil] * n
  table[goal] = Result.new(nil, '')
  n.times do
    table = advance(table, n, goes, arrows)
  end
  return nil unless table[start]
  (n*5).times do
    table = advance(table, n, goes, arrows)
  end
  result = table[start]
  has_cycle(table, result, n) ? nil : result.spell
end
 
loop do
  n, a, s, g = STDIN.gets.split.map(&:to_i)
  break if n == 0
 
  arrows = (0...a).map do |i|
    x, y, lab = STDIN.gets.split
    x = x.to_i
    y = y.to_i
    Arrow.new(x, y, lab)
  end
 
  start = s
  goal = g
 
  puts work(n, arrows, start, goal) || 'NO'
end

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

using namespace std;
using nagai = long long;
mt19937 rnd(228);


nagai dp[2002][2002][2];

nagai stup(int l, int n, vector<int> c)
{
	if (n > 2000)
		return -1;
	nagai oo = 1e18;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			dp[i][j][0] = dp[i][j][1] = -oo;
	dp[0][0][0] = dp[0][0][1] = 0;
	nagai ans = 0;
	auto dist = [&](int a, int b)
	{
		nagai ans = c[b] - c[a];
		if (ans < 0)
			ans += l;
		return ans;
	};
	for (int len = 0; len < n; ++len)
	{
		for (int i = 0; i < n; ++i)
		{
			int j = (i + len) % n;
			int i1 = i == 0 ? n - 1 : i - 1;
			int j1 = j + 1 == n ? 0 : j + 1;
			ans = max(ans, dp[i][j][0]);
			ans = max(ans, dp[i][j][1]);
//			cerr << i << ' ' << j << ' ' << dp[i][j][0] << ' ' << dp[i][j][1] << '\n';
			if (len + 1 == n)
				continue;
			dp[i1][j][0] = max(dp[i1][j][0], dp[i][j][0] + dist(i1, i));
			dp[i][j1][1] = max(dp[i][j1][1], dp[i][j][0] + dist(i, j1));
			dp[i1][j][0] = max(dp[i1][j][0], dp[i][j][1] + dist(i1, j));
			dp[i][j1][1] = max(dp[i][j1][1], dp[i][j][1] + dist(j, j1));
		}
	}
	return ans;
}

nagai smart(int l, int n, vector<int> c)
{
	auto go = [&](int a, int b)
	{
		nagai ans = c[b] - c[a];
		if (ans < 0)
			ans += l;
		return ans;
	};
	nagai ans = 0;
	vector<nagai> pos(n), neg(n);
	for (int i = 0; i < n; ++i)
		pos[i] = go(0, i), neg[i] = go(i, 0);
	vector<nagai> prpos(n), suneg(n);
	for (int i = 1; i < n; ++i)
		prpos[i] = prpos[i - 1] + pos[i];
	suneg[n - 1] = neg[n - 1];
	for (int i = n - 2; i > 0; --i)
		suneg[i] = suneg[i + 1] + neg[i];
	assert(pos[0] == 0 && neg[0] == 0);
	for (int i = 1; i < n; ++i)
	{
		nagai ansich = 0;
		int rest = n - (i + 1);
		int last0 = (n - (rest + 1) / 2) % n;
		int lasti = i + rest / 2;
		ansich += (prpos[lasti] - prpos[i - 1]) * 2;
		ansich += suneg[last0] * 2;
		if (rest % 2 == 0)
			ansich -= pos[lasti];
		else
			ansich -= neg[last0];
		//cerr << i << ' ' << rest << ' ' << last0 << ' ' << lasti << ' ' << ansich << '\n';
		ans = max(ans, ansich);
		ansich = 0;
		rest = i - 1;
		last0 = (rest + 1) / 2;
		lasti = (i - rest / 2);
		ansich += prpos[last0] * 2;
		ansich += (suneg[lasti] - suneg[(i + 1) % n]) * 2;
		if (rest % 2 == 0)
			ansich -= neg[lasti];
		else
			ansich -= pos[last0];
//		cerr << i << ' ' << rest << ' ' << last0 << ' ' << lasti << ' ' << ansich << '\n';
		ans = max(ans, ansich);
	}
	return ans;
}

nagai solve(int l, int n, vector<int> c)
{
	c.insert(c.begin(), 0);
	++n;
	return smart(l, n, c);
	nagai a = stup(l, n, c);
	nagai b = smart(l, n, c);
	if (a != -1 && a != b)
	{
		//cerr << a << ' ' << b << '\n';
		exit(239);
	}
	return b;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	/*
	for (int i = 0; i < 1000; ++i)
	{
		int l = rnd() % 1000 + 2, n = rnd() % 10 + 1;
		vector<int> c(n);
		for (auto& x : c)
			x = rnd() % (l - 1) + 1;
		sort(c.begin(), c.end());
		c.resize(unique(c.begin(), c.end()) - c.begin());
		n = c.size();
		solve(l, n, c);
	}
	cerr << "OK\n";
	return 0;
	*/
	int l, n;
	cin >> l >> n;
	vector<int> c(n);
	for (auto& x : c)
		cin >> x;
	cout << solve(l, n, c) << '\n';
}



Measured memory_bytes: 8816
#include <bits/stdc++.h>
using namespace std;
string s;
int ans = INT_MAX;
int main()
{
    ios::sync_with_stdio(false);
	cin >> s;
	for (int i = 1; i < s.length(); ++i)
    {
        if (s[i] != s[i - 1])
        {
            ans = min(ans, max(i, (int)(s.length() - i)));
        }
    }
    cout << min(ans, (int)s.length()) << endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
#define ll long long
using namespace std;
const int maxn=200010;
int n,tr[maxn][2],bg[maxn],tot=1;ll L;
bool num[100];
char s[maxn];
int lowbit(ll x)
{
    int r=0;
    for(;!(x&1);r++,x>>=1);
    return r;
}
void ins(int v,int id,int d,int len)
{
    if(tr[v][s[bg[id]+d-1]-'0']==0)     tr[v][s[bg[id]+d-1]-'0']=++tot;
    if(d!=len) ins(tr[v][s[bg[id]+d-1]-'0'],id,d+1,len);
}
void dfs(int v,int d)
{
    for(int k=0;k<=1;k++)
        if(tr[v][k]==0) {if(L-d>0) num[lowbit(L-d)]^=1;}
        else dfs(tr[v][k],d+1);
}
int main()
{
    scanf("%d%lld",&n,&L);
    int top=0;
    for(int i=1;i<=n;i++)
    {
        bg[i]=top+1;
        scanf("%s",s+bg[i]);
        top+=strlen(s+bg[i]);
        ins(1,i,1,strlen(s+bg[i]));
    }
    dfs(1,0);
    for(int i=0;i<=60;i++) if(num[i]) {puts("Alice");return 0;}
    puts("Bob");
    return 0;
}

Measured memory_bytes: 5760
n = input()
a = int(n[0]+n[1])
b = int(n[2]+n[3])

if 1 <= a <= 12 and 1 <= b <=12:
  print("AMBIGUOUS")
elif 1 <= b <= 12:
  print("YYMM")
elif 1 <= a <= 12 :
  print("MMYY")
else:
  print("NA")


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin >> n;
    vector<int> a(n);
    int cnt = 0;
    int ans = 0;
    
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i <n - 1; i++){
        if(a[i] >= a[i+1]){
            cnt++;
        }else {
            ans = max(cnt, ans);
            cnt = 0;
        }
        
    }
    
    ans = max(cnt, ans);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>

using namespace std;

int main()
{
	int n;
	
	for(;;)
	{
		cin >> n ;
		if(n==0)
			break;
		
		int ans=0;
		
		int a;
		a=1000-n;
		ans+=a/500;
		a%=500;
		ans+=a/100;
		a%=100;
		ans+=a/50;
		a%=50;
		ans+=a/10;
		a%=10;
		ans+=a/5;
		a%=5;
		ans+=a/1;
		a%=1;
		
		cout << ans << endl;
	}
}

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

array<array<long long, 2001>, 2001> pcl;

void constructPascal()
{
	pcl[0][0] = 1;
	pcl[1][0] = 1;
	pcl[1][1] = 1;
	for (long long i = 2; i < 2001; ++i) {
		pcl[i][0] = 1;
		for (long long j = 1; j <= i; ++j) {
			pcl[i][j] = (pcl[i - 1][j - 1] + pcl[i - 1][j]) % 1000000007;
		}
	}
}

long long f(long long a, long long b) {
	if (a < b) {
		return 0;
	}
	if (b == 0) {
		return 0;
	}

	return pcl[a - 1][b - 1];
}

int main()
{
	constructPascal();

	long long n, k;
	cin >> n >> k;

	for (long long i = 1; i <= k; ++i) {
		long long ret = 0;
		//ret += f(n - k, i - 1) % 1000000007 * f(k, i) % 1000000007;
		//ret += f(n - k, i) * 2 % 1000000007 * f(k, i) % 1000000007;
		//ret += f(n - k, i + 1) % 1000000007 * f(k, i) % 1000000007;
		ret += f(n - k + 2, i+1) % 1000000007 * f(k, i) % 1000000007;
		cout << ret << endl;
	}

	return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
    int N;
    cin >> N;

    vector<int64_t> a_arr(N);
    int64_t a_sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> a_arr[i];
        a_sum += a_arr[i];
    }

    vector<int64_t> b_arr(N);
    int64_t b_sum = 0;
    for (int j = 0; j < N; j++) {
        cin >> b_arr[j];
        b_sum += b_arr[j];
    }

    if (a_sum < b_sum) {
        cout << -1 << endl;
        return 0;
    }

    int ans = 0;
    int64_t sub_sum = 0;
    vector<int64_t> c_arr;
    for (int k = 0; k < N; k++) {
        int64_t a = a_arr[k];
        int64_t b = b_arr[k];
        if (a < b) {
            ans++;
            sub_sum += (b - a);
        }
        if (a > b) {
            c_arr.push_back(a - b);
        }
    }

    //  合格するのに必要な差分を、いくつの
    //  準備度が高い値で満たせるか

    if (sub_sum == 0) {
        cout << 0 << endl;
    } else {
        sort(c_arr.begin(), c_arr.end(), greater<int>());

        for (int l = 0; l < c_arr.size(); l++) {
            sub_sum -= c_arr[l];
            ans++;
            if (sub_sum <= 0) {
                break;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


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

using namespace std;

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

    n %= 10;
    if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9) cout << "hon" << endl;
    else if(n == 0 || n == 1 || n == 6 || n == 8) cout << "pon"  << endl;
    else cout << "bon" << endl;
    
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

string S;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> S;
    ll ans = 0;
    F0R(i,sz(S)) FOR(j,i,sz(S)) {
        int l = max(0,i-1), r = max(sz(S)-2-j,0);
        ans += (ll)stoll(S.substr(i,j-i+1))<<l<<r;
    }
    cout << ans;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	nextReader = newScanner()
	n := nextInt()
	fmt.Println(sum(n) - sum(n/3)*3 - sum(n/5)*5 + sum(n/15)*15)
}

func sum(n int) int {
	return n * (n + 1) / 2
}

// ---------------------------------------------------------------
// I/O
// ---------------------------------------------------------------
var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextString() string { return nextReader() }

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }

func nextInts(size int) []int {
	ns := make([]int, size)
	for i := 0; i < size; i++ {
		ns[i] = nextInt()
	}
	return ns
}

Measured memory_bytes: 1760
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#include <math.h>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int N = 1e3 + 10;
const int mod = 998244353;
const double eps = 1e-8;

LL n;
int a[] = {2, 3, 5, 7};
int check(LL n) {
    for(int i = 0; i < 4; i++) {
        if(n % a[i] == 0) return 1;
    }
    return 0;
}

int main()
{
    cin>>n;
    int sum = 0, mx = 0;
    for(int i=1;i<=n;i++) {
        int x; scanf("%d", &x);
        sum += x;
        if(mx < x) mx = x;
    }
    cout<<sum - mx / 2;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n,k;
  unsigned long count=0;
  unsigned long abs_s=0;
  unsigned long abs_t=0, abs_u=0;
  scanf("%d %d", &n, &k);
  
  for(int a=1;a<n+1;a++){
    if((2*a)%k==0){
      abs_s++;
      if(a%k==0)
        abs_t++;
    }
  }

  abs_u = abs_s - abs_t;

  count = abs_s + (abs_u*(abs_u-1))*3 + (abs_t*(abs_t-1))*3 + (abs_u*(abs_u-1)*(abs_u-2)) + (abs_t*(abs_t-1)*(abs_t-2));

  printf("%lu\n", count);

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;

int h, w;

int count(vector<vector<char>> &field, int x, int y){
  int count = 0;
  for(int i=-1;i<=1;i++){
    for(int j=-1;j<=1;j++){
      int nx=x+i, ny=y+j;
      if((0<=nx&&nx<h)&&(0<=ny&&ny<w)){
        count+=int(field[nx][ny]=='#');
      }
    }
  }
  return count;
}

int main(){
  cin>>h>>w;
  vector<vector<char>> field(h, vector<char>(w));
  for(int i=0;i<h;i++){
    string s;cin>>s;
    for(int j=0;j<w;j++)field[i][j]=s[j];
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(field[i][j]=='#')continue;
      field[i][j]=char(count(field, i, j)+'0');
    }
  }
  for(int i=0;i<h;i++){
    for(char c:field[i])cout<<c;
    cout << endl;
  }
}

Measured memory_bytes: 256
import itertools,sys
def S(): return sys.stdin.readline().rstrip()
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
H,W = LI()
S = [S() for _ in range(H)]
ans = []
for h,w in itertools.product(range(H),range(W)):
    if S[h][w]=='#':
        ans.append('#')
        continue
    count = 0
    for dh,dw in itertools.product([-1,0,1],repeat=2):
        nh,nw = h+dh,w+dw
        if not(0<=nh<=H-1) or not (0<=nw<=W-1):
            continue
        if S[nh][nw]=='#':
            count += 1
    ans.append(count)
for i,x in enumerate(ans,1):
    print(x,sep='',end='')
    if i%W==0:
        print()


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
int main() {
    int a,b,c;cin>>a>>b>>c;
    if(a==b&&b==c)cout<<1<<endl;
    else if(a==b&&b!=c||b==c&&a!=c||a==c&&a!=b)cout<<2<<endl;
    else cout<<3<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main()
{
  int N, W, w, v;

  cin >> N >> W;

  vector<int64_t> dp(W + 1, 0);

  for (int i = 0; i < N; i++)
  {
    cin >> w >> v;
    for (int64_t j = W; j >= w; j--)
    {
      dp[j] = max(dp[j], dp[j - w] + v);
    }
  }

  cout << dp.back() << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int X,Y,A,B,C,x; cin>>X>>Y>>A>>B>>C;
	multiset<int> p,q,r;
	for (int i=0; i<A; i++)
		cin>>x, p.insert(x);
	for (int i=0; i<B; i++) 
		cin>>x, q.insert(x);
	for (int i=0; i<C; i++) 
		cin>>x, r.insert(x);

	vector<int> ret;
	while(X--) {
		int cur=*p.rbegin();
		p.erase(p.find(cur));
		ret.push_back(cur);
	}
	while(Y--) {
		int cur=*q.rbegin();
		q.erase(q.find(cur));
		ret.push_back(cur);
	}
	sort(ret.begin(),ret.end());
	for (int i=0; i<ret.size(); i++) {
		if(r.empty())
			break;
		int cur=*r.rbegin();
		if(cur>ret[i]) {
			r.erase(r.find(cur));
			ret[i]=cur;
		}
	}
	ll ans=0;
	for (int x : ret)
		ans+=x;
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 15484
#include <iostream>

int main(void) {
    int n;
    std::cin >> n;
    int a[n], b[n];
    a[0] = 0;
    b[0] = 0;
    for (int i = 1; i < n; i++) {
        std::cin >> a[i];
        b[i] = 0;
    }
    for (int i = 0; i < n; i++) {
        b[a[i]-1]++;
    }
    for (int i = 0; i < n; i++) {
        std::cout << b[i] << std::endl;
    }
    return 0;
}

Measured memory_bytes: 5200
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


A, B = read_ints()
if (1 <= A <= 9) and (1 <= B <= 9):
    print(A*B)
else:
    print(-1)


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

int main(void) {
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;
    if (s.at(a) != '-') {
        cout << "No" << endl;
        return 0;
    }
    for (int i = 0; i < a + b + 1; i++) {
        if (i == a) continue;
        if (!isdigit(s.at(i))) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>

int main(void)
{
	char str[21];
	int i, j;

	scanf("%s", str);

	i = 0;
	while (str[i] != '\0'){
		i++;
	}

	for (j = i - 1; j >= 0; j--){
		printf("%c", str[j]);
	}
	printf("\n");

	return (0);
}

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

using namespace std;
#define int long long
long long total, a[15];
int n;
int h, w, x[100005], y[100005];

map<pair<int, int>, bool> mymap;
map<pair<int, int>, bool> mymap1;
signed main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> h >> w >> n;
    total = (h - 2) * (w - 2);
    for(int i = 1; i <= n; i++){
        cin >> y[i] >> x[i];
        mymap1[{x[i], y[i]}] = 1;
    }
    for(int i = 1; i <= n; i++){
        for(int l = max(x[i] - 2, 1LL); l <= min(x[i], w); l++){
            for(int j = max(y[i] - 2,1LL); j <= min(y[i], h); j++){
                if(l + 2 <= w && j + 2 <= h && mymap.count({l, j})==0){
                    int count1 = 0;
                    for(int l1 = l; l1 <= l + 2; l1++){
                        for(int l2 = j; l2 <= j + 2; l2++){
                            if(mymap1.count({l1, l2}))
                                count1++;
                            //if(l == 3 && j == 1)
                                //cout << l1 << " " << l2 << "\n";
                        }
                    }
                    a[count1]++;
                    mymap[{l, j}] = 1;
                }
            }
        }
    }
    for(int i = 1; i <= 9; i++)
        total-=a[i];
    a[0] = total;
    for(int i =0;i <= 9;i ++)
        cout << a[i] << "\n";
}


Measured memory_bytes: 64384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,l;
  cin >> n >> l;
  vector<string> s(n);
  for(int i=0; i<n; i++){
    cin >> s.at(i);
  }
  sort(s.begin(),s.end());
  for(int i=0; i<n; i++){
    cout << s.at(i);
  }
  cout << endl;
}

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

const long long infinity = 1e18;




// vector<vector<long long> > dp( 100 , vector<long long> (1000000, 0));
int main(){
	int n,W;
	cin>>n>>W;
	
	int w[n];
    int v[n];
	int sum = 0;
	for(int i=0;i<n;i++){
		cin>>w[i]>>v[i];
		sum += v[i];
	}
    vector<vector<long long> > dp( n , vector<long long> (sum+1, 0));
	for(int i=0;i<n;i++){
		for(int j=0;j<=sum;j++){
			dp[i][j] = infinity;
		}
	}

	dp[0][0] = 0;
	dp[0][v[0]] = w[0];
	
	for(int id=1;id<n;id++){
		dp[id][0] = 0;
		for(int j=1;j<=sum;j++){
			
			// Discard current object
			dp[id][j] = dp[id-1][j];
			
			// Pick current object
			if(j >= v[id])
				dp[id][j] = min(dp[id][j], w[id] + dp[id-1][j-v[id]]);
			
		}
	}
	
	long long answer;
	
	for(int val = sum;val>=0;val--){
		if(dp[n-1][val] <= W){
			answer = val;
			break;
		}
	}
	
	cout<<answer;
	
	return 0;
}


Measured memory_bytes: 82296
#include <iostream>
#include <array>
#include <string>

#define DAY_XMAS 25

int main()
{
  int D;

  std::cin >> D;
  std::array<std::string, 4> xmas{"Christmas", " Eve", " Eve", " Eve"};

  for (auto i = 0; i <= DAY_XMAS - D; ++i) std::cout << xmas[i];
  std::cout << std::endl;

  return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
a = list(map(int,input().split()))
a0 = a[0]
an = a[n-1]
now = a0
c_self = 0
c_inter = 0
for i in range(n):
    for j in range(i,n):
        #print(i,j)
        #print("a",a[i],a[j])
        if a[i] > a[j]:
            c_self += 1
        if a[i] != a[j]:
            c_inter += 1

t =( (k-1) * k//2) % (10**9 + 7)
l = (k * c_self) % (10**9 + 7)
q = (t * c_inter) % (10**9 + 7)
# ans =  (k * c_self   + 0.5 * k*(k-1) * c_inter) % (10**9+7)
ans = (l + q ) % (10**9 + 7)
print(int(ans))


Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
int main() {
	int N;
	string S[100010];
	cin >> N;
	ll ans[5] = {};
	for (int i = 0; i < N; ++i) {
		cin >> S[i];
		if (S[i][0] == 'M')ans[0]++;
		else if (S[i][0] == 'A')ans[1]++;
		else if (S[i][0] == 'R')ans[2]++;
		else if (S[i][0] == 'C')ans[3]++;
		else if (S[i][0] == 'H')ans[4]++;
	}
	ll A = 0;
	for (int i = 0; i < 3; ++i) {
		for (int j = i + 1; j < 4; ++j) {
			for (int k = j + 1; k < 5; ++k) {
				A += ans[i] * ans[j] * ans[k];
			}
		}
	}
	cout << A << endl;
	return 0;
}

Measured memory_bytes: 6144
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	string str;
	cin >> str;
	bool c=false,f=false;
	for(int i=0;i<str.size();i++){
		if(str[i]=='C')c=true;
		if(c && str[i]=='F')f=true;
	}
	printf("%s\n",c && f?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

class LowLink:
    def __init__(self, v):
        self.size = len(v)
        self.v = v
        self.pre = [None]*self.size
        self.low = [None]*self.size
        self.par = [None]*self.size
        self.articulation = []
        self.bridge = []
        for x in range(self.size):
            if self.pre[x] is None:
                self.cnt = 0
                self.pre[x] = self.low[x] = self.cnt
                self.dfs(x)

    def dfs(self, x):
        is_articulation = False
        n = 0
        for y in self.v[x]:
            if self.pre[y] is None:
                self.cnt += 1
                n += 1
                self.pre[y] = self.low[y] = self.cnt
                self.par[y] = x
                py = self.dfs(y)
                if py < self.low[x]:
                    self.low[x] = py
            else:
                if self.par[x] != y and self.pre[y] < self.low[x]:
                    self.low[x] = self.pre[y]
            if self.pre[x] <= self.low[y]:
                if self.pre[x]:
                    is_articulation = True
                if self.pre[x] < self.low[y]:
                    self.bridge.append((x,y))

        if not self.pre[x] and n > 1:
            is_articulation = True
        if is_articulation:
            self.articulation.append(x)

        return self.low[x]


def solve():
    n,m = LI()
    v = [[] for i in range(n)]
    for i in range(m):
        a,b = LI()
        a -= 1
        b -= 1
        v[a].append(b)
        v[b].append(a)
    ans = LowLink(v)
    print(len(ans.bridge))
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 38384
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

def main(X):
  if is_prime(X) == True:
    print(X)
  else:
    return main(X+1)

if __name__ == '__main__':
  X = int(input())
  main(X)

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

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    //good luck kittu!
    string s; cin>>s;
    int n = s.size();
    int freq = 0;
    for(int i = 0; i<n; i++){
        if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T'){
            int j = i;
            while(s[j]=='A' || s[j]=='C' || s[j]=='G' || s[j]=='T') j++;
            //cout<<j<<"\n";
            freq = max(freq, j-i);
            i = j--;
        }
    }
    cout<<freq<<"\n";
    return 0;
}


Measured memory_bytes: 256
ns = (0..43000).map {|i| [7 * i + 1, 7 * i + 6]}.flatten
ns.delete(1)

primes = []
until ns.empty?
    x = ns[0]
    primes << x
    new_ns = []
    loop do
        y = ns[-1]
        break if y < x * x
        new_ns.unshift y if y % x > 0
        ns.pop
    end
    ns = ns + new_ns
    ns.shift
end

loop do
    n = gets.to_i
    break if n == 1
    puts "#{n}: " + primes.select {|q| n % q == 0} * ' '
end



Measured memory_bytes: 120044
//arc069_c.cpp
//Sat Jun  9 10:30:50 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;

int main(){
	ll n,m;
	cin >> n >> m;

	ll ans = 0;
	if (m < 2*n){
		ans = m/2;
	}else{
		ans = n + (m-2*n)/4;
	}

	cout << ans << endl;
}

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

map<pair<int,int>,int> s;
long long x[10];
 
void add(int i,int j)
{
	pair<int,int> u=make_pair(i, j);
	if(s.find(u)!=s.end())
		s[u]++;
	else s.insert(make_pair(u,1));
}
 
int main()
{
	long long h,w,n;
	cin>>h>>w>>n;
	
	for (int i=0;i<n;i++)
	{
	    int a,b;
	    cin>>a>>b;
	    a--;
		b--;
	    for(int x=-1;x<=1;x++)
		{
		    for(int y=-1;y<=1;y++)
			{
			    if(a+x<=0||b+y<=0||a+x>=h-1||b+y>=w-1) 
					continue;
			    add(a+x, b+y);
      		}
    	}
	}
	
	long long sum = 0;
	
	for(map<pair<int,int>,int>::iterator it=s.begin();it!=s.end();it++)
	{
		sum++;
		x[it->second]++;
   	}
   	
	x[0]=(h-2)*(w-2)-sum;
	
	for(int i=0;i<10;i++)
		cout<<x[i]<<endl;
	
	return 0;
}

Measured memory_bytes: 56448
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb(in,tmp) in.push_back(tmp)
#define all(in) in.begin(),n.end()
#define PI acos(-1)
using namespace std;
int main(){
  int a,b,c,d,e,f;
  while(cin>>a>>b>>c>>d>>e>>f){
    int x,y,z;
    if(a<=d&&b<=e&&c>f){z=f+60-c;if(e)e--;else {e=59;d--;}}
    else z=f-c;
    if(a<=d&&b>e){y=e+60-b;d--;}
    else y=e-b;
    x=d-a;
    cout<<x<<" "<<y<<" "<<z<<endl;
  }




}

Measured memory_bytes: 1160