akhauriyash/Code-Regression huggingface dataset:
N = int(input())
L = list(map(int,input().split()))
ans = 0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if L[i] == L[j] or L[j] == L[k] or L[i] == L[k]:
                continue
            else:
                if L[i]+L[j] > L[k] and L[j]+L[k] > L[i] and L[k]+L[i] > L[j]:
                    ans += 1
print(ans)

Measured memory_bytes: 9204
s = input()
top = ''
n = int(input())
isReverse = False
for i in range(n):
    Q = input().split()
    if(Q[0] == '1'):
        isReverse = not isReverse
    else:
        if Q[1] == '1':
            if isReverse: s += Q[2]
            else: top += Q[2]
        else:
            if isReverse: top += Q[2]
            else: s += Q[2]
if isReverse: s = s[::-1] + top
else: s = top[::-1] + s
print(s)

Measured memory_bytes: 4192
n = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

l = make_divisors(n)
ans = n
for i in range(len(l)):
  ans = min(ans,(l[i] + n // l[i]) - 2)
print(ans)

Measured memory_bytes: 3268
#include<bits/stdc++.h>
using namespace std;
const int M = 1000005;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> c(M); 
    for(int i = 0; i < n; i++)
    cin >> a[i];
    for(int j : a)
    {
        if(c[j]>0)
        {
            c[j]=2;
            continue;
        }
        for(int i = j; i <= M; i += j){
            c[i]++;
        }
    }
    int ans = 0;
    for(int j : a){
        if(c[j]==1)ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 7992
#define DBG 0 //submit 0
#define ll long long
#if DBG
    #include <algorithm>
    #include <array>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <unordered_map>
    #include <iostream>
    #include <cmath>
    #include <queue>
    #include <numeric>
#else
    #include <bits/stdc++.h>
#endif
 
using namespace std;
 
 
int main(){
    int n=0,ans;
    string s,t;
    bool flag = false;

    cin >> s >> t;
    
    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),greater<char>());

    if(s<t)flag=true;
    
    cout << (flag ? "Yes" : "No") << endl;
    //cout << ans << endl;
 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 2000015
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define F first
#define S second
const ll mod = 1e9+7;
ll pre[maxn];
ll inv[maxn];
ll prei[maxn];
void build(int n){
    pre[1] = pre[0] = 1, inv[1] = inv[0] = 1, prei[1] = prei[0] = 1;
    for(int i = 2 ; i <= n ; i++){
        pre[i] = pre[i-1] * i % mod;
        inv[i] = (mod - mod / i * inv[mod % i] % mod) % mod;
        prei[i] = prei[i-1] * inv[i] % mod;
    }
}
ll C(int n, int k){
   return pre[n] * prei[k] % mod * prei[n-k] % mod;
}
ll pm(int n,int p){
    ll ret = 1;
    ll now = n;
    while(p){
        if(p & 1){
            ret *= now;
            ret %= mod;
        }
        now *= now;
        now %= mod;
        p >>= 1;
    }
    return ret;
}
ll solve(ll x,ll y){
    if(x==0||y==0)return 0;
    ll ret = 0;
    for(int i = 1 ; i <= y ; i++){
        ret += C(x+i+1,x);
        ret += mod - 1;
        ret %= mod;
    }
    return ret;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    build(2000005);
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << ((solve(x2,y2)-solve(x1-1,y2)-solve(x2,y1-1) + solve(x1-1,y1-1))%mod + mod) % mod;
}

Measured memory_bytes: 47104
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i,l,r) for(int i = (int)l;i<(int)r;i++)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7
//#define int long long
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

const int N = 1010;
vector<int> g[N];
int pai[N];
int d[N];
int n,m;
int vis[N];
vector<int> ans;
void bfs(int ini){
  queue<int> q;
  q.push(ini);
  d[ini]=0;
  int small = 1e9;
  int id=0,id2=0;
  vis[ini] = 1;
  while(!q.empty()){
    int cur = q.front();
      q.pop();
      for(int to : g[cur]){
          if(!vis[to]){
            vis[to] = 1;
            q.push(to);
            d[to] = d[cur] + 1;
            pai[to] = cur;
          }
          if(to==ini){
            vector<int> res;
            int c = cur;
            while(c!=to){
              res.pb(c);
              c = pai[c];
            }
            res.pb(to);
            if(ans.size()==0 or res.size() < ans.size())ans = res;
            return;
          }
      }
  }
 
   
}

// long long ? ?
int32_t main(){
  fastio;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    g[a].pb(b);
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      vis[j] = 0;
      d[j] = 0;
      pai[j]= -1;
    }
    bfs(i);
  }
  if(ans.size()){
    cout<<ans.size()<<endl;
    for(int x : ans){
      cout<<x<<endl;
    }
    return 0;
  }
  cout<<-1<<endl;



  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

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

