akhauriyash/Code-Regression huggingface dataset:
x=int(input())
lst = []
for i in range (0,x):
    ele=input()

    lst.append(ele)

a=0
b=0
c=0
d=0

for j in range (0,x):
    if(lst[j]=='AC'):
        a=a+1
    elif(lst[j]=='WA'):
          b=b+1

    elif (lst[j] == 'TLE'):
             c=c+1

    elif (lst[j] == 'RE'):
                d=d+1

print("AC x ",a)
print("WA x ",b)
print("TLE x ",c)
print("RE x ",d)











Measured memory_bytes: 16240
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937_64 mt64(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/

int n;
char c[305][305];
signed main() {
	cin >> n;
	rep(i, n)rep(j, n)cin >> c[i][j];
	int ans = 0;
	//横方向
	rep(i, n) {
		char d[305][305];
		rep(j, n)rep(k, n)d[j][(i + k) % n] = c[j][k];
		rep(j, n)rep(k, n) {
			if (d[j][k] != d[k][j])goto ng;
		}
		ans += n - i;
	ng:;
	}
	REP(i, n) {
		char d[305][305];
		rep(j, n)rep(k, n)d[(i + j) % n][k] = c[j][k];
		rep(j, n)rep(k, n) {
			if (d[j][k] != d[k][j])goto ng2;
		}
		ans += n - i;
	ng2:;
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include<string>
#include <string.h>
using namespace std;
int main(void){
    // Your code here!
    char s[100];
    bool jud=true;
    cin>>s;
    for(int i=0;i<strlen(s);i++){
        if(i%2==1){
            if(s[i]=='R'){
                jud=false;
                break;
            }
        }
        if(i%2==0){
            if(s[i]=='L'){
                jud=false;
                break;
            }
        }
    }
    if(jud==true)
        cout<<"Yes";
    if(jud==false)
        cout<<"No";
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define mp(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

int m,n,a[100][100],memo[100][101][101];

int DFS(int y,int l,int r){
	if(y==m) return 0;
	int &res=memo[y][l][r];
	if(res!=-1) return res;
	if(l==r) return res=DFS(y+1,0,n);

	res=max(res,DFS(y,l+1,r)+(a[y][l]+(y>0)+(l==0?0:1)+((r!=n)&&(r-l==1)))%2);
	res=max(res,DFS(y,l,r-1)+(a[y][r-1]+(y>0)+(r==n?0:1)+((l!=0)&&(r-l==1)))%2);
	return res;
}

void Solve(){
	cin >> m >> n;
	rep(i,0,m) rep(j,0,n) cin >> a[i][j];

	fill_n((int*)memo,100*101*101,-1);
	cout << DFS(0,0,n) << endl;
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	Solve();
	return 0;
}

Measured memory_bytes: 6008
while True:
	q = int(input())
	if q < 1: break
	
	x = q / 2
	err = 0.00001*q
	while True:
		x2 = x * x
		t = x2 * x - q
		if -err < t < err: break
		x = x - t / (3 * x2)
	print(x)


Measured memory_bytes: 5608
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double INF=1e+10;
const long double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		// if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
char in[210000];
int L[210000];
int R[210000];
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	scanf("%s",in);
	for(int i=1;i<=a;i++){
		L[i]=L[i-1];
		if(in[i-1]=='x')continue;
		if(i-c-1>=0)L[i]=max(L[i],L[i-c-1]+1);
		L[i]=max(L[i],1);
	}
	for(int i=1;i<=a;i++){
		R[i]=R[i-1];
		if(in[a-i]=='x')continue;
		if(i-c-1>=0)R[i]=max(R[i],R[i-c-1]+1);
		R[i]=max(R[i],1);
	}
	for(int i=0;i<a;i++){
		if(L[i]+R[a-i-1]<b){
			printf("%d\n",i+1);
		}
	}
}

Measured memory_bytes: 3200
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque> 
#include <algorithm>
 
using namespace std;
 
#define     lli                 long long int
#define     ulli                unsigned long long int

#define     ifor(st,lim)        for(int i=st;i<lim;i++)
#define     jfor(stt,llim)      for(int j=stt;j<llim;j++)
#define		Test(tt)			for(int test=1;test<=tt;test++)
#define		For(var,srt,nnd)	for(var=srt;var<nnd;var++)
#define		Rfor(var,srt,nnd)	for(var=srt;var>=nnd;var--)
 
#define     pb                  push_back
#define     mkp                 make_pair
 
#define     pi                  acos(-1)
#define     mod                 100000007
 
#define     Clear(var,val)      memset(var,val,sizeof(var))
#define     len(var)            var.length()
#define     vlen(vect)          (int)vect.size()
#define     line(ss)            getline(cin,ss)

#define		FIO					ios_base::sync_with_stdio(false);cin.tie(NULL)

#define		sclock				int start_s=clock()
#define		eclock				int end_s=clock()
#define		pclock				printf("\nRuntime :: %.2lf\n", (double)(end_s-start_s)/CLOCKS_PER_SEC)
 
/****************************** IO ************************************/
#define		ina(a)				scanf("%d",&a)
#define		inb(a,b)			scanf("%d %d",&a,&b)
#define		inc(a,b,c)			scanf("%d %d %d",&a,&b,&c)
#define		ins(chr)			scanf("%s",s)
#define		inlla(a)			scanf("%lld",&a)
#define		inllb(a,b)			scanf("%lld %lld",&a,&b)
#define		inllc(a,b,c)		scanf("%lld %lld %lld",&a,&b,&c)
 
#define		outa(a)				printf("%d",a)
#define		outlla(a)			printf("%lld",a)

#define		yn(b)				puts(b ? "YES" : "NO") 

#define		outar(ar,ln,c)		for(int i=0;i<ln;i++){printf("%d%c",ar[i],c);}

#define		outCase()			printf("Case %d:",test)
 
#define		blank				printf("\n")
/**********************************************************************/


int main()
{
    FIO;
/******************************* C ************************************/
	
	lli k,n,total,mx;
	mx=0;
	cin >> k >> n;
	lli ar[n];
	ifor(0,n) cin >> ar[i];
	total=0;
	ifor(1,n)
	{
		mx=max(mx,ar[i]-ar[i-1]);
		total+=ar[i]-ar[i-1];
	}
	k=k-ar[n-1]+ar[0];
	mx=max(mx,k);
	total+=k;
	total-=mx;
	cout << total << endl;
	
/**********************************************************************/
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++)
    cin >> a.at(i);
  
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  
  int answer = 0;
  
  for(int i=0;i<N;i++){
    if(i%2==0)
      answer += a.at(i);
    else
      answer -= a.at(i);
  }
  cout << answer << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
// template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE


typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define Mod 1000000007
#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n;cin>>n;
	if(n%2==0){
		cout<<n/2-1<<endl;
	}else{
		cout<<n/2<<endl;
	}































	
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;
const int N=55;

char f[N][N];
int res[N][N];
int main(int argc, char *argv[])
{
  int h,w;
  scanf("%d %d",&h,&w);
  for (int i = 0; i < h; i++) {
    scanf("%s",f[i]);
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (f[i][j]=='#') continue;
      for (int n = -1; n < 2; n++) {
	for (int m  = -1; m < 2; m++) {
	  if(i+n>=0 && j+m>=0 && i+n<h && j+m<w){
	    if(f[i+n][j+m]=='#') res[i][j]++;
	  }
	}
      }
    }
  }
  
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if(f[i][j]=='.') f[i][j]= '0' +res[i][j];
    }
  }
  for (int i = 0; i < h; i++) {
    printf("%s\n",f[i]);
  }
  return 0;
}


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

class UnionFind{
    public:
        vector<int> uni;
        UnionFind(int s) : uni(s, -1) { }

       //頂点aが所属するグループを調べる
        int root(int a)
        {
            if (uni[a] < 0) return a;
            return uni[a] = root(uni[a]);
        }

        //頂点aと頂点bを繋ぐ。もともと同じグループの時falseを返す
        bool connect(int a,int b)
        {
            a = root(a);
            b = root(b);
            if (a == b) return false;

            if (uni[a] > uni[b])
            {
                a ^= b;
                b ^= a;
                a ^= b;
            }

            uni[a] = uni[a] + uni[b];
            uni[b] = a;
            return true;
        }

        //頂点a,bが同じグループであるかを調べる
        bool isConnect(int a,int b)
        {
            return root(a) == root(b);
        }

        //頂点aを含むグループの頂点数を調べる
        int size(int a)
        {
            return -uni[root(a)];
        }

    };


int main(){
  int N,M;
  cin>>N>>M;
  vector<int> A(M),B(M);
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    a--,b--;
    A[i] = a;
    B[i] = b;
  }

  UnionFind UF(N);
  vector<ll> ans(M);
  for(int i=M-1;i>=0;i--){
    if(UF.isConnect(A[i],B[i])) ans[i] = 0;
    else ans[i] = (ll)UF.size(A[i]) * UF.size(B[i]);
    UF.connect(A[i],B[i]);
  }
  for(int i=1;i<M;i++) ans[i] += ans[i-1];
  for(int i=0;i<M;i++) cout<<ans[i]<<endl;
  return 0;
}


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

