akhauriyash/Code-Regression huggingface dataset:
def main():
    N = input()
    reversed_N = ("0" + N)[::-1]

    kuriage = 0
    ans = 0
    for i in range(len(reversed_N)):
        n = int(reversed_N[i]) + kuriage

        if n < 5:
            ans += n
            kuriage = 0
        elif n == 5 and i < len(reversed_N) - 1:
            next_n = int(reversed_N[i + 1])
            if next_n < 5:
                ans += n
                kuriage = 0
            else:
                ans += 10 - n
                kuriage = 1
        else:
            ans += 10 - n
            kuriage = 1

    print(ans)


main()


Measured memory_bytes: 6336
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i,p=0,q=0,min=1000000000000;
    cin>>n;
    for(i=1; i<=sqrt(n); i++)
    {
        if(n%i==0)
        {
            p=i;
            q=n/i;
            if((p+q-2)<min)
                min=p+q-2;
        }
    }
    //cout<<p<<" "<<q<<endl;
    cout<<min;
    return 0;
}


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

using namespace std;

inline long long read(){
	char ch=getchar();long long x=0,f=1;
    while(ch<'0' || ch>'9') {
       if(ch=='-') f=-1;
	  	  ch=getchar();
	}
    while(ch<='9' && ch>='0') {
	   x=x*10+ch-'0';
	   ch=getchar();
	}
    return x*f;
}

long long a[1010][1010];
long long f[9][5];
long long s[1010];
long long maxn;

bool cmp(long long a,long long b){
	return a>b;
}

int main(){
	int n=read(),m=read();
	for(int i=1;i<=n;i++){
		for(int j=1;j<=3;j++){
			a[i][j]=read();
		}
	}
	f[1][1]=1;f[1][2]=1;f[1][3]=1;
	f[2][1]=1;f[2][2]=1;f[2][3]=-1;
	f[3][1]=1;f[3][2]=-1;f[3][3]=1;
	f[4][1]=1;f[4][2]=-1;f[4][3]=-1;
	f[5][1]=-1;f[5][2]=1;f[5][3]=1;
	f[6][1]=-1;f[6][2]=-1;f[6][3]=1;
	f[7][1]=-1;f[7][2]=1;f[7][3]=-1;
	f[8][1]=-1;f[8][2]=-1;f[8][3]=-1;
	for(int k=1;k<=8;k++){
		for(int i=1;i<=n;i++){
			s[i]=0;
			for(int j=1;j<=3;j++){
				s[i]+=a[i][j]*f[k][j];
			} 
		}
		sort(s+1,s+1+n,cmp);
		long long sum=0;
		for(int i=1;i<=m;i++){
			sum+=s[i];
		}
		maxn=max(sum,maxn);
	}
	cout<<maxn;
	return 0;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds; 
using ll = long long int;
#define INF             1e14
#define dd              double
#define MOD             1000000007
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define nl              cout<<endl
#define fill(a,val)     memset(a,val,sizeof(a))
#define mp              make_pair
#define endl            "\n"
#define pb              push_back
#define ff              first    
#define ss              second
#define SIZE            200005
#define all(v)          v.begin(),v.end()
#define s(ar,n)         sort(ar,ar+n)
#define rs(ar,n)        sort(ar, ar+n, greater<ll>()) 
#define oa(a,n)         for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n)         for(ll i=0;i<n;i++)cin>>a[i];
#define maxa(ar,N)      *max_element(ar,ar+N)
#define mina(ar,N)      *min_element(ar,ar+N)
#define fastio()        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define printclock      cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n";
typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order() - 0 indexing
// order_of_key() - number of elements strictly smaller
ll power(ll x, ll y){
    ll res=1;x=x;
    while(y>0){
        if(y&1)
            res = (res*x);
        y = y>>1;
        x = (x*x);
    }
    return res;
}  
ll logtwo(ll n){
    if(n==1)
        return 0;
    return logtwo(n/2)+1;
}
//---------------------------------------GL HF------------------------------------------------------
// -------------------------------------ManavJ07----------------------------------------------------
signed main()
{
    fastio();   
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll N;
        cin>>N;
        cout<<360/__gcd(360ll,N)<<endl;
    }
}

Measured memory_bytes: 3648
// abc138_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    int ans = 0;
    int tmp = 0;
    REP(i, N-1){
        if (A[i+1] <= A[i]) {
            tmp++;
            ans = max(ans, tmp);
        } else {
            tmp = 0;
        }
    }
    print(ans);


    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	ll N;
	cin >> N;
	
	vector<vector<ll>> dp(N, vector <ll>(3, 0));
	for (int ii = 0; ii < N; ++ii){
		ll a, b, c;
		cin >> a >> b >> c;
		if (ii == 0){
			dp[ii][0] = a;
			dp[ii][1] = b;
			dp[ii][2] = c;
		}
		else {
			dp[ii][0] = max(dp[ii-1][1]+a, dp[ii-1][2]+a);
			dp[ii][1] = max(dp[ii-1][0]+b, dp[ii-1][2]+b);
			dp[ii][2] = max(dp[ii-1][0]+c, dp[ii-1][1]+c);
		}
	}

	cout << max(dp[N-1][0], max(dp[N-1][1],dp[N-1][2])) << endl;

	return 0;
}


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