int main(){
    int x,y;
    string xname,yname;
    cin >> xname >> yname >> x >> y;
    string han;
    cin >> han;
    if(han == xname){
        x--;
    }
    else y--;

    cout << x << ' ' << y << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int m,n,t=0,c=0,s=0;
    cin>>n;
    int a[n+10],b[n+10];
    //memset(a,0,sizeof(a));
    for(int i = 0; i < n; i++)
    {
        cin>>a[i];
        s += a[i];
    }

    sort(a,a+n);
    s -= a[n-1];

    if(a[n-1] < s)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    //cout<<c<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef pair<LL, LL> PII;
typedef vector<string> VS;
inline LL toInt(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(x,c) for(auto x: (c))
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ALL(c) (c).begin(), (c).end()
#define REVERSE(c) reverse(ALL(c))
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define STABLE_SORT(c) stable_sort(ALL(c))
#define STABLE_RSORT(c) stable_sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)), (c).end());
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define dump(x)  cerr << #x << " = " << (x) << endl;

class UnionFind {
public:
    VI parent;
    UnionFind(LL N) : parent(N) {
        iota(ALL(parent), 0);   // 初期化(親==自分)
    }
    LL getRoot(LL x) {   // 根に到達するまで親を辿る
        if (parent[x] == x) return x;   // 根は親==自分
        return parent[x] = getRoot(parent[x]);   // 経路圧縮(辿った要素を全て根に直結させる)
    }
    bool inSameSet(LL x, LL y) {   // 根が同じなら同じ集合に属する
        return getRoot(x) == getRoot(y);
    }
    void unite(LL x, LL y) {   // 同値関係 x~y を追加(xが属する集合とyが属する集合をマージ)
        x = getRoot(x);
        y = getRoot(y);
        if (x == y) return;   // すでに同じ集合
        parent[x] = y;
    }
};


int main() {
    LL N, M;
    cin >> N >> M;
    UnionFind uf(N + 1);
    REP(i, M) {
        LL x, y, z;
        cin >> x >> y >> z;
        uf.unite(x, y);
    }
    unordered_set<LL> P;
    FOR(i, 1, N + 1) {
        P.insert(uf.getRoot(i));
    }
    cout << SZ(P) << endl;
	
    return 0;
}


Measured memory_bytes: 5156
require 'pp'

while (w, h = gets.chomp.split(" ").map{|str| str.to_i}) != [0, 0]
	queue = []
	table = []
	for y in 0..(h - 1)
		table << gets.chomp.split("").map.with_index do |char, x|
			if char == "."
				0
			elsif char == "#"
				-1
			elsif char == "@"
				queue << [y, x]
				0
			end
		end
	end
	while !queue.empty?
		y, x = queue.shift
		if table[y][x] == 0
			table[y][x] = 1
			add = []
			add << [y, x - 1] if x != 0 
			add << [y - 1, x] if y != 0
			add << [y, x + 1] if x != w - 1
			add << [y + 1, x] if y != h - 1
			queue += add
		end
	end
	puts table.flatten.count(1)
end

Measured memory_bytes: 9696
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};

const int MAX_N = 110000;

int memo[MAX_N];

int rec(int n) {
	if (n == 0)return 0;
	if (memo[n] != -1)return memo[n];

	int res = n;

	for (int pow6 = 1; pow6 <= n; pow6 *= 6)res = min(res, rec(n - pow6) + 1);

	for (int pow9 = 1; pow9 <= n; pow9 *= 9)res = min(res, rec(n - pow9) + 1);

	return memo[n] = res;
}


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

	cin >> N;
	rep(i, 0, MAX_N)memo[i] = -1;



	cout << rec(N) << endl;
	
	

		
	

	
	
}
	

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

int main() {
    
    int x, n;
    cin >> x >> n;
    vector<int> v(102,0);
    rep(i,n) {
        int p;
        cin >> p;
        v[p] = 1;
    }
    P ans(1e9, -1);
    for(int i = 0; i <= 101; ++i){
        if(v[i] == 1) continue;
        int dif = abs(x - i);
        ans = min(ans, P(dif,i));
    }
    cout << ans.second << endl;

    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    priority_queue<int> q;
    for(int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        q.push(a);
    }
    while(m-- > 0)
    {
        int a = q.top();
        a /= 2;
        q.pop();
        q.push(a);
    }
    long long ans = 0;
    while(!q.empty())
    {
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 892
import java.util.Scanner;
class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();        
        int b = sc.nextInt();
        
        System.out.print(a*b + " ");
        System.out.println(2*(a+b));
    }
}


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

int main() {
  int N, K; cin >> N >> K;

  int dif;
  
  dif = N - K;
  
  if (K != 1) {
    cout << dif << endl; 
  } else {
    cout << "0" << endl;
  }
  
  return 0;
}

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

char s1[100001], s2[100001];
int x1[100001], x2[100001];

