akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

int main()
{
    int n{};
    std::vector<int> ps;
    std::vector<int> qs;

    int x{};
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> x;
        ps.emplace_back(x);
    }
    for (int i = 0; i < n; i++) {
        std::cin >> x;
        qs.emplace_back(x);
    }

    int total = 1;
    std::vector<int> table = {1};
    for (int i = 1; i <= n; i++) {
        total *= i;
        table.emplace_back(total);
    }

    int a{}, b{};
    std::vector<int> numbers;
    for (int i = 0; i < n; i++) numbers.emplace_back(i + 1);
    for (int i = 0; i < n - 1; i++) {
        const auto itr = std::find(numbers.begin(), numbers.end(), ps[i]);
        const auto pos = std::distance(numbers.begin(), itr);
        numbers.erase(itr);
        a += pos * table[n - i - 1];
    }
    numbers.clear();
    for (int i = 0; i < n; i++) numbers.emplace_back(i + 1);
    for (int i = 0; i < n - 1; i++) {
        const auto itr = std::find(numbers.begin(), numbers.end(), qs[i]);
        const auto pos = std::distance(numbers.begin(), itr);
        numbers.erase(itr);
        b += pos * table[n - i - 1];
    }
    std::cout << std::abs(a - b) << std::endl;
    return 0;
}


Measured memory_bytes: 256
//File: abc174d.cpp
//Author: yanyanlongxia
//Date: 2020/8/3
//
#include <bits/stdc++.h>

using namespace std;
int n,cnt,ans;
string s;
int main() {
    scanf("%d",&n);
    cin>>s;
    for(int i=0;i<n;i++)
        if(s[i]=='W')
            cnt++;
    for(int i=n-cnt;i<n;i++)
        if(s[i]!='W')
            ans++;
    printf("%d\n",ans);
    return 0;
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char const *argv[]) {
	int a,b;
	std::cin >> a >> b;
	std::vector<std::vector<char>> v(100,std::vector<char> (100,'.'));
	for (size_t i = 0; i < v.size()/2; i++) {
		for (size_t j = 0; j < v[i].size(); j++) {
			v[i][j] = '#';
		}
	}

	for (size_t i = 0; i < v.size(); i+=2) {
		for (size_t j = 0; j < v[i].size()-2; j+=2) {
			if (a > 1) {
				v[i][j+i%2] = '.';
				a--;
			}
		}
		if (i > 50) {
			for (size_t j = 0; j < v[i].size()-2; j+=2) {
				if (b > 1) {
					v[i][j+i%2] = '#';
					b--;
				}
			}
		}
	}

	std::cout << "100 100" << '\n';
	for (size_t i = 0; i < v.size(); i++) {
		for (size_t j = 0; j < v[i].size(); j++) {
			std::cout << v[i][j];
		}
		std::cout << '\n';
	}
	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().solve();
	}

	private void solve() throws IOException {
		try {
			solveA();
			// solveB();
			// solveC();
			// solveD();
			// solveE();
			// solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		StringBuilder builder = new StringBuilder();
		IntStream.range(0, 3).forEach(i -> builder.append(next().charAt(0)));
		out.println(builder.toString().toUpperCase());
	}

	private void solveB() {
		int numN = nextInt();

		out.println("");
	}

	private void solveC() {
		int numN = nextInt();

		out.println("");
	}

	private void solveD() {
		int numN = nextInt();

		out.println("");
	}

	private void solveE() {
		int numN = nextInt();

		out.println("");
	}

	private void solveF() {
		int numN = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 26708
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);

        int h1 = sc.nextInt();
        int m1 = sc.nextInt();
        int h2 = sc.nextInt();
        int m2 = sc.nextInt();
        int k = sc.nextInt();

        int t = h2*60 + m2 - (h1*60 + m1);
        System.out.println(t - k);
    }
}

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

int main(void){
    int n,m;
    cin>>n>>m;
    int t = 100*(n-m)+1900*m;
    double p = pow(0.5,m);
    double q = 1-pow(0.5,m);
    double res = 0;
    rep(i,10000){
        res += t*(i+1)*p;
        p *= q;
    }
    cout<<round(res)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>

int main(){
    char str[1001];
    
    while(1){
        scanf("%s", str);
        if ( str[0] == '0' ) break;
        int sum = 0;
        for ( int i = 0; i < strlen(str); i++ ){
            sum += (str[i]-'0');
        }
        
        printf("%d\n", sum);
    }
    
    return 0;
}


Measured memory_bytes: 2604
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
#include <functional>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
constexpr long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;

string s[12];
int dx[4] = {-1,0,1,0}, dy[4] = {0,1,0,-1};


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    while(cin >> s[0]) {
        rep(i,1,12) cin >> s[i];
        function<void(int,int)> dfs = [&](int i, int j) {
            s[i][j] = '0';
            REP(k,4) {
                int ny = i + dy[k], nx = j + dx[k];
                if(0 <= ny && ny < 12 && 0 <= nx && nx < 12 && s[ny][nx] == '1') dfs(ny, nx);
            }
        };

        int ans = 0;
        REP(i,12) {
            REP(j,12) {
                if(s[i][j] == '1') {
                    dfs(i, j);
                    ++ans;
                }
            }
        }
        cout << ans << '\n';
    }
    return 0;
}