int main(){
	long n, m;
	char op;
	while(~scanf("%ld %c %ld", &n, &op, &m)){
		if(op == '+')  cout << n + m << endl;
		else cout << n - m << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/* AOJ (Aizu Online Judge) My Practice
 * Author: Leonardone @ NEETSDKASU
 */
#include <stdio.h>

int gcd(int a, int b) {
    if (a == b) return a;
    if (a * b == 0) return a + b;
    if (a > b) {
        return gcd(a % b, b);
    } else {
        return gcd(b % a, a);
    }
}

int lcm(int a, int b) {
    return a * (b / gcd(a, b));
}

int main(void) {
    
    int a, b;
    
    while (0 < scanf("%d %d\n", &a, &b)) {
        printf("%d %d\n", gcd(a, b), lcm(a, b));
    }
    
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; ++i) cin >> vec[i];
    sort(vec.begin(), vec.end());

    int ans = 0;

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < i; ++j) {
            for (int k = 0; k < j; ++k) {
                if (vec[k] != vec[j] and vec[i] != vec[j] and
                    vec[k] + vec[j] > vec[i]) {
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3632
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long t = sc.nextInt(), a = sc.nextInt();
		for(int i = 1; i < N; i++) {
			int T = sc.nextInt();
			int A = sc.nextInt();
			long m = Math.max((t+T-1)/T, (a + A-1)/A);
			t = m * T;
			a = m * A;
		}
		System.out.println(t+a);
	}

}


Measured memory_bytes: 25296
import java.util.Arrays;
import java.util.Scanner;

public class Main{ //ABC128B
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());

		int[] W = new int[N];

		for(int i=0;i<N;i++) {
			W[i] = Integer.parseInt(sc.next());
		}

		int[] min = new int[N-1];

		for(int i=0;i<N-1;i++) {

			int l = 0;
			int r = 0;
			for(int j=0;j<N;j++){
				if(j<=i){
					l += W[j];
				}else {
					r += W[j];
				}
			}
			min[i] = Math.abs(l-r);
		}//Math.abs();

		Arrays.sort(min);
		System.out.println(min[0]);
	}
}

Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<string> 
#include<map>
#include<set>
#include<vector>
#include<string.h> 
#include<math.h>
#include<stdio.h> 
#include<queue>
using namespace std;
int main()
{int a,b,x;cin>>a>>b>>x;
if(a>x||a+b<x)cout<<"NO";
else cout<<"YES";
system("pause");
return 0;
}

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