vector<int> get_kmp_array(const string& str){
	vector<int> pi(str.size(), 0), rez;
	for(int i = 1, k = 0; i < str.size(); ++i){
		while(k && str[i] != str[k]) k = pi[k-1];
		if(str[k] == str[i]) ++k;
		pi[i] = k; }
	for(int i = pi.back(); i > 0; i = pi[i-1]){
		rez.push_back(i); }
	rez.push_back(0);
	return rez; }

int main(){
	int n;
	string s, t;
	cin >> n >> s >> t;

	string for_kmp;
	copy(begin(t), end(t), back_inserter(for_kmp));
	for_kmp.push_back('#');
	copy(begin(s), end(s), back_inserter(for_kmp));

	const auto possible_pref_suffs = get_kmp_array(for_kmp);

	int rez;
	for(const auto x : possible_pref_suffs){
		if(s.size() + t.size() - (rez = x) >= n) break; }

	cout << s.size() + t.size() - rez << endl;
	
	return 0; }

Measured memory_bytes: 256
#include <iostream>
using namespace std;
//3????????°??¨3???????????°??????????????????????????°??????

int main(){

	int n, num, count;
	cin >> n;

	for (int i = 1; i <= n; i++){
		
		if (i % 3 == 0 || i % 10 == 3)
		{
			cout << " " << i;
		}

		else {
			//3???????????°???????????????
			count = 0;
			num = i / 10;
			
			while (num != 0){
				if (num % 10 == 3)
					count++; 
	
				num = num / 10;

			}
			if (count!=0){
				cout << " " << i;
			}
		}

	}cout << endl;

	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  vector<int>P(N);
  for(int i=0;i<N;i++){
    cin>>P.at(i);
  }
  sort(P.begin(),P.end());
  reverse(P.begin(),P.end());
  int i=0;
  for(int j=0;j<N;j++){
	if(P.at(j)>=K){
      i++;
    }else{
      break;
    }
  }
  cout<<i<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    int dp[k+1];
    dp[0]=0;
    for(int i=1;i<=k;i++){
        int win=0;
        for(int j=0;j<n;j++)if(i-a[j]>=0 && dp[i-a[j]]==0)win=1;
        dp[i]=win;
    }
    if(dp[k])cout<<"First"<<endl;
    else cout<<"Second"<<endl;
    return 0;
}

Measured memory_bytes: 3984
import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;

public class Main {
	public static void main(String[] args) {
		new Main();
	}

	public Main() {
		FasterScanner sc = new FasterScanner(System.in);

		int a = sc.nextInt();
		int b =sc.nextInt();
		int c = sc.nextInt();
		System.out.println(c + " " +a + " " +b);

		sc.close();
	}
	
	class FasterScanner {
		private InputStream mIs;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public FasterScanner() {
			this(System.in);
		}

		public FasterScanner(InputStream is) {
			mIs = is;
		}