Measured memory_bytes: 3148
#include <iostream>

using namespace std;

int main()
{
    int a,b,c,q,w;
    cin >> a >> b;
    if(a%500==0)
    {
        cout << "Yes";
    }
    else if(a%500>b)
    {
        cout << "No";
    }
    else
        cout << "Yes";
        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

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;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;


signed main(){
	int N;
	cin>>N;
	N=N%10;
	if(N==2||N==4||N==5||N==7||N==9)cout<<"hon"<<endl;
	else if(N==3)cout<<"bon"<<endl;
	else cout<<"pon"<<endl;
}


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

typedef long long ll;
#define rep(i,l,r) for(int i=l;i<=r;++i)
template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
template <typename T> void chmin(T &x,const T &y)
{
	if(x>y)x=y;
}

const int N=1e5+5,T=N*2;
int X,qq[T],*q=qq+N;
ll qk[T],*k=qk+N,qb[T],*b=qb+N;
int head=0,tail=0;ll adb=0;
int r[N];
int t[N],a[N],ans[N];
vector<int>lk[N];

inline int F(int i,int x)
{
	return k[i]*x+b[i]+adb;
}
int qiu(int x)
{
	int i=lower_bound(q+head,q+tail+1,x)-q;
	return F(i,x);
}
void decrease(int x)
{
	adb-=x;
	int nt=-1;
	while(head<=tail&&F(head,q[head])<=0)
	{
		nt=q[head];
		++head;
	}
	if(head<=tail&&k[head])chmax(nt,int(-(b[head]+adb)/k[head]));
	if(nt!=-1)
	{
		--head;
		q[head]=nt;
		k[head]=0;
		b[head]=-adb;
	}
}
void increase(int x)
{
	adb+=x;
	q[head-1]=-1;
	while(head<=tail&&F(tail,q[tail-1]+1)>=X)--tail;
	if(head<=tail&&k[tail])chmin(q[tail],int((X-(b[tail]+adb))/k[tail]));
	if(!(head<=tail&&q[tail]==X))
	{
		++tail;
		q[tail]=X;
		k[tail]=0;
		b[tail]=X-adb;
	}
}

int main()
{
	cin>>X;
	int n;
	cin>>n;
	rep(i,1,n)scanf("%d",r+i);
	int m;
	cin>>m;
	rep(i,1,m)
	{
		scanf("%d%d",t+i,a+i);
		lk[lower_bound(r+1,r+n+1,t[i]+1)-r-1].push_back(i);
	}
	
	q[0]=X;
	k[0]=1;
	b[0]=0;
	rep(x,0,n)
	{
		for(auto i:lk[x])
		{
			ans[i]=qiu(a[i]);
			if(x%2==0)ans[i]=max(0,ans[i]-(t[i]-r[x]));
			else ans[i]=min(X,ans[i]+(t[i]-r[x]));
		}
		if(x<n)
		{
			if(x%2==0)decrease(r[x+1]-r[x]);
			else increase(r[x+1]-r[x]);
		}
	}
	rep(i,1,m)printf("%d\n",ans[i]);
}

Measured memory_bytes: 9088
# -*- coding: utf-8 -*-
N = int(input())
An = list(map(int, input().split()))

#総和
all_sum = 0
for i in range(N):
    if i == 0:
        all_sum += abs(An[i])
    else:
        all_sum += abs(An[i] - An[i-1])

#0戻り分
all_sum += abs(An[-1])

for i in range(N):
    if i == 0:
        ans = all_sum - abs(An[i]) - abs(An[i] - An[i+1]) + abs(An[i+1])
    elif i == N-1:
        ans = all_sum - abs(An[i-1] - An[i]) - abs(An[i]) + abs(An[i-1])
    else:
        ans = all_sum - abs(An[i-1] - An[i]) - abs(An[i] - An[i+1]) + abs(An[i-1]-An[i+1])

    print(ans)


Measured memory_bytes: 14172
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        String str = lines[0];
        String[] str1 = str.split(" ");
        int sheep = Integer.parseInt(str1[0]);
        int wolf = Integer.parseInt(str1[1]);

        if (sheep <= wolf){
            System.out.println("unsafe");
        } else {
            System.out.println("safe");
        }
    
    
        
    }
  
  private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  }
  
}


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