using namespace std;

#define MAX_V 100*2

int V;
vector<int> G[MAX_V];
int match[MAX_V];
bool used[MAX_V];

void add_edge(int u, int v){
  G[u].push_back(v);
  G[v].push_back(u);
}

bool dfs(int v) {
  used[v] = true;
  for (int i = 0; i<G[v].size();i++){
    int u = G[v][i], w = match[u];
    if ( w < 0 || !used[w] && dfs(w)){
      match[v]=u;
      match[u]=v;
      return true;
    }
  }
  return false;
}

int bipartite_matching(){
  int res = 0;
  //memset(match, -1, sizeof(match));
  for(int i=0;i<MAX_V;i++)
    match[i]=-1;
  for (int v = 0;v<V;v++){
    if(match[v]<0){
      //memset(used,0,sizeof(used));
      for(int i=0;i<MAX_V;i++)
	used[i]=0;
      if(dfs(v)){
	res++;
      }
    }
  }
  return res;
}

struct Point{
  int x,y;
};

bool goodPair(const Point &r,const Point &b){
  if((r.x<b.x)&&(r.y<b.y))
    return true;
  return false;
}

int main(){
  int N;
  cin>>N;
  vector<Point> reds(N);
  vector<Point> blues(N);

  for(int i=0;i<N;i++){
    Point &r=reds[i];
    cin>>r.x>>r.y;
  }

  for(int i=0;i<N;i++){
    Point &b=blues[i];
    cin>>b.x>>b.y;
  }

  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(goodPair(reds[i],blues[j]))
	add_edge(i,N+j);
    }
  }
  
  V=2*N;
  int result = bipartite_matching();
  cout << result <<endl;

  return 0;
}