int main(){
	int q;
	scanf("%s%s%d", s1, s2, &q);
	int n = strlen(s1), m = strlen(s2);
	f(i, 1, n + 1){
		if (s1[i - 1] == 'A')x1[i] = 1; else x1[i] = 2;
		x1[i] += x1[i - 1];
	}
	f(i, 1, m + 1){
		if (s2[i - 1] == 'A')x2[i] = 1; else x2[i] = 2;
		x2[i] += x2[i - 1];
	}
	while (q--){
		int a, b, c, d;
		scanf("%d%d%d%d", &a, &b, &c, &d);
		int z1 = x1[b] - x1[a - 1], z2 = x2[d] - x2[c - 1];
		if (z1 % 3 == z2 % 3)printf("YES\n");
		else printf("NO\n");
	}
}


Measured memory_bytes: 1664
/** Seek God..Trust God..Praise God..**/

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


#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)

#define mt              make_tuple
#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////



/*
long long  Prime[3000000],nPrime;
long long  mark[10000002];

void seive(long long int n)
{
	long long int i,j,limit=sqrt(n*1.0)+2;
	mark[1]=1;
	for(i=4; i<=n ;i+=2)
	mark[i]=1;
	Prime[nPrime++]=2;
	for(i=3; i<=n; i+=2)
	{
		if(!mark[i])
		{
			Prime[nPrime++]=i;
			if(i<=limit)
			{
				for(j=i*i; j<=n ;j+=i*2)
				{
					mark[j]=1;
				}
			}
		}
	}
}
*/


int main()
{
    FASTIO;

    ll n;

    cin >> n;

    ll a[n+1];


    for(int i=0; i<n; i++)
        cin >> a[i];



        ll sum = 0 , ans = 0;



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

        if(a[i]<a[i+1])
            continue;
        else
        {
            ans = abs(a[i]-a[i+1]);

           // cout << ans << endl;


            a[i+1] += ans;

            sum += ans;

            ans = 0;



        }

    }

    if(ans>0)
        sum += ans;


    cout << sum << endl;






    return 0;
}



Measured memory_bytes: 5212
#include <iostream>
#include <fstream>
using namespace std;
int n,a,b;
int main()
{
    //freopen("data.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin>>n>>a>>b;
    cout<<min(a,b)<<' ';
    cout<<max(0,a+b-n);
    return 0;
}


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

int main(){
	
	double a,b,c,d,e,f ;
	double x,y ;
	
	while(1){
		cin >> a ;
		if( cin.eof() ) break ;
		cin >> b >> c ;
		cin >> d >> e >> f ;
		
		if( a*e - b*d == 0 ){
			cout << "error" << endl ;
		}
		else{
			x = ( c*e - b*f ) / ( a*e - b*d ) + 0.00005 ;
			y = ( a*f - d*c ) / ( a*e - b*d ) + 0.00005 ;
		}
		
		printf("%.3lf %.3lf\n",x ,y) ;
	}
	
return 0 ;
}

/*
ax + by = c
dx + ey = f
*/

