akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int nc = N;
	int digit = 0;
	int cnt = 0;
	while(nc!=0) {
	    nc = nc/10;
	    digit++;
	}
	int max = (int)Math.pow(3,digit+1);
	digit = 3;
	for(int i = 0; i<max; i++) {
	    if(i==Math.pow(3,digit)) {
		i = 1;
		digit++;
	    }
	    int n10 = i;
	    int n3 = 0;
	    int d = 1;
	    int dc =digit;
	    StringBuilder builder = new StringBuilder();
	    while(dc>0) {
		n3 = n10%3*d + n3;
		builder.insert(0,n10%3);
		d *= 10;
		n10 = n10/3;
		dc--;
	    }
	    int decode = decode753(builder.toString());
	    if(N >= decode && decode > 0) {
		cnt++;
	    }
	}
	System.out.println(cnt);
    }
    public static int decode753 ( String n3 ) {
	int d = 0;
	int digit = 10;
	int[] array = {7,5,3};
	int[] haveArray = {0,0,0};
	int cnt = 0;
	while(cnt < n3.length()){
	    char c = n3.charAt(cnt);
	    if(c == '0') {
		d = digit*d + 7;
		haveArray[0]++;
	    } else if( c == '1' ) {
		d = digit*d + 5;
		haveArray[1]++;
	    } else {
		d = digit*d + 3;
		haveArray[2]++;
	    }
	    cnt++;
	}
	if(haveArray[0] > 0 && haveArray[1] > 0 && haveArray[2] > 0) {
	    return d;
	} else {
	    return -1;
	}
    }
}

Measured memory_bytes: 46068
while (x = gets.to_i) >= 0 
    c = 1150
    c += [(x - 10), 10].min * 125 if x >= 10
    c += [(x - 20), 10].min * 140 if x >= 20
    c += (x - 30) * 160 if x >= 30
    p 4280 - c
end


Measured memory_bytes: 6872
#include<iostream>
main(){int l[4][2]={0},i=0;for(double a;std::cin>>a;i++)if(a<0.2)l[3][i%2]++;else if(a<0.6)l[2][i%2]++;else a<1.1?l[1][i%2]++:l[0][i%2]++;for(int i=0;i<4;i++)std::cout<<l[i][0]<<" "<<l[i][1]<<"\n";}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int itemCount = scan.nextInt();
		int maxWait = scan.nextInt();

		int[][] itemArray = new int[itemCount + 1][2];

		for (int i = 1; i < itemCount + 1; i++) {

			// 重さ
			itemArray[i][0] = scan.nextInt();

			// 価値
			itemArray[i][1] = scan.nextInt();
		}

		long[][] dp = new long[itemCount + 1][maxWait + 1];

		for (int i = 1; i < itemCount + 1; i++) {

			for (int w = 0; w < maxWait + 1; w++) {

				if (itemArray[i][0] <= w) {

					dp[i][w] = Math.max(
							dp[i - 1][w - itemArray[i][0]] + itemArray[i][1],
							dp[i - 1][w]);

				} else {

					dp[i][w] = dp[i - 1][w];
				}
			}
		}

		System.out.println(dp[itemCount][maxWait]);
	}
}


Measured memory_bytes: 125524
#include<unordered_map>
#include<utility>
template<typename T>
class UnionFind {
 public:
  void unite(const T& a, const T& b) {
    auto x = find(a), y = find(b);
    if(rank_[x] < rank_[y]) std::swap(x, y);
    parent_[y] = x;
    if(rank_[x] == rank_[y]) rank_[x] += 1;
  }
  T find(const T& x) {
    if(!parent_.count(x)) {
      rank_[x] = 1;
      return parent_[x] = x;
    }
    return (parent_[x] == x) ? x : (parent_[x] = find(parent_[x]));
  }
 private:
  std::unordered_map<T, T> parent_;
  std::unordered_map<T, int> rank_;
};

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

struct Point {int id, x, y;};

using LL = long long;

int main() {
  int N;
  cin >> N;
  vector<Point> P;
  for(auto i=0; i<N; ++i) {
    int x, y;
    cin >> x >> y;
    P.push_back({i, x, y});
  }

  UnionFind<int> uf;
  sort(begin(P), end(P), [](auto l, auto r) {return l.x < r.x;});
  for(auto i=1; i<N; ++i) if(P[i-1].x == P[i].x) uf.unite(P[i-1].id, P[i].id);
  sort(begin(P), end(P), [](auto l, auto r) {return l.y < r.y;});
  for(auto i=1; i<N; ++i) if(P[i-1].y == P[i].y) uf.unite(P[i-1].id, P[i].id);

  set<int> G;
  map<int, set<int>> X, Y;
  for(const auto& p: P) {
    auto g = uf.find(p.id);
    G.emplace(g);
    X[g].emplace(p.x);
    Y[g].emplace(p.y);
  }

  LL sum = 0;
  for(auto g: G) {
    LL x = X[g].size();
    LL y = Y[g].size();
    sum += x * y;
  }
  cout << sum - N << endl;
}


Measured memory_bytes: 14324
#include <cstdio>
#include <algorithm>
using namespace std;