using namespace std;

int main(int argc, char const *argv[])
{
  int n; cin >> n;
  int p;
  int c = 0;
  for(int i=1;i<=n;++i) {
    cin >> p;
    if (i!=p) ++c;
  }
  cout << ((c<=2)? "YES" :"NO") << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	int a, b;
	cin >> a >> b;
	if( b > 0 && a < 0) cout << "Zero";
	else if(a > 0) cout << "Positive";
	else if (a <0 && b > 0) cout << (a%2==0?"Positive":"Negative");
	else cout << ((b-a-1)%2==0?"Positive":"Negative");

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
int main() {
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  cout << (h2 * 60 + m2) - (h1 * 60 + m1) - k << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
int uni[maxn*4],part[maxn*4];
#define lson (rt<<1)
#define rson (rt<<1|1)

/* 
左闭右开，index——0
 */
void add(int rt,int l,int r,int x,int y,int v){
    if(y<=l||x>=r)return;
    if(x<=l&&y>=r)uni[rt]+=v;
    else{
        part[rt]+=(min(r,y)-max(x,l))*v;
        add(lson,l,l+r>>1,x,y,v);
        add(rson,l+r>>1,r,x,y,v);
    }
}
int sum(int rt,int l,int r,int x,int y){
    if(y<=l||x>=r)return 0;
    if(x<=l&&y>=r)return (r-l)*uni[rt]+part[rt];
    int ret=(min(r,y)-max(x,l))*uni[rt];
    ret+=sum(lson,l,l+r>>1,x,y);
    ret+=sum(rson,l+r>>1,r,x,y);
    return ret;
}
signed main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,q;
    cin>>n>>q;
   // int N=1;
    //while(N<n)N*=2;n=N;
    rep(i,1,q){
        int op,x,y,v;
        cin>>op;
        if(op){
            cin>>x>>y;
            cout<<sum(1,1,n+1,x,y+1)<<endl;
        }else{
            int v;
            cin>>x>>y>>v;
            add(1,1,n+1,x,y+1,v);
        }
    }
}
/* 
3 5
0 1 2 1
0 2 3 2
0 3 3 3
1 1 2
1 2 3

1≤n≤100000
1≤q≤100000
1≤s≤t≤n
0≤x<1000
 */


Measured memory_bytes: 6168
#include <bits/stdc++.h>
#define MAX_INT 2100000000
#define rep(i,n) for (i=1;i<=(n);++i)
using namespace std;
typedef long long int ll;
#ifdef COMPILE_IN_VCPP
#include <windows.h>
HWND GetConsoleHwnd(void)
{
#define MY_BUFSIZE 1024 // Buffer size for console window titles.
	HWND hwndFound;         // This is what is returned to the caller.
	char pszNewWindowTitle[MY_BUFSIZE]; // Contains fabricated// WindowTitle.
	char pszOldWindowTitle[MY_BUFSIZE]; // Contains original// WindowTitle.
	ULARGE_INTEGER nt;
	nt.QuadPart = GetTickCount64();
	GetConsoleTitle(pszOldWindowTitle, MY_BUFSIZE);
	wsprintf(pszNewWindowTitle, "%d%d/%d", nt.HighPart, nt.LowPart, GetCurrentProcessId());
	SetConsoleTitle(pszNewWindowTitle);
	Sleep(40);
	hwndFound = FindWindow(NULL, pszNewWindowTitle);
	SetConsoleTitle(pszOldWindowTitle);
	return(hwndFound);
}
#endif
ll mod = 1e9 + 7;
ll countr(vector<string> a)
{
	vector<ll> c;
	int n=1;
	ll ans = 0;
	for (int i = 0; i < a.size() - 1; i++)
	{
		if (a[i] != a[i + 1])
		{
			c.push_back(n);
			n = 1;
		}
		else n++;
	}
	c.push_back(n);
	for (int i = 0; i < c.size(); i++)
	{
		ans += c[i] * (c[i]-1) / 2;
		printf("%d\n", c[i]);
	}
	return ans;
}
int main()
{
	int a;
	string s;
	cin >> a;
	cin >> s;
	if (a >= 3200) cout << s << endl;
	else cout << "red" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,w[105];
    long long sum1=0,sum2=0,ans=0x3f3f3f3f3f3f3f3f;
    cin>>n;
    for (int i=0; i<n; i++) {cin>>w[i]; sum2+=w[i];}
    for (int i=0; i<n; i++) {
        ans=min(ans,abs(sum2-sum1));
        sum2-=w[i]; sum1+=w[i];
    }
    ans=min(ans,abs(sum2-sum1));
    cout<<ans<<'\n';
}

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

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

  int a, b;
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    sum += a;
    if (i == 0)
      b = a;
    else if (b > a)
      b = a;
  }
  int ans = n + (x - sum) / b;

  cout << ans << endl;
}

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

