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

int main() {
  int N,sum=0;
  bool f=false;
  cin>>N;
  string s[N],p;
  int t[N];
  for(int i=0;i<N;i++) cin>>s[i]>>t[i];
  cin>>p;
  for(int i=0;i<N;i++){
    if(s[i]==p){
      f=true;
      continue;
    }
    if(f) sum+=t[i];
  }
  cout<<sum<<endl;
}	


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

#define rep(i,a,b)     for(int i=a;i<(b);i++)
typedef long long                ll;
const int mod = 1e9 + 7;

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

    ll d, t, s;

    cin >> d >> t >> s;

    if (t * s >= d)
        cout << "Yes";
    else
        cout << "No";

    return 0;
}

Measured memory_bytes: 3484
import java.util.Scanner;

public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if (s.endsWith("s")) {
			System.out.println(s + "es");
		}else {
			System.out.println(s + "s");
		}
	}
}


Measured memory_bytes: 38504
#include<iostream>
using namespace std;
#define MAX_H 100
#define MAX_W 100
#define INF 1000;
int h,w;
int field[MAX_H+1][MAX_W+1];
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
void dfs(int y,int x,const int sc){
	if(y<=0 || x<=0 || y>h || x>w)return;
	if(field[y][x]==sc){
		field[y][x]=0;
		for(int i=0;i<4;i++)dfs(y+dy[i],x+dx[i],sc);
	}
	return;
}
int main(){
	int sx,sy,gx,gy,n;
	while(cin>>w>>h){
        if(!w && !h)break;
		cin>>sx>>sy>>gx>>gy>>n;
		for(int i=0;i<MAX_H;i++){
			for(int j=0;j<MAX_W;j++){
					field[i][j]=INF;
				}
		}
		while(n--){
			int c,d,x,y;
			cin>>c>>d>>x>>y;
			for(int i=0;i<2;i++){
				for(int j=0;j<4;j++){
					if(d)field[y+j][x+i]=c;
					else field[y+i][x+j]=c;
				}
			}
		}
		dfs(sy,sx,field[sy][sx]);
		if(field[gy][gx])cout<<"NG"<<endl;
		else cout<<"OK"<<endl;

	}
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    string str;
    cin >> str;
    int i, a, b = N, l = 0, r = 0;

    for(i=0; i<N; ++i) {
        // cout << str.substr(0, i+1) << endl;
        if(str[i] == '(') ++l;
        else if(str[i] == ')') ++r;
        if(b > (l-r)) b = l - r;
    }
    a = l - r;

    /*
    cout << "l = " << l << endl;
    cout << "r = " << r << endl;
    cout << "a = " << a << endl;
    cout << "b = " << b << endl;
    */

    if(b>0) b = 0;
    str.insert(str.begin(), -b, '(');
    str.insert(str.end(), a-b, ')');

    cout << str << endl;
    // cout << a-2*b << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int x,y,n,c[2][6008]={},cid[2]={},f=0,flag=0,tmp[2]={};
	string s;
	cin>>s;
	cin>>x>>y;
	s=s+"T";
	//x=fabs(x);
	//y=fabs(y);
	int l=s.length();
	int iii=0;
	while(iii<l){
		if(s[iii]=='F'){
			x--;
		}else{
			f=(f+1)%2;
			iii++;
			break;
		}
		iii++;
	}
	x=fabs(x);
	y=fabs(y);
	int goal[2]={};
	goal[0]=x;
	goal[1]=y;

	//cout<<"now f:"<<f<<endl;
	FOR(i,iii,l){
		if(s[i]=='F'){
			//cout<<"tmp f:"<<f<<endl;
			tmp[f]++;
		}else{
			if(tmp[f]!=0){

				c[f][cid[f]]=tmp[f];
			tmp[f]=0;
			cid[f]++;
		}
			f=(f+1)%2;
		}
	}
	//cout<<x<<" "<<y<<" "<<cid[0]<<" "<<cid[1]<<" g0:"<<goal[0]<<" g1:"<<goal[1]  << endl;
	int dp[8008][2]={};
	FOR(i,0,2){
		FOR(j,0,8008)dp[j][0]=0;
		FOR(j,0,8008)dp[j][1]=0;
		dp[0][0]=1;
		FOR(j,0,cid[i]){
			//cout<<"te1"<<j<<endl;
			FOR(k,0,8006){
				if(dp[k][0]==1){
					if(k-c[i][j]>=0)dp[k-c[i][j]][1]=1;
					dp[k+c[i][j]][1]=1;
				}
			}
			FOR(k,0,8006){
				dp[k][0]=dp[k][1];
				dp[k][1]=0;
			}
		}
		//cout<<"te2"<<goal[i]<<" flag"<<flag<<endl;
		if(dp[goal[i]][0]==1)flag=1;
		else{
			 flag=0;
			 break;
		 }
	}
	if(flag==1)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
using namespace std;
signed main()
{
  int n;
  while(1){
  cin>>n;
  if(n==0) break;
  int a,b=0,c=0;
  for(int i=0;i<n;i++){
    cin>>a;
    if(b<a) b=a;
    if(a) c++;
  }
  if(b<2) cout<<"NA\n";
  else cout<<c+1<<"\n";
  }
  return(0);
}
  



Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define int long long
#define fi first
#define sc second
#define pii pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define msi map<string,int>
#define si set<int>
#define all(v) v.begin(),v.end()
#define sz(v)  int((v).size())
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define dep(i,a,b)	for(int i=a;i>=b;i--)
#define isinarr(i,n) ((i>=0)?((i<n)?1:0):0)
#define fastio  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ppb pop_back
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mp make_pair
#define inparr(a,n) rep(i,0,n)cin>>a[i];
#define give(x,y) cout<<x<<" "<<y<<endl;
#define setp(n) cout<<fixed<<setprecision(n);
#define	endl '\n'

using namespace std;
void solve()
{
	int n,i,j,k,l;
	string s;
	cin>>s;
	if(s[2]==s[3] && s[4]==s[5])
		cout<<"Yes\n";
	else
		cout<<"No\n";
} 



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

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    long long A,B,N; cin>>A>>B>>N;
    long long q1,q2,r1,r2;

    if(N<B){
        r1 = N;
    }else{
        r1 = B-1;
    }

    cout << A*r1/B << endl;


    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ph 1000006
#define mod 1000000007
#define pf pop_front
#define pob pop_back
#define size_f 200007
int main()
{
   ll a,b,c,k;
   cin>>a>>b>>c>>k;

   if(k<a)
    cout<<k<<"\n";
   else if(k==a||k<=(a+b))
     cout<<a<<"\n";
   else
     cout<<a-(k-(a+b))<<"\n";

    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = (1LL << 60);

int main()
{
  int N, M;
  cin >> N >> M;
  vector<vector<ll>> dist(N, vector<ll>(N, INF));
  for (int i = 0; i < N; i++)
  {
    dist.at(i).at(i) = 0;
  }
  for (int i = 0; i < M; i++)
  {
    int s, t;
    ll d;
    cin >> s >> t >> d;
    dist.at(s).at(t) = d;
  }

  for (int k = 0; k < N; k++)
  {
    for (int i = 0; i < N; i++)
    {
      if (dist.at(i).at(k) == INF)
      {
        continue;
      }
      for (int j = 0; j < N; j++)
      {
        if (dist.at(k).at(j) == INF)
        {
          continue;
        }
        dist.at(i).at(j) = min(dist.at(i).at(j), dist.at(i).at(k) + dist.at(k).at(j));
      }
    }
  }

  bool negative_cycle = false;
  for (int i = 0; i < N; i++)
  {
    if (dist.at(i).at(i) < 0)
    {
      negative_cycle = true;
    }
  }

  if (negative_cycle)
  {
    cout << "NEGATIVE CYCLE" << endl;
    return 0;
  }

  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < N; j++)
    {
      if (j)
      {
        cout << " ";
      }
      if (dist.at(i).at(j) == INF)
      {
        cout << "INF";
      }
      else
      {
        cout << dist.at(i).at(j);
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 3244
#include<stdio.h>
	#include<string.h>
	#include<unistd.h>
	#include<stdlib.h>
	#include<time.h>
	int main()
	{
		long long a,b[100001],c[100000],d,e,f=0,g=0,i,cnt=0;
		scanf("%lld",&a);
		for(i=0;i<a+1;i++)
		{
			scanf("%lld",&b[i]);
			g+=b[i];
		}
		for(i=0;i<a;i++)
		{
			scanf("%lld",&c[i]);
			f+=c[i];
		}
		for (i=0;i<a;i++) {
		if (c[i]<=b[i]) {
			cnt+=c[i];
			c[i]=0;
		}
		else {
			cnt+=b[i];
			c[i]-=b[i];
		}
		if (c[i]<=b[i+1]) {
			cnt+=c[i];
			b[i+1]-=c[i];
		}
		else {
			cnt+=b[i+1];
			b[i+1]=0;
		}
	}
	printf("%lld\n",cnt);
	return 0;
	}
	

Measured memory_bytes: 1664
#include "bits/stdc++.h"
 
using namespace std;
 
#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009
#define pi 3.141592653589793238
 
typedef pair<int, int> P;
 

void solve(std::string C){
    C[0] = C[0]+1;
    cout<<C<<endl;
}
 
signed main(){
    // ios::sync_with_stdio(false);
    // cin.tie(0);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
    std::string C;
    std::cin >> C;
    solve(C);
    return 0;
}


Measured memory_bytes: 256
N = int(input())
h = list(map(int,input().split()))
c = 0
while h != [0]:
    b = max(h)
    if b == 0:break
    newh = []
    con = False
    for i in range(len(h)):
        if h[i] != b:
            newh.append(h[i])
            con = False
        else:
            if con == False:
                newh.append(b)
                con = True
    for j in range(len(newh)):
        if newh[j] == b:
            newh[j] -= 1
            c += 1
    h = newh
print(c)

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

char field[8][8];

void bomb(int X, int Y) {
    field[Y][X] = '0';
    for(int i = 0; i < 4; ++i) {
        //右側を爆破
        if(X + i < 8 && field[Y][X + i] == '1') bomb(X + i, Y);
        if(Y + i < 8 && field[Y + i][X] == '1') bomb(X, Y + i);
        if(X - i > -1 && field[Y][X - i] == '1') bomb(X - i, Y);
        if(Y - i > -1 && field[Y - i][X] == '1') bomb(X, Y - i);
    }
}

int main(void) {
    int n;
    cin >> n;
    
    for(int k = 0; k < n; ++k) {
        int X, Y;
        for(int i = 0; i < 8; ++i) {
            cin >> field[i];
        }
        cin >> X;
        cin >> Y;
        
        bomb(X - 1, Y - 1);
        
        cout << "Data " << k + 1 << ':' << endl;
        for(int y = 0; y < 8; ++y) {
            for(int x = 0; x < 8; ++x) {
                cout << field[y][x];
            }
            cout << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3076
import numpy as np

N,D=list(map(int,input().split()))
X=[]

for i in range(N):
    Xi=list(map(int,input().split()))
    X.append(Xi)

X=np.array(X)
result=0
for i in range(N-1):
    for j in range(i+1,N):
        diff=X[i]-X[j]
        distance=np.sum(np.square(diff))
        if int(np.sqrt(distance))==np.sqrt(distance):
            result+=1

print(result)

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

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

typedef long long ll;

template <class T>
T GetCeil(T a, T b) { T ans = a / b; if (a % b) ++ans; return ans; }

signed main()
{
    int n; cin >> n;
    vector<int> t(n),a(n); rep(i,n) cin >> t[i] >> a[i];

    ll lastT = t[0], lastA = a[0];

    if (n == 1) {cout << lastT + lastA << endl; return 0;}

    rep(i,n-1){
        ll timesT = GetCeil(lastT, (ll)(t[i+1]));
        ll timesA = GetCeil(lastA, (ll)(a[i+1]));
        ll times = max(timesT,timesA);
        lastT = t[i+1]*times;
        lastA = a[i+1]*times;
    }

    cout << lastT + lastA << endl;    

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#define llint long long
#define mod 1000000007
#define inf 1e18

using namespace std;
typedef pair<double, llint> P;
typedef pair<llint, P> E;

llint n, k;
llint a[5005];
bool ldp[5005][5005], rdp[5005][5005];
int sum[5005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> k;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	ldp[0][0] = true;
	for(int i = 0; i < n; i++){
		for(int j = 0; j <= k; j++){
			if(!ldp[i][j]) continue;
			ldp[i+1][j] = true;
			if(j+a[i+1] <= k) ldp[i+1][j+a[i+1]] = true;
		}
	}
	rdp[n+1][0] = true;
	for(int i = n+1; i > 1; i--){
		for(int j = 0; j <= k; j++){
			if(!rdp[i][j]) continue;
			rdp[i-1][j] = true;
			if(j+a[i-1] <= k) rdp[i-1][j+a[i-1]] = true;
		}
	}
	
	int ans = 0;
	for(int i = 1; i <= n; i++){
		if(rdp[i+1][0]) sum[0] = 1; else sum[0] = 0;
		for(int j = 1; j <= k; j++){
			sum[j] = sum[j-1];
			if(rdp[i+1][j]) sum[j]++;
		}
		for(int j = 0; j <= k-1; j++){
			if(!ldp[i-1][j]) continue;
			llint l = max(0LL, k-a[i]-j), r = k-1-j;
			llint s = sum[r];
			if(l > 0) s -= sum[l-1];
			if(s > 0){
				ans++;
				break;
			}
		}
	}
	
	cout << n-ans << endl;

	return 0;
}

Measured memory_bytes: 49280
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int h, w, n;
	cin >> h >> w >> n;
	const int k = max(h, w);
	const int answer = (n + k - 1) / k;
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef pair<ii,int>iii;
int main(){
	int n, m; cin>>n>>m;
	map<int,vector<int>>adj;
	map<int,int>post;
	for(int i=0;i<m;i++){
		int a,b; cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	queue<int>q; 
	post[1]=0;
	q.push(1);
	//vis.insert(1);
	while(!q.empty()){
		int cur=q.front(); q.pop();
		for(const int& node:adj[cur]){
			if(post.count(node)) continue;
			post[node]=cur;
			q.push(node);
		}
	}
	if(post.size()!=n){
		cout<<"No\n";
	}
	else{
		cout<<"Yes\n";
		for(int i=2;i<=n;i++){
			cout<<post[i]<<'\n';
		}
	}
	return 0;
}

Measured memory_bytes: 20072
#include<bits/stdc++.h>
using namespace std;
#define max1 1005
#define siz 100000
#define mod 1000000007
#define inf 1e18+5
#define ll long long int
#define debug(x) cout<<#x<<" "<<x<<endl
#define jam(x) cout<<"Case #"<<x<<": "
typedef pair<ll,ll> pr;
vector<vector<ll> > dp(max1,vector<ll>(max1,-1));
vector<vector<char> > a(max1,vector<char>(max1) );
ll h,w;
ll dfs(ll x,ll y)
{
  if(x==h&&y==w)
  {
    return 1;
  }
  if(x>h||y>w)
  {
    return 0;
  }
  if(a[x][y]=='#')
  {
    return 0;
  }
  if(dp[x][y]!=-1)
  {
    return dp[x][y];
  }
  ll cnt=0;
  cnt=dfs(x+1,y)%mod;
  cnt=(cnt+dfs(x,y+1))%mod;
  return dp[x][y]=cnt%mod;
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  /*#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif*/
  cin>>h>>w;
  for(ll i=1;i<=h;i++)
  {
    for(ll j=1;j<=w;j++)
    {
      cin>>a[i][j];
    }
  }
  cout<<dfs(1,1)<<endl;
}


Measured memory_bytes: 9344
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

struct UnionFind {
    vector<ll> par;
    vector<ll> siz;

    UnionFind(ll N) : par(N),siz(N,1LL) {
        for(int i = 0; i < N; i++) par[i] = i;
    }
    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if(siz[rx]<siz[ry])swap(rx,ry);
        siz[rx]+=siz[ry];
        par[ry] = rx;
    }
    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    ll size(ll x){
        return siz[root(x)];
    }
};

int main(){
    ll N,M; cin >> N >> M;
    vector<ll> A(M),B(M);
    rep(i,M){
        int a,b;
        cin >> a >> b;
        --a,--b;
        A[i]=a;
        B[i]=b;
    }
    vector<ll> ans;
    ll res = N*(N-1)/2;
    UnionFind uf(N);
    ans.push_back(res);
    for(int i=M-1;i>=0;i--){
        if(!uf.same(A[i],B[i])){
            res-=uf.size(A[i])*uf.size(B[i]);
        }
        uf.unite(A[i],B[i]);
        if(i!=0)ans.push_back(res);
    }
    reverse(All(ans));
    rep(i,M){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 5364
num=input().split()
W=int(num[0])
H=int(num[1])
x=int(num[2])
y=int(num[3])
r=int(num[4])
if(x-r<0 or y-r<0 or x+r>W or y+r>H): print('No')
else: print('Yes')

Measured memory_bytes: 7612
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int A,B;
    R(A,B);
    REP(i,1000000){
        if(i*8/100==A&&i/10==B){
            W(i);
            return 0;
        }
    }
    W(-1);
    return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

namespace sumitomo2019
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.SetIn(new StreamReader("input.txt"));
            solve_sumitomo2019A();
        }

        public static void solve_sumitomo2019B()
        {

        }

        public static void solve_sumitomo2019A()
        {
            int[] md1 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int[] md2 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

            Console.WriteLine(md2[0] != md1[0] ? 1 : 0);
        }
    }
}


Measured memory_bytes: 11220
n,m = map(int,input().split())
a = set([int(input()) for _ in range(m)])
MOD = 1000000007
dp = [0] * (n+1)
dp[0] = 1
if 1 not in a:
    dp[1] = 1
else:
    dp[1] = 0
    
for i in range(2,n+1):
    if i in a:
        continue
        
    dp[i] = dp[i-1] + dp[i-2]
    dp[i] %= MOD
        
print(dp[n])

Measured memory_bytes: 13192
import java.io.*;
import java.util.*;
import java.math.*;
import java.util.regex.Pattern;
class Main
{
		// your code goes here
		public static void main(String args[])
		{
                   // Comparator cmprtr=null;
                    int a,b,c;
                    Scanner sc= new Scanner(System.in);
                    a=sc.nextInt(); b=sc.nextInt(); c=sc.nextInt();
                    if(a==b && a!=c && b!=c)
                    {
                        System.out.println("Yes");
                    }
                    else if(a==c && a!=b && c!=b)
                    {
                        System.out.println("Yes");
                    }
                    else if(b==c && b!=a && c!=a)
                    {
                        System.out.println("Yes");
                    }
                   else
                    {
                        System.out.println("No");
                    }
                }}     


Measured memory_bytes: 21844
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b + c >= 22) cout << "bust" << endl;
  else cout << "win" << endl;
  
}


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

int Ls, Lt;
string s, t;

string dp[3001][3001];

int main()
{
    cin >> s >> t;
    Ls = s.size();
    Lt = t.size();

    for (int i = Ls - 1; i >= 0; --i)
    {
        for (int j = Lt - 1; j >= 0; --j)
        {
            if (s[i] == t[j])
            {
                if (dp[i + 1][j + 1].size() + 1 > dp[i + 1][j].size())
                {
                    if (dp[i + 1][j + 1].size() + 1 > dp[i][j + 1].size())
                        dp[i][j] = s[i] + dp[i + 1][j + 1];
                    else
                        dp[i][j] = dp[i][j + 1];
                }
                else if (dp[i + 1][j].size() > dp[i][j + 1].size())
                    dp[i][j] = dp[i + 1][j];
                else
                    dp[i][j] = dp[i][j + 1];
            }
            else
            { 
                if (dp[i + 1][j].size() > dp[i][j + 1].size())
                    dp[i][j] = dp[i + 1][j];
                else
                    dp[i][j] = dp[i][j + 1];
            }
        }
    }
    cout << dp[0][0] << endl;

    return 0;
}

Measured memory_bytes: 841600
<?php
fscanf(STDIN,"%d %d",$N,$K);
$V = fgets(STDIN);
$arrayV = explode(" ",$V);
$max = 0;
//配列内で負数の要素数を求める
$minusMax = count(array_filter($arrayV,"minusCount"));

//必ず1つは取り出すのでKが1の時は最大値が0より小さい可能性があるため別処理
if($K === 1){
  echo max($arrayV[0],$arrayV[$N-1]);
}else{
  //左から取り出す数、回数制限、配列の要素数を超えない
  for($i=0; $i<=$K && $i<=$N; $i++){
    if($i !== 0){
      //最大を求めるので取り出すのが負数で止まることはない
      if($arrayV[$i-1] <= 0){
        continue;
      }
    }
    //右から取り出す数、合計が回数制限、配列の要素数を超えない
    for($j=0; $j<=$K-$i && $j<=$N-$i; $j++){
      if($j !== 0){
        //最大を求めるので取り出すのが負数で止まることはない
        if($arrayV[$N-$j] <= 0){
          continue;
        }
      }
      //削除する数、合計が回数制限を越えない、取り出した数より少ない、負数のみ削除
      for($m=0; $m<=$K-$i-$j && $m<$i+$j && $m<=$minusMax; $m++){
        $value = calculate($i,$j,$m,$arrayV,$N);
        //最大値更新
        if($value > $max){
          $max = $value;
        }
      }
    }
  }
  echo $max;
}

function calculate($left,$right,$delete,$array,$N){
  $arrayResult = array();
  for($i=0;$i<$left;$i++){
    $arrayResult[] = $array[$i];
  }
  for($i=0;$i<$right;$i++){
    $arrayResult[] = $array[$N-1-$i];
  }
  for($i=0;$i<$delete;$i++){
    //最小値を1つだけ配列から削除
    $mins = array_keys($arrayResult, min($arrayResult));
    unset($arrayResult[$mins[0]]);
  }
  //配列内の合計を返す
  return array_sum($arrayResult);
}

function minusCount($value){
  return $value < 0;
}


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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int &i : a) cin >> i;
  for (int i = k; i < n; i++) cout << (a[i] > a[i - k] ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 4048
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll a,b,c;
	scanf("%lld%lld%lld",&a,&b,&c);
	ll ans=0;
	while(ans<100&&a%2==0&&b%2==0&&c%2==0){
		ll ta=(b+c)/2;
		ll tb=(a+c)/2;
		ll tc=(a+b)/2;
		a=ta;
		b=tb;
		c=tc;
		ans++;
	}
	printf("%lld\n",ans==100?-1:ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
struct UnionFind {
  vector<int> data;
  int all;
  UnionFind(int size) : data(size, -1) { all = size; }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
      all--;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};


void solve(long long W, long long H, vector<long long> p, vector<long long> q){
	UnionFind ufw(W+1),ufh(H+1);
	vector< array<int,3> > X;
	
	for(int i = 0 ; i < p.size() ; i++)
		X.push_back({p[i],i,0});
	for(int i = 0 ; i < q.size() ; i++)
		X.push_back({q[i],i,1});
	sort(X.begin(),X.end());
	int ans = 0;
	for( auto e : X ){
		if( e[2] == 0 ){
			ans += e[0] * ufh.all;
			ufw.unionSet(e[1],e[1]+1);
		}else{
			ans += e[0] * ufw.all;
			ufh.unionSet(e[1],e[1]+1);
		}
	}
	cout << ans << endl;
	
	
	
}



signed main(){	
	ios::sync_with_stdio(false);
	long long W;
	long long H;
	cin >> W;
	vector<long long> p((W-1)-0+1);
	cin >> H;
	vector<long long> q((H-1)-0+1);
	for(int i = 0 ; i <= (W-1)-0 ; i++){
		cin >> p[i];
	}
	for(int i = 0 ; i <= (H-1)-0 ; i++){
		cin >> q[i];
	}
	solve(W, H, p, q);
	return 0;
}

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

int x[1005], y[1005];

int main(){
    int w, h, n;
    cin >> w >> h >> n;
    
    for(int i = 0; i < n; i++) cin >> x[i] >> y[i];
    
    int ans = 0;
    for(int i = 1; i < n; i++){
        int dx = x[i]-x[i-1];
        int dy = y[i]-y[i-1];
        if(dx*dy >= 0) ans += max(abs(dx),abs(dy));
        else ans += abs(dx)+abs(dy);
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3040
def lastjudge(L, i, G):
  mi = 1000
  for j in L:
    if j[4] == 0:
      if j[3] < G:
        continue
      elif j[3] - j[1] > G:
        t = -(-G // j[2])
      else:
        t = j[0]
      if mi > t:
        mi = t
  return mi
def judge(L, i, G):
  if i+1 < len(L):
    m = judge(L, i+1, G)
    if L[i][3] >= G:
      if L[i][3] - L[i][1] > G:
        t = -(-G // L[i][2])
      else:
        t = L[i][0]
    else:
      G -= L[i][3]
      L[i][4] = 1
      t = L[i][0] + judge(L, i+1, G)
    return min(t, m)
  else:
    m = lastjudge(L, i, G)
    if L[i][3] < G:
      G -= L[i][3]
      L[i][4] = 1
      t = L[i][0] + lastjudge(L, i, G)
    elif L[i][3] - L[i][1] > G:
      t = -(-G // L[i][2])
    else:
      t = L[i][0]
    return min(t, m)
 
D, G = list(map(int,input().split()))
L = []
for i in range(D):
  L.append(list(map(int, input().split())))
  L[i].append((i+1) * 100)
  L[i].append(L[i][0] * L[i][2] + L[i][1])
  L[i].append(0)
print(judge(L, 0, G))

Measured memory_bytes: 3188
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
      int N = sc.nextInt(); // 合計値
      String S = sc.next();
      S = S.replaceAll("ABC", "");
      int diff = N - S.length();
      if(diff > 0){
      	System.out.println(diff / 3);
      } else {
        System.out.println(0);
      }
   }
}


Measured memory_bytes: 21716
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<string>
#include<math.h>
#include<vector>
using namespace std;
int main(){
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    int ans;
    ans=min(A,B)+min(C,D);
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define rd(x) cin >> x;
#define rda(a,n) for(int i=1;i<=n;i++) cin >> a[i];
#define wr(x) cout << x << ' ';
#define wrl(x) cout << x << '\n';
#define wra(a,n) for(int i=1;i<=n;i++) cout << a[i] << ' '; cout << '\n';
#define lg length()
#define pb push_back
ifstream in("ciclueuler.in");
ofstream out("ciclueuler.out");
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

long long n,m,a[100005],k,t,bst;

vector <int> s[100005],e[100005];

long long md(long long x){
    while(x<0) x+=m;
    x%=m;
    return x;
}

long long p(long long x){
    if(x<=m) return x;
    else return 1;
}

int32_t main(){
    ios_base :: sync_with_stdio(0);
    cin >> n >> m;
    cin >> a[1]; s[p(a[1]+1)].pb(2);
    for(int i=2;i<n;i++) cin >> a[i],e[a[i]].pb(i),s[p(a[i]+1)].pb(i+1);
    cin >> a[n],e[a[n]].pb(n);
    for(int i=2;i<=n;i++){
        t+=min(md(a[i]-a[i-1]),md(a[i]-1)+1);
        if(md(a[i]-a[i-1])>=md(a[i]-1)+1) k++;
    }
    bst=t;
    for(int i=2;i<=m;i++){
        for(int j : e[i-1]){
            k--;
            t+=md(a[j]-a[j-1])-1;
        }
        for(int j : s[i]){
            k++;
            t++;
        }
        t-=k;
        bst=min(bst,t);
    }
    cout << bst;
}


Measured memory_bytes: 10496
import numpy as np

N = int(input())
scores = np.zeros((2, N))
sum_max_scores = np.zeros((2, N))

for i in range(2):
    # rows.append(list(map(int, input().split())))
    for j, num in enumerate(map(int, input().split())):
        scores[i][j] = num

for j in range(N):
    for i in range(2):
        if i == 0:
            if j == 0:
                sum_max_scores[0][0] = scores[0][0]
            else:
                sum_max_scores[i][j] = sum_max_scores[i][j-1] + scores[i][j]
        else:
            if j == 0:
                sum_max_scores[i][j] = scores[1][0] + sum_max_scores[0][0]
            else:
                sum_max_scores[i][j] = \
                    max(
                        sum_max_scores[i][j-1] + scores[i][j],
                        sum_max_scores[i-1][j] + scores[i][j]
                    )
print(int(sum_max_scores[-1][-1]))


Measured memory_bytes: 12396
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var n, k int
	const M int64 = int64(1e9) + 7
	fmt.Fscan(r, &n, &k)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(r, &a[i])
	}

	var nn int
	for i := 0; i < n; i++ {
		if a[i] < 0 {
			nn++
		}
	}

	var b []int
	if n == k {
		b = a
	} else if nn == n && k&1 == 1 {
		// negative
		sort.Sort(sort.Reverse(sort.IntSlice(a)))
		b = a[:k]
	} else {
		// positive or zero
		sort.Sort(sort.Reverse(sort.IntSlice(a)))
		l, r := 0, n-1
		check := func() bool {
			if l == r {
				return false
			}
			return int64(a[l])*int64(a[l+1]) < int64(a[r])*int64(a[r-1])
		}

		for len(b) < k {
			if len(b) <= k-2 && check() {
				b = append(b, a[r], a[r-1])
				r -= 2
			} else {
				b = append(b, a[l])
				l++
			}
		}
	}

	var ans int64 = 1
	for i := 0; i < len(b); i++ {
		ans *= int64(b[i])
		ans %= M
	}
	ans += M
	ans %= M
	fmt.Println(ans)

}


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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}

void solve() {
	char x, y; scanf(" %c %c", &x, &y);
	if (x > y) puts(">");
	else if (x < y) puts("<");
	else puts("=");
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


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

using namespace std;

int main(void) {
	double a, b;
	cin >> a >> b;
	for (int i = 10; i <= 1000; i++) {//bが100まで
		if ((int)(i*0.08) == a) {
			if ((int)(i*0.1) == b) {
				cout << i;
				return 0;
			}
		}
	}
	cout << "-1";
	return 0;
}

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

int n,m;
vector<vector<bool>> g(50,vector<bool>(50,false));

bool bfs(int a,int b){
	queue<int> q;
	rep(i,n){
		if(i!=b && g[a][i]) q.push(i);
	}
	bool ans=false;
	vector<bool> c(n);
	c[a]=true;
	while(!q.empty()){
		int x=q.front();
		q.pop();
		if(x==b){
			ans=true;
			break;
		}
		if(c[x]) continue;
		c[x]=true;
		rep(i,n){
			if(g[x][i]){
				q.push(i);
			}
		}
	}
	return ans;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> m;
	rep(i,m){
		int a,b;
		cin >> a >> b;
		g[a-1][b-1]=true;
		g[b-1][a-1]=true;
	}
	int ans=0;
	rep(i,n){
		for(int j=i+1;j<n;++j){
			if(g[i][j]){
				if(!bfs(i,j)) ans++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
using namespace std;
int n;
int tmp;
int dp[5001];
const int INF = 10000;

struct node {
  //  struct node* parent;                                                                           
  struct node* child;
  struct node* next;
  //  int depth;                                                                                     
  int x;
  int y;
};

void sum(struct node* p, int x){
  int tmp;
  if(!p->next){
    dp[p->x] = p->y;
    if(dp[p->y] > p->x) dp[p->y] = p->x;
  }
  else{
    sum(p->next, x);
    for(int i=x;i>=0;i--){
      if(dp[i] != INF){
        tmp = dp[i];
        dp[i] = INF;
        if(i + p->x <= x && dp[i + p->x] > tmp + p->y) dp[i + p->x] = min(tmp + p->y, 5001);
        if(i + p->y <= x && dp[i + p->y] > tmp + p->x) dp[i + p->y] = min(tmp + p->x, 5001);
      }
    }
  }
}

int main(void) {
  struct node* p[1001];
  struct node* p_tmp;

  scanf("%d",&n);
  for(int i=0;i<=n;i++) p[i] = new struct node;
  //  p[1]->parent = NULL;                                                                           
  p[1]->child = NULL;
  p[1]->next = NULL;
  for(int i=2;i<=n;i++){
    scanf("%d",&tmp);
    //    p[i]->parent = p[tmp];                                                                     
    if(p[tmp]->child == NULL)  p[tmp]->child = p[i];
    else{
      p_tmp = p[tmp]->child;
      while(p_tmp->next != NULL) p_tmp = p_tmp->next;
      p_tmp->next = p[i];
    }
    p[i]->next = NULL;
    p[i]->child = NULL;
  }

  for(int i=1;i<=n;i++){
    scanf("%d",&p[i]->x);
  }
  /*                                                                                                 
  printf("\n");                                                                                      
  for(int i=1;i<=n;i++){                                                                             
    printf("%d %d %d %d %d\n", i, p[i], p[i]->x, p[i]->child, p[i]->next);                           
  }                                                                                                  
  printf("\n");                                                                                      
  */

  for(int i=n;i>0;i--){
    for(int k=p[i]->x;k>=0;k--) dp[k] = INF;
    if(!p[i]->child){
      p[i]->y = 0;
      continue;
    }
    sum(p[i]->child, p[i]->x);
    p[i]->y = INF;
    for(int k=p[i]->x;k>=0;k--) if(dp[k] != INF && dp[k] < p[i]->y) p[i]->y = dp[k];
    if(p[i]->y == INF){
      printf("IMPOSSIBLE\n");
      return 0;
    }
  }

  printf("POSSIBLE\n");
  return 0;

}


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

using namespace std;

int n;

void solve() {
  int mul = n * 2;
  int k = 2;
  while (k * (k - 1) < mul) {
    k++;
  }
  if (k * (k - 1) != mul) {
    cout << "No" << endl;
    return;
  }
  cout << "Yes" << endl;
  cout << k << endl;
  vector<vector<int> > v(k, vector<int>());
  int first = 0;
  int second = 1;
  for (int i=1;i<=n;i++) {
    v[first].push_back(i);
    v[second++].push_back(i);
    if (second >= k) {
      first++;
      second = first + 1;
    }
  }
  for (int i=0;i<v.size();i++) {
    cout << v[i].size();
    for (int j=0;j<v[i].size();j++) {
      cout << " " << v[i][j];
    }
    cout << endl;
  }
}

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


Measured memory_bytes: 2304
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

using ll = long long int;

ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

int main(void) {
  ll a, b, c, d;
  cin>>a>>b>>c>>d;
  ll lcm = c * d / gcd(c, d);
  ll n = (b / c) - (a / c);
  if(a % c == 0)
    n++;
  ll m = (b / d) - (a / d);
  if(a % d == 0)
    m++;
  ll p = (b / lcm) - (a / lcm);
  if(a % lcm == 0)
    p++;
  std::cout << (b-a)+1 - (m+n-p) << std::endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl

using namespace std;

template<typename S,typename T>auto&operator<<(auto&o,pair<S,T>p){return o<<"{"<<p.fi<<","<<p.se<<"}";}
template<typename T>auto&operator<<(auto&o,set<T>s){for(auto&e:s)o<<e<<" ";return o;}
template<typename S,typename T,typename U>
auto&operator<<(auto&o,priority_queue<S,T,U>q){while(!q.empty())o<<q.top()<<" ",q.pop();return o;}
template<typename K,typename T>auto&operator<<(auto&o,map<K,T>&m){for(auto&e:m)o<<e<<" ";return o;}
template<typename T>auto&operator<<(auto&o,vector<T>v){for(auto&e:v)o<<e<<" ";return o;}
void ashow(){cout<<endl;}template<typename T,typename...A>void ashow(T t,A...a){cout<<t<<" ";ashow(a...);}
template<typename S,typename T,typename U>
struct TRI{S fi;T se;U th;TRI(){}TRI(S f,T s,U t):fi(f),se(s),th(t){}};
template<typename S,typename T,typename U>
auto& operator<<(auto& o,TRI<S,T,U>& t){return o<<"{"<<t.fi<<","<<t.se<<","<<t.th<<"}";}

typedef pair<int, int> P;
typedef pair<ll, ll> pll;
typedef TRI<int, int, int> tri;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<string> vs;

const int MAX_N = 2005;

int t[MAX_N][MAX_N], a[MAX_N][MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    rep(i,h){
        string s;
        cin >> s;
        rep(j,w){
            t[i][j] = (s[j] == '#');
        }
    }
    h--, w--;
	rep(i,h){
		rep(j,w){
			a[i][j] = (t[i][j]+t[i+1][j]+t[i][j+1]+t[i+1][j+1])%2;
		}
	}
	rep(i,h){
		t[i][w] = 0;
	}
	rep(i,w){
		t[0][i] = 1^a[0][i];
	}
	for(int i = 1; i < h; i++){
		rep(j,w){
			if(a[i][j] == 0){
				t[i][j] = t[i-1][j] + 1;
			}else{
				t[i][j] = 0;
			}
		}
	}
	int ans = max(h+1, w+1);
    deque<P> deq;
	rep(i,h){
		rep(j,w+1){
			if(deq.empty()){
				deq.push_back(P(t[i][j],j));
				continue;
			}
			P p = deq.back();
			if(p.first < t[i][j]){
				deq.push_back(P(t[i][j],j));
			}else if(p.first > t[i][j]){
				int pos;
				while(p.first >= t[i][j]){
					pos = p.second;
					ans = max(ans, (p.first+1)*(j-p.second+1));
                    deq.pop_back();
					if(!deq.empty()) p = deq.back();
                    else break;
				}
				deq.push_back(P(t[i][j],pos));
			}
		}
	}
	cout << ans << "\n";
    return 0;
}


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


ll _main(){
    ll h,w,m;
    cin >> h >> w >> m;
    vector<ll> col = vector<ll>(h,0);
    vector<ll> row = vector<ll>(w,0);
    vector<tuple<ll,ll>> mine = vector<tuple<ll,ll>>(m);
    for(ll i=0;i<m;i++){
        ll _y,_x;
        cin >> _y >> _x;
        ll y=_y-1; ll x=_x-1;
        col[y]++;
        row[x]++;
        mine[i] = tuple<ll,ll>(y,x);
    }

    ll cmax=0;
    for(ll c=0;c<h;c++){
        if(cmax<col[c]){
            cmax = col[c];
        }
    }
    ll rmax=0;
    for(ll r=0;r<w;r++){
        if(rmax<row[r]){
            rmax = row[r];
        }
    }
    bool flag = false;
    ll maxsc = 0;
    ll maxsr = 0;
    for(ll c=0;c<h;c++){
        if(cmax==col[c]){
            maxsc++;
        }
    }
    for(ll r=0;r<w;r++){
        if(rmax==row[r]){
            maxsr++;
        }
    }
    ll left = maxsc*maxsr;
    for(ll i=0;i<m;i++){
        if(col[get<0>(mine[i])]==cmax && row[get<1>(mine[i])]==rmax){
            left--;
        }
    }
    return cmax+rmax-(left>0?0:1);

}

int main(){
    cout << _main();
    return 0;
}

Measured memory_bytes: 12760
#include<bits/stdc++.h>
using namespace std ;
int main () {
	long long n , ans = 0 ;
	cin >> n ;
	for (long long i = 2 ; i*i <= n ; ++i) {
		if (n % i == 0) {
			long long div = i ;
			while(n % div == 0) {
				++ans ;
				n /= div ;
				div *= i ;
			}
		}
		if(n % i == 0) {
            while(n % i == 0) {
                n /= i ;
            }
        }
	}
	if (n > 1) {
		++ans ;
	}
	cout << ans ;
	return 0 ;
}

Measured memory_bytes: 3620
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }


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

    // ifstream fin(".in");
    // ofstream fout(".in");
    i64 n,k;
    cin>>n>>k;
    vi v(n+1);
    vector<bool>vis(n+1,false);
    for1(i,n)cin>>v[i];
    vi cy;
    int x=1;
    while(!vis[x])
    {
      vis[x]=true;
      cy.pb(x);
      x=v[x];
    }int i=0;
    while(cy[i]!=x)i++;
    int in=i;
    vi cyc;
    for(i;i<cy.size();i++)cyc.pb(cy[i]);

    int nn=cyc.size();

    if(k>=in)
    cout<<cyc[(k-in)%nn];
    else cout<<cy[k];
// forn(i,nn)cout<<cyc[i]<<" ";




    return 0;
  }


Measured memory_bytes: 6224
import numpy as np


def solve():
    h, w = map(int, input().split(' '))
    max_value = h + w
    values = []
    for i in range(h):
        values.append([0 if i == '#' else max_value for i in list(input())])
    values = np.array(values)

    for x in range(w - 1):
        values[:, x+1] = np.minimum(values[:, x] + 1, values[:, x+1])
    for x in range(w - 1, 0 , -1):
        values[:, x-1] = np.minimum(values[:, x-1], values[:, x] + 1)
    for x in range(h - 1):
        values[x+1, :] = np.minimum(values[x, :] + 1,values[x+1, :])
    for x in range(h - 1, 0, -1):
        values[x-1, :] = np.minimum(values[x, :] + 1, values[x-1, :])
    print(np.max(values))


solve()


Measured memory_bytes: 28948
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
using P = pair<ll,ll>;

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

struct DisjointSet{
    vector<int> p;
    DisjointSet(int n) : p(n){
        rep(i,n) p[i] = -1;
    }

    ll root(int x){
        if(p[x] < 0) return x;
        return p[x] = root(p[x]);
    }

    ll size(int x){
        return -p[x];
    }

    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx > ry) swap(rx, ry);
        if(rx == ry) return;
        p[rx] += p[ry];
        p[ry] = rx;
    }
};

int main()
{
    int n, m; cin >> n >> m;
    int a[m], b[m];
    rep(i,m){
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
    }

    DisjointSet dis = DisjointSet(n);
    rep(i,m){
        if(dis.same(a[i], b[i])) continue;
        dis.unite(a[i], b[i]);
    }

    ll maxg = 0;
    rep(i,n){
        maxg = max(maxg, dis.size(i));
        // cout << dis.size(i) << endl;
    }

    cout << maxg << endl;
}

Measured memory_bytes: 5640
#include <iostream>

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

using namespace std;

int main(){
	
	string n;
	cin >> n;
	
	if (n[0]==n[2]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <valarray>
#include <cstdio>
using namespace std;
typedef valarray<int>V;
int n,m;
//V z;
V Me(const V &_x,const V &_y){
	V z(n*n);
	int i=0,j;
	for(;i<n;i++)for(j=0;j<n;j++)z[i*n+j]=(_x[slice(i*n,n,1)]*_y[slice(j,n,n)]).sum()%m;
	return z;
}
V Mx(const V &_x){
	V z(n*n);
	int i=0,j;
	for(;i<n;i++)for(j=0;j<n;j++)z[i*n+j]=(_x[slice(i*n,n,1)]*_x[slice(j,n,n)]).sum()%m;
	return z;
}
void O(const V &r,const V &s){
	int i=0;
    for(;i<n-1;i++)printf("%d ",(r[slice(i*n,n,1)]*s).sum()%m);
    printf("%d\n",(r[slice(i*n,n,1)]*s).sum()%m);
}
main(){
	int i,a,b,c,t;
	for(;scanf("%d%d%d%d%d%d",&n,&m,&a,&b,&c,&t),n;){
		V x(n*n);
		V e(n*n);
		//z.resize(n*n);

		x[0]=b;
		x[1]=c;
		e[0]=1;
		for(i=1;i<n-1;i++){
			x[i*n+i-1]=a;
			x[i*n+i]=b;
			x[i*n+i+1]=c;
			e[i*n+i]=1;
		}
		x[i*n+i-1]=a;
		x[i*n+i]=b;
		e[i*n+i]=1;
		for(;t;t>>=1){
			if(t&1)e=Me(e,x);
			x=Mx(x);
		}
		V s(n);
		for(i=0;i<n;i++)scanf("%d",&s[i]);
		O(e,s);
	}
}

Measured memory_bytes: 1080
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  while (s != "0") {
    int sum = 0;
    for (int i = 0; i < s.size(); i++) {
      sum += stoi(s.substr(i, 1));
    }
    cout << sum << endl;
    cin >> s;
  }
  return 0;
}



Measured memory_bytes: 3064