typedef long long ll;
const int Maxn = 18;
const ll INF = 0x3f3f3f3f3f3f3f3f;

int N, A[Maxn + 5];

ll DFS(int lef, int rig, int cl, int cr) {
	if(rig - lef + 1 <= 2) return 0;
	ll ret = INF;
	for(int i = lef + 1; i < rig; i++)
		ret = min(ret, DFS(lef, i, cl, cl + cr) + DFS(i, rig, cl + cr, cr) + 1LL * (cl + cr) * A[i]);
	return ret;
}

int main() {
#ifdef LOACL
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	scanf("%d", &N);
	for(int i = 1; i <= N; i++)
		scanf("%d", &A[i]);
	printf("%lld\n", DFS(1, N, 1, 1) + A[1] + A[N]);
	return 0;
}

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

using namespace std;

const int N = 1e6 + 7;
int  n , m;
int a[N] ; 

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
   // freopen("in.in" , "r" , stdin) ;
    cin>>n ; 
    for(int i = 0 ;i < n-1;i++){
        int t ; 
        cin>>t ; 
        a[t]++ ; 
    }
    for(int i = 1 ;i <=n;i++){
        cout<<a[i] <<"\n" ; 
    }
    return 0;
}

Measured memory_bytes: 4404
/*..............................................*\
Author:Kishor Kumar Paroi
Dept:CSE-1703053
email.kishor.josephite@gmail.com
RUET,BANGLADESH
\*---------------------------*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include <sstream>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include<bits/stdc++.h>
#include<iostream>
#include<iterator>

#define max(a,b) ((a>b)?a:b)                        //finding max
#define min(a,b) ((a<b)?a:b)                        //finding min
#define Max(a,b,c) max(a,max(b,c))                  //finding max between 3 numbers
#define Min(a,b,c) min(a,min(b,c))                  //finding min between 3 numbers
#define Pi acos(-1.0)                               //defining Pi for mathematical uses
#define Clear(a) memset(a,0,sizeof(a))              //clearing memory of an array
#define setfalse(a) memset(a,false,sizeof(a))       //setting the array into false
#define settrue(a) memset(a,true,sizeof(a))         //setting the array into true
#define clrstr(a) memset(a,'\0',sizeof(a))          //setting string array to null
#define open freopen("input.txt","r",stdin)         //opening input file
#define close freopen ("output.txt","w",stdout)     //opening output file
#define Case(a) printf("Case %d: ",a)               //printing case number
#define caseh(a) printf("Case #%d: ",a)             //printing case number having '#'
#define getcase(a) scanf("%d",&a)                   //scanning case number
#define caseloop(a,b) for(a=1;a<=b;a++)             //making case loop
#define EPS 1e-9                                    //small value for avoiding preccesion error
#define LL long long                                //long long short form
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

//const int N=100*1000;
//const int mod=1e9+7;

//# define int min3(int a,int b,int c){return min(a,min(b,c));}
//#define int max3(int a,int b,int c){return max(a,max(b,c));}
//#define int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
//#define int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   int i,n,max=0,s=0;
   cin>>n;
   vector<int>v(n);
   for(i=0;i<n;i++)
    cin>>v[i];
   sort(v.begin(),v.end());
  /* for(vector<int>:: iterator it=v.begin();it!=v.end();it++)
   {
       cout<< *it << " ";
   }
   cout << "\n";
   */
   for(i=0;i<n-1;i++)
   {
       s+=v[i];
   }
   //cout<<s<<endl;
   //cout<<v[n-1]<<endl;
   if(s>v[n-1])
    cout<< "Yes"<<endl;
   else
    cout<< "No"<<endl;
    return 0;
}



Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n,a[5],mi=1000000000000000,sum;
  cin >> n;
  for(int i=0;i<5;i++){
    cin >> a[i];
    mi=min(a[i],mi);
  }
  sum = 4+(n+mi-1)/mi;
  cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline void ri(int &x){
	x=0; static char c; bool t=0;
	while(c=getchar(),c<'0'||c>'9') if(c=='-') t=1; else t=0;
	do x=x*10+c-'0'; while(c=getchar(),c>='0'&&c<='9');
	if(t) x=-x;
}
const int N=200024;
vector<int> Q[N];
int sg[N];
void dfs(int fa,int x){
	int i,l=Q[x].size(),ne;
	for(i=0;i<l;++i){
		ne=Q[x][i];
		if(ne==fa) continue;
		dfs(x,ne);
		sg[x]^=sg[ne]+1;
	}
}
int main(){
	int i,n,x,y; ri(n);
	for(i=1;i<n;++i){
		ri(x); ri(y);
		Q[x].push_back(y);
		Q[y].push_back(x);
	}
	dfs(-1,1);
	if(sg[1]==0) puts("Bob");
	else puts("Alice");
	return 0;
}

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