int main() {
  int64_t a, b, x, ans = 0LL;
  scanf("%ld%ld%ld", &a, &b, &x);
  if(a == 0 && b == 0) ans = 1;
  else if(a == 0) ans = b / x + 1;
  else ans = b / x - (a - 1) / x;
  printf("%ld", ans);
}

Measured memory_bytes: 3828
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    final Scanner sc = new Scanner(System.in);
    final List<Integer> list = new ArrayList<>();
    //final List<Long> list2 = new ArrayList<>();

    String s = sc.next();

    char[] work = new char[s.length()];
    int count = 0;

    for(int i = 0; i < s.length(); i++){
            work[i] = s.charAt(i);
    }
    for(int i = 0; i < s.length() - 1; i++){
        if(work[i] == work[i+1]){
            if(work[i+1] == '1'){
                work[i+1] = '0';
            }else{
                work[i+1] = '1';
            }
            count++;
        }
    }
    System.out.println(count);




}
}

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

int main()
{
  char s[10];
  for(int i = 0; i < 10; i++){
    cin >> s[i];
  }
  if(s[5] == '0' && s[6] - '4' <= 0){
    cout << "Heisei" << endl;
  }
  else{
    cout << "TBD" << endl;
  }
}

Measured memory_bytes: 256
#include<cstdlib>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<cstring>
#include<cmath>
using namespace std;
const int MAXN = (int) 50 + 10;
const int INF = (int) 0x3f3f3f3f;
typedef long long LL;

int M,N,A,B,C,T;
int s[MAXN];

struct Matrix{
    LL a[MAXN][MAXN];
}st,mp;

Matrix Matrix_Multiply(const Matrix& a,const Matrix& b,int MOD){
    Matrix c;
    memset(c.a,0,sizeof(c.a));
    for(int k=1;k<=N;k++){
        for(int i=1;i<=N;i++){
            for(int j=1;j<=N;j++){
                c.a[i][k]=(c.a[i][k]+a.a[i][j]*b.a[j][k])%MOD;
            }
        }
    }
    return c;
}

void Power(int X,int MOD){
    while(X){
        if(X&1) st=Matrix_Multiply(st,mp,MOD);
        mp=Matrix_Multiply(mp,mp,MOD);
        X>>=1;
    }
}

void work(){
    while(~scanf("%d%d%d%d%d%d",&N,&M,&A,&B,&C,&T)){
        for(int i=1;i<=N;i++) scanf("%d",&s[i]);
        memset(mp.a,0,sizeof(mp.a));
        for(int i=1;i<=N;i++){
            mp.a[i][i-1]=A;
            mp.a[i][i]=B;
            mp.a[i][i+1]=C;
        }
        for(int i=1;i<=N;i++){
            for(int j=1;j<=N;j++) st.a[i][j]=(i==j);
        }
        Power(T,M);
        for(int i=1;i<=N;i++){
            LL ans=0;
            for(int j=1;j<=N;j++){
                ans=(ans+st.a[i][j]*s[j])%M;
            }
            printf("%lld%s",ans,i==N ? "\n" : " ");
        }
    }
}

