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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll N,M;
ll S,T;
vector<P> G[100005][3];

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

    cin >> N >> M;

    for (int i = 0;i < M;i++){
        ll u,v; cin >> u >> v;
        G[u][0].push_back(P(v,1));
        G[u][1].push_back(P(v,2));
        G[u][2].push_back(P(v,0));
    }
    cin >> S >> T;

    queue<P> que; // node
    que.push(P(S,0));
    ll dis[100005][3];

    for (int i = 0;i <= N;i++){
        for (int j = 0;j < 3;j++){
            dis[i][j] = -1;
        }
    }
    dis[S][0] = 0;

    while(que.size()){
        P p = que.front(); que.pop();
        ll from = p.first;
        ll idx = p.second;
        //cout << from << " " << dist << endl;
        if(from == T && idx == 0){
            break;
        }
        for (int i = 0;i < G[from][idx].size();i++){
            ll to = G[from][idx][i].first;
            ll idx2 = G[from][idx][i].second;
            if(dis[to][idx2] == -1){
                dis[to][idx2] = dis[from][idx]+1;
                que.push(P(to,idx2));
            }
        }
    }

    if(dis[T][0] != -1)cout << dis[T][0]/3 << endl;
    else cout << -1 << endl;

    return 0;

}

Measured memory_bytes: 19072
from itertools import permutations
import math
def dist(x,y):
    return ((x[0]-y[0])**2+(x[1]-y[1])**2)**(0.5)
N = int(input())
X = [list(map(int,input().split())) for _ in range(N)]
ans = 0
for z in permutations(range(N),N):
    for i in range(N-1):
        ans += dist(X[z[i]],X[z[(i+1)%N]])
print(ans/math.factorial(N))

Measured memory_bytes: 41324
using System;
using System.Linq;
namespace Program
{
    class Program
    {
        static void Main()
        {
            int count = 0;
            bool flag = false;
            string In = Console.ReadLine();
            string[] s = Console.ReadLine().Split();
            int[] aa = s.Select(int.Parse).ToArray();
            while (true)
            {
                for (int i = 0; i < aa.Length; i++)
                {
                    if (aa[i] % 2 != 0)
                    {
                        flag = true;
                    }
                    
                }
                aa = aa.Select(n => n / 2).ToArray();
                if (flag == true) break;
                count++;
            }
            Console.WriteLine(count);
        }
    }
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S, T;
    cin >> S >> T;
    for (char c = 'a'; c <= 'z'; ++c) {
        S.push_back(c);
        if (S == T) {
            cout << "Yes\n";
            return 0;
        }
        S.pop_back();
    }
    cout << "No\n";
    return 0;
}

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