Measured memory_bytes: 1240
A=list(input())
n=int(input())
tmp=0
if len(set(A)) == 1:
   print(len(A)*n//2)
   exit()
sum_n=0
tmp3=0
while A[0] == A[tmp3]:
   tmp3+=1
sum_n+=tmp3
tmp3=0
while A[-1] == A[-1-tmp3]:
   tmp3+=1
sum_n+=tmp3
for i in range(len(A)-1):
   if A[i] == A[i+1]:
      A[i+1]="1"
      tmp+=1
tmp2=0
if A[0] == A[-1]:
   tmp2=n-1
   if sum_n%2 == 1:
      tmp2-=n-1
print(tmp*n+tmp2)

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

int main() {
	int h, w;
	string s;
    cin >> h >> w;
	for(int i = 0; i < 2; i++) {
		for(int j = 0; j < w + 2; j++) {
			cout << '#';
		}
		cout << endl;
		if(i == 1){
			break;
		}
		for(int k = 0; k < h; k++) {
			cin >> s;
			cout << '#' << s << '#' << endl;
		}
	}
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main
{
    static PrintWriter out = new PrintWriter((System.out));

    public static void main(String args[]) throws IOException
    {
        Kioken sc = new Kioken();
        for(int x=0;x<5;x++)
        {
            int a=sc.nextInt();
            if(a==0)
            {
                out.println(x+1);
                break;
            }
        }
        out.close();
    }

    public static void kamehameha()
    {
    }

    static class Kioken
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        public String next()
        {
            while (!st.hasMoreTokens())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (Exception e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        public long nextLong()
        {
            return Long.parseLong(next());
        }

        public double nextDouble()
        {
            return Double.parseDouble(next());
        }

        public String nextLine()
        {
            try
            {
                return br.readLine();
            }
            catch (Exception e)
            {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext()
        {
            String next = null;
            try
            {
                next = br.readLine();
            }
            catch (Exception e)
            {
            }
            if (next == null)
            {
                return false;
            }
            st = new StringTokenizer(next);
            return true;
        }
    }
}

Measured memory_bytes: 32624
n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ai = -1
bi = -1
answer = 0
t_sum = 0
if sum(a) + sum(b) <= k:
    print(n + m)
elif sum(a) <= k:
    t_sum = sum(a)
    ai = n-1
    while True:
        bi += 1
        if bi == m:
            break
        if t_sum + b[bi] > k:
            break
        t_sum += b[bi] 
    bi -= 1
    answer = ai + bi + 2
    while ai >= 0:
        t_sum -= a[ai]
        ai -= 1
        while bi <= m-1:
            bi += 1
            if bi == m:
                break
            if t_sum + b[bi] > k:
                break
            t_sum += b[bi]
        bi -= 1
        if ai + bi +2 > answer:
            answer = ai + bi +2
    print(answer)
else:
    while True:
        ai += 1
        if t_sum + a[ai] > k:
            break
        t_sum += a[ai]
    ai -= 1
    while True:
        bi += 1
        if bi == m:
            break
        if t_sum + b[bi] > k:
            break
        t_sum += b[bi]
    bi -= 1
    answer = ai + bi + 2
    while ai >= 0:
        t_sum -= a[ai]
        ai -= 1
        while bi <= m-1:
            bi += 1
            if bi == m:
                break
            if t_sum + b[bi] > k:
                break
            t_sum += b[bi]
        bi -= 1
        if ai + bi +2 > answer:
            answer = ai + bi +2
    print(answer)

Measured memory_bytes: 41736
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<char>> c(H, vector<char>(W));
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      cin >> c[i][j];
    }
  }
  int ans = 0;
  for (int i = 0; i < (1 << (H + W)); i++){
    int cnt = 0;
    for (int j = 0; j < H; j++){
      for (int k = 0; k < W; k++){
        if (c[j][k] == '#'){
          if (!(i >> j & 1) && !(i >> (H + k) & 1)){
            cnt++;
          }
        }
      }
    }
    if (cnt == K){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int n,k,ans;
int a[50+10];
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+1+n);
	for(int i=n;i>=n-k+1;i--)
		ans+=a[i];
	cout<<ans<<"\n";
	return 0;
}

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

#define mod 1000000007
#define int long long int
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pii>
#define vs vector<string>
#define fi first
#define se second
#define psb push_back
#define ppb pop_back
#define fio ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define all(v) v.begin(),v.end()
#define endl "\n"

const int maxn=2e5+5;
int ar[maxn];

int32_t main()
{
	int h;
	cin>>h;
	int ans=0,ct=1;
	while(h>1)
	{
		ans+=ct;
		h/=2;
		ct*=2;
	}
	ans+=ct;
	cout<<ans<<endl;
}

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n;
	cin >> n;
	vector<int> b(n + 1, INF);
	FOR(i, 1, n) cin >> b[i];
	int ans = 0;
	FOR(i, 1, n + 1) ans += min(b[i], b[i - 1]);	
	cout << ans << endl;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
using namespace std;
int main()
{
    string s;
    cin>>s;
    int a=0,b=0,c=0;
    rep(i,0,3)
    {
        if(s[i]=='a') a++;
        if(s[i]=='b') b++;
        if(s[i]=='c') c++;
    }
    if(a==1&&b==1&&c==1)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll 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++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  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;
  }
};

int main()
{
  int n; cin >> n;
  vector<int> ans(n+1, 0);
  for(int x = 1; x <= 100; ++x) for(int y = 1; y <= 100; ++y) for(int z = 1; z <= 100; ++z) {
    if(x*x+y*y+z*z+x*y+y*z+z*x > n) break;
    ++ans[x*x+y*y+z*z+x*y+y*z+z*x];
  }
  for(int i = 1; i <= n; ++i) cout << ans[i] << endl;
}


Measured memory_bytes: 3580
import math

n = int(input())
tl = [int(input()) for _ in range(n)]

if n == 1:
    print(tl[0])
else:
    g = tl[0] // math.gcd(tl[0], tl[1]) * tl[1]
    for i in range(1, n):
        g = g // math.gcd(g, tl[i]) * tl[i]
    print(g)


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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()

template<typename T> istream& operator>>(istream& is, vector<T>& a) { for (T& x : a) is >> x; return is; }

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); } } initCpp;