int main(){
#ifdef NNever
    freopen("data.in","r",stdin);
//    freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}










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

int main(){
  int n;
  cin>>n;
  int Y,M,D;
  int day[101]={};
  for(int i=0;i<n;i++){
    cin>>Y>>M>>D;
    for(int j=Y+1;j<1000;j++){
      if(j%3==0){
	day[i]+=20*10;
      }
      else {
	day[i]+=20*5+19*5;
      }
    }
    for(int d=M+1;d<=10;d++){
      if(Y%3==0){
	day[i]+=20;
      }
      else{
	if(d==1 || d==3 || d==5 ||d==7 || d==9){
	  day[i]+=20;
	}
	else day[i]+=19;
      }
    }
    if(Y%3!=0){
    if(M==1 || M==3 ||
       M==5 ||M==7 || M==9) day[i]+=(21-D);
    else day[i]+=(20-D);
    }
    else day[i]+=(21-D);
  }

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

Measured memory_bytes: 1160
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;

int ma[1 << 18][2];

int main()
{
  int n;
  cin >> n;
  vector<int> a(1 << n);
  for (int i = 0; i < a.size(); ++i) cin >> a[i];

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

  for (int i = 0; i < n; ++i) for (int mask = 0; mask < (1 << n); ++mask) {
    if (mask & (1 << i)) {
      int mask2 = mask ^ (1 << i);
      for (int t : ma[mask2]) {
        if (t > ma[mask][0]) {
          ma[mask][1] = ma[mask][0];
          ma[mask][0] = t;
        } else if (t > ma[mask][1]) {
          ma[mask][1] = t;
        }
      }
    }
  }          

  int result = 0;
  for (int k = 1; k < (1 << n); ++k) {
    result = max(result, ma[k][0] + ma[k][1]);
    cout << result << endl;
  }

  return 0;
}


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

int main() {
    int n;
    scanf("%d", &n);
    vector<int> a1(n), a2(n), b1(n), b2(n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a1[i]);
        a2[i] = a1[i];
    }
    for (int i = 0; i < n; ++i) {
        scanf("%d", &b1[i]);
        b2[i] = b1[i];
    }
    sort(a2.begin(), a2.end());
    sort(b2.begin(), b2.end());
    int a = 0, b = 0;
    do {
        a++;
    } while(a1 != a2 && next_permutation(a2.begin(), a2.end()));
    do {
        b++;
    } while(b1 != b2 && next_permutation(b2.begin(), b2.end()));
    printf("%d\n", abs(a-b));
 
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <iomanip>
using namespace std;

;;

int main(){
  ;;
    int x, a, b;
    cin >> x >> a >> b;
    ;
    if(abs(x-a)<abs(x-b)) {;cout << ("A") << endl;;}
    else {;cout << ("B") << endl;;};
}

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

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


Measured memory_bytes: 3576
#include <stdio.h>

int main(void)
{
    int a;
    int b;
    int n;
    int i;

    scanf("%d %d", &a, &b);
    
    n = b - a;

    i = 0;

    while(n > 0){
        i += n;
        n--;
    }

    printf("%d", i - b);

    return(0);
}


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

const int INFTY = 1000000001;

int C=0;

void Merge(int A[],int left,int mid,int right){
  int n1 = mid-left;
  int n2 = right-mid;

  int L[n1+1];
  int R[n2+1];

  for(int i=0;i<n1;i++){
    L[i] = A[left+i];
  }

  for(int i=0;i<n2;i++){
    R[i] = A[mid+i];
  }

  L[n1] = INFTY;
  R[n2] = INFTY;

  int i=0;
  int j=0;

  for(int k=left;k<right;k++){
    C++;
    if(L[i]<=R[j]){
      A[k] = L[i];
      i++;
    }else{
      A[k] = R[j];
      j++;
    }
  }
}

void MergeSort(int A[],int left,int right){
  if(left+1 < right){
    int mid = (left+right)/2;
    MergeSort(A,left,mid);
    MergeSort(A,mid,right);
    Merge(A,left,mid,right);
  }
}

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

  int S[500000];
  for(int i=0;i<n;i++){
    cin >> S[i];
  }

  MergeSort(S,0,n);

  for(int i=0;i<n;i++){
    if (i)
			cout << " ";
    cout << S[i];
  }
  cout << endl;

  cout << C << endl;

  return 0;
}



Measured memory_bytes: 6880
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
	vector<int>v(n);
	int a;
	cin>>a;
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	int sum=0;
	for(int j=0;j<a;j++){
		sum+=v.at(j);
	}
	cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var (
		n int 
		count = 0 
	)

	fmt.Scan(&n)

	nums := make([]int, n)
	for i :=0; i < n; i++ {
		fmt.Scan(&nums[i])
	}
  
	for flag:=true; flag; {
		for i := 0; i < n; i++ {
			if nums[i] %2 == 0 {
				nums[i] /= 2
			} else {
				flag = false
				break
			}
		}
		if flag{
			count++
		}
	}
	fmt.Println(count)
}



Measured memory_bytes: 512
#include<cstdio> 
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
using namespace std;
#define fo(i,j,k) for(i=j;i<=k;i++)
#define fd(i,j,k) for(i=j;i>=k;i--)
#define cmax(a,b) (a=(a>b)?a:b)
#define cmin(a,b) (a=(a<b)?a:b)
typedef long long ll;
const int N=1e6+5,M=1e7+50,mo=1e9+7;
int vis[N],pdd[N],pd[M],pri[N],Ref[N],d[N],e[N],c[M],x,ttt,n,i,j,ans,y;
int tt,b[N],nxt[N],fst[N];
void cr(int x,int y)
{
	tt++;
	b[tt]=y;
	nxt[tt]=fst[x];
	fst[x]=tt;
}
int dfs(int x)
{
	if (vis[x]==ttt) return 0;
	vis[x]=ttt;
	for (int p=fst[x];p;p=nxt[p])
	{
		if (!Ref[b[p]]||dfs(Ref[b[p]]))
		{
			Ref[b[p]]=x;
			pdd[x]=b[p];
			return 1;
		}
	}
	return 0;
}
void match()
{
	fo(i,1,n)
		if (!pdd[i])
		{
			ttt++;
			if (dfs(i)) ans++;
		}
}
void predo(int n)
{
	fo(i,2,n)
	{
		if (!pd[i]) pri[++pri[0]]=i;
		fo(j,1,pri[0])
		{
			if (1ll*i*pri[j]>n) break;
			pd[i*pri[j]]=1;
		}
	}
}
int main()
{
	scanf("%d",&n);
	fo(i,1,n)
	{
		scanf("%d",&x);
		c[x]^=1;
		c[x+1]^=1;
	}
	predo(1e7+5);
	fo(i,1,1e7+5)
		if (c[i])
		{
			if (i%2)
				d[++d[0]]=i;
			else e[++e[0]]=i;
		}
	pd[1]=pd[2]=1;
	fo(i,1,d[0])
		fo(j,1,e[0])
		if (!pd[abs(e[j]-d[i])])
			cr(i,j);
	ans=0;
	match();
	x=y=0;
	fo(i,1,d[0]) if (!pdd[i]) x++;
	fo(i,1,e[0]) if (!Ref[i]) y++;
	ans+=x-x%2+y-y%2;
	if (x%2) ans+=3;
	printf("%d",ans);
}