Measured memory_bytes: 256
N =int(input())
L = [(list(map(int, input().split()))) for _ in range(N)]
ans = ('Yes')
L.insert(0, [0, 0, 0])
for i in range(N):
	if L[i+1][0]-L[i][0] < L[i+1][1]+L[i+1][2]-L[i][1]-L[i][2] or ((L[i+1][1]+L[i+1][2]-L[i][1]-L[i][2])+(L[i+1][0]-L[i][0]))%2==1:
		ans = ('No')
		break
print(ans)

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


int main() {
	// your code goes here
	vector<int>v;
	int n;
	cin>>n;
	int dp[n+3];
	for(int j=0;j<=n;j++)
	{
		dp[j]=INT_MAX;
	}
	int ans=0;
	v.push_back(1);
	for(int j=0;j<10;j++)
	{
		v.push_back(pow(9,j));
		v.push_back(pow(6,j));
	}
	dp[0]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<21;j++)
		{
			if (v[j] <= i)
			 {
				    int sub_res = dp[i-v[j]];
			               if (sub_res != INT_MAX && sub_res + 1 <dp[i])
            			 dp[i] = sub_res + 1;
			  }
		}
	}
	cout<<dp[n];
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void)
{
    char buf[256];
    int h, m, s;
    fgets(buf, 256, stdin);
    buf[255] = '\0';
    sscanf(buf, "%d", &s);
    m = s >> 2;
    m /= 15;
    h = m >> 2;
    h /= 15;
    m %= 60;
    s %= 60;
    printf("%d:%d:%d\n", h, m, s);
    return 0;
}



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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define CIN(v) cin >> v;
#define COUT(v) cout << v << "\n";

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

  string S;

  CIN(S);

  for (int i = 0; i < S.length(); i++) {
    if (i % 2 == 0) {
      if (S[i] == 'L') {
        // COUT(i << " " << S[i]);
        COUT("No");
        return 0;
      }
    } else {
      if (S[i] == 'R') {
        // COUT(i << " " << S[i]);
        COUT("No");
        return 0;
      }
    }
  }

  COUT("Yes");

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int inf=1e9;
const int MOD=1e9+7;
ll ans=0;

ll gcd(ll a, ll b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
int main(void)
{
    ll A,B;
    cin >> A >> B;
    ll mx=max(A,B);
    ll mini=min(A,B);
    if(mini==1)
    {
        cout << 1 << endl;
        return 0;
    }
    set<ll> div;
    set<ll> div2;
    for(ll i=1;i<=sqrt(mx);i++)
    {
        if(mx%i==0) 
        {
            div.insert(i);
            div.insert(mx/i);
        }
    }
    for(ll i=1;i<=sqrt(mini);i++)
    {
        if(mini%i==0) 
        {
            div2.insert(i);
            div2.insert(mini/i);
        }
    }
    vector<ll> lastdiv;
    for(auto it=div.begin();it!=div.end();it++)
    {
        //cout << *it << endl;
        auto it2=div2.find(*it);
        if(it2!=div2.end()) lastdiv.push_back(*it);
    }
    sort(lastdiv.begin(),lastdiv.end());
    /*for(int i=0;i<int(lastdiv.size());i++)
    {
        cout << lastdiv[i] << endl;
    }*/
    set<ll> NG;
    for(int i=0;i<int(lastdiv.size());i++)
    {

        auto it=NG.find(lastdiv[i]);
        if(it!=NG.end() || lastdiv[i]==1) continue;
        ans++;
        for(int j=i+1;j<int(lastdiv.size());j++)
        {
            if(lastdiv[j]%lastdiv[i]==0)
            {
                NG.insert(lastdiv[j]);
            }
        }
    }
    cout << ans+1 << endl;
}

Measured memory_bytes: 1280
#include <stdio.h>


int main(void)
{
  int n, m;
  scanf("%d %d", &n, &m);
  
  int a[n][m];
  int b[m];
  int c[n];
  
  int i, j;
  
  for( i = 0; i < n; i++ ){
    for( j = 0; j < m; j++ ){
      scanf(" %d", &(a[i][j]) );
    }
  }
  
  for( j = 0; j < m; j++ ){
    scanf(" %d", b+j );
  }
  
  for( i = 0; i < n; i++ ){
    c[i] = 0;
    for( j = 0; j < m; j++ ){
    
      c[i] += (a[i][j]*b[j]);
      
    }
    printf("%d\n", c[i]);
  }
  
  return 0;

 
}       

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, x);
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