signed main() {
  i32 x, y, z, k;
  cin >> x >> y >> z >> k;
  vector<i64> A(x), B(y), C(z);
  cin >> A >> B >> C;
  sort(ALL(A), greater<i64>());
  sort(ALL(B), greater<i64>());
  sort(ALL(C), greater<i64>());
  using T = tuple<i32, i32, i32>;
  using P = pair<i64, T>;
  priority_queue<P> Q;
  Q.push({A[0] + B[0] + C[0], make_tuple(0, 0, 0)});
  set<T> S;
  S.insert(make_tuple(0, 0, 0));
  REP(_, k) {
    i64 p = Q.top().first;
    i32 u, v, w;
    tie(u, v, w) = Q.top().second;
    Q.pop();
    cout << p << endl;
    auto u1 = make_tuple(u + 1, v, w);
    auto v1 = make_tuple(u, v + 1, w);
    auto w1 = make_tuple(u, v, w + 1);
    if (u + 1 < x && !S.count(u1)) { S.insert(u1); Q.push({A[u + 1] + B[v] + C[w], u1}); }
    if (v + 1 < y && !S.count(v1)) { S.insert(v1); Q.push({A[u] + B[v + 1] + C[w], v1}); }
    if (w + 1 < z && !S.count(w1)) { S.insert(w1); Q.push({A[u] + B[v] + C[w + 1], w1}); }
  }
}

Measured memory_bytes: 1024
import java.util.*;
     
public class Main{
  public static void main(String args[]){
    Scanner scanner = new Scanner(System.in);
    String input = scanner.nextLine();
    String[] str = input.split(" ");
    int in1 = Integer.parseInt(str[0]);
    int in2 = Integer.parseInt(str[1]);
     
    System.out.println(in1*in2+" "+(in1+in2)*2);
  }
}

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

int main()
{
	string s, t;
	cin >> s >> t;
	vector<vector<int>> tp('z' - 'a' + 1);
	int slength = static_cast<int>(s.size());
	for (int i = 0; i < slength; ++i) {
		tp[s[i] - 'a'].push_back(i);
	}

	int current = 0;
	long long loop = 0;
	for (auto& j : t) {
		auto itr = lower_bound(tp[j - 'a'].begin(), tp[j - 'a'].end(), current);
		if (itr == tp[j - 'a'].end()) {
			if (!tp[j - 'a'].empty()) {
				current = 0;
				++loop;
				auto itr2 = lower_bound(tp[j - 'a'].begin(), tp[j - 'a'].end(), current);
				current = (*itr2) + 1;
			}
			else {
				cout << -1 << endl;
				return 0;
			}
		}
		else {
			current = (*itr) + 1;
		}
	}

	long long ret = loop * (long long)slength + (long long)current;
	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 1216
#include <algorithm>
#include <iostream>
#include <cstdio>

using namespace std ;

const int N=1e5+10 ;

struct Edge { int to , nxt , w ; };
Edge e[N<<1] ;
int lst[N] ;
inline void add ( int u , int v , int w )
{
	static int cnt=0;
	e[++cnt]=(Edge){v,lst[u],w},lst[u]=cnt,
	e[++cnt]=(Edge){u,lst[v],w},lst[v]=cnt;
}

int c[N] ;
inline void dfs ( int x , int f )
{
	int i , y ;
	for ( i=lst[x],y=e[i].to ; i ; i=e[i].nxt,y=e[i].to )
		if ( y^f ) c[y]=(c[x]+e[i].w)%2,dfs(y,x);
}

int n ;
int main ()
{
	int i , u , v , w ;
	scanf("%d",&n);
	for ( i=1 ; i<n ; i++ ) scanf("%d%d%d",&u,&v,&w),add(u,v,w);
	dfs(1,1);
	for ( i=1 ; i<=n ; i++ ) printf("%d\n",c[i]);
	return 0 ;
}

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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  int N,K;
  cin >> N >> K;
  COMinit();
  for (int i=1;i<K+1;i++){
    cout << COM(N-K+1,i)*COM(K-1,i-1)%MOD << endl;
  }
}

Measured memory_bytes: 12288
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int p[]=new int[n];
		for(int i=0;i<n;i++) {
			p[i]=scan.nextInt();
		}
		scan.close();

		int cnt=0;
		int min=Integer.MAX_VALUE;
		for(int i=0;i<n;i++) {
			if(min>p[i]) {
				cnt++;
				min=p[i];
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 82252
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<39;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

#define N 100010
ll n, e, t;
ll x[N], dp[N];

int main(){
	cin>>n>>e>>t;
	rep(i, n) cin>>x[i];
	fill(dp, dp+N, INF);
	dp[0] = 0;
	rep(i, n){
		ll r = upper_bound(x, x+n, x[i]+t/2)-x;
		if(r<n){
			ll d = x[r]-x[i];
			chmin(dp[r+1], dp[i]+2*d+max(t-2*d, 0LL));
		}
		r--;
		if(r>=i){
			ll d = x[r]-x[i];
			chmin(dp[r+1], dp[i]+2*d+max(t-2*d, 0LL));
		}
		if(i>=1) chmin(dp[i+1], dp[i]+2*(x[i]-x[i-1]));
	}
	cout<<dp[n]+e<<endl;
	rep(i, n+1) cerr<<dp[i]<<endl;
	return 0;
}


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

int n;
char s[1000001];
int O[1000000], I[1000000], a, b;
bool ok(int t) {
	if (a < t || b < t)return false;
	int p = n - 1;
	rep(i, t) {
		p = min(p - 1, O[i] - 1);
		while (0 <= p && (s[p] == 'O' || (s[p] == 'I'&&p >= I[t - 1])))p--;
		if (p < 0)return false;
	}
	return true;
}
int main() {
	scanf("%d%s", &n, s);
	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == 'I')I[a++] = i;
		if (s[i] == 'O'&&b < a)O[b++] = i;
	}
	int l = 0, r = n / 3;
	while (l != r) {
		int t = (l + r) / 2;
		if (r - l == 1)t = r;
		if (ok(t))l = t;
		else r = t - 1;
	}
	printf("%d\n", l);
}

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