		public int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = mIs.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public String nextString() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		public void close() {
			try {
				mIs.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
}


Measured memory_bytes: 21204
#include <stdio.h>
int n, m, p, an, bn, f, ans;
int a[50];
int b[50];
int x[50];
int y[50];
int z[50];
int root(int c) {
	int t = 0;
	while (x[c] >= 0) {
		y[t] = c;
		c = x[c];
		t++;
	}
	for (int i = 0; i < t - 1; i++) {
		x[y[i]] = c;
	}
	return c;
}
void merge(int c, int d) {
	if (c == d)return;
	if (x[c] < x[d]) {
		x[d] = c;
	}
	else if (x[c] == x[d]) {
		x[d] = c;
		x[c]--;
	}
	else{
		x[c] = d;
	}
}
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d%d", a + i, b + i);
		a[i]--, b[i]--;
	}
	for (int j = 0; j < m; j++) {
		for (int i = 0; i < n; i++)x[i] = -1;
		for (int i = 0; i < m; i++) {
			if (i != j) {
				an = root(a[i]);
				bn = root(b[i]);
				merge(an, bn);
			}
		}
		f = 0;
		for (int i = 1; i < n; i++) {
			if (root(0) != root(i))f = 1;
		}
		if (f)ans++;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
  int a,b,x,n;
  scanf("%d\n",&x);
  scanf("%d\n",&a);
  scanf("%d\n",&b);
  n=x-a;
  while(n>=b){
    n=n-b;
  }
  printf("%d\n",n);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define N 110000
#define ll long long
int X,n,m,h,r,pos;
int a[N],a1[N],q[N],ans[N],v[N],mx[N];
ll sum[N];
struct node
{
	int t,a,pos;
	friend bool operator < (const node &r1,const node &r2)
	{return r1.a<r2.a;}
}b[N];
void change(int x)
{
	v[x-1]=X;
	for(int i=x,now=X;i<pos;i++)
	{
		if(i&1)now=max(0,now-a[i]);
		else now=min(X,now+a[i]);
		v[i]=now;
	}
	pos=x;
}
int calc(int x){return min(max(x,0),X);}
int query(int x,int y)
{
	int v2=0,ret;
	if(x>a1[n])
	{
		v2=x-a1[n];
		if(~n&1)v2=-v2;
		x=a1[n];
	}
	int t=lower_bound(a1+1,a1+1+n,x)-a1;
	int v1=x-a1[t-1];
	if(t&1)v1=-v1;
	if(t>=pos)ret=v[t-1];
	else if(h>r||t<=q[h])ret=sum[t-1]+y;
	else
	{
		int t1=upper_bound(q+h,q+r+1,t-1)-q-1;
		ret=sum[t-1]-sum[q[t1]];
	}
	return calc(calc(ret+v1)+v2);
}
int main()
{
	//freopen("tt.in","r",stdin);
	scanf("%d%d",&X,&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a1[i]);a[i]=a1[i]-a1[i-1];
		if(i&1)sum[i]=sum[i-1]-a[i];
		else sum[i]=sum[i-1]+a[i];
		mx[i]=i==1 ? 1:(sum[mx[i-1]]>sum[i] ? mx[i-1]:i);
	}
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
	{
		b[i].pos=i;
		scanf("%d%d",&b[i].t,&b[i].a);
	}
	sort(b+1,b+1+m);
	h=1;r=0;pos=n+1;
	for(int i=1,now=b[1].a;i<=n;i++)
	{
		if(i&1)
		{
			now-=a[i];
			if(now<0)now=0,q[++r]=i;
		}
		else 
		{
			now+=a[i];
			if(now>X){change(i+1);break;}
		}
	}
	ans[b[1].pos]=query(b[1].t,b[1].a);
	for(int i=2;i<=m;i++)
	{
		while(h<=r&&q[h]<pos)
		{
			if(sum[mx[q[h]]]+b[i].a>X)
				{change(mx[q[h]]+1);break;}
			if(sum[q[h]]+b[i].a<0)break;
			h++;
		}
		while(h<=r&&q[r]>=pos)r--;
		while(h>r&&sum[mx[pos-2]]+b[i].a>X)
			change(mx[pos-2]+1);
		ans[b[i].pos]=query(b[i].t,b[i].a);
	}
	for(int i=1;i<=m;i++)
		printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 5760
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

int main() {
	string str; cin >> str;
	int q; cin >> q;
	for (int i = 0; i < q; i++) {
		string s; cin >> s;
		int a, b; cin >> a >> b;
		if (s == "replace") {
			string r; cin >> r;
			str = str.substr(0, a) + r + str.substr(b + 1);
		}
		else if (s == "reverse") {
			string r = str.substr(a, b - a + 1);
			reverse(r.begin(), r.end());
			str = str.substr(0, a) + r + str.substr(b + 1);
		}
		else if (s == "print") {
			cout << str.substr(a, b - a + 1) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1232
#include "bits/stdc++.h"
using namespace std;
#define l_ength size

int main(void){
int n,i,c,j,l;
bool flag=true;
string w[111];
cin >> n;
for(i=0; i<n; ++i){
cin >> w[i];
}
for(i=0;i<n;++i){
c=0;
for(j=0;j<n;++j){
if(w[i]==w[j]){
++c;
}
}
if(c>1){
flag = false;
}
}
for(i=1;i<n;++i){
l=w[i-1].l_ength();
if(w[i-1][l-1] != w[i][0]){
flag = false;
}
}
cout << ((flag)?"Yes":"No") << endl;
return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
int n;
typedef long long LL;
int main() {
	while(~scanf("%d", &n)) {
		int a = n % 10;//个位
		int b = (n % 100) / 10;//十位
		int c = (n % 1000) / 100;//百位
		int d = n / 1000;
		if((a == b && b == c) || (b == c && c == d) || (a == b && b == c && c == d)) puts("Yes");
		else puts("No");
	}
	return 0;
}

Measured memory_bytes: 256
// AOJ 1370 Hidden Anagrams
// 2018.2.8 bal4u

#include <stdio.h>
#include <string.h>

#define HASHSIZ		10007
typedef struct { short f[26]; } HASH;
HASH hash[HASHSIZ+2], *hashend = hash+HASHSIZ;			// Hash table

void insert(short *f)
{
	int i;
	unsigned long long k;
	HASH *tp;

	f[0]++;
	k = 0; for (i = 0; i < 26; i+=2) k = (k << 4) + f[i];
	tp = hash + (int)(k % HASHSIZ);
	while (tp->f[0]) {
		if (!memcmp(tp->f, f, 52)) goto done;
		if (++tp == hashend) tp = hash;
	}
	memcpy(tp->f, f, 52);
done:
	f[0]--;
}

int lookup(short *f)
{
	int i;
	unsigned long long k;
	HASH *tp;

	f[0]++;
	k = 0; for (i = 0; i < 26; i+=2) k = (k << 4) + f[i];
	tp = hash + (int)(k % HASHSIZ);
	while (tp->f[0]) {
		if (!memcmp(tp->f, f, 52)) { f[0]--; return 1; }
		if (++tp == hashend) tp = hash;
	}
	f[0]--;
	return 0;
}

char sa[4004]; int wa;
char sb[4004]; int wb;
short f[26];

int main()
 {
	int i, k, w;
	char *p, *q;

	fgets(p=sa, 4004, stdin); while (*p > ' ') *p -= 'a', p++; wa = p - sa;
	fgets(p=sb, 4004, stdin); while (*p > ' ') *p -= 'a', p++; wb = p - sb;
	w = wa; if (w > wb) w = wb;

    for (k = w; k > 0; k--) {
		memset(hash, 0, sizeof(hash));

		memset(f, 0, sizeof(f));
		p = sa; for (i = 0; i < k; i++) f[*p++]++;
		insert(f);

		i = wa - k, q = sa; while (i--) {
			f[*q++]--, f[*p++]++;
			insert(f);
		}

		memset(f, 0, sizeof(f));
		p = sb; for (i = 0; i < k; i++) f[*p++]++;
		if (lookup(f)) goto done;

		i = wb - k, q = sb; while (i--) {
			f[*q++]--, f[*p++]++;
			if (lookup(f)) goto done;
		}
    }
done:
	printf("%d\n", k);
    return 0;
}


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

int main(void){
    int n[4] = {};
    string s,t = "No";
    cin >> s;
    for(int i = 0;i < s.size();i++){
        if(s[i] == 'N')n[0] = 1;
        else if(s[i] == 'S')n[1] = 1;
        else if(s[i] == 'E')n[2] = 1;
        else n[3] = 1;
    }
    if(n[0]+n[1] == 2 && n[2]+n[3] == 2)t = "Yes";
    else if(n[0]+n[1] == 2 && n[2]+n[3] == 0)t = "Yes";
    else if(n[0]+n[1] == 0 && n[2]+n[3] == 2)t = "Yes";
    cout << t;
}

Measured memory_bytes: 256
<?php
  while (true) {
    $height_width = explode(" ", trim(fgets(STDIN)));
    $h = $height_width[0];
    $w = $height_width[1];
    if ($h == 0 && $w == 0) {
      break;
    }
    for($i = 0; $i < $h; $i++){
      for($j = 0; $j < $w; $j++){
        echo '#';
      }
      echo PHP_EOL;
    }
    echo PHP_EOL;
  }

Measured memory_bytes: 15392
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
ll A, B, C;

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

  cin >> A >> B >> C;

  ll ans = 0ll;
  if (A+B < C){
    ans = B+A+B+1;
  } else ans = B+C;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int dfs(int n, int s, int k){
  if( !n )return ( s == 0 )? 1 : 0;
  int res = 0;
  for(int i=k; i<10; i++){
    res += dfs(n - 1, s - i, i + 1);
  }
  return res;
}

int main(){
  int n, s;
  while( cin >> n >> s, n ){
    cout << dfs(n, s, 0) << endl;
  }
}

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

int main()
{
	int N,i,max,min,a;
	cin >> N;
	cin >> max;
	min = max;
	for (i = 0; i < N-1; i++) {
		cin >> a;
		if (a > max) {
			max = a;
		}
		else if (a < min) {
			min = a;
		}
	}
	cout << max - min << endl;
	return 0;
}

Measured memory_bytes: 256
n, m= list(map(int, input().split()))
key=[]
for i in range(m):
    a,b= list(map(int, input().split()))
    c= list(map(int, input().split()))
    s=0
    for j in range(b):
        s|=1<<c[j]-1
    tmp=[s,a]
    key.append(tmp)
inf=1001001001
dp=[inf for _ in range(1<<n)]
dp[0]=0
for s in range(1<<n):
    for i in range(m):
        t = s|key[i][0]
        cost=dp[s]+key[i][1]
        dp[t]=min(dp[t],cost)
ans=dp[-1]
if ans==inf:
    ans=-1
print(ans)

Measured memory_bytes: 46424
<?php
while(true){
list($x,$y) = explode(" ",trim(fgets(STDIN)));
if($x == 0 and $y == 0){
break;
}
if($x > $y){
$min = $y;
echo $min." ".$x;
}else{
$min = $x;
echo $min." ".$y;
}
echo "\n";
}
?>


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

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T> p) {
    out << "(" << p.first << "," << p.second << ")";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto a: v)
        out << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const multiset<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& M) {
    for (auto m: M)
        cout << "(" << m.first << "->" << m.second << ") ";
    return out;
}

template<typename S, typename T>
pair<S, T> operator+(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

template<typename S, typename T>
pair<S, T> operator-(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, x, t;
    cin >> n >> x >> t;
    cout << (n + x - 1) / x * t << endl;
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> P;
typedef pair<int64_t, int64_t> Pll;
  
int main() {
    int X;
    cin >> X;
    int j = 2;

    while (true) {
        if (X == 1) {
            cout << 1 << endl;
            return 0;
        }
        for (int i = 2; i * i <= X; i++) {
            while (pow(i, j) <= X) {
                if (pow(i, j) == X) {
                    cout << X << endl;
                    return 0;
                }
                j++;
            }
            j = 2;
        }
        X--;
    }
}

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

#define ff first
#define ss second
#define maxn 2000006
#define pb push_back
#define ll long long
#define lll __int128
#define vll vector<ll>
#define mll map<ll,ll>
#define MOD 1000000007
#define pll pair<ll,ll>
#define ull unsigned long long
#define f(i,x,n) for(int i=x;i<=n;i++)

int dx[] = { -1, 0, 1, 0, -1, -1, 1, 1};
int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};

using namespace std;

ll fix[1001][1001];
ll to_play[1001];
ll day;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	ll n; cin >> n;

	f(i, 1, n) {
		f(j, 0, n - 2) cin >> fix[i][j];
	}

	// f(i,1,n){
	// 		cout<<i<<"--> ";
	// 	f(j,0,n-2){
	// 		cout<<fix[i][j]<<", ";
	// 	}
	// 	cout<<endl;
	// }

	while (true) {
		day++;
		vector<bool> is_free(n + 1, true);
		ll cnt = 0;
		f(i, 1, n) {
			if ((to_play[i] != (n - 1)) and
			        (is_free[i] == true) and
			        (is_free[fix[i][to_play[i]]] == true) and
			        (fix[fix[i][to_play[i]]][to_play[fix[i][to_play[i]]]] == i)) {

				cnt++;

				is_free[i] = false;
				is_free[fix[i][to_play[i]]] = false;
				to_play[fix[i][to_play[i]]]++;
				to_play[i]++;
			}
		}

		if (cnt == 0) {
			cout << "-1";
			exit(0);
		}
		bool end = true;
		f(i, 1, n) {
			if (to_play[i] < n - 1) {
				end = false;
				break;
			}
		}
		if (end == true) {
			break;
		}
	}

	cout << day ;

	return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define PI 3.14159265;
const int nax=2e5+5;
ll a[nax],f[nax];
ll n,k;
bool g(ll x){
    ll r=0;
    for(int i=0;i<n;i++){
        ll g=x/f[i];
        r+=max((ll)0,a[i]-g);
    }
    return r<=k;
}
ll fun(ll st, ll end){
    if(st >end) return -1;
    ll mid=(st+end)/2;
    if(g(mid)){
        ll lans=fun(st,mid-1);
        if(lans==-1)  return mid;
        return lans;
    }
    return fun(mid+1,end);
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>f[i];
    }
    sort(a,a+n);
    reverse(a,a+n);
    sort(f,f+n);
    cout<<fun(0,1e12+4);
}

Measured memory_bytes: 3328
#include<iostream>
#include<string>
using namespace std;
int main(void)
{
	string set;
	int joi=0;
	int ioi=0;
	for (int a=0;a<5;a++)
	{
		cin>>set;
		int b=set.size();	
		for (int c=0;c<b-2;c++)
		{
			if (set.substr(c,3)=="JOI") joi++;
			if (set.substr(c,3)=="IOI") ioi++;
		}
		cout<<joi<<endl<<ioi<<endl;
		joi=0;
		ioi=0;
	}
	return 0;
}

Measured memory_bytes: 3048
tmp = int(input())
timing = [int(i) for i in input().split()]
num_dict = {}
for i  in range(0,tmp):
    num_dict[timing[i]] = i+1

for i in range (0,tmp):
    print(num_dict.pop(i+1),end="")
    if i <tmp-1:
        print(" ",end="")

#for i in range(0,tmp):
#    #ans.append(timing.index(i+1)+1)
#    print(timing.index(i+1)+1,end="")
#    


Measured memory_bytes: 20704
//
//  main.cpp
//  ATcode131
//
//  Created by didi on 2020/1/16.
//  Copyright © 2020年 didi. All rights reserved.
//

#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cassert>
#include <queue>
#include <list>
using namespace std;

#define ll long long

int main(int argc, const char * argv[]) {
    int N, K;
    cin >> N >> K;
    int MOD = 1e9 + 7;
    const int LEN = N+1;
    vector<vector<int>> f(LEN, vector<int>(LEN));
    //在计算组合数的时候，有两种方式：
    //1.方法一、C(m, n) = m! / (n!*(m-n)!), 这种方式复杂度为 O(N)
    //但是对于(如果用阶乘的方式，则有问题，因为 (a/b) % MOD != ((a % MOD) / (b % MOD)) % MOD
    //比如: (10/5) % 8 = 2, 但是 (10%8) / (5%8) = 0
    //2.方法二、 C(i, j) = C(i-1, j-1) + C(i-1, j); 复杂度:O(N^2)
    //转成加法之后，就可以拆分取模。
    for (int i = 0; i < LEN; ++i) {
        for (int j = 0; j <= i; ++j) {
            if (j == 0 || i == j) {
                f[i][j] = 1;
            } else {
                f[i][j] = (f[i-1][j-1] + f[i-1][j]) % MOD;
            }
        }
    }
    
    for (int i = 1; i <= K; ++i) {
        int ans = ((long long)f[N-K+1][i] * f[K-1][i-1]) % MOD;
        cout << ans << endl;
    }
    return 0;
}




Measured memory_bytes: 16000
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
  int h, w;
  cin >> h >> w;
  vector<vector<char>>s(h, vector<char>(w)), ret(h, vector<char>(w, '0'));
  for(int i=0; i<h; i++)for(int j=0; j<w; j++)cin >> s[i][j];
  for(int i=0; i<h; i++)for(int j=0; j<w; j++){
    if(s[i][j]=='#'){
      ret[i][j]='#';
      for(int x=max(i-1, 0); x<min(i+2, h); x++){
        for(int y=max(j-1, 0); y<min(j+2, w); y++){
          if(s[x][y]!='#')ret[x][y]++;
        }
      }
    }
  }
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++)cout << ret[i][j];
    cout << endl;
  }
  return 0;
}

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

int h, w;
char mp[55][55], ans[55][55];

int main() {
  cin >> h >> w;
  for(int i = 0; i < h; ++i)
    for(int j = 0; j < w; ++j) {
      ans[i][j] = '0';
      cin >> mp[i][j];
      if(mp[i][j] == '#') ans[i][j] = '#';
    }
  for(int i = 0; i < h; ++i)
    for(int j = 0; j < w; ++j)
      if(mp[i][j] == '#')
        for(int k = -1; k <= 1; ++k)
          for(int l = -1; l <= 1; ++l) {
            if(k == 0 && k == l) continue;
            if(i + k >= 0 && i + k < h && j + l >= 0 &&
               j + l < w && ans[i + k][j + l] != '#')
              ++ans[i + k][j + l];
          }
  for(int i = 0; i < h; ++i) {
    for(int j = 0; j < w; ++j) cout << ans[i][j];
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N;
  cin>>N;
  ll ans = 1;
  for(ll i=1;i<=N;++i){
    ans *= i;
    ans %= mod;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int gcd(int a,int b)
{
	if(b==0)
	return a;
	
	return gcd(b,a%b);
}
int power(int x,int y,int p)
{
	int res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
		res=(res*x)%p;
		
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
struct Matrix{ 
	int a[2][2] = {{0,0},{0,0}};
	Matrix operator *(const Matrix& other){
		Matrix product;
		for(int i=0;i<2;i++){
			for(int j=0;j<2;j++){
				for(int k=0;k<2;k++){
						product.a[i][k] =product.a[i][k] + (ll)a[i][j]*other.a[j][k];
				}
			}
		}
		return product;
	}
};
int modInverse(int n,int p)
{
	return power(n,p-2,p);
}
int main() {
	// your code goes here
	 ios_base::sync_with_stdio(0);
	 cin.tie(0);
	 int n;
	 cin>>n;
	 string s;
	 cin>>s;
	 int red = 0,white = 0;
	 for(int i=0;i<n;i++)
	 {
		 if(s[i] == 'R')
		 red++;
		 else
		 white++;
	 }
	 int change = 0;
	 for(int i=0;i<red;i++)
	 {
		 if(s[i]=='W')
		 change++;
	 }
	 cout<<min({red,white,change})<<'\n';
	 return 0;
}


Measured memory_bytes: 3780
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main (){
  ll n,k;
  cin>>n>>k;
  ll ans=0;
  vector<ll>v;
  while(n){
    ans=1;
    v.assign(k,0);
    for(ll i=0;i<k;i++){
      cin>>v[i];
    }
    sort(v.begin(),v.end());
    if(v[0]!=0){
      ll b=v[0];
      ll tmp=1;
      for(ll i=1;i<k;i++){
        if(v[i]==b+1)tmp++;
        else tmp=1;
        if(ans<tmp)ans=tmp;
        b=v[i];
      }
    }
    else{
      if(n>1){
        ll b=v[1];
        ll tmp1=0;
        ll tmp2=1;
        for(ll i=2;i<k;i++){
          if(v[i]==b+1){
            tmp2++;
          }
          else if(v[i]==b+2){
            if(ans<tmp1+tmp2+1)ans=tmp1+tmp2+1;
            tmp1=tmp2;
            tmp2=1;
          }
          else {
            if(ans<tmp1+tmp2+1)ans=tmp1+tmp2+1;
            tmp1=0;
            tmp2=1;
          }
          b=v[i];
        }
        if(ans<tmp1+tmp2+1)ans=tmp1+tmp2+1;
      }
    }
    cout<<ans<<endl;
    cin>>n>>k;
  }
}



Measured memory_bytes: 3276
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<random>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
struct val{
  ll n,c;
  bool mk;
};
const val INV = val{0,0,true};
void next_que(queue<val> &que,val &use){
  if(que.empty()){
    use = INV;
  }else{
    use = que.front();
    que.pop();
  }
}
void timers(chrono::system_clock::time_point start,double tl){
  double time;
  chrono::system_clock::time_point now;
  ll n;
  cin >> n;
  vector<ll> a(n),b(n),ans(n,0);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  bool can = false;
  map<ll,ll> mp;
  for(int i=0;i<n;i++){
    cin >> b[i];
    mp[b[i]]++;
  }
  vector<val> mpr;
  for(auto itr=mp.rbegin();itr!=mp.rend();itr++){
    mpr.push_back(val{itr->first,itr->second,false});
  }
  while(!can){
    val fi,se;
    queue<val> que;
    for(auto itr=mpr.begin();itr!=mpr.end();itr++){
      if(itr->n<=a.back()&&itr->n>=a.front()){
        que.push(val{itr->n,itr->c,false});
      }
    }
    for(auto itr=mpr.begin();itr!=mpr.end();itr++){
      if(itr->n>a.back()||itr->n<a.front()){
        que.push(val{itr->n,itr->c,true});
      }
    }
    next_que(que,fi);
    next_que(que,se);
    for(int i=0;i<n;i++){
      if(fi.n!=a[i]){
        ans[i] = fi.n;
        fi.c--;
        if(fi.c==0){
          fi = se;
          next_que(que,se);
        }
      }else{
        if(se.n==0){
          break;
        }
        ans[i] = se.n;
        se.c--;
        if(se.c==0){
          next_que(que,se);
        }
      }
    }
    if(ans.back()!=0){
      can = true;
      break;
    }
    auto tmp = mpr.back();
     std::random_device seed_gen;
  std::mt19937 engine(seed_gen());
    shuffle(mpr.begin(),mpr.end(),engine);
    now = chrono::system_clock::now();
    time = chrono::duration_cast<chrono::milliseconds>(now-start).count();
    if(time>=tl) break;
  }
  if(!can){
    cout <<"No\n";
    return;
  }
  cout << "Yes\n";
  for(int i=0;i<n;i++){
    cout << ans[i]<<" ";
  }
  cout << endl;
}
signed main(){
  init_io();
  timers(chrono::system_clock::now(),1800);
}


Measured memory_bytes: 29788
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  h,w=LI()
  a=(w+1)//2
  b=w//2

  if h==1:
    return 1

  if w==1:
    return 1

  if h%2==0:
    return h//2*a+h//2*b
  return (h+1)//2*a+h//2*b

# main()
print(main())


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

int main()
{
	int n, m, l;

	long int A[100][100], B[100][100], C[100][100];

	cin >> n >> m >> l;

	for (int i = 0; i < n; i++){
		for (int j = 0; j < l; j++){
			C[i][j] = 0;
		}
	}

	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			cin >> A[i][j];
		}
	}

	for (int i = 0; i < m; i++){
		for (int j = 0; j < l; j++){
			cin >> B[i][j];
		}
	}

	for (int i = 0; i < n; i++){
		for (int j = 0; j < l; j++){
			for (int k = 0; k < m; k++){
				C[i][j] += A[i][k] * B[k][j];
			}
		}
	}

	for (int i = 0; i < n; i++){
		for (int j = 0; j < l; j++){
			if (j != 0)
				cout << " ";

			cout << C[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3308
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize, k: usize,
    }
    if 2 * k > (n - 1) * (n - 2) {
        puts!("-1\n");
        return;
    }
    let mut e = vec![];
    // urchin
    for i in 1..n {
        e.push((0, i));
    }
    let mut rem = (n - 1) * (n - 2) / 2 - k;
    for i in 1..n {
        for j in 1..i {
            if rem > 0 {
                e.push((i, j));
                rem -= 1;
            }
        }
    }
    puts!("{}\n", e.len());
    for &(a, b) in &e {
        puts!("{} {}\n", a + 1, b + 1);
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
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; }
//#define int long long

void solve() {
	int n, h, w; cin >> n >> h >> w;
    cout << (n - h + 1) * (n - w + 1) << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << 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 NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int taroScore = 0;
		int hanakoScore = 0;
		int number = Integer.parseInt(br.readLine());
		for(int i = 0;i < number;i++){
			String[] cardName = br.readLine().split(" ");
			if(cardName[0].compareTo(cardName[1]) > 0){
				taroScore += 3;
			}
			else if(cardName[0].compareTo(cardName[1]) == 0){
				taroScore += 1;
				hanakoScore += 1;
			}
			else{
				hanakoScore += 3;
			}
		}
		System.out.println(taroScore + " " + hanakoScore);
	}
}

Measured memory_bytes: 24956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int main(){
    
    int N; cin >> N;
    int data[N],ans[2] ={0,0};
    for(int i=0;i<N;i++) cin >> data[i];
    sort(data,data+N,greater<int>());
    int index=0;
    for(int i=0;i<N-1;i++){
        if(data[i] == data[i+1]){ans[index] = data[i]; index++; i++;}
        if(index == 2) break;
    }
    cout << (ull)ans[0] * ans[1] << endl;
}

Measured memory_bytes: 4024
n = int(input())
a = list(map(int, input().split()))
a.sort()
a.append(0)
num = a[0]
cnt = 1
ans = 0
for i in range(1, n + 1):
    if a[i] == num:
        cnt += 1
    else:
        diff = num - cnt
        if diff <= 0:
            ans += abs(diff)
        else:
            ans += cnt
        num = a[i]
        cnt = 1
print(ans)

Measured memory_bytes: 14244
#include<bits/stdc++.h>
#define MOD (1e9+7)
#define rep(i, x, n) for(int i = x; i < n; i++)
#define repr(i, x, n) for(int i = x; i > n; i--)
#define pii pair<int,int>
#define ll long long
const long long iinf = 1e18;
const int inf = 1e9;
int dir4[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};
int knight[8][2] = {{2,1},{2,-1},{-2,1},{-2,-1},{1,2},{-1,2},{1,-2},{-1,-2}};

using namespace std;

void solve()
{
   int n;
   cin >> n;
   vector<long long> a;
   for(int i = 1; i <= n; i++){
       long long x; cin >> x;
       a.push_back(x);

   }
   sort(a.begin(), a.end());
   if(a[0] == 0) {
       cout << 0;
       return;
   }
   long long ans = 1LL;
   for(int i = 0; i < n; i++){
       
       ans *= a[i];
       if(ans < 1LL || ans > 1000000000000000000){
           cout << -1;
           return;
       }
   }
   cout << ans;

    
}
//new line is printed in the main

int main()
{
    int t = 1;
        //cin >> t; // comment out if no test case is required
    // int i = 1;
    while(t--){
        //cout << "Case " << i++ << ": ";
        solve();
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 4320
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

int main(int argc, char **argv){
  if(argc = 0)
    fprintf(stderr, "no inputs\n");
  
  char pre[3];
  char real[3];
  int count = 0;
  
  scanf("%s", pre);
  scanf("%s", real);
   
  for(int j = 0; j < 3; j++){
    if(pre[j] == real[j])
      count++;
    else
      continue;
  }
  
  
  printf("%d\n", count);
}
  
  


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

using namespace std;

using i64 = int64_t;

int main() {
#ifdef GOLIKOV
  freopen("in", "rt", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, m;
  cin >> m >> n;

  vector<vector<pair<int, int>>> seg(m + 1);
  i64 s = 0;
  for (int i = 0; i < n; ++i) {
    int l, r, w;
    cin >> l >> r >> w;
    seg[r].emplace_back(l, w);
    s += w;
  }
  struct node {
    i64 min{};
    i64 add{};

    node() = default;
    node(i64 min, i64 add) : min(min), add(add) {}
  };
  vector<node> tree(4 * (m + 1));
  auto join = [](node const& x, node const& y) {
    assert(!x.add);
    assert(!y.add);
    return node(min(x.min, y.min), 0);
  };
  auto pull = [&](int v) {
    tree[v] = join(tree[2 * v], tree[2 * v + 1]);
  };
  auto push = [&](int v, int l, int r) {
    tree[v].min += tree[v].add;
    if (l != r) {
      tree[2 * v].add += tree[v].add;
      tree[2 * v + 1].add += tree[v].add;
    }
    tree[v].add = 0;
  };
  function<void(int, int, int, int, int, i64)> add_seg =
          [&](int v, int l, int r, int ql, int qr, i64 delta) {
    push(v, l, r);
    if (l > qr || ql > r) {
      return;
    }
    if (ql <= l && r <= qr) {
      tree[v].add += delta;
      push(v, l, r);
      return;
    }
    auto m = (l + r) / 2;
    add_seg(2 * v, l, m, ql, qr, delta);
    add_seg(2 * v + 1, m + 1, r, ql, qr, delta);
    pull(v);
  };
  function<node(int, int, int, int, int)> query =
          [&](int v, int l, int r, int ql, int qr) {
    push(v, l, r);
    if (l > qr || ql > r) {
      return node(numeric_limits<i64>::max() / 4, 0);
    }
    if (ql <= l && r <= qr) {
      return tree[v];
    }
    auto m = (l + r) / 2;
    return join(query(2 * v, l, m, ql, qr),
            query(2 * v + 1, m + 1, r, ql, qr));
  };
  for (int r = 1; r <= m + 1; ++r) {
    for (auto const& sg : seg[r - 1]) {
      add_seg(1, 0, m, 0, sg.first - 1, sg.second);
    }
    auto result = query(1, 0, m, 0, r - 1).min;
    if (r == m + 1) {
      cout << s - result << '\n';
      return 0;
    }
    add_seg(1, 0, m, r, r, result);
  }
  return 0;
}

Measured memory_bytes: 23680
S = input()

head = S[:2]
tail = S[2:]


if 12>=int(head)>=1 and 12>=int(tail)>=1:
    print("AMBIGUOUS")
elif 12>=int(head)>=1:
    print("MMYY")
elif 12>=int(tail)>=1:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3060
/**
 *   Praveen Fulera    
**/

// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")

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

typedef long long int ll;
#define endl '\n'
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define point pair <double, double>
#define debug(x) cerr << #x << " is " << x << endl;

const int mod = 1e9 + 7;
//const int mod = 998244353;

double eps = 1e-9;

signed main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  
  // #ifndef ONLINE_JUDGE
  //   freopen("input.txt", "r", stdin);
  //   //freopen("output.txt", "w", stdout);
  // #endif
  int a, b, c; cin >> a >> b >> c;
  if(4*a*b < (c-a-b)*(c-a-b) && (c-a-b) >= 0){
      cout << "Yes\n";
  }
  else cout << "No\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

string s, t;

int main(void){
	
	cin >> s >> t;
	
	sort(s.begin(), s.end());
	sort(t.begin(), t.end(), greater<char>());
	
	if(s < t) printf("Yes\n");
	else printf("No\n");
	
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

		int N = scanner.nextInt();

		HashMap<Integer, Integer> hashMap = new HashMap<Integer, Integer>();
		ArrayList<Integer> arrayList = new ArrayList<Integer>();

		for (int i = 1; i <= N; i++) {
			int A = scanner.nextInt();
			hashMap.put(A, i);
			arrayList.add(A);
		}

		Collections.sort(arrayList);

		for (int i = 0; i < N; i++) {
			System.out.print(hashMap.get(arrayList.get(i)) + " ");
		}

	}
}

Measured memory_bytes: 78368
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>
#define rep(i,n) for(int i = 0; i < (n); i++) 
using namespace std;

int main() {
	int a,b;
	cin >> a >> b;
	if (a >= 10 or b >= 10) {
		cout << -1 << endl;
	} else {
		cout << a * b << endl;
	}
	return 0;
}


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

#define ll long long

vector <ll> V;
ll n,W,w,v,sol=0;
ll dp[110][100010];

int main()
{
    for (int j=1;j<=100000;j++){
        dp[0][j]=INT_MAX;
    }

    cin >> n >> W;
    for (int i=1;i<=n;i++){
        cin >> w >> v;
        for (int j=1;j<=100000;j++){
            dp[i][j]=dp[i-1][j];
            if (j-v>=0) dp[i][j]=min(dp[i][j],dp[i-1][j-v]+w);
        }
    }

    for (int i=100000;i>=0;i--){
        if (dp[n][i]<=W){cout << i; return 0;}
    }
}


Measured memory_bytes: 82536
#include<stdio.h>

int main(void)
{
  int num, a;
  scanf("%d", &num);
  char array[num];
  for(a=0; a<num; a++) 
  {
    scanf("%s", &array[a]);
    if(array[a]=='Y') 
    {
      printf("Four");
      break;
    }
    if(a==num-1) printf("Three");
  }
 return 0;
}

Measured memory_bytes: 128