int gcd(int a, int b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

int lcm(int a, int b) { return a * b / gcd(a, b); }

int main(void) {
  char c;
  cin >> c;
  string s = "aiueo";
  cout << ((s.find(c) == string::npos) ? "consonant" : "vowel") << endl;
  return 0;
}

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

class Dice{
    /* left-hand dice      right-hand dice
            +---+                +---+    
            | 1 |                | 1 |    
    +---+---+---+---+    +---+---+---+---+
    | 5 | 3 | 0 | 2 |    | 5 | 2 | 0 | 3 |
    +---+---+---+---+    +---+---+---+---+
            | 4 |                | 4 |    
            +---+                +---+    
    */
    public:
    std::array<int, 6> state;
    Dice(bool isRight=false):state(std::array<int, 6>{{1, 2, (isRight)?3:4, (isRight)?4:3, 5, 6}}){}
    Dice(std::array<int, 6> d, bool isRight=false):state(d){if(isRight){int tmp=state[2];state[2]=state[3];state[3]=tmp;}}
    void RollTo(int d){
        /*
            0
            |
        2 --#-- 1
            |
            3
        */
        std::array<int, 6> tmp(state);
        switch(d){
            case 0: state[0] = tmp[4]; state[1] = tmp[0]; state[4] = tmp[5]; state[5] = tmp[1]; break;
            case 1: state[0] = tmp[3]; state[2] = tmp[0]; state[3] = tmp[5]; state[5] = tmp[2]; break;
            case 2: state[0] = tmp[2]; state[2] = tmp[5]; state[3] = tmp[0]; state[5] = tmp[3]; break;
            case 3: state[0] = tmp[1]; state[1] = tmp[5]; state[4] = tmp[0]; state[5] = tmp[4]; break;
        }
    }
    void RollTo(char c){
        switch(c){
            case 'N': RollTo(0); break;
            case 'E': RollTo(1); break;
            case 'W': RollTo(2); break;
            case 'S': RollTo(3); break;
        }
    }
    void Rotate(int d){
        /* 90d degrees clockwise
         -> 0 ->
        ^   |   v
        2 --#-- 1
        ^   |   v
         <- 3 <-
        */
        d%=4;
        std::array<int, 6> tmp(state);
        switch(d){
            case 0: state[1] = tmp[1]; state[2] = tmp[2]; state[4] = tmp[4]; state[3] = tmp[3]; break;
            case 1: state[1] = tmp[3]; state[2] = tmp[1]; state[4] = tmp[2]; state[3] = tmp[4]; break;
            case 2: state[1] = tmp[4]; state[2] = tmp[3]; state[4] = tmp[1]; state[3] = tmp[2]; break;
            case 3: state[1] = tmp[2]; state[2] = tmp[4]; state[4] = tmp[3]; state[3] = tmp[1]; break;
        }
    }
};  

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

    std::array<int, 6> state;
    for(auto& i : state){
        std::cin >> i;
    }
    std::string command;
    std::cin >> command;
    Dice d(state, true); d.Rotate(2);
    for(const auto& c : command){
        d.RollTo(c);
    }
    std::cout << d.state[0] << "\n";
    return 0;
}

Measured memory_bytes: 3196
#include <stdio.h>
 
int main (void){

	int n = 0 ;
	int m = 0 ;

	int i = 0 ;
	int j = 0 ;

	scanf("%d %d", &n, &m);

	int A[n][m];
	int b[m];
	int c[n];

	for( i = 0 ; i < n ; i++){
		c[i] = 0 ;
	}

	for( i = 0 ; i < n ; i++){
		for( j = 0 ; j < m ; j++){
			scanf("%d", &A[i][j]);
		}
	}

	for( j = 0 ; j < m ; j++){
		scanf("%d", &b[j]);
	}

	for( i = 0 ; i < n ; i++){
		for( j = 0 ; j < m ; j++){
			c[i] += A[i][j] * b[j];
		}
		printf("%d\n" ,c[i]);
	}

	return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <cstdio>
#include <vector>
#include <cctype>
#include <cmath>
using namespace std;
typedef long long ll;
const double PI = acos( -1.0 );

int main( void ) {
    int n;
    double p1, p2, p3, p4, x[105], y[105];
    cin >> n;
    p1 = p2 = p3 = p4 = 0;
    for( int i = 0; i < n; ++i ) cin >> x[i];
    for( int i = 0; i < n; ++i ) cin >> y[i];
    for( int i = 0; i < n; ++i ) {
        double c = fabs( x[i] - y[i] );
        p1 += c;
        p2 += c * c;
        p3 += c * c * c;
        p4 = max( p4, c );
    }
    p2 = sqrt( p2 );
    p3 = pow( p3, 1.0/ 3.0);
    printf( "%.6lf\n", p1 );
    printf( "%.6lf\n", p2 );
    printf( "%.6lf\n", p3 );
    printf( "%.6lf\n", p4 );
    return 0;
}



Measured memory_bytes: 3396
#include <stdio.h>
int main()
{
  int N;
  int a[100000];
  int i;
  int counter = 0;
  
  scanf("%d", &N);
  for(i = 0; i < N; ++i)
    scanf("%d", &a[i]);
  
  for(i = 0; i < N; ++i){
    if(a[a[i] - 1] == (i + 1))
      ++counter;
  }
  counter /= 2;
  printf("%d\n", counter);
  return 0;
}


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

#define int long long

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

	cout << fixed << setprecision(10);
	double r;
	cin >> r;
	cout << 3.14 * r * 2;

	return 0;
}