int main() {
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> a(A);
    vector<int> b(B);
    vector<pair<int, int>> xy(M);
    vector<int> c(M);
    int a_min = 1000000;
    int b_min = 1000000;

    for(int i = 0; i < A; i++) {
        cin >> a.at(i);
        a_min = min(a_min, a.at(i));
    }
    for(int i = 0; i < B; i++) {
        cin >> b.at(i);
        b_min = min(b_min, b.at(i));
    }
    int x, y;
    for(int i = 0; i < M; i++) {
        cin >> xy.at(i).first >> xy.at(i).second >> c.at(i);
    }

    int ans = a_min + b_min;
    for(int i = 0; i < M; i++) {
        ans =
            min(a.at(xy.at(i).first - 1) + b.at(xy.at(i).second - 1) - c.at(i),
                ans);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
#define INF (1<<28)
 
struct edge{int to,cost;};
struct state{
  int pos,pos2,cost;
  bool operator < (const state &p)const{
    return cost > p.cost;
  }
};
 
vector<edge> G[1005];
int T[1005][1005];
int n,m,k,p;
vector<int> cpoint;
 
int di[1005][(1<<13)];
 
void solve(){
  for(int i=0;i<1005;i++)
    for(int j=0;j<(1<<13);j++)
    di[i][j]=INF;
 
  di[p][0]=0;
  priority_queue<state> Q;
  Q.push((state){p,0,0});
  while(!Q.empty()){
    state s=Q.top();Q.pop();
    if(s.pos2+1==(1<<(k+k))){
      cout<<s.cost<<endl;
      return;
    }
    if(s.cost>di[s.pos][s.pos2])continue;
    for(int i=1;i<(int)cpoint.size();i++){
      int to=cpoint[i];
      int ncost=s.cost+T[s.pos][to];
      int npos2=s.pos2;
      int a=(i-1)/2,b=a+k;
      if(i%2){
    npos2|=(1<<a);
      }else if(i%2==0&&(s.pos2>>a)&1){
    npos2|=(1<<b);
      }
      if(ncost>=di[to][npos2])continue;
      di[to][npos2]=ncost;
      Q.push((state){to,npos2,ncost});
    }
  }
  cout<<"Cannot deliver"<<endl;
}
 
void dijkstra(int si){
  int d[1005];
  for(int i=0;i<1005;i++)d[i]=INF;
  d[si]=0;
  priority_queue<state> Q;
  Q.push((state){si,si,0});
  while(!Q.empty()){
    state s=Q.top();Q.pop();
    if(s.cost>d[s.pos])continue;
    for(int i=0;i<(int)G[s.pos].size();i++){
      edge e=G[s.pos][i];
      int ncost=s.cost+e.cost;
      if(ncost<d[e.to]){
    d[e.to]=ncost;
    Q.push((state){e.to,e.to,ncost});
      }
    }
  }
 
  for(int i=0;i<n;i++)T[si][i]=d[i];
}
 
void init(){
  cpoint.clear();
  for(int i=0;i<1005;i++){
    G[i].clear();
    for(int j=0;j<1005;j++){
      T[i][j]=INF;
    }
  }
}
 
 
int main(){
  while(cin>>n>>m>>k>>p){
    init();
    p--;
    cpoint.push_back(p);
    for(int i=0;i<m;i++){
      int x,y,z;
      cin>>x>>y>>z;
      x--,y--;
      G[x].push_back( (edge){y,z} );
      G[y].push_back( (edge){x,z} );
    }
    for(int i=0;i<k;i++){
      int a,b;
      cin>>a>>b;
      a--,b--;
      cpoint.push_back(a);
      cpoint.push_back(b);
    }
    for(int i=0;i<(int)cpoint.size();i++)
      dijkstra(cpoint[i]);
 
    //    for(int i=0;i<n;i++)      for(int j=0;j<n;j++)  cout<<i<<" "<<j<<" "<<T[i][j]<<endl;
 
 
    solve();
  }
  return 0;
}

Measured memory_bytes: 37496
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val (x, t) = listOfInt()
    with(x - t) {
        println(if (this > 0) this else 0)
    }
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt()= listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 37876
from bisect import bisect_right

N, *A = map(int, open(0).read().split())

INF = 10 ** 10
dp = [INF] * N
for i in range(N):
    dp[bisect_right(dp, -A[i])] = -A[i]

print(max(i + 1 for i, v in enumerate(dp) if v < INF))


Measured memory_bytes: 71612
import java.util.Scanner;
import java.util.ArrayList;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<String> before = new ArrayList<String>();
		String x;
		int sum = 0;
		while (true) {
			x = sc.next();
			if (x.equals("0")) {
				break;
			}
			before.add(x);
		}
		char[] c;
		for (int i = 0; i < before.size(); i++) {
			c = (before.get(i)).toCharArray();
			for (int j = 0; j < c.length; j++) {
				sum += (c[j] - '0');
			}
			System.out.println(sum);
			sum = 0;
		}
		sc.close();
	}
}