Measured memory_bytes: 96384
package main

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

func main() {
	fmt.Println(resolve(parseProblem(os.Stdin)))
}

func parseProblem(r io.Reader) (int, int) {
	const (
		initialBufSize = 100000
		maxBufSize     = 1000000
	)
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines

	return scanInt(sc), scanInt(sc)
}

func resolve(n, m int) int {
	l := m / n
	dd := make([]int, 0)
	for i := 2; i*i <= m; i++ {
		if m%i != 0 {
			continue
		}
		dd = append(dd, i)
		if i == m/i {
			continue
		}
		dd = append(dd, m/i)
	}
	dd = append(dd, 1)
	dd = append(dd, m)
	sort.Sort(sort.Reverse(sort.IntSlice(dd)))
	for _, v := range dd {
		if v <= l {
			return v
		}
	}
	// no path
	return 0
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 640
import numpy as np

H, W = map(int, input().split())
S = np.array([list(input()) for _ in range(H)]) == '.'
up = np.zeros((H, W), dtype=int)
down = np.zeros((H, W), dtype=int)
left = np.zeros((H, W), dtype=int)
right = np.zeros((H, W), dtype=int)
s = 0
for i in range(H):
    #print(S[i])
    up[i] = (up[i-1] + 1) * S[i]
    down[-i-1] = (down[-i] + 1) * S[-i-1]
    s+=1
    #print(up[i])

for i in range(W):
    left[:, i] = (left[:, i-1] + 1) * S[:, i]
    right[:, -i-1] = (right[:, -i] + 1) * S[:, -i-1]
#count the 
print(np.max(up+down+left+right)-3)

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

signed main () {
	int x;
	cin >> x;
	if (x >= 1800)
		cout << 1 << '\n';
	else if (x >= 1600)
		cout << 2 << '\n';
	else if (x >= 1400)
		cout << 3 << '\n';
	else if (x >= 1200)
		cout << "4\n";
	else if (x >= 1000)
		cout << "5\n";
	else if (x >= 800)
		cout << "6\n";
	else if (x >= 600)
		cout << "7\n";
	else
		cout << "8\n";
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string a; cin>>a;
  map<char,ll> m;
  rep(i,a.size()){
    m[a[i]]++;
  }
  vll v;
  for(auto e: m){
    v.push_back(e.second);
  }
  
  ll n=v.size();
  ll ans=0;
  rep(i,n){
    irep(j,i+1,n){
      ans+=v[i]*v[j];
    }
  }
  cout<<ans+1<<endl;
}

Measured memory_bytes: 720
import sys
input = sys.stdin.readline

mod = 10**9+7
n,m= map(int, input().split())
s= list(map(int, input().split()))
t= list(map(int, input().split()))

# dp[i][j]:nからi番目までとtからj番目まで取ったときの共通部分整数列の組み合わせ
dp=[[1]*(m+1) for i in range(n+1)]

for i in range(n):
    for j in range(m):
        if s[i]==t[j]:
            dp[i+1][j+1]=dp[i+1][j]+dp[i][j+1]
        else:
            dp[i+1][j+1]=dp[i+1][j]+dp[i][j+1]-dp[i][j]
        dp[i+1][j+1]%=mod

print(dp[n][m])

Measured memory_bytes: 98652
#include <cstdio>

typedef long long ll;

template<typename T> inline bool chkmax(T &x, T y){ x < y ? x = y, true : false; }

const int MAXN = 5e3 + 10, MAXM = 210;

int n, m;
ll a[MAXN], b[MAXN][MAXM], mat[MAXN][MAXN];
int L[MAXN][MAXM], R[MAXN][MAXM];

int s[MAXN], top = 0;

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 2; i <= n; ++i) {    
        ll x;
        scanf("%lld", &x);
        a[i] = a[i - 1] + x;
    }
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            scanf("%lld", &b[i][j]);
    
    for (int j = 1; j <= m; ++j) {
        top = 0;
        for (int i = 1; i <= n; ++i) {
            while (top and b[s[top]][j] < b[i][j])
                --top;
            L[i][j] = top ? s[top] + 1 : 1;
            s[++top] = i;
        }
        top = 0;
        for (int i = n; i; --i) {
            while (top and b[s[top]][j] < b[i][j])
                --top;
            R[i][j] = top ? s[top] - 1 : n;
            s[++top] = i;
        }

        for (int i = 1; i <= n; ++i) {
            mat[L[i][j]][i] += b[i][j];
            mat[i + 1][R[i][j] + 1] += b[i][j];
            mat[i + 1][i] -= b[i][j];
            mat[L[i][j]][R[i][j] + 1] -= b[i][j];
        }
    }

    ll ans = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j)
            mat[i][j] += mat[i - 1][j] + mat[i][j - 1] - mat[i - 1][j - 1];
        for (int j = i; j <= n; ++j)
            chkmax(ans, mat[i][j] - a[j] + a[i]);
    }

    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 212864