Measured memory_bytes: 3792
s = input().split()

d = int(s[0])
n = int(s[1])

answer = 0

if d == 0:
    if n == 100:
        answer = 101
    else:    
        answer = n
elif d == 1:
    if n == 100:
        answer = 10100
    else:
        answer = 100 * n
elif d == 2:
    if n == 100:
        answer = 1010000
    else:
        answer = 10000 * n

print(answer)

Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N, A, B; cin >> N >> A >> B;
    A--; B--;
    
    if((B - A) % 2 == 0){
        Out((B - A) / 2);
    }else{
        int a = 0, b = B - A - 1;
        int t1 = A + 1 + (b - a) / 2;

        int t2 = N - 1 - B;
        a = A + t2; b = B + t2;
        a++; t2++;
        t2 += (b - a) / 2;
        Out(min(t1, t2));
    }

    return 0;
}


Measured memory_bytes: 256
#問題D
#これだとタイムアウト
import numpy as np
import warnings
warnings.filterwarnings('ignore')

N, W = list(map(int, input().split()))
w = np.array([0] * (N+1))
v = np.array([0] * (N+1))
for i in range(N):
    w[i+1], v[i+1] = map(int, input().split())

dp = np.array([[0] * (W+1)] * (N+1))
for i in range(1, N+1):
    tmp_arr = np.zeros(W + 1, dtype=int)
    tmp_arr = np.zeros(W + 1, dtype=int)
    tmp_arr[w[i]:] = dp[i-1][:-w[i]] + v[i]
    dp[i] = np.maximum(dp[i-1], tmp_arr)

print(dp[N, W])



Measured memory_bytes: 106956
#include <iostream>
#include <string>

using namespace std;
using ll = long long;

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

	int ans = 0;
	for (int i = 0; i < 3; ++i) {
		if (S[i] == T[i]) {
			ans++;
		}
	}

	cout << ans << endl;
	return 0;
}


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