int main() {
	int N, C, Bmax = 0;
	cin >> N >> C;
	vector<int> A(N), B(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> B[i];
		if (B[i] > Bmax) Bmax = B[i];
	}
	long long mod = 7 + pow(10, 9);

	vector<vector<long long>> NpowC(C + 1, vector<long long>(Bmax + 1, 1));
	for (int j = 1; j <= Bmax; j++) {
		for (int i = 1; i <= C; i++) {
			NpowC[i][j] = (NpowC[i - 1][j] * j) % mod;
		}
	}

	vector<vector<long long>> Cpower(C + 1, vector<long long>(Bmax + 1, 0));
	for (int i = 0; i < C + 1; i++) {
		Cpower[i][1] = 1;
		for (int j = 2; j <= Bmax; j++) {
			Cpower[i][j] = (Cpower[i][j - 1] + NpowC[i][j]) % mod;
		}
	}

	vector<vector<long long>> DP(N + 1, vector<long long>(C + 1, 0));
	DP[0][0] = 1;
	for (int n = 0; n < N; n++) {
		for (int c = 0; c < C+1; c++) {
			long long total = 0;
			for (int k = 0; k < c + 1; k++) {
				long long frolic = Cpower[k][B[n]] - Cpower[k][A[n] - 1];
				if (frolic < 0) frolic += mod;
				total += (DP[n][c - k] * frolic) % mod;
				total %= mod;
			}
			DP[n + 1][c] = total;
		}
	}
	cout << DP[N][C] << endl;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 998244353;

signed main() {
  int n,m;
  cin>>n>>m;
  int q,p[n];
  for(int i=0;i<n;i++){
    cin>>q;
    p[i]=q-1;
  }
  int used[n]={},t=1;
  vector<int> hen[n];
  int x ,y;
  for(int i=0;i<m;i++){
    cin>>x>>y;
    hen[x-1].push_back(y-1);
    hen[y-1].push_back(x-1);
  }
  queue<int> que;
  int ans=0,b;
  for(int i=0;i<n;i++){
    if(used[i]!=0)continue;
    que.push(i);
    while(!que.empty()){
      b=que.front();
      if(used[b]<=0){
          if(used[b]==0)used[b]=t;
          if(used[b]==-1*t){
            ans++;
            
          }
          if(used[b]<0)used[b]=MOD;
          if(used[p[b]]==0)used[p[b]]=-1*t;
          if(used[p[b]]==t)ans++;
        }
      for(int j=0;j<hen[b].size();j++){
        if(used[hen[b][j]]<=0)que.push(hen[b][j]);
      }
      que.pop();
      //cerr<<used[b];
    }
    t++;
  }
cout<<ans;





  return 0;
}


Measured memory_bytes: 7936
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;
lint inf=1e9;

int main(){
  lint H,N;
  cin>>H>>N;
  lint A[N],B[N];
  REP(i,N)cin>>A[i]>>B[i];
  lint dp[H+1];
  REP(i,H)dp[i]=inf;
  dp[H]=0;
  for(int h=H;h>0;h--){
    if(dp[h]==inf)continue;
    REP(i,N){
      int c=h-A[i];
      c=max(c,0);
      dp[c]=min(dp[c],dp[h]+B[i]);
    }
  }
  cout<<dp[0]<<endl;
  return 0;
}


Measured memory_bytes: 384
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <array>

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

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

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

int main(void) {

	std:;array<int,51> c;
	c.fill(0);
	int N, M;

	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int ai, bi;
		cin >> ai >> bi;
		c[ai-1] ++;
		c[bi-1] ++;
	}

	for (int i =0; i < N; i++) {
		cout << c[i] << endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define INF 1e+8

using namespace std;

int fr[11101];
int cnt,temp,temp1,temp2;
int n,m;
int a[11100],b[11100];
int main(void){
    while(1){
        cin>>n>>m;
        if(n==0&&m==0)break;
        cnt=0;
        REP(i,11000){
            fr[i]=0;
            a[i]=0;
            b[i]=0;
        }
        REP(i,m){
            cin>>a[i]>>b[i];
            if(a[i]>b[i]){
                temp=a[i];
                a[i]=b[i];
                b[i]=temp;
            }
        }
        REP(i,m){
            REP(j,m-1){
                if(a[i]==1&&a[j]>a[i]){
                    temp1=a[i];
                    a[i]=a[j];
                    a[j]=temp1;
                    temp2=b[i];
                    b[i]=b[j];
                    b[j]=temp2;
                }
            }
        }
        /*REP(i,m){
            cout<<a[i]<<" "<<b[i]<<endl;
        }*/
        REP(i,m){
            if(a[i]==1){
                fr[a[i]]=1;
                fr[b[i]]=1;
            }
            if(fr[a[i]]==1&&fr[b[i]]==0){
                fr[b[i]]=2;
            }
            if(fr[a[i]]==0&&fr[b[i]]==1){
                fr[a[i]]=2;
            }
        }
        FOR(i,2,m){
            if(fr[i]){
                cnt++;
                //printf("%d\n",i);
            }
        }
        cout<<cnt<<endl;
    }
    return 0;
}

Measured memory_bytes: 1288
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int a, b, c;
	cin >> a >> b >> c;
	
	for(int i = 0; i < 1000000; ++i) { 
		if( a % 2 || b % 2 || c % 2 ) {
			cout << i << endl;
			return 0;
		}
		
		int at = a / 2LL;
		int bt = b / 2LL;
		int ct = c / 2LL;
		
		a = bt + ct;
		b = at + ct;
		c = at + bt;
	}
	
	cout << -1 << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint a, b;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> a >> b;
	cout << a*b << endl;
	
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stdlib.h>
#include <cmath>
#include <math.h>
#include <fstream>
#include <bitset>
#include <time.h>
#define int long long
using namespace std;
int n, xi, yi, ci;
vector<vector<int> > data, money, maxs;
vector<int> w, mw;
int ans, minimum;
void dfs(int vertex, int last){
    int max_w = 0;
    int sw = 1;
    for (int i=0; i < data[vertex].size(); i++){
        int to = data[vertex][i];
        if (to == last) {
            maxs[vertex].push_back(0);
            continue;
        }
        dfs(to, vertex);
        ans += 2 * min(w[to], n - w[to]) * money[vertex][i];
        maxs[vertex].push_back(max(w[to], n - w[to]));
        max_w = max(max_w, w[to]);
        sw += w[to];
    }
    max_w = max(max_w, n - sw);
    w[vertex] = sw;
    mw[vertex] = max_w;
}
void dfs2(int vertex, int last){
    for (int i=0; i < data[vertex].size(); i++){
        int to = data[vertex][i];
        if (to == last) {
            continue;
        }
        int mm = maxs[vertex][i];
        bool can = true;
        if (2 * mw[vertex] >= n && mw[vertex] != mm) can = false;
        if (2 * mw[to] >= n && mw[to] != mm) can = false;
        if (can) minimum = min(minimum, money[vertex][i]);
        dfs2(to, vertex);
    }
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin >> n;
    for (int i=0; i < n; i++){
        w.push_back(0);
        mw.push_back(0);
        vector<int> h1, h2, h3;
        data.push_back(h1);
        money.push_back(h2);
        maxs.push_back(h3);
    }
    ans = 0;
    for (int i=0; i < n-1; i++){
        cin >> xi >> yi >> ci;
        data[xi-1].push_back(yi-1);
        data[yi-1].push_back(xi-1);
        money[xi-1].push_back(ci);
        money[yi-1].push_back(ci);
    }
    dfs(0, -1);
    minimum = 1e18;
    dfs2(0, -1);
    cout << ans - minimum << endl;
    return 0;
}


Measured memory_bytes: 26316
ary = [list(map(int, input().split())) for i in range(3)]
a = [0]
b = []
ans = 0

for i in range(3):
    b_i = ary[0][i] - a[0]
    b.append(b_i)

for i in range(1, 3):
    a_i = ary[i][0] - b[0]
    a.append(a_i)

for i in range(3):
    for j in range(3):
        if ary[i][j] == a[i] + b[j]:
            ans += 1

if ans == 9:
    print('Yes')
else:
    print('No')

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

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

void solve()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    cin>>arr[i];
    int q;
    cin>>q;
    unordered_map<long long int,long long int>m;
     long long int sum=0;
    for(int i=0;i<n;i++)
   { 
       m[arr[i]]++;
       sum+=arr[i];
   }
    for(int i=0;i<q;i++)
    {
       long long int b,c;
        cin>>b>>c;
        if(m.find(b)!=m.end())
        {sum= sum - (b*m[b])+(c*m[b]);
        cout<<sum<<endl;
        m[c]=m[c]+m[b];
        m.erase(b);
        }
        else
        cout<<sum<<endl;
    }
}


int main()
 {  fast();
   solve();
	return 0;
}

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

int main(){
  int N;
  cin>>N;
  vector<int64_t> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec[i];
  }
  
  int zero=0;
  for(int i=0;i<N;i++){
    if(vec[i]==0)
      zero++;
    if(zero>0){
      cout<<0<<endl;
      return 0;
    }
  }
  
  int64_t s=1;
  for(int i=0;i<N;i++){
    if(vec[i]>1000000000000000000/s){
      s=-1;
      break;
    }
    s*=vec[i];
  }
  cout<<s<<endl;
}