int main() {
 string S ;
 cin >> S ;
  int N =0;
  for (int i=0; i<S.size();i++){
    if ((i%2 == 0)&&(S.at(i) =='L')){
        cout <<"No";
        break;
    }
    else if ((i%2 == 1)&&(S.at(i)=='R')){
         cout << "No";
          break;
    }
    N ++ ;
             }
   if (N ==S.size())
       cout <<"Yes";
 // cout << N ;
      
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<ctype.h>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<utility>
#define For(a,b) for(int i=(a);i<(b);i++)
#define Rep(n) for(int i=0; i<(n); ++i)
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
//----------program from here----------

int main(){
    int a=0;
    string s;
    cin >> a >> s;
    cout << (a<3200?"red":s) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define debug(x) cout<<#x<<"="<<x<<endl;
#define LL long long 
#define sz(x) x.size()
using namespace std;
int func(int a)
{
	int ans=0;
	while(a>0)
	{
		ans+=a%10;
		a/=10;
	}
	return ans;
}
int main(void)
{
	int n,a,b;
	int sum=0;
	cin>>n>>a>>b;
	rep(i,1,n+1)
	{
		if(func(i)>=a&&func(i)<=b)
		{
			sum+=i;
		}
	}
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 256
def main():
	while True:
		cmd = input()
		if cmd == "#":
			return
		right = "qwertasdfgzxcvb"
		count = 0
		isr =  cmd[0] in right
		for c in cmd[1::]:
			if c in right and not isr:
				count += 1
				isr = not isr
			if not c in right and isr:
				count += 1
				isr = not isr
		print(count)
				

if __name__ == '__main__':
	main()


Measured memory_bytes: 5564
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;

int main() {
    int n;
    cin >> n;
    vector<map<char, int>> mp(n);
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        for (auto& c : s) mp[i][c]++;
    }
    
    map<char, int> cnt;
    for (char c = 'a'; c <= 'z'; c++) {
        int mn = INF;
        bool all = true;
        for (int i = 0; i < n; i++) {
            if (!mp[i].count(c)) all = false;
            mn = min(mn, mp[i][c]);
        }
        if (mn == INF || !all) continue;
        cnt[c] = mn;
    }
    
    for (auto& e : cnt) {
        for (int i = 0; i < e.second; i++) {
            cout << e.first;
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int devide(int x){
	int sum;
	if(x>=10000){
		sum=x/10000;	x=x-sum*10000;
		sum+=x/1000;	x=x-(x/1000)*1000;
		sum+=x/100;		x=x-(x/100)*100;
		sum+=x/10;		x=x-(x/10)*10;
		sum+=x;
	}else if(x>=1000){
		sum=x/1000;	x=x-(x/1000)*1000;
		sum+=x/100;		x=x-(x/100)*100;
		sum+=x/10;		x=x-(x/10)*10;
		sum+=x;
	}else if(x>=100){
		sum=x/100;		x=x-(x/100)*100;
		sum+=x/10;		x=x-(x/10)*10;
		sum+=x;
	}else if(x>=10){
		sum=x/10;		x=x-(x/10)*10;
		sum+=x;
	}else{
		sum=x;
	}
	
	return sum;
}

int main(void)
{
	int N;
	scanf("%d",&N);
	int a,min=100;
	for(a=1;a<=N/2;a++){
		int b=N-a;
		int suma=devide(a);
		int sumb=devide(b);
		if(sumb+suma<min){
			min=sumb+suma;
		}
	}
	printf("%d\n",min);
	return 0;
}

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

using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
#define fr(i,a,b) for(ll i=a; i<b; i++)
#define rf(i,a,b) for(ll i=a; i>=b; i--)
#define pb push_back
#define mp make_pair
#define show(a) for(auto el:a)cout<<el<<" "
#define ff first
#define ss second
#define pairv vector<pair<ll,ll>>
#define vec vector <ll> 
#define all(a) a.begin(),a.end()
#define fam(v,i) for(auto i=v.begin();i!=v.end();i++)
#define fai(v,i) for(auto i : v)
#define mo 1000000007
#define nn cout<<"\n";
ll pow1(ll n,ll p)
{
if(p==0) return 1;
ll x=pow1(n, p/2);
x=(x*x)%mo;
if(p%2==0)
return x;
else
return (x*n)%mo;
}
bool sortbysec(const pair<ll,ll> &a, 
const pair<ll,ll> &b) 
{ 
return (a.second < b.second); 
} 
bool compare(const pair<ll, ll>&p1, const pair<ll,ll>&p2)
{
if(p1.ff < p2.ff) return true;
if(p1.ff == p2.ff) return p1.ff < p2.ss;
return false;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
        ll n;
        cin>>n;
        ll i,x,f=0,y,c=0;
        fr(i,0,n)
        {
            cin>>x>>y;
            if(c>2)
            {
               f=1;
               break;
            }
            if(x==y)
            c++;
            else
            {
                c=0;
            }
             if(c>2)
            {
               f=1;
               break;
            }
        }
        if(f==1)
        cout<<"Yes";
        else
         cout<<"No";
        
        nn
   
    
     return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>

struct Process {
  std::string name;
  int time;
  Process(std::string name, int time) {
    this->name = name;
    this->time = time;
  };
};

int main() {
  int n, q;
  std::cin >> n >> q;
  std::vector<Process> processes;
  std::vector<int> queue;
  for (int i = 0; i < n; i++) {
    std::string name;
    int time;
    std::cin >> name >> time;
    processes.emplace_back(name, time);
    queue.push_back(i);
  }
  int timePassed = 0;
  while (queue.size() > 0) {
    int& index = queue.front();
    auto& process = processes[index];
    if (process.time > q) {
      process.time -= q;
      timePassed += q;
      queue.push_back(index);
    } else {
      timePassed += process.time;
      std::cout << process.name << " " << timePassed << std::endl;
    }
    queue.erase(queue.begin());
  }
  return 0;
}



Measured memory_bytes: 6132
N = int(input())
a = list(map(int, input().split()))
a = list(map(lambda x: min(x // 400, 8), a))
#print(a)
m = len(set(a))
M = len(set(a))
if 8 in a:
    m -= 1
    M += a.count(8)
    M -= 1
#M = min(M, 8)
if m == 0:
    m = 1
print(m, M)

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    ll A,B,Q; cin >> A >> B >> Q;
    vector<ll> s(A+2), t(B+2);
    s[0] = -1e+18; s[A+1] = 1e+18; t[0] = -1e+18; t[B+1] = 1e+18;
    REP(i,A) cin >> s[i+1]; REP(i,B) cin >> t[i+1];

    REP(i,Q){
        ll x; cin >> x;
        ll si = lower_bound(ALL(s), x) - s.begin();
        ll ti = lower_bound(ALL(t), x) - t.begin();
        ll ans = LL_INF;
        chmin(ans, abs(x-s[si-1])+abs(s[si-1]-t[ti-1]));
        chmin(ans, abs(x-s[si-1])+abs(s[si-1]-t[ti]));
        chmin(ans, abs(x-s[si])+abs(s[si]-t[ti-1]));
        chmin(ans, abs(x-s[si])+abs(s[si]-t[ti]));
        chmin(ans, abs(x-t[ti-1])+abs(t[ti-1]-s[si-1]));
        chmin(ans, abs(x-t[ti-1])+abs(t[ti-1]-s[si]));
        chmin(ans, abs(x-t[ti])+abs(t[ti]-s[si-1]));
        chmin(ans, abs(x-t[ti])+abs(t[ti]-s[si]));
        cout << ans << endl;
    }
    return 0;
}

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


int main(){
	int n;
	cin>>n;
	vector<int> l(n);
	vector<int> a;
	for(int i=0;i<n;i++)cin>>l[i];
	int now = l[0];
	int lng = 1;
	for(int i=1;i<n;i++)if(now != l[i]){
		now = l[i];
		lng ++;
	}else{
		a.push_back(lng);
		lng = 1;
	}

	a.push_back(lng);
	//for(int i=0;i<a.size();i++)cout<<a[i]<<' ';
	//cout<<endl;
	int ans = a[0];
	if(a.size()<3){
		ans = 0;
		for(int i=0;i<a.size();i++)ans+=a[i];
	}else
	for(int i=0;i<a.size()-2;i++){
		ans = max(ans,a[i]+a[i+1]+a[i+2]);
	}
	cout<<ans<<endl;

	return 0;
}



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

ull gcd(ull a,ull b){
	if(!b) return a;
	return gcd(b,a%b);
}

int main(){
	int n,q;
	cin >> q >> n;
	int a,b,c;
	vector< vector<int> > vec(q);
	
	rep(i,0,n){
	    cin >> a;
	    if(a == 0){
	        cin >> b >> c;
	        vec[b].push_back(c);
	    }
	    else if(a == 1){
	        cin >> b;
	        rep(j,0,vec[b].size()){
	            cout << vec[b][j];
	            if(j != vec[b].size()-1){
	                cout << " ";
	            }
	        }
	        cout << endl;
	    }
	    else{
	        cin >> b;
	        vec[b].erase(vec[b].begin(),vec[b].end());
	    }
	}
  	return 0;
}






Measured memory_bytes: 5740
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll INF=1e18+5;
int main(){
    cin.tie(0);cout.tie(0);
    ios::sync_with_stdio(false);

    int n;cin>>n;
    vl a(n);
    rep(i,n)cin>>a[i];
    int m=1;
    if(n%2)m++;
    vvl dp(n+10,vl(m+1,-INF));
    rep(i,m+1)dp[i][i]=0;
    rep (i, n) {
        rep (j, m + 1) {
            if (dp[i][j] == -INF) continue;
            dp[i + 2][j]=max(dp[i+2][j],dp[i][j] + a[i]);
            if (j + 1 <= m) {
                dp[i + 3][j + 1]=max(dp[i+3][j+1],dp[i][j] + a[i]);
            }
            if (j + 2 <= m) {
                dp[i + 4][j + 2]=max(dp[i+4][j],dp[i][j] + a[i]);
            }
        }
    }
 
    ll ans = -INF;
    int mi;
    if (n % 2 == 0) mi = 0;
    else mi = 1;
    for (int i = n; i <= n + 5; i++) {
        for (int j = mi; j <= m; j++) {
            ans=max(ans,dp[i][j]);
        }
    }
    cout << ans << endl;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int h, a; cin >> h >> a;
    if(h % a == 0) cout << h / a << endl;
    else cout << h / a + 1 << endl;

    return 0;
}


Measured memory_bytes: 3624
#セキュリティコードは4桁の数字列
#入力しづらい＝連続した箇所がある場合　”Bad＂

S = input()
if S[0] == S[1] or S[1] == S[2] or S[2] == S[3]:
    print("Bad")
else:
    print("Good")

Measured memory_bytes: 8956
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
typedef unsigned long long int uli;
using namespace std;
int main() {
	int i, j, k;
	int a, b, m,mi=100001,num=0,ans=0;
	int s_mi = 100001, f_mi = 100001;
	cin >> a >> b >> m;
	vector<int> s(a), f(b);
	for(j = 0; j < a; ++j) {
		cin >> s.at(j);
		s_mi = min(s_mi, s.at(j));
	}
	for(k = 0; k < b; ++k) {
		cin >> f.at(k);
		f_mi = min(f_mi, f.at(k));
	}
	mi = s_mi + f_mi;
	for(i = 0; i < m; ++i) {
		int x, y, c;
		cin >> x >> y >> c;
		mi = min(mi, s.at(x-1) + f.at(y-1) - c);
	}
	cout << mi << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using graph = vector<vector<int>>;

vector<bool> seen;
graph G;

void dfs(const graph &G,int pla){
	seen.at(pla)=true;
	// cout<<"checked:"<<pla+1<<endl;
	for(auto i : G.at(pla)){
		if(seen.at(i)){
			continue;
		}
		else{
			dfs(G,i);
		}
	}
}


main(){
	int N,M;
	cin >> N >>M;
	vector<int> a(M);
	vector<int> b(M);
	int A,B;
	for (int i=0;i<M;i++){
		cin>>A>>B;
		A--;
		B--;
		a.at(i)=A;
		b.at(i)=B;
	}
	int count=0;
	for(int i=0;i<M;i++){
		seen.assign(N,false);
		G.assign(N,vector<int>(0));
		int Ctmp=0;
		
		//第iの道を含まないでグラフに道をブチ込む
		for(int j=0;j<M;j++){
			if(i!=j){
				G.at(a.at(j)).push_back(b.at(j));
				G.at(b.at(j)).push_back(a.at(j));
			}
		}
		
		for(int j=0;j<N;j++){
			if(seen.at(j)){
				continue;
			}
			else{
				dfs(G,j);
				Ctmp++;
				// cout<<"started_from;"<<j+1<<endl;
			}
		}
		
		if(Ctmp>=2){
			count++;
		}
		// cout<<"next"<<endl;
	}
	
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int W = scan.nextInt();
        int H = scan.nextInt();
        int x = scan.nextInt();
        int y = scan.nextInt();
        int r = scan.nextInt();
        
        if (x - r < 0 || x + r > W || y - r < 0 || y + r >H) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
    
}



Measured memory_bytes: 26340
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=505;
int a[MAXN*MAXN],n,ps[MAXN],id[MAXN];
bool cmp(int n1,int n2){return ps[n1]<ps[n2];}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)ps[i]=read(),id[i]=i;
	sort(id+1,id+1+n,cmp);
	for(int i=1,len=1;i<=n;i++)
	{
		int u=id[i];
		while(a[len])++len;if(len>ps[u])return puts("No"),0;
		a[ps[u]]=u;int cnt=0;
		while(cnt<u-1)
		{
			while(a[len])++len;
			if(len>=ps[u])return puts("No"),0;
			a[len]=u;++cnt;
		}
	}int len=n*n;
	for(int i=n;i>=1;i--)
	{
		int cnt=0;int u=id[i];
		while(cnt<n-u)
		{
			while(a[len])--len;
			if(len<=ps[u])return puts("No"),0;
			a[len]=u;++cnt;
		}
	}puts("Yes");
	for(int i=1;i<=n*n;i++)pr1(a[i]);puts("");
	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
set<string> sp;

int main()
{
    // 3桁の値を入れて初期化
    sp.insert("357");
    sp.insert("375");
    sp.insert("537");
    sp.insert("573");
    sp.insert("735");
    sp.insert("753");
    // 4桁以降を生成
    for(int i=3;i<9;i++){
        for(auto itr=sp.begin();itr!=sp.end();++itr){
            string t=*itr;
            if(t.size()==i){
                for(int j=0;j<=i;j++){
                    string tmp3=t; tmp3.insert(j,"3");
                    sp.insert(tmp3);
                    string tmp5=t; tmp5.insert(j,"5");
                    sp.insert(tmp5);
                    string tmp7=t; tmp7.insert(j,"7");
                    sp.insert(tmp7);
                }
            }
            //else if(t.size()>i) break;
        }
    }
    int x; cin>>x;
    int cnt=0;
    for(auto itr=sp.begin();itr!=sp.end();++itr){
        int val=stoi(*itr);
        if(val<=x) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 2688
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();

		int ans = 0;
		for (int i = 1; i <= n; i+=2) {
			if (divList(i).size() == 8) {
				ans++;
			}
		}
		System.out.println(ans);
	}

	static List<Long> divList(long n) {
		List<Long> list = new ArrayList<>();
		long end = (long) Math.sqrt(n);
		for (int i = 1; i <= end; i++) {
			if (n % i == 0) {
				list.add((long) i);
			}
		}
		int i = end * end == n ? list.size() - 2 : list.size() - 1;
		for ( ; i >= 0; i--) {
			list.add(n / list.get(i));
		}
		return list;
	}
}


Measured memory_bytes: 21972
#include<stdio.h>
int main(){
  int a,b,c,d,t=0;
  char s;
  while(scanf("%d %d %d",&a,&b,&c)!=EOF){
    if(a<=1868 && b<=9 && c<8){
      printf("pre-meiji\n");
      d=1;
      t=1;
    }
    else if(a<=1912){
      if(a!=1912){
	printf("meiji ");
	a=a-1868+1;
	d=0;
	t=1;
      }
      else if(a==1912){
	if(b<7){
	  printf("meiji ");
	  a=a-1868+1;
	  d=0;
	  t=1;
	}
	else if(b==7){
	  if(c<30){
	    printf("meiji ");
	    a=a-1868+1;
	    d=0;
	    t=1;
	  }
	}
      }
    }
    if(a<=1926 && t==0){
      if(a!=1926){
	printf("taisho ");
	a=a-1912+1;
	d=0;
	t=1;
      }
      else if(a==1926){
	if(b<12){
	  printf("taisho ");
	  a=a-1912+1;
	  d=0;
	  t=1;
	}
	else if(b==12){
	  if(c<25){
	    printf("taisho ");
	    a=a-1912+1;
	    d=0;
	    t=1;
	  }
	  if(c>=25){
	    printf("showa ");
	    a=a-1926+1;
	    d=0;
	    t=1;
	  }
	}
      }
    }
    if(a<=1989 && t==0){
      if(a!=1989){
	printf("showa ");
	a=a-1926+1;
	d=0;
	t=1;
      }
      else if(a==1989){
	if(b==1){
	  if(c<8){
	    printf("showa ");
	    a=a-1926+1;
	    d=0;
	    t=1;
	  }
	}
      }
    }
    if(a>=1989 && t==0){
      if(a!=1989){
      printf("heisei ");
      a=a-1989+1;
      d=0;
    }
      else if(a==1989){
	if(b!=1){
	  printf("heisei ");
	  a=a-1989+1;
	  d=0;
	}
	else if(b==1){
	  if(c>=8){
	  printf("heisei ");
	  a=a-1989+1;
	  d=0;
	  }
	}
      }
    }
    if(d==0){
      printf("%d %d %d\n",a,b,c);
    }
    t=0;
  }
  return (0);
}

Measured memory_bytes: 608
using System;

namespace B___TAKOYAKI_FESTIVAL_2019
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] D = Console.ReadLine().Split(' ');
            int energy = 0;
            for (int i = 0; i < D.Length; i++)
            {
                for (int j = i+1; j < D.Length; j++)
                {
                    energy += int.Parse(D[i]) * int.Parse(D[j]);
                }
            }
            Console.WriteLine(energy);
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
double a,b;
int main(){
	cin>>a>>b;
	int c=(a+b)/2;
	double cp=(a+b)/2;
//	cout<<c<<" "<<cp<<" "<<cp-(double)c<<" "<<(double)c+1-cp<<endl;
	if(cp-(double)c<(double)c+1-cp)
		cout<<c;
	else
		cout<<c+1;
}


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

int cnt[26];
char C[101];

void solve(int n) {
    for (int i = 0; i < n; i++) {
        cin >> C[i];
    }
    for (int i = 0; i < 26; i++) {
        cnt[i] = 0;
    }
    for (int i = 0; i < n; i++) {
        cnt[C[i] - 'A']++;
        int max_cnt = -1;
        int idx = -1;
        for (int j = 0; j < 26; j++) {
            if (max_cnt < cnt[j]) {
                max_cnt = cnt[j];
                idx = j;
            }
        }
        int next_cnt = -1;
        for (int j = 0; j < 26; j++) {
            if (j == idx) continue;
            next_cnt = max(next_cnt, cnt[j]);
        }
        if (max_cnt > next_cnt + n - i - 1) {
            cout << char('A' + idx) << ' ' << i + 1 << endl;
            return;
        }
    }
    cout << "TIE" << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    while (true) {
        cin >> N;
        if (N == 0) break;
        solve(N);
    }
    return 0;
}


Measured memory_bytes: 3184
#include<iostream>
#include <math.h>
using namespace std;
int main(){
  int n,x[100],y[100];
  double ma=0,eu=0,m3=0,ch=0,di;
  cin>>n;
  for(int i=0;i<n;i++) cin>>x[i];
  for(int i=0;i<n;i++) cin>>y[i];
  for(int i=0;i<n;i++){
    di = fabs(x[i]-y[i]);
    ma += di;
    eu += di*di;
    m3 += di*di*di;
    if(ch<di) ch = di;
  }
  cout<<fixed<<ma<<endl<<sqrt(eu)<<endl<<pow(m3,1./3)<<endl<<ch<<endl;
}

Measured memory_bytes: 3416
import sys
import numpy as np

X, Y, A, B, C = map(int, sys.stdin.readline().rstrip().split())
P = list(map(int, sys.stdin.readline().rstrip().split()))
Q = list(map(int, sys.stdin.readline().rstrip().split()))
R = list(map(int, sys.stdin.readline().rstrip().split()))

if A == 1 and B == 1 and C == 1:
    ans = sum(sorted([P[0], Q[0], R[0]], reverse=True)[:2])
    print(ans)
    sys.exit()

Pmin = np.min(P)
Qmin = np.min(Q)
Rmax = np.max(R)

# 着色する必要がない場合
if Pmin > Rmax and Qmin > Rmax:
    sP = np.sort(P)[::-1] if len(set(P)) > 1 else P
    sQ = np.sort(Q)[::-1] if len(set(Q)) > 1 else Q
    ans = np.sum(sP[:X]) + np.sum(sQ[:Y])
    print(ans)
    sys.exit()

gS = P + Q + R
p = A + B
iX = 0
iY = 0
iR = []
aX = [0] * X
aY = [0] * Y
aR = []
for index in np.argsort(gS)[::-1]:
    if iX == X and iY == Y:
        break
    if index < A:
        if iX == X:
            continue
        else:
            aX[iX] = gS[index]
            iX += 1
    elif index < p:
        if iY == Y:
            continue
        else:
            aY[iY] = gS[index]
            iY += 1
    else:
        iR.append((iX, iY))
        aR.append(gS[index])

sumX = sum(aX)
sumY = sum(aY)
for (iX, iY), s in zip(iR, aR):
    if len(aX) == 0 and len(aY) == 0:
        break
    if len(aX) == 0:
        if s <= aY[-1]:
            break
        sumY = sumY + s - aY.pop()
        if len(aY) == 0:
            break
    elif len(aY) == 0:
        if s <= aX[-1]:
            break
        sumX = sumX + s - aX.pop()
        if len(aX) == 0:
            break
    else:
        if s <= aX[-1] and s <= aY[-1]:
            break
        if iX == X:
            sumY = sumY + s - aY.pop()
        elif iY == Y:
            sumX = sumX + s - aX.pop()
        else:
            if aX[-1] < aY[-1]:
                sumX = sumX + s - aX.pop()
            else:
                sumY = sumY + s - aY.pop()

print(sumX + sumY)

Measured memory_bytes: 41404
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

int t;
ll a,b,c,d,n;
ll inf = 1LL<<60;

unordered_map<ll, ll> m;

ll f(ll x)
{
    if(m.count(x)) return m[x];
    ll ans = inf;
    if(x < inf / d) ans = x * d;
    for(int i=-1; i<=1; i++) if((x + i) % 2 == 0)
    {
        ans = min(ans, d * abs(i) + a + f((x+i) / 2));
    }
    for(int i=-2; i<=2; i++) if((x + i) % 3 == 0)
    {
        ans = min(ans, d * abs(i) + b + f((x+i) / 3));
    }
    for(int i=-4; i<=4; i++) if((x + i) % 5 == 0)
    {
        ans = min(ans, d * abs(i) + c + f((x+i) / 5));
    }
    m.insert({x, ans});
    return ans;

}

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    cin >> t;
    while(t--)
    {
        cin >> n >> a >> b >> c >> d;
        m.clear();
        m.insert({0, 0});
        m.insert({1, d});

        cout << f(n) << endl;

    }
}


Measured memory_bytes: 4020
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n;cin>>n;
	int ans = 0;
	vector<int> a(n);
	for(int i = 0; i < n; i++) {
		cin>>a[i];
	}
	int i = 0;
	while(i < n) {
		if(i + 1 == a[i]){
			ans += 1;
			if(i + 2 == a[i + 1]){
				i += 2;
			}
			else{
				i++;
			}
		}
		else{
			i++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
int main(){
    int n;
    char s[100],t[100];
    
    scanf("%d",&n);
    scanf("%100s %100s",s,t);
    
    for(int i = 0; i < n; i++) printf("%c%c",s[i],t[i]);
    printf("\n");
    return 0;
}



Measured memory_bytes: 128
/*
 Shahadat Hossain
 I.C.T Department
 Comilla University
 Session: 2013-2014
 */

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

typedef long long ll;
typedef unsigned long long ull;

#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define UNIQUE(x)       x.erase(unique(all(x)), x.end())

#define fs              first
#define sc              second
#define pb              push_back

#define sz(x)           (int)x.size()
#define all(v)          v.begin(),v.end()
#define D(x)            cerr << #x " = " << x << '\n'
#define ms(a,b)         memset(a, b, sizeof(a))
#define valid(x,y,n, m)      x>=0 && y>=0 && x<n && y<m

#define input           freopen("/Users/shahadat/Desktop/input.txt", "r", stdin)
#define output          freopen("/Users/shahadat/Desktop/output.txt", "w", stdout)

#define endl            '\n'
#define eps             1e-5
#define yes             printf("Yes\n")
#define no              printf("No\n")

#define int             long long

inline void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
}

//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//uniform_int_distribution<int>(10, 20)(rng);

int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
inline int Set(int n,int pos) { return n = n | (1LL << pos); }
inline int Reset(int n,int pos) { return n = n & ~(1LL << pos); }
inline bool Check(int n,int pos) { return (bool)(n & (1LL << pos)); }
inline int Count(ll n) { return __builtin_popcountll(n); }

typedef pair<int,int> pint;

//int const INF = 1e9 + 10;
//int const MOD = 1e9 + 7;

int const N = 1e6;
int ar[N];

int32_t main(){
    int n;
    cin >> n;
    
    for(int i = 1; i <= n; i++){
        cin >> ar[i];
    }
    sort(ar + 1, ar + n + 1);
    
    int mid = n / 2;
    int res = ar[mid + 1] - ar[mid];
    cout << res << endl;
}





Measured memory_bytes: 1024
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let (n, nq) = get!(usize, usize);
    let v: Vec<char> = get!(String).chars().collect();
    let mut q = Vec::new();
    for _ in 0..nq {
        let mut tup = get!(usize, usize);
        tup.0 -= 1;
        tup.1 -= 1;
        q.push(tup);
    }
    let mut sum = vec![0; n];
    for i in 0..v.len() - 1 {
        if v[i] == 'A' && v[i + 1] == 'C' {
            sum[i + 1] = sum[i] + 1;;
        } else {
            sum[i + 1] = sum[i];
        }
    }
    //eprintln!("{:?}", v);
    //eprintln!("{:?}", q);
    //eprintln!("{:?}", sum);

    for i in 0..nq {
        let ans = sum[q[i].1] - sum[q[i].0];
        println!("{}", ans);
    }
}


Measured memory_bytes: 6908
#include<stdio.h>
int main(){
	char a[2],s[2];
	scanf("%s", a);
	scanf("%s", s);
	if (a[0] == s[2]){
		if (a[1] == s[1]){
			if (a[2] == s[0]){
				printf("YES\n");
			}
			else
			{
				printf("NO\n");
			}
		}
		else
		{
			printf("NO\n");
		}
	}
	else{
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
sa = input()
sb = input()
sc = input()

next = "a"
while True:
    if next == "a":
        if sa == "": break
        next = sa[0]
        sa = sa[1:]
    elif next == "b":
        if sb == "": break
        next = sb[0]
        sb = sb[1:]
    else:
        if sc == "": break
        next = sc[0]
        sc = sc[1:]
if next == "a":
    print("A")
elif next == "b":
    print("B")
else:
    print("C")

Measured memory_bytes: 9080
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

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

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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}

int main() {
  int h,w;
  cin>>h>>w;
  vector<string> v(h);
  vector<bool> row(false);
  vector<bool> col(false);
  rep(i,h) cin>>v[i];
  rep(i,h){
    rep(j,w){
      if(v[i][j]=='#'){
        row[i]=true;
        col[j]=true;
      }
    }
  }
  rep(i,h){
    rep(j,w){
      if(row[i] && col[j]){
        cout<<v[i][j];
      }
    }
    cout<<endl;
  }
  
  
  
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fill(a)  memset(a, 0, sizeof (a))
#define ff first
#define ss second
#define pb push_back
typedef long double ld;
typedef vector<ll> vll;
typedef vector<pair<ll,ll>> vpl;
const ll INF = 1e18;
const ld PI = 4*atan((ld)1);
const ll mod = 1e9+7;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll tt=1;
        // cin >> tt;
    while((tt)--){
        string s,t; cin >> s >> t;
        ll ans =0;
        rep(i,sz(s)){
            if(s[i]!=t[i]) ans++;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3784
isP :: Int -> Bool
isP i = case cs of 
  (a:b:c:d:e) -> a == (head e) && b == d
  otherwise -> False
  where 
    cs = [[c] | c <- show i]

main = do
  n <- fmap (read :: String -> Int) . words <$> getLine
  let l = head n
  let r = last n
  putStrLn $ show $ length $ filter isP [l .. r]

Measured memory_bytes: 1020
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	rep(i,N) cin >> A[i];

	ll res = 0;
	for(int i = 0; i < A.size(); i++) {
		if(A[i] % 2) {
			if(i+1 < A.size() && A[i+1]) {
				A[i]--;
				A[i+1]--;
				res++;
			}
		}
		res += A[i] / 2;
		A[i] -= (A[i] / 2) * 2;
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int mod = 998244353;
const int N = 1e5 + 5;

int main()
{
	ios::sync_with_stdio(false);
	cout.tie(NULL);
	int n;
	cin >> n;
	int f = 0,t = 0;
	for(int i = 1; i <= n; i++){
		int a,b;
		cin >> a >> b;
		if(a == b){
			t++;
		}
		else{
			f = max(f,t);
			t = 0;
		}
	}
	if(f >= 3 || t >= 3)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;  
} 

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

using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int x = (a + d - 1) / d;
    int y = (c + b - 1) / b;
    if (x >= y) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int main()
{
	int n , m ;
	cin >> n >> m ;
	vector<pair<int,int>> sc(m);
	rep(i,m) cin >> sc[i].first >> sc[i].second;

	SORT(sc);
	//同じ桁数を指定シていて、違う数があったらダメ
	int num = -1 ;
	int keta = -1;
	int ans = 0 ;
	if(n==1){
		if(m==0){
			puts("0");
			return 0 ;
		}
		int now = sc[0].second;
		//m個とも全部.secondが0なら0を出力する
		rep(i,m){
			if(now == sc[i].second){
				// ok ;
			} else {
				puts("-1");
				return 0 ;
			}
		}
		cout << now << endl;
		return 0 ;
	}
	rep(i,m){
		if( n == 1 && m == 1 && sc[i].first == 1 && sc[i].second == 0){
			puts("0") ;
			return 0;
		}
		if(sc[i].first == keta && sc[i].second != num){
			puts("-1");
			return 0 ;//存在しない
		}
		if(sc[i].first == keta) continue;
		//人桁目が０はだめ
		if(sc[i].first == 1  && sc[i].second == 0){
			puts("-1");
			return 0 ;
		}
		//そうでない時
		num = sc[i].second;
		keta = sc[i].first ;
		ans += pow(10,n-keta) * num ;
	}
	if(n == 2){
		if(ans < 10){
			ans += 10;
		}
	}
	if( n== 3){
		if(ans < 100){
			ans += 100 ;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
const main = (input) => {
  input = input.trim();
  input = input.split('\n');
  const A = input[0];
  const B = input[1];
 
  if (A[0]==B[2]&&A[2]==B[0]&&A[1]==B[1]){
    console.log("YES");
  }else{
    console.log("NO");
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  
  vector<int> h(n);
  rep(i, 0, n) cin >> h.at(i);
  
  vector<int> dp(n, 0);
  dp.at(1) = abs(h.at(1) -h.at(0));
  rep(i, 2, n) {
    dp.at(i) = min(dp.at(i-1) +abs(h.at(i) -h.at(i-1)), dp.at(i-2) +abs(h.at(i) -h.at(i-2)));
  }  
  
  cout << dp.at(n-1) << "\n";

}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<n;i++)
int main(){
while(1){
ll n;
cin >>n;
if(n==0){
break;
}
string name[n];
REP(i,n){
cin>>name[i];
}
ll num[n];
REP(i,n){
num[i]=name[i].length();
}

REP(i,n){
ll len=0;
ll now=i;
while(len<5){
len+=num[now];
now++;
}

if(len==5){
len=0;
while(len<7){
len+=num[now];
now++;
}
if(len==7){
len=0;
while(len<5){
len+=num[now];
now++;
}
if(len==5){
len=0;
while(len<7){
len+=num[now];
now++;
}
if(len==7){
len=0;
while(len<7){
len+=num[now];
now++;
}
if(len==7){
cout<<i+1<<endl;
break;
}
}
}

}
}

}





}


return 0;
}


Measured memory_bytes: 3044
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();
        int max = Math.max(A*B,C*D);
        System.out.println(max);
    }
}


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

using namespace std;


int MinCostTopDownDP(int source, int destination, int * height, vector<int> &Memo);



int main() {
  int n;
  cin >> n;
  int height[n];
  for (int i = 0; i < n; i++) {
    cin >> height[i];
  }
  vector<int> Memo(n, -1);
  cout << MinCostTopDownDP(0, n - 1, height, Memo) << endl;

}

int MinCostTopDownDP(int source, int destination, int * height, vector<int> &Memo) { // Memoized
  if (source < destination) {

    if (Memo[source] == -1) {
      
      if (source == destination - 1)
        Memo[source] = abs(height[source] - height[destination]);
      else {
        int min_cost = INFINITY;
        for (int i = 1; i <= 2; i++) {
          int this_route_min = MinCostTopDownDP(source + i, destination, height, Memo) + abs(height[source] - height[source + i]);
          min_cost = min(min_cost, this_route_min);
        }
        Memo[source] = min_cost;
      }
    }
    return Memo[source];    
  }
  return 0;
}

Measured memory_bytes: 8832
H,W = map(int,input().split())
S = [list(input()) for _ in range(H)]

row = [[0]*W for _ in range(H)]
column = [[0]*W for _ in range(H)]

for j in range(W):
    tmp = set()
    cnt = 0
    for i in range(H):
        if S[i][j] == "#":
            for pi,pj in tmp:
                row[pi][pj] = cnt
            tmp = set()
            cnt = 0
        else:
            tmp.add((i,j))
            cnt += 1
    for pi,pj in tmp:
        row[pi][pj] = cnt

for i in range(H):
    tmp = set()
    cnt = 0
    for j in range(W):
        if S[i][j] == "#":
            for pi,pj in tmp:
                column[pi][pj] = cnt
            tmp = set()
            cnt = 0
        else:
            tmp.add((i,j))
            cnt += 1
    for pi,pj in tmp:
        column[pi][pj] = cnt

ans = 0
for i in range(H):
    for j in range(W):
        res = row[i][j] + column[i][j] - 1
        ans = max(ans,res)

print(ans)

Measured memory_bytes: 271112
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0, i##_len=(n); i<i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

int main(){
          int height,width;
          string line;
          cin >> height >> width; cin.ignore();

          char maze[height][width];

          REP(i,height){
                    getline(cin,line);
                    REP(j,width){
                              maze[i][j]=line[j];
                    }
          }

          /*
          REP(i,height){
                    REP(j,width){
                              cout << maze[i][j];
                    }
                    cout <<endl;
          }
          迷路の確認表示
          */
          int flag=0;

          REP(i,height){
                    REP(j,width){
                              if (maze[i][j]=='#'){
                                        if(maze[i-1][j]=='.' and maze[i+1][j]=='.' and maze[i][j+1]=='.' and maze[i][j-1]=='.'){
                                                  flag=1;
                                        }
                              }
                    }
          }
          if(flag==0) cout << "Yes" << endl;
          else cout << "No" << endl;
          return 0;
}


Measured memory_bytes: 256
n, x, m = map(int,input().split())
a = x; s = a
k = {a}
memo = [a]
mode = 0
cnt = 1
for i in range(n-1):
	a = (a**2)%m
	cnt += 1
	memo.append(a)
	if a in k:
		mode = 1
		break
	s += a
	k.add(a)
if mode:
	targ = memo.index(a)
	nagasa = cnt-1-targ
	ruisekiwa = [0 for _ in range(nagasa)]
	ruisekiwa[0] = memo[targ]
	for i in range(1, nagasa):
		ruisekiwa[i] = ruisekiwa[i-1] + memo[i+targ]
	t = n - cnt
	s += ruisekiwa[-1]*(t//nagasa) + ruisekiwa[t%nagasa]
print(s)

Measured memory_bytes: 80616
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};
 
 
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (b - a == c - b) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

void main() {
    int N;
    scan(N);
    auto x = new int[](N);
    auto y = new int[](N);
    iota(N).each!(i => scan(x[i], y[i]));
    x[] -= 1;
    y[] -= 1;

    int L = 10^^5;
    auto adj = new int[][](2 * L, 0);
    foreach (i ; 0 .. N) {
        adj[x[i]] ~= y[i] + L;
        adj[y[i] + L] ~= x[i];
    }

    auto visited = new bool[](2 * L);

    long ans;
    long cx, cy;

    void dfs(int v) {
        visited[v] = true;
        (v >= L ? cy : cx)++;

        foreach (u ; adj[v]) {
            if (!visited[u]) dfs(u);
        }
    }

    foreach (i ; 0 .. 2 * L) {
        cx = cy = 0;
        if (!visited[i]) {
            dfs(i);
        }
        ans += cx * cy;
    }

    ans -= N;
    writeln(ans);
}








void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
    int N, M;
    cin >> N >> M;
    int a[M], b[M];
    REP(i, M) cin >> a[i] >> b[i];
    int hash[200005] = {};
    REP(i, M){
        if(a[i]==1) hash[b[i]]++;
    }
    bool flag = false;
    REP(i, M){
        if(b[i]==N && hash[a[i]]>0) flag = true;
    }
    cout << (flag?"POSSIBLE":"IMPOSSIBLE") << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int n;
void nhap()
{
    scanf("%d",&n);
}
void solve()
{
    int xmax = -1;
    int xmin = 10000000;
    for (int i=1; i<=n; i++)
    {
        int x;
        scanf("%d",&x);
        xmax = max(x,xmax);
        xmin = min(x,xmin);
    }
    cout<<xmax-xmin<<endl;
}
int main()
{
    nhap();
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define endl '\n'
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--) 
#define fast_io ios_base::sync_with_stdio(0);
#define show(x) cout<<x<<endl;
#define pret(x) cout<<x<<endl; return 0;
#define disp(x) cout<<x<<" ";
#define let(x,y) cout<<x<<" "<<y<<endl;
ll MOD=1e9+7;
ll MAX=9223372036854775807;

int main(){
    fast_io;
    int n;
    cin>>n;
	ll a[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	ll l=a[0],r=a[0];
	int st=1,en=n-1;
	ll ans=0;
	while(st<=en){
		ll t1=max(abs(l-a[st]),abs(r-a[st]));
		ll t2=max(abs(l-a[en]),abs(r-a[en]));
		if(t1>t2){
			if(abs(l-a[st])>abs(r-a[st])){
				ans+=abs(l-a[st]);
				l=a[st];
				st++;
			}
			else{
				ans+=abs(r-a[st]);
				r=a[st];
				st++;
			}
		}	
		else{
			if(abs(l-a[en])>abs(r-a[en])){
				ans+=abs(l-a[en]);
				l=a[en];
				en--;
			}
			else{
				ans+=abs(r-a[en]);
				r=a[en];
				en--;
			}
		}	
	}
	show(ans);
    return 0;
}	

Measured memory_bytes: 1024