Measured memory_bytes: 26024
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };
#define MOD 1000000007
#define ARRAY_MAX 100005

const int INF = 1e9 + 7;

int dp[(1 << 17)];//各ステージのクリア状況

struct area {
	int width;
	int depth;
};

int main() {

	int n, w, d;
	while (cin >> n >> w >> d,n|w|d)
	{
		area mp[150];
		mp[1] = area({ w,d });
		int index_end = 2;//格納されている図形の最後のインデックス番号
	
		for (int i = 0; i < n; i++)
		{
			int p, s;//識別番号、分ける点
			cin >> p >> s;
			area tmp = mp[p];//分けるもとになる図形番号の図形の縦、横の長さ
			s %= (tmp.width + tmp.depth);//上の辺と右の辺から引けばよい

			for (int  j = p;  j < index_end-1;  j++)
			{
				//識別番号のずれを修正
				swap(mp[j], mp[j + 1]);
			}

			if (s < tmp.width)
			{
				//縦方向に分割
				int mini_width = min(s, tmp.width - s);//短い方

				mp[index_end-1] = area({ mini_width,tmp.depth });
				mp[index_end] = area({tmp.width - mini_width,tmp.depth });
				index_end++;
			}
			else
			{
				//横方向分割
				s -= tmp.width;
				int mini_depth = min(s, tmp.depth - s);
				mp[index_end - 1] = area({ tmp.width,mini_depth });
				mp[index_end] = area({ tmp.width,tmp.depth - mini_depth });
				index_end++;
			}
		}
		vector<int> ans;

		for (int i = 1; i < index_end; i++)
		{
			ans.push_back(mp[i].width*mp[i].depth);
		}

		sort(ans.begin(), ans.end());

		for (int i = 0; i < ans.size(); i++)
		{
			if (i == 0) {
				cout << ans[i];
			}
			else
			{
				cout << " " << ans[i];
			}
		}
		cout << endl;
		ans.shrink_to_fit();
	}
	return 0;
}


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

#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i+=a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