#include <stdio.h>

int nextInt() {
  int n = 0;
  int c;
  while ((c = getchar()) != EOF) {
    if (('0' <= c) && (c <= '9'<c)) {
      n = n * 10 + (c - '0');
    }
    else {
      break;
    }
  }
  return n;
}

int main(){
	int n = nextInt();
    int max = 0;
    int sum = 0;
    for (int i = 0; i < n; i++) {
      int l = nextInt();
      if (l > max) {
        max = l;
      }
      sum += l;
    }
    if (max < (sum - max)) {
      printf("Yes\n");
    }
    else {
      printf("No\n");
    }
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
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; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


int N, A, B, C;
vector<int>l;
//A 0 B 1 C 2 使わないなら 3
int ans = INF;

void dfs(vector<int>v) {
	if (v.size() == N) {
		int a, b, c;
		int cnta, cntb, cntc;
		a = b = c = cnta = cntb = cntc = 0;
		rep(i, N) {
			if (v[i] == 0)a += l[i];
			else if (v[i] == 1)b += l[i];
			else if (v[i] == 2)c += l[i];
			if (v[i] == 0)cnta++;
			else if (v[i] == 1)cntb++;
			else if (v[i] == 2)cntc++;
		}
		if (cnta && cntb && cntc) {
			int MP = abs(a - A) + abs(b - B) + abs(c - C);
			MP += 10 * (cnta + cntb + cntc - 3);
			chmin(ans, MP);
		}
		return;
	}

	rep(i, 4) {
		vector<int>nv = v;
		nv.push_back(i);
		dfs(nv);
	}
}

signed main() {
	cin >> N >> A >> B >> C;
	l.resize(N);
	rep(i, N)cin >> l[i];
	vector<int>v;
	dfs(v);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;

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

	ll ans = 1;
	ans *= k;
	rep (i, n - 1) ans *= k - 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

struct UnionFind{
    v: Vec<usize>
}

impl UnionFind{
    fn new(n: usize) -> UnionFind{
        let mut v: Vec<usize> = Vec::new();
        for i in 0..n{
         v.push(i);
        }
        UnionFind{v:v}
    }

    fn find(&mut self, i: usize) -> usize{
        if self.v[i] == i{
            i
        }else{
            let ni = self.v[i];
            self.v[i] = self.find(ni);
            self.v[i]
        }
    }

    fn union(&mut self, i: usize, j: usize){
        let root_i = self.find(i);
        let root_j = self.find(j);
        self.v[root_i] = root_j;
    }
    
}

fn main(){
    let  n: usize = read_as_vec()[0];

    let s = read_as_string();

    let num_red = s.chars().filter(|x| *x == 'R').collect::<Vec<_>>().len();

    let num_blue = s.chars().filter(|x| *x == 'B').collect::<Vec<_>>().len();

    if num_red > num_blue{
        println!("Yes");
    }else{
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans = 0;
    if(a >= k)
        cout << k << endl;
    else if(a + b >= k)
        cout << a << endl;
    else 
        cout << 2 * a + b - k << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
int main(void)
{
	//変数の宣言
	int n;
	int group[100010];
	
	//よく使う変数
	int i,j,k,l;
	int flag=0;
	long int ans=0;
	int count=0;
	int temp,temp1,temp2;
	int max,min;
	int len;
	//データの読み込み
	
	scanf("%d",&n);
	
	for(i=0;i<100000;i++){
		group[i]=-1;
	}
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	temp=(int)((sqrt(8*n+1)-1)/2+0.01);
	if(temp*(temp+1)/2!=n){
		printf("No");
	}else{
		printf("Yes\n");
		printf("%d\n",temp+1);
		count=1;
		for(i=0;i<temp+1;i++){
			printf("%d",temp);
			for(j=0;j<temp;j++){
				printf(" ");
				if(j<i){
					printf("%d",group[j]);
					group[j]++;
				}else{
					printf("%d",count);
					if(group[i]==-1) group[i]=count;
					count++;
				}
			}
			printf("\n");
		}
	}
	
//	printf("計算部分終了\n");
	//出力
	
//	printf("結果の出力終了\n");
	
	return 0;
	
}



Measured memory_bytes: 1664
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
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(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) (a*a)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(a*b, c*d) << endl;
	return 0;
}

Measured memory_bytes: 384
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

constexpr usize operator"" _z(unsigned long long x) noexcept {
  return static_cast<usize>(x);
}

class rep {
  const usize f, l;

public:
  class itr {
    friend rep;
    usize i;
    constexpr itr(const usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr rep(const usize first, const usize last) noexcept
      : f(first), l(last) {}
  constexpr itr begin() const noexcept { return itr(f); }
  constexpr itr end() const noexcept { return itr(l); }
};
class revrep {
  const usize f, l;

public:
  class itr {
    friend revrep;
    usize i;
    constexpr itr(usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
  constexpr itr begin() const noexcept { return itr(l); }
  constexpr itr end() const noexcept { return itr(f); }
};
template <class T> using vec_alias = std::vector<T>;
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) {
  return a < b ? b - a : a - b;
}
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <string>
#include <utility>

namespace n91 {

void main_() {
  const usize n = scan<usize>();
  std::vector<u32> h(n);
  for (auto &e : h) {
    std::cin >> e;
  }
  usize ans = 0_z;
  usize cur = 0_z;
  for (const auto i : rep(1_z, n)) {
    if (h[i - 1_z] >= h[i]) {
      ++cur;
    } else {
      cur = 0_z;
    }
    ans = std::max(ans, cur);
  }
  std::cout << ans << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,K;
int A[5010],B[5010];

signed main(){
	cin>>N>>K;
	REP(i,N){
		cin>>A[i];
		A[i]--;
	}
	REP(i,N){
		cin>>B[i];
	}
	int ans=-INF;
	REP(i,N){
		int s=i;
		int sum=0;
		int cyclecnt=0;
		while(true){
			cyclecnt++;
			sum+=B[s];
			s=A[s];
			if(s==i)break;
		}
		int path=0;
		int cnt=0;
		while(true){
			cnt++;
			path+=B[s];
			if(cnt>K)break;
			int num=(K-cnt)/cyclecnt;
			int score=path+max(0,sum)*num;
			ans=max(ans,score);
			s=A[s];
			if(s==i)break;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3724
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int main() {
    string S;
    cin >> S;

    // YYMM
    bool isYYMM = true;
    if (stoi(S.substr(2, 2)) < 1 || 12 < stoi(S.substr(2, 2))) {
        isYYMM = false;
    }


    // MMYY
    bool isMMYY = true;
    if (stoi(S.substr(0, 2)) < 1 || 12 < stoi(S.substr(0, 2))) {
        isMMYY = false;
    }

    if(isYYMM && isMMYY) {
        cout << "AMBIGUOUS" << endl;
    } else if(isYYMM) {
        cout << "YYMM" << endl;
    } else if(isMMYY) {
        cout << "MMYY" << endl;
    } else {
        cout << "NA" << endl;
    }

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl digit10(intl a){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl a,b,c,d;
    cin >> a >> b >> c;
    swap(a,b);
    swap(a,c);
    cout << a << " " << b << " " << c << endl;
    return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		int a = 0;
		String op;
		int b = 0;

		
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			// ?????????????§?
			while (true) {
			// ??\?????????????????????????????????
			String str = br.readLine();
			// ??\????????????????????????????????§????????????
			String[] num = str.split(" ");
			// a??¨b?????????????????´??°???????????????
			a = Integer.parseInt(num[0]);
			op = num[1];
			b = Integer.parseInt(num[2]);
			// if?????§?????????????????£????¨??????????????????????
			if (op.equals("+")) {
				System.out.println(a + b);
			} else if (op.equals("-")) {
				System.out.println(a - b);
			} else if (op.equals("*")) {
				System.out.println(a * b);
			} else if (op.equals("/")) {
				System.out.println(a / b);
			}
			// op?????????´????????\?????????????????????
			if (op.equals("?")) {
				break;
			}
			// ?¨?????????????1?????§????????????
			// ???????????????
		}

	}
}

Measured memory_bytes: 24224