Measured memory_bytes: 4024
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#include<set>

using namespace std;
using LLI = long long int;

//struct UnionFind {
//	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
//
//	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
//		for (int i = 0; i < N; i++) par[i] = i;
//	}
//
//	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
//		if (par[x] == x) return x;
//		return par[x] = root(par[x]);
//	}
//
//	void unite(int x, int y) { // xとyの木を併合
//		int rx = root(x); //xの根をrx
//		int ry = root(y); //yの根をry
//		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
//		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
//	}
//
//	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
//		int rx = root(x);
//		int ry = root(y);
//		return rx == ry;
//	}
//};

int main(void) {
	LLI A, B, C;
	cin >> A >> B >> C;
	if (A+B >= C) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

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

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

int main() {

    int N, K, Q;
    int t;
    int AN[100000];
    cin >> N >> K >> Q;

    REP(i, N) AN[i] = 0;

    REP(i, Q) {
        cin >> t;
        AN[t-1]++;
    }

    REP(i, N){
        if(K - Q + AN[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 2000000000;
using namespace std;

const int N = 60;

//n個を選ぶ組み合わせの中、k個を選ぶ組み合わせの割合。
void Pascals(long long m[N][N]){
    m[0][0] = 1;
    range(i,1,55){
        rep(j,i + 1){
            if(j == 0) m[i][j] = m[i - 1][j] / 1;
            else if(j == i) m[i][j] = m[i - 1][j - 1] / 1;
            else m[i][j] = (m[i - 1][j] + m[i - 1][j - 1]) / 1;
        }
    }
}


int main(){
    int n, a, b;
    cin >> n >> a >> b;

    vector<double> v;
    map<double, int> have, need;
    rep(i,n){
        double x;
        cin >> x;
        have[x]++;
        v.emplace_back(x);
    }

    sort(all(v), greater<double>());
    double sum = 0;
    rep(i,a){
        sum += v[i];
        need[v[i]]++;
    }
    cout << fixed << setprecision(9) << sum / a << endl;

    long long ans = 1;
    long long m[N][N];
    Pascals(m);
    for(auto it:need){
        ans *= m[have[it.first]][it.second ];
    }
    range(i,a + 1,min(have[v[0]] + 1, b + 1)){
        ans += m[have[v[0]]][i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#define lowbit(x) ((x)&(-x))
#define sc scanf
#define debug1(x) cout<<x<<" "
#define debug2(x) cout<<x<<"\n"
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
typedef long long ll;
const ll inf=1e18;
const int N=2e5+10;
using namespace std;
int gcd(int a,int  b)
{
	return b==0?a:gcd(b,a%b);
}

int main()
{
	int k,n;
	cin>>n>>k;
	int ans=k;
	for(int i=1;i<n;i++)
	ans*=(k-1);
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int r,c,n,cnt=0;
pair<int,int>a[200005];
int stk[200005];
bool chk(int x,int y){return x==0||y==0||x==r||y==c;}
void chg(int i,int x,int y)
{
	if(x==0)a[cnt++]=make_pair(r+r+c+c-y,i);
	else if(x==r)a[cnt++]=make_pair(r+y,i);
	else if(y==0)a[cnt++]=make_pair(x,i);
	else if(y==c)a[cnt++]=make_pair(r+c+r-x,i);
}
int main()
{
	scanf("%d%d%d",&r,&c,&n);
	for(int i=1;i<=n;i++)
	{
		int x1,y1,x2,y2;
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		if(chk(x1,y1)&&chk(x2,y2))
		{
			chg(i,x1,y1);
			chg(i,x2,y2);
		}
	}
	sort(a,a+cnt);
	int t=0;
	for(int i=0;i<cnt;i++)if(t&&stk[t-1]==a[i].second)t--;else stk[t++]=a[i].second;
	if(!t)printf("YES\n");else printf("NO\n");
	return 0;
}

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

int main(void)
{
    int N;
    cin >> N;
    vector<int> vec(N);
    vector<int> f(N, 0);
    for (int i = 0; i < N; ++i)
        cin >> vec[i];
    for (int i = N - 1; i > 0; --i)
    {
        if (vec[i - 1] <= vec[i])
            continue;
        if (f[i - 1] == 1)
            continue;
        --vec[i - 1];
        ++f[i - 1];
        if (vec[i - 1] > vec[i])
        {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 4040
#include <stdio.h>

int main()
{
  int n;
  scanf("%d",&n);
  
  char s[n+1];
  scanf("%s",s);

  if(n%2 ==1){
    puts("No");
    return 0;
  }
  for(int i=0;i<(n/2);i++){
    if(s[0+i]!=s[n/2 + i]){
      puts("No");
      return 0;
    }
    }
  puts("Yes");
  return 0;
    
  }

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()  {
  int N; cin >> N;
  vector<int> H(N);
  for (int i = 0; i < N; i++) cin >> H[i];

  int res = 0;
  int current_max = 0;
  for (int i = 0; i < N; i++) {
    
    if (H[i] >= current_max) res++;

    if (current_max < H[i]) current_max = H[i];
  }
cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ini(a,i) memset(a,i,sizeof(a))
#define pb push_back
#define ll long long

int main()
{
	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//ll tt;	cin>>tt;	while(tt--)
	{
		ll n,i,d,count;
		cin>>n;
		
		i=100;count=0;
		while(i<n)
		{
			d=i/100;
			i+=d;
			count++;
		}

		cout<<count;
 	
 	}
	cerr<<" Execution : "<<(1.0*clock())/CLOCKS_PER_SEC<<"s \n";
		
		
return 0;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
typedef long double ld;
using namespace std;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    //positive and negative signs will be used to indicate directions
    //right and upward are defined as positive
    int dx = x2 - x1;
    int dy = y2 - y1;
    cout << x2 - dy << ' ' << y2 + dx << ' ' << x1 - dy << ' ' << y1 + dx;

    return 0;
}


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

typedef long long int ll;

typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<string,string> Pstring;
typedef pair<double,double> Pdouble;

#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define Precision(i) cout << fixed << setprecision(i)

const double PI=3.14159265358979323846;
const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = 1e18;

int main() {

  ll n;
  cin >> n;
  set<string> x;
  vector<string> px(n);
  REP(i,n) cin >> px.at(i);
  REP(i,n) x.insert(px.at(i));

  cout << x.size() <<endl;
}

Measured memory_bytes: 25084
use proconio::input;
fn main() {    
    input!{
        n: i64,
        m: i64,
        mut ab: [[i64; 2]; n]
    }
    let mut ans = 0;
    ab.sort();
    ab.iter()
    .try_fold((0, 0), |(acc, sum), x| {
        if acc == m {
            ans = sum;
            None
        }
        else if  acc + x[1] < m{
            let s = sum + x[0]*x[1];
            ans = s;
            Some((acc+x[1], s))
        }
        else{            
            let s = sum + x[0]*(m-acc);
            ans = s;
            Some((m, s))
        }});

    println!{"{}", ans};
}


Measured memory_bytes: 9912
--{-# LANGUAGE OverloadedStrings #-}
--{-# LANGUAGE OverloadedLists   #-}
{-# LANGUAGE BangPatterns      #-} --引数に!
{-# LANGUAGE MultiWayIf        #-}
{-# LANGUAGE TupleSections     #-}

import Data.Bits
import Data.Foldable (foldlM,foldrM)
import Data.Maybe (fromJust)
import Data.List
--import Data.Matrix.Unboxed
import Data.Array  --変数衝突
import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.ST
import Data.Graph
--import Data.Vector as V　--変数衝突
import qualified Data.Vector.Unboxed as V
import Control.Monad
import Control.Monad.State
import Control.Monad.ST
import qualified Data.ByteString.Lazy.Char8 as B

solve :: Int  -> Int  -> [(Int,Int)]-> Bool
solve n t [] = True
solve n t ((a,b):ls)= if t+a > b then False else solve n (t+a) ls

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

main0 :: B.ByteString -> String
main0 cont =
   let remLines0 = map B.words (B.lines cont)
       [n']:remLines1 = remLines0
       n = readBInt n'
   in if solve n 0 $ sortOn snd $ map (\[x,y] -> (readBInt x, readBInt y)) $ take n remLines1 then "Yes" else "No"


main :: IO ()
main =  putStrLn . main0 =<< B.getContents


Measured memory_bytes: 104700
#include<bits/stdc++.h>
using namespace std;
long long a[294128];
long long b[329282];
main()
{
long long n;
cin >> n;
long long s1=0,s2=0;
for (long long i=0; i < n; i++)
{
    cin >>a[i];
    s1+=a[i];
}
long long A=0,B=0;
for (long long i=0; i < n; i++)
{    cin >>b[i];
    s2+=b[i];
    if(a[i] <=b[i])
    {
        A+=(b[i]-a[i]+1)/2;
        B+=(b[i]+a[i])%2;
    }
    else B+=a[i]-b[i];
}
if(A>=B) cout <<"Yes"<< endl;
else cout <<"No"<<endl;

}


Measured memory_bytes: 2432
#include <stdio.h>

float cross(float x1,float y1,float x2,float y2,float xp,float yp){
  return (x1-xp)*(y2-yp)-(y1-yp)*(x2-xp);
}

int main(){
  float x[4],y[4];

  while(~scanf("%f%f%f%f%f%f%f%f",x,y,x+1,y+1,x+2,y+2,x+3,y+3)){
    int i,ans=1;
    float j=0;
    for(i=0;i<3;i++){
      float a = cross(x[i],y[i],x[(i+1)%3],y[(i+1)%3],x[3],y[3]);
      if(a==0||a*j<0) ans = 0; else j = a;
    }
    puts(ans?"YES":"NO");
  }

  return 0;
}

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

const int N = 100005;

vector<ll> d(N, -1);
vector<P> G[N];
int c[N];

void dfs(int x) {
  rep(i, G[x].size()) {
    P p = G[x][i];
    int to = p.first;
    if (d[to] != -1) continue;
    d[to] = d[x] + p.second;
    c[to] = d[to] % 2;
    dfs(to);
  }
  return;
}

int main() {
  int n;
  cin >> n;
  rep(i, n-1) {
    int u, v, w;
    cin >> u >> v >> w;
    u--; v--;
    G[u].push_back(make_pair(v, w));
    G[v].push_back(make_pair(u, w));
  }
  d[0] = 0;
  c[0] = 0;
  dfs(0);
  rep(i, n) cout << c[i] << endl;
  return 0;
}

Measured memory_bytes: 11880
#include <iostream>

using namespace std;

int main(){
    int h;
    int w;
    for(int i = 0; i < 300; i++){
        cin >> h >> w;
        if(h == 0 && w == 0){
            break;
        }
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                cout << "#";
            }
            cout << "" << endl;
        }
        cout << "" << endl;
    }
}


Measured memory_bytes: 3092
#include <stdio.h>
#include <stdlib.h>

int main(){
	long *towns;
	long i, N;
	long A, B;
	long *distance;
	long tiredness=0;

	scanf("%ld %ld %ld", &N, &A, &B);
	towns = (long*)malloc(sizeof(long) * N);

	for(i=0; i<N; i++){
		scanf("%ld", &towns[i]);
	}

	for(i=0; i<N-1; i++){
		if(B < A * (towns[i+1] - towns[i])){	//テレポートした方がコストが低い場合
			tiredness += B;
		}else{
			tiredness += A * (towns[i+1] - towns[i]);
		}
	}

	printf("%ld\n", tiredness);

	

	return 0;
}


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

#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> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define INF 1000000000007
#define MOD 1000000007
#define ARRAY_MAX 3005

int main(){

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




    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
long long upper,counter;
void solve(long long num,long long three,long long five,long long seven){
    if(num>upper){
        return;
    }
    if(three>=1&&five>=1&&seven>=1){
     counter++;
    }
    solve((num*10)+3,three+1,five,seven);
    solve((num*10)+5,three,five+1,seven);
    solve((num*10)+7,three,five,seven+1);
}
int main()
{
cin>>upper;
solve(0,0,0,0);
cout<<counter<<endl;



    return 0;
}


Measured memory_bytes: 3596
# -*- coding: utf-8
a = int(input())
b = [a]
i = 1
while True:
    if a % 2 == 0:
        a = a//2
    else :
        a = 3*a+1
    i+=1
    if a in b:
        print(i)
        break
    b.append(a)

Measured memory_bytes: 61884
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

int main(){
	int n;

	std::vector<long long> aList;
	std::vector<long long> edge;

	std::cin>>n;

	aList.resize(n);
	for(int i=0; i<n; i++)
		std::cin>>aList[i];

	std::sort(aList.begin(), aList.end(), [](long long x, long long y){return x>y;});

	long long tmp=0;
	for(int i=0; i<n; i++){
		if(tmp==0)
			tmp= aList[i];
		else{
			if(tmp==aList[i]){
				edge.push_back(aList[i]);
				tmp=0;
			}
			else{
				tmp= aList[i];
			}
		}
	}

	if(edge.size()<2)
		std::cout<<0<<std::endl;
	else
		std::cout<<edge[0]*edge[1]<<std::endl;
	

	return 0;

}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
      ll x,k;
        cin>>k>>x;
        for(ll i=x-k+1;i<=x+k-1;i++)
        cout<<i<<" ";
  }
  return 0;
}

Measured memory_bytes: 256
package main

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

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var W, H, N int
	con.Scan(&W, &H, &N)
	M := make([][]bool, H)
	for i := range M {
		M[i] = make([]bool, W)
	}
	for i := 0; i < N; i++ {
		var x, y, a int
		con.Scan(&x, &y, &a)
		switch a {
		case 1:
			for j := 0; j < x; j++ {
				for k := 0; k < H; k++ {
					M[k][j] = true
				}
			}
		case 2:
			for j := x; j < W; j++ {
				for k := 0; k < H; k++ {
					M[k][j] = true
				}
			}
		case 3:
			for j := 0; j < y; j++ {
				for k := 0; k < W; k++ {
					M[j][k] = true
				}
			}
		case 4:
			for j := y; j < H; j++ {
				for k := 0; k < W; k++ {
					M[j][k] = true
				}
			}
		}
	}
	c := 0
	for i := range M {
		for _, a := range M[i] {
			if !a {
				c++
			}
		}
	}
	con.Println(c)
	return nil
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T> bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> ostream &operator<<(ostream &os, vector<T> v) {
    for (int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
    for (auto &e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << max({a + b, a - b, a * b}) << endl;
}


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


int main() {
  int a,b,c;
  
  cin >> a >> b >> c;
  
  set<int> val{a,b,c};
  
  if(val.size() == 2)
    cout << "Yes";
  else
    cout << "No";
  
  
}

Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let s: Vec<char> = input::<String>().chars().collect();

    let x = s[..2].iter().cloned().collect::<String>();
    let y = s[2..].iter().cloned().collect::<String>();
    let x = x.parse::<i32>().ok().unwrap();
    let y = y.parse::<i32>().ok().unwrap();

    if 0 < x && x < 13 && 0 < y && y < 13 {
        println!("AMBIGUOUS");
    } else if 0 < x && x < 13 {
        println!("MMYY");
    } else if 0 < y && y < 13 {
        println!("YYMM");
    } else {
        println!("NA");
    }
}


Measured memory_bytes: 4352
import bisect
n=int(input())
A=list(map(int,input().split()))
AA=[0]*n
AAA=[0]*n
for i in range(n):
  AA[i]=i+1-A[i]
  AAA[i]=A[i]+i+1
AA.sort()
AAA.sort()
ans=0
for i in range(n):
  ans=ans+bisect.bisect_right(AA,A[i]+i+1,lo=0, hi=len(AA))-bisect.bisect_left(AA,A[i]+i+1,lo=0, hi=len(AA))
  ans=ans+bisect.bisect_right(AAA,i+1-A[i],lo=0, hi=len(AAA))-bisect.bisect_left(AAA,i+1-A[i],lo=0, hi=len(AAA))
print(ans//2)

Measured memory_bytes: 92656
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>

struct card {
    char suit;
    int value;
};

void bubble(int n, struct card* c)
{
    for (int i = 0; i < n; ++i) {
        for (int j = n-1; j > i; --j) {
            if (c[j].value < c[j-1].value) {
                char cbuf    = c[j].suit;
                int  vbuf    = c[j].value;
                c[j].value   = c[j-1].value;
                c[j].suit    = c[j-1].suit;
                c[j-1].value = vbuf;
                c[j-1].suit  = cbuf;
            }
        }
    }
}

void select(int n, struct card* c)
{
    for (int i = 0; i < n; ++i) {
        int mini = i;
        for (int j = i; j < n; ++j) {
            if (c[j].value < c[mini].value) {
                mini = j;
            }
        }
        char cbuf    = c[i].suit;
        int  vbuf    = c[i].value;
        c[i].value   = c[mini].value;
        c[i].suit    = c[mini].suit;
        c[mini].value = vbuf;
        c[mini].suit  = cbuf;
    }
}

bool isStable(int n, struct card* c, struct card* orig)
{
    for (int i = 1; i <= 9; ++i) {
        std::vector<char> modCharList;
        std::vector<char> orgCharList;
        for (int j = 0; j < n; ++j) {
            if (c[j].value == i) {
                modCharList.push_back(c[j].suit);
            }

            if (orig[j].value == i) {
                orgCharList.push_back(orig[j].suit);
            }
        }

        if (modCharList != orgCharList) {
            return false;
        }
    }

    return true;
}

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

    struct card a[n] = {};
    struct card b[n] = {};
    struct card orig[n] = {};
    for (int i = 0; i < n; ++i) {
        std::string s;
        std::cin >> s;
        a[i].suit  = b[i].suit  = orig[i].suit  = s[0];
        a[i].value = b[i].value = orig[i].value = (int)(0b00001111 & (char)s[1]);
    }

    bubble(n, a);

    for (int i = 0; i < n; ++i) {
        std::cout << a[i].suit << a[i].value;
        if (i == (n-1)) {
            std::cout << std::endl;
        } else {
           std::cout << " ";
        }
    }
    std::cout << (isStable(n, a, orig) ? "Stable" : "Not stable") << std::endl;

    select(n, b);

    for (int i = 0; i < n; ++i) {
        std::cout << b[i].suit << b[i].value;
        if (i == (n-1)) {
            std::cout << std::endl;
        } else {
           std::cout << " ";
        }
    }
    std::cout << (isStable(n, b, orig) ? "Stable" : "Not stable") << std::endl;

    return 0;
}


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

#define ll long long
#define MAX 300005
#define pp pair<int,pair<int,int>>
#define pb push_back
#define mod 1000000007

using namespace std;

/*
 * author: Kruti_20
 */

ll power(ll x, ll y);

ll gcd(ll a, ll b);

ll dp[(1 << 22)];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int a[n + 1][n + 1];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) cin >> a[i][j];
    }
    dp[0] = 1;
    for (int i = 1; i < (1 << n); i++) {
        int cnt = __builtin_popcount(i);
        for (int j = 0; j < n; j++) {
            if (((1 << j) & i) && a[j][cnt - 1]) dp[i] += dp[i ^ (1 << j)];
            dp[i] %= mod;
        }
    }
    cout << dp[(1 << n) - 1];
    return 0;
}


ll power(ll x, ll y) {
    ll res = 1;
    x = x % mod;
    while (y > 0) {
        if (y & 1) res = (res * x) % mod;
        y = y >> 1;
        x = (x * x) % mod;
    }
    return res;
}

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

Measured memory_bytes: 18688
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		
		int[] dic=new int[6];
		String s;
		
		
		for(int i=0;i<6;i++){
			dic[i]=scan.nextInt();
		}
		s=scan.next();
		int tmp;
		for(int i=0;i<s.length();i++){
			if(s.charAt(i)=='N'){
				tmp=dic[0];
				dic[0]=dic[1];
				dic[1]=dic[5];
				dic[5]=dic[4];
				dic[4]=tmp;
			}else if(s.charAt(i)=='E'){
				tmp=dic[0];
				dic[0]=dic[3];
				dic[3]=dic[5];
				dic[5]=dic[2];
				dic[2]=tmp;
			}else if(s.charAt(i)=='W'){
				tmp=dic[0];
				dic[0]=dic[2];
				dic[2]=dic[5];
				dic[5]=dic[3];
				dic[3]=tmp;
			}else{
				tmp=dic[0];
				dic[0]=dic[4];
				dic[4]=dic[5];
				dic[5]=dic[1];
				dic[1]=tmp;
			}
		}
		
		System.out.println(dic[0]);
		
		scan.close();
	}
}

Measured memory_bytes: 17328
def main():
    # initialize
    _ = int(input())
    nums = [int(n) for n in input().split(' ')]

    hash_table = {}
    for n in nums:
        if n in hash_table.keys():
            hash_table[n] += 1
        else:
            hash_table[n] = 1

    ans_cash = {}
    for n in nums:
        num_n = hash_table[n]
        if num_n in ans_cash.keys():
            ans = ans_cash[num_n]
        else:
            ans = 0
            for k, v in hash_table.items():
                if k == n:
                    v -= 1
                ans += v * (v - 1) / 2 if v > 1 else 0
            ans_cash[num_n] = ans
        print(int(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 26140