int main() {
    int n, cnt=0;
    string s;
    cin >> n;
    cin >> s;
    rep(i, n-2){
        if(s[i]=='A'){
            if(s[i+1]=='B'){
                if(s[i+2]=='C'){
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    bool f = true;
    string s; cin >> s;
    int n = s.length();
    rep(i, (n-1)/2){
        if(s[i] != s[n-i-1]) f = false;
    }

    rep(i, ((n-1)/2)/2){
        if(s[i] != s[(n-1)/2-i-1]) f = false;
    }
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

#include <atcoder/maxflow>

int main() {
	int N, M;
	cin >> N >> M;
	vector<string> S(N);
	REP(i, N) cin >> S[i];
	
	constexpr int dx[]{1,0,-1,0}, dy[]{0,1,0,-1};
	
	atcoder::mf_graph<int> g(N * M + 2);
	const int source = N * M, sink = N * M + 1;
	
	auto to_idx = [&](int y, int x) { return y * M + x; };
	auto isin = [&](int y, int x) { return y >= 0 && y < N && x >= 0 && x < M; };
	
	REP(i, N) REP(j, M) {
		if (((i + j) & 1) || S[i][j] == '#') continue;
		REP(k, 4) {
			int ny = i + dy[k], nx = j + dx[k];
			if (!isin(ny, nx) || S[ny][nx] == '#') continue;
			g.add_edge(to_idx(i, j), to_idx(ny, nx), 1);
		}
	}
	
	REP(i, N) REP(j, M) {
		if (S[i][j] == '#') continue;
		if ((i + j) & 1) g.add_edge(to_idx(i, j), sink, 1);
		else g.add_edge(source, to_idx(i, j), 1);
	}
	
	int ans = g.flow(source, sink);
	cout << ans << endl;
	
	vector<string> ansS = S;
	for (auto &&e : g.edges()) {
		if (e.flow == 0 || e.from == source || e.to == sink) continue;
		int y = e.from / M, x = e.from % M;
		int ny = e.to / M, nx = e.to % M;
		
		if (x > nx || y > ny) { swap(x, nx); swap(y, ny); }
		
		if (y + 1 == ny) { ansS[y][x] = 'v'; ansS[ny][nx] = '^'; }
		else { ansS[y][x] = '>'; ansS[ny][nx] = '<'; }
	}
	
	REP(i, N) cout << ansS[i] << '\n';
	cout.flush();
	return 0;
}


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

int main(){
  vector<long> trees;
  int N, K;
  
  cin >> N >> K;
  trees.resize(N);
  for(int i = 0; i < N; i++){
    cin >> trees[i];
  }
  
  sort(begin(trees), end(trees));
  
  long min = 1000000000;
  
  for(int i = 0; i < N - K + 1; i++){
    long sub = trees[i + K - 1] - trees[i];
    if(sub < min)
      min = sub;
  }
  
  cout << min << endl;
  return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            long a=sc.nextLong();
            long b=sc.nextLong();
            long temp;
            if(a==b){
                System.out.println(1+" "+a);
                continue;
            }
            
            if(a<b){
                temp=a;
                a=b;
                b=temp; //a>bにしちゃったの
            }
            
            //a = b*p + r
            //b = r*p' + r'
            long GCD=1; //最大公約数
            long LCM=a; //最小公倍数
            long c=a,d=b;
            long r;
            while(true){
                r = c%d;
                if(r!=0){
                    c = d;
                    d = r;
                }else{
                    GCD=d;
                    LCM=a*b/GCD;
                    /*
                     a=p*GCD
                     b=q*GCD pとqは互いに素
                     このとき
                     LCM=p*q*GCD
                        =p*q*GCD*GCD/GCD
                        =(p*GCD)*(q*GCD)/GCD
                        =a*b/GCD
                     よって
                     LCM=a*b/GCD                     
                     */
                    
                    break;
                }
            }
            System.out.println(GCD+" "+LCM);
            
            
        }
    }
}

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

  int n,k,x,y;
  int c = 0;

  scanf("%d",&n);
  scanf("%d",&k);
  scanf("%d",&x);
  scanf("%d",&y);
  if(k<=n){
  c = k	* x + y	* (n-k);
  }
  else
    {c = n * x;
}
  printf("%d\n",c);
  return 0;

}

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

using namespace std;

int n, m;

int main() {
    cin >> n >> m;
    int mx = 0;
    for(int i = 1; i <= sqrt(m); i++) {
        if(m % i == 0) {
            int num = m / i;
            if(num >= n)
                mx = max(mx, i);
            int xam = m / i;
            num = m / xam;
            if(num >= n)
                mx = max(mx, xam);
        }
    }
    cout << mx;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
  int a, b, c, d;
  int ab, bc, ac;
  
  scanf("%d %d %d %d", &a, &b, &c, &d);
  ac = abs(c - a);
  ab = abs(b - a);
  bc = abs(c - b);
  if(ac <= d || (ab <= d && bc <=d)) printf("Yes\n");
  else printf("No\n");
  
  return 0;
}

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

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

using namespace std;
using ll = long long;

const char* solve(int n, vector<ll>& aa, vector<ll>& ka) {

    ll y, a, k, b, q, r;

    y = 0;
    rep(i, 0, n) {
        a = aa[i];
        k = ka[i];
        if (k == 1)
            y ^= a;
        else {
            b = a;
            while (true) {
                if (b < k)
                    break;
                q = b / k;
                r = b % k;
                if (r == 0) {
                    y ^= q;
                    break;
                }
                if (q + 1 <= r) {
                    b = b - r + r % (q + 1);
                } else {
                    b -= (q + 1);
                }
            }
        }
    }
    if (y)
        return "Takahashi";
    else
        return "Aoki";
}

int main(int argc, const char * argv[]) {

    int n;
    ll a, k;
    vector<ll> aa, ka;
    
    cin >> n;
    rep(i, 0, n) {
        cin >> a >> k;
        aa.push_back(a);
        ka.push_back(k);
    }

    cout << solve(n, aa, ka) << endl;

    return 0;
}


Measured memory_bytes: 384
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val xs = readLine()!!.split(" ").map { it.toInt() }
    val sortedXs = xs.sortedDescending()
    val a = sortedXs.filterIndexed { index, value -> index % 2 == 0 }.sum()
    val b = sortedXs.filterIndexed { index, value -> index % 2 == 1 }.sum()
    println(a - b)
}

Measured memory_bytes: 36140
import java.util.Scanner;

public class Main {
    public static void main (String [] args){
        Scanner sc = new Scanner(System.in);
        int A =sc.nextInt();
        int B =sc.nextInt();
        String S =sc.next();
        boolean flag = true;
        String[] w =S.split("-");
        if (w.length != 2){
            flag = false;
        }else{
            if(w[0].length() !=A){
                flag = false;
            }
            if(w[1].length() != B){
                flag = false;
            }
        }
        if(flag){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23764