int main() {
	int A, B;
	cin >> A >> B;
	int ans = -1;
	for (int i = 1; i < 1010; i++) {
		if (floor(i * 0.08) == A && floor(i * 0.1) == B) {ans = i;
		break;}
	}
	cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

typedef long long ll;
const int MAXN = 1e5 + 10;
const int Mod = 1e9 + 7;
int N;
ll A[MAXN];
ll fac[MAXN], inv[MAXN];
ll ans;

int main() {
	register int i;
	scanf("%d", &N);
	for(*fac = i = 1; i <= N; ++i) fac[i] = 1ll * fac[i - 1] * i % Mod;
	for(inv[1] = 1, i = 2; i <= N; ++i) inv[i] = 1ll * (Mod - Mod / i) * inv[Mod % i] % Mod;
	for(i = 1; i <= N; ++i) inv[i] = (ll) (inv[i] + inv[i - 1]) % Mod;
	for(i = 1; i <= N; ++i)
		scanf("%lld", A + i),
		ans = (ll) (ans + A[i] * (inv[i] + inv[N - i + 1] - 1 + Mod) % Mod) % Mod;
	printf("%lld\n", (ll) ans * fac[N] % Mod);
	return 0;
}

Measured memory_bytes: 2560
n, k = map(int, input().split())
*A, = map(int, input().split())
DP = [False] * (k+1)
for i in range(k+1):
    for a in A:
        if i+a <= k and not DP[i]:
            DP[i+a] = True
if DP[k]:
    print('First')
else:
    print('Second')


Measured memory_bytes: 3828
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;

int main()
{
    int h, w;
    cin >> h >> w;
    vector<vector<char>> s(h, vector<char>(w));
    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] == '#'){
                if(i != 0 && s[i-1][j] == '#') continue;
                if(j != 0 && s[i][j-1] == '#') continue;
                if(i != h-1 && s[i+1][j] == '#') continue;
                if(j != w-1 && s[i][j+1] == '#') continue;
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

int main() {
  string s,t;
  cin>>s>>t;
  int ans=0;
  rep(i,3) {
    if (s[i]==t[i]) ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
paper = {}
ans = 0
for i in range(N):
  A = int(input())
  if A in paper.keys():
    paper[A] += 1
  else:
    paper[A] = 1
for i in paper.values():
  if i%2 == 1:
    ans += 1
print(ans)

Measured memory_bytes: 15072
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#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;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#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 pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;

void solve() {
	int x, a; cin >> x >> a;
	if (x < a)cout << 0 << endl;
	else cout << 10 << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(9);
	//init();
	solve();
	//stop
	return 0;
}


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

#define M 1000005
#define ep emplace_back
#define mp make_pair

typedef long long int lli;
typedef pair<lli,lli> PII;

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

//    freopen("input.txt","rt",stdin);

    lli x;
    cin>>x;

    lli ffq = x/500;

    lli ans = 0;

    lli rem = x%500;

    lli fq = rem/5;

    ans = (ffq*1000)+(fq*5);

    cout<<ans<<"\n";

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
#include <cassert>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////

int main(){
	ll N;
	cin >> N;
	vll A(N + 1);
	repn(i, N)cin >> A[i];

	ll mx = 0;
	ll ans = 0;
	repn(i, N) {
		mx = max(A[i], mx);
		ans += mx - A[i];
	}
	cout << ans << endl;
}



Measured memory_bytes: 4836
W,H,N = map(int,input().split())
X = [0]*N
Y = [0]*N
A = [0]*N
X_max= W
X_min= 0
Y_max= H
Y_min= 0
for i in range(N):
	X[i],Y[i],A[i] = map(int,input().split())
for i in range(N):
	if A[i]==1:
		X_min=max(X_min,X[i])
	elif A[i]==2:X_max=min(X_max,X[i])
	elif A[i]==3:Y_min=max(Y_min,Y[i])
	else:Y_max=min(Y_max,Y[i])

if X_max-X_min>0 and Y_max-Y_min>0:
	print((X_max-X_min)*(Y_max-Y_min))
else: print(0)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>

int main()
{
	int ans = 0;
	for (int i = 0; i < 5; i++) {
		int x;
		scanf("%d", &x);
		if (x == 0) {
			ans = i + 1;
		}
	}
	printf("%d\n", ans);
	return 0;
}


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n;
ll a[200005];
map<ll, bool> mp;
void solve() {
    cin >> n;
    rep(i, n) { cin >> a[i]; mp[a[i]] = true; }

    if (mp.size() == n) cout << "YES" << endn;
    else cout << "NO" << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


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

using namespace std;

struct node{
	int cost, state;
}p[1005];

int n, m, f[1 << 14];
int main() {
	cin >> n >> m;
  	memset(f, 0x3f3f3f3f, sizeof(f));
  	f[0] = 0;
  	for (int i = 1; i <= m; i++){
    	cin >> p[i].cost;
    	int sum = 0, t, x;
      	cin >> t;
      	while (t--) {
        	cin >> x;
          	sum += (1 << (x - 1));
        }
    	p[i].state = sum;
      	f[sum] = p[i].cost;
    }
  	for (int i = 0; i < 1 << n; i++)
      	for (int j = 1; j <= m; j++) {
        	f[i | p[j].state] = min(f[i | p[j].state], f[i] + p[j].cost);
        }
  	if (f[(1 << n) - 1] == 0x3f3f3f3f)cout << -1 << endl;
  	else cout << f[(1 << n) - 1] << endl;
}


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

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
//dream dreamer erase eraser
  string str,s="";cin>>str;
  int len=str.length();
  for(int i=0;i<len;i++) s+=str[len-i-1];
  bool ans=false;
  for(int i=0;i<100000;i++){
      if(s.length()<5) break;
      else if(s.length()<6){
          ans=(s=="maerd" || s=="esare");
          break;
      }
      else if(s.length()<7){
          ans=(s=="resare");
          break;
      }
      else{
          string sub5=s.substr(0,5);
          string sub6=s.substr(0,6);
          string sub7=s.substr(0,7);
          if(sub7=="remaerd") s.erase(s.begin(),s.begin()+7);
          else if(sub6=="resare") s.erase(s.begin(),s.begin()+6);
          else if(sub5=="maerd"||sub5=="esare") s.erase(s.begin(),s.begin()+5);
          else break;
      }
  }
  if(s=="") ans=true;
  if(ans) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


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

int main() {
  string s, t, u;
  cin >> s >> t;
  
  int a, b;
  cin >> a >> b;
  
  cin >> u;
  
  if (u == s) a -= 1;
  if (u == t) b -= 1;
  
  cout << a << " " << b << endl;
}

Measured memory_bytes: 256
object Main extends App{
  import scala.io.StdIn._
  val n=readInt()
  val a=readLine().split(" ").map(_.toInt)
  var A=new Array[Int](n)
  for{i <- (0 until(n-1))}{
    A(a(i)-1) += 1
  }
  println(A.mkString("\n"))
}

Measured memory_bytes: 75820
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
  long int i, j, k;
  int N, f=0;
  scanf("%d",&N);

  for(i=1;i<=3500;i++){
    if(4*i<N) continue;
    for(j=i;j<=3500;j++){
      if(4*i*j<N*(i+j)) continue;
      for(k=j;k<=3500;k++){
	if(4*i*j*k==N*(i*j+j*k+k*i)){f=1;  break;}
	if(4*i*j*k==N*(i*j+j*k+k*i)) break;
      }
      if(f==1) break;
    }
    if(f==1) break;
  }
  printf("%ld %ld %ld\n",i,j,k);
  return 0;
}


Measured memory_bytes: 128
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  string s;cin>>s;
  int k;cin>>k;

  int n = sz(s);
  if (n==1){
    cout << k/2 << endl;
    return 0;
  }

  int cnt1 = 0;
  bool flag1 = false;
  rep(i, 1, n){
    if (s[i]==s[i-1]){
      if (i==n-1){
        flag1 = true;
      }
      cnt1++;
      i++;
    }
  }
  int cnt2 = 1;
  bool flag2 = false;
  rep(i, 2, n){
    if (s[i]==s[i-1]){
      if (i==n-1){
        flag2 = true;
      }
      cnt2++;
      i++;
    }
  }
  dump(cnt1, flag1);
  dump(cnt2, flag2);

  if (s[0]==s[n-1]){
    if (flag1){
      cout << cnt1*k << endl;
      return 0;
    }
    else{
      if (flag2){
        //c1->c2->c1->c2
        dump(cnt1, (k+2-1)/2, cnt2, k/2);
        int ans = 0;
        ans += cnt1 * ((k+2-1)/2);
        ans += cnt2 * (k/2);
        cout <<  ans  << endl;
      }
      else{
        //c1->c2->c2->c2
        dump("hello");
        cout << cnt1 + cnt2*(k-1) << endl;
        return 0;
      }
    }
  }
  else{
    dump(cnt1);
    cout << cnt1*k << endl;
    return 0;
  }

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
possible = set()
for i in range(2 ** n):
    tmp = 0
    for j in range(n):
        if (i >> j) & 1:
            tmp += a[j]
    possible.add(tmp)

q = int(input())
m = list(map(int, input().split()))
for i in range(q):
    if m[i] in possible:
        print('yes')
    else:
        print('no')


Measured memory_bytes: 5656
N, K = list(map(int,input().split()))
A = [list(map(int,input().split())) for _ in range(N)]
cnt = 0
A = sorted(A, key = lambda x: x[0])
for i in range(N):
    cnt += A[i][1]
    if cnt >= K:  
        print(A[i][0])
        break

Measured memory_bytes: 94144
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo (1LL<<63-1)
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >

using namespace std;

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

const long double Pi=acos(-1),e=2.718;
const int N=2e5+10, mod=1e9+7;
string s,t;
vector<ll> occ[26];
int main ()
{
    FASTIO
    cin >> s >> t;
    for(int i=0;i<s.si;i++)occ[s[i]-'a'].pb(i);
    ll last=-1,ans=0;
    for(int i=0;i<t.si;i++){
        if(occ[t[i]-'a'].si==0)return cout << -1 << endl,0;
        auto it=upper_bound(all(occ[t[i]-'a']),last);
        if(it==occ[t[i]-'a'].end()){
//            cout << "#1 " << s.si-last-1 << endl;
            ans += s.si-last-1;
            last = -1;
            i--;
        }
        else{
//            cout << "#2 " << *it-last << endl;
            ans += *it-last;
            last = *it;
        }
    }
    cout << ans << endl;
    return 0;
}
/**

*/


Measured memory_bytes: 1736