akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
#define int long long

template<typename T>
struct MP {
    int n;
    T t;
    vector<int> a;
    MP() {}
    MP(const T& t): t(t) {
        n = t.size();
        a = vector<int>(n+1);
        a[0] = -1;
        int j = -1;
        for (int i = 0; i < n; ++i) {
            while (j != -1 && t[j] != t[i]) j = a[j];
            j++;
            a[i+1] = j;
        }
    }
    int operator[](int i) { return a[i]; }
    vector<int> findAll(const T& s) {
        vector<int> res;
        int j = 0;
        for (int i = 0; i < s.size(); ++i) {
            while (j != -1 && t[j] != s[i]) j = a[j];
            j++;
            if (j == n) {
                res.push_back(i-j+1);
                j = a[j];
            }
        }
        return res;
    }
};
const int MX = 500005;
int to[MX];
bool used[MX];
bool visited[MX];
int path[MX];

bool dfs (int v) {
    if (visited[v]) return false;
    if (used[v]) return true;
    visited[v] = true;
    if (to[v]==-1) {
        path[v] = 0;
        used[v] = true;
        visited[v] = false;
        return true;
    }
    
    bool res = dfs(to[v]);
    if (!res) return false;
    path[v] = path[to[v]] + 1;
    
    visited[v] = false;
    used[v] = true;
    return true;
}

signed main(){
    string s, t;
    cin >> s >> t;
    string temp = s;
    int ns = s.size();
    int nt = t.size();
    while (temp.size()<=ns+nt+2) {
        temp += s;
    }
    
    MP<string> mp(t);
    
    
    vector<int> v = mp.findAll(temp);
    
    //debug(v.size());
    rep(i, ns) {
        to[i] = -1;
        path[i] = 0;
    }
    
    for (int i: v) {
        if (i<ns) {
            to[i] = ((i+nt)%ns);
        }
    }
    
    int ans = 0;
    rep(i, ns) {
        //if (to[i]==-1) continue;
        bool res = dfs(i);
        if (!res) {
            cout << "-1" << endl;
            return 0;
        }
    }
    rep(i, ns) {
        ans = max(ans, path[i]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 32552
#include<bits/stdc++.h>
using namespace std;
#define DEBUG 0
#if DEBUG
#define PRINT 1
#else
#define PRINT 0
#endif // DEBUG

int main()
{
#if DEBUG
    freopen("test.txt","r",stdin);
#endif // DEBUG
#if PRINT
    printf("===DEBUG===\n");
#endif
string str1,str2;
    cin>>str1;
    cin>>str2;
    str1+=str1;
    if(str1.find(str2)==string::npos)
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
const ll INF = 1LL<<60;
typedef pair<ll, ll> P;

int main() {
    cin>>N;
    ll sum = 0;
    reps(i,1,N+1){
        if(i%3 != 0 && i%5 != 0) sum += i;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3636
n=int(input())
if n%2==0:
    print((n**2-2*n)//2)
    for i in range(1,n):
        for j in range(i+1,n+1):
            if j!=n-i+1:
                print(i,j)
else:
    print((n**2-2*n+1)//2)
    for i in range(1,n):
        for j in range(i+1,n+1):
            if j!=n-i:
                print(i,j)

Measured memory_bytes: 9160
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int h,w,k;cin>>h>>w>>k;
	vector<vector<ll>> dp(110,vector<ll>(10,0LL));
	dp[0][0] = 1LL;
	for(int i = 0; i <h; i++) {
		for(int j = 0; j < w; j++) {
			for(int bit = 0; bit < (1 << (w-1)); bit++) {
				bool flag = false;
				for(int l = 0; l < w - 2; l++) {
					if (((bit >> l) & 1) && ((bit >> (l + 1)) & 1)){
						flag = true;
					}
				}
				if (flag) {
					continue;
				}
				else{
						if ((bit >> j) & 1){
							dp[i + 1][j + 1] += dp[i][j]; 
							dp[i + 1][j + 1] %= mod;
						}
						else if (j > 0 && ((bit >>(j - 1)) & 1)){
							dp[i + 1][j - 1] += dp[i][j]; 
							dp[i + 1][j - 1] %= mod;
						}
						else{
							dp[i + 1][j] += dp[i][j];
							dp[i + 1][j] %= mod;

						}
				}
			}
		}
	}
	cout << dp[h][k - 1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	long long i, j;
	for(i=0; i<(1 << n); i++)
	{
		cout << i << ":";
		for(j=0; j<n; j++)
		{
			if(i & (1 << j)) cout << " " << j;
		}
		cout << endl;
	}
	return 0;
}


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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"

void Main() {
    int n, d;
    cin >> n >> d;

    int w = d * 2 + 1;
    int ans = (n + (w - 1)) / w;
    cout << ans << "\n";
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,sum=1,i=1;
    cin>>n;
    while(n>1)
    {
        n=floor(n/2);
        sum = sum + pow(2,i);
        i++;
    }
    cout<<sum;
    return 0;
}

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

int main(){
    int N;
    long long cnt = 0;

    cin >> N;

    
    for(int i = 1;i <= N;i++){
        if(i % 3 == 0) continue;
        if(i % 5 == 0) continue;
        else cnt += i;
    }

    cout << cnt;

    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    vector<int> h(n);
    rep(i,n) cin>>h[i];//i-1番目はHi
    vector< vector<int> > array(n);
    rep(i,m)
    {
        int a,b;
        cin>>a>>b;
        array[a-1].push_back(b-1);
        array[b-1].push_back(a-1);
    }

    int cnt=0;
    rep(i,array.size())
    {
        bool flag=true;
        rep(j,array[i].size())
        {
            if(array[i].size()==0) break;
            if(h[i]<=h[array[i][j]])
            {
                flag=false;
                break;
            }
        }
        if(flag) cnt++;
    }
    cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 8752
#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
	int k;
	cin >> k;
	if (k % 2 == 0) {
		cout << (k / 2)*(k / 2) << endl;
	}
	else {
		cout << ((k / 2) + 1)*(k / 2) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int hoge[6];
    hoge[0] = a + b;
    hoge[1] = a + c;
    hoge[2] = b + a;
    hoge[3] = b + c;
    hoge[4] = c + a;
    hoge[5] = c + b;
    sort(hoge,hoge+6);
    cout<<hoge[0]<<endl;
    return 0;
}

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

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

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

    // start
    char c;
    cin >> c;
    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
        cout << "vowel" << endl;
    else
        cout << "consonant" << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
import sys

N = int(input())
a=[]
a.append(0)

for i in range(N):
    a.append(int(input()))

b=[]
for i in range(N+1):
    b.append(1)

index=1
counter=1
if a[1]==2:
    print(1)
    sys.exit()

while True:
    counter+=1
    b[index]=-1
    index = a[index]
    if b[index]==-1:
        print(-1)
        break
    if a[index]==2:
        print(counter)
        break


Measured memory_bytes: 7900
#include <stdio.h>
#define NUM 100000

int n;
int A[NUM];

int pertion(int X[],int p,int r);


int main()
{
  int i,x;

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    scanf("%d",&A[i]);
  }
  x = A[n-1];
  pertion(A,0,n-1);
  printf("%d",A[0]);
  for(i = 1;i < n;i++){
    if(A[i] == x && A[i+1] > x) printf(" [%d]",A[i]);
    else printf(" %d",A[i]);
  }
  printf("\n");

  return 0;
}

int pertion(int A[],int p,int r)
{
  int i,x,x1,j;
  x = A[r];
  i = p-1;
  for(j = p;j < r;j++){
    if(A[j] <= x){
      i = i + 1;
      x1 = A[i];
      A[i] = A[j];
      A[j] = x1;
    }
  }
  x1 = A[i+1];
  A[i+1] = A[r];
  A[r] = x1;

  return i+1;
}





Measured memory_bytes: 2116
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abcdef
{
    public class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            //Input int array
            int[] inputArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            (int h, int w, int k) = (inputArray[0], inputArray[1], inputArray[2]);
            char[,] c = GetChar2d(h, w);

            var ans = 0;
            for (int i = 0; i < 1<<h; i++)
            {
                for (int j = 0; j < 1<<w; j++)
                {
                    var sharpTotal = 0;
                    for (int l = 0; l < h; l++)
                    {
                        for (int m = 0; m < w; m++)
                        {
                            if (((j >> m) & 1) != 1 && ((i >> l) & 1) != 1) 
                            {
                                if (c[l, m] == '#') 
                                {
                                    sharpTotal++;                  
                                }
                            } 
                        }
                    }

                    if (sharpTotal == k) ans++;
                }
            }
            Console.WriteLine(ans);

            Console.Out.Flush();
        }

        static public char[,] GetChar2d(int h, int w)
        {
            char[,] c = new char[h, w];
            for (int i = 0; i < h; i++)
            {
                var s = Console.ReadLine();
                for (int j = 0; j < s.Length; j++)
                {
                    c[i, j] = s[j];
                }
            }

            return c;
        }
    }
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
const long long INF = 1e10;
const int MOD = (int)1e9+7;
const double EPS = 1e-9;
typedef long long ll;
typedef long li;
#define pb push_back
#define mp make_pair

// lower_bound を使う練習
signed main (){
  ll n;
  cin >> n;
  vector<ll> l(n);
  for(ll & x : l){
    cin >> x;
  }
  sort(l.begin(), l.end());
  ll ans = 0;
  rep(i,n) {
    Rep(j,i+1,n) {
      // a <= b <= c を仮定する。lがソート済みのとき a = l[i], b = l[j]として良い。
      //探索範囲は j+1番目 ~ end まで

      // 三角不等式から c < a + b (*)がわかっているので、
      //c >= a + b を満たす最小要素のイテレータを取得する
      auto it = lower_bound(l.begin() + j + 1, l.end(), l[i] + l[j]);
      if(it != l.end()) {
        // イテレータがある場合は  最小の不等式(*)を満たさない要素のindex - 始点
        // ※ 3番目から6番目前満たす時、 7番目のitが帰ってくるので 7 - 3 = 4 でほしい値になるよ
        ans += it - (l.begin() + j + 1);
      } else {
        // イテレータが無いってことは j+1 ~ n-1は(*)を満たす。
        // (n-1) - (j+1) + 1= n - j - 1
        // ※ 3~6, 6 - 3 + 1　個が満たすよ。
        ans += n - j - 1;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";

int main(){
  ll a,b,c,d; cin >> a>> b>>c>>d;
  bool taka=true;
  while(a>0&&c>0){
    if(taka){
      c-=b;
    }else{
      a-=d;
    }
    taka=(!taka);
  }
  if(a>0) cout << yes << endl;
  else cout << no << endl;
  return 0;
}


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

int main() {
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    int neru = 60 * H2 + M2;
    int okiru = 60 * H1 + M1;
    neru -= K;
    cout << neru - okiru << endl;
    return 0;
}

Measured memory_bytes: 3636
import copy
N, W = [int(i) for i in input().split(' ')]
dic = {}
dic_num = {}
dic4calc  = {}

for i in range(N):
    new_w, new_v = [int(i) for i in input().split(' ')]
    if new_w in dic:
        dic[new_w].append(new_v)
    else:
        dic[new_w] = [new_v]
        
w = sorted(list(dic.keys()))
for wi in w:
    dic[wi].sort(reverse=True)
    dic_num[wi] = len(dic[wi])
    dic4calc[wi] = 0

cond = []
def rec(i, rest, dic4calc):
    if rest<w[i]:
        cond.append(dic4calc)
        return

    if i+1<len(w):
        new_dic4calc = copy.deepcopy(dic4calc)
        rec(i+1, rest, new_dic4calc)
    if not dic_num[w[i]]-dic4calc[w[i]]==0:
        new_dic4calc = copy.deepcopy(dic4calc)
        new_dic4calc[w[i]] += 1
        rec(i, rest-w[i], new_dic4calc)
    if i+1>=len(w):
        cond.append(dic4calc)
        return

rec(0, W, dic4calc)
ans = 0
for c in cond:
    total = 0
    for wi in w:
        total += sum(dic[wi][:c[wi]])
    if ans < total:
        ans = total
        
print(ans)

Measured memory_bytes: 55112
#include<iostream> 
using namespace std;
int N,S;
int main() {
    while (cin >> N && N > 0) {
        int sum = 0;
        int largest = 0;
        int smallest = 1000;
        for (int i = 0; i < N; ++i) {
            cin >> S;
            if (largest < S) largest = S;
            if (smallest > S) smallest = S;
            sum += S;
        }
        cout << (int)((sum-largest-smallest)/(N-2)) << endl;
    }
    return 0;
}


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

#define MAX_INT 0x3f3f3f3f 
#define precision(x) setprecision(x)
#define boost ios_base::sync_with_stdio(false);     cin.tie(NULL);

int main()
{
    boost;
    int n,k;
    cin >> n >> k;
    map<int,int> mp;
    for(int i=0;i<k;i++)
    {
        int p;
        cin >> p;
        for(int i=1;i<=p;i++)
        {
            int z;
            cin >> z;
            mp[z]++;
        }
    }
    int count=0;
    for(int i=1;i<=n;i++)
    {
        if(mp[i]<=0)
        {
            count++;
        }
    }
    cout << count << "\n";
}

Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <utility>
#include <climits>
#include <cstring>
#include <cstdio>

using namespace std;
typedef long long int llg;

template <typename T>
using reverse_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;

const int INF = 1000001000;
#define REP(var, count) for(int var=0; var<count; var++)


int vert[100010];
vector<pair<int, int> > edge[500010];

int main(void) {
	int V, E, r;
	scanf("%d", &V);
	scanf("%d", &E);
	scanf("%d", &r);
	
	REP(v, V) { vert[v] = INF; }
	vert[r] = 0;
	
	REP(i, E) {
		int s, t, d;
		scanf("%d", &s);
		scanf("%d", &t);
		scanf("%d", &d);
		
		edge[s].push_back( make_pair(t, d) );
	}
	
	reverse_queue<pair<int, int> > que;
	que.push(make_pair(0, r));
	
	while( que.size() ) {
		auto nx = que.top();
		que.pop();
		
		int s = nx.second;
		
		for( auto e : edge[s] ) {
			int t = e.first;
			int d = e.second;
			if ( vert[s]+d < vert[t] ) {
				vert[t] = vert[s] + d;
				que.push(make_pair(vert[t], t));
			}
		}
	}
	
	REP(v, V) {
		if ( vert[v] == INF ) {
			cout << "INF" << endl;
		} else {
			cout << vert[v] << endl;
		}
	}

}

Measured memory_bytes: 22432
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#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 UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
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();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  string s, t;
  cin >> s >> t;

  int n, m;
  n = s.size(), m = t.size();

  static int dp[3030][3030];
  m0(dp);

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (s[i] == t[j]) {
        dp[i + 1][j + 1] = dp[i][j] + 1;
      } else {
        dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
      }
    }
  }

  string ans = "";
  while (n > 0 || m > 0) {
    if (m >= 1 && dp[n][m] == dp[n][m - 1]) {
      m--;
    } else if (n >= 1 && dp[n][m] == dp[n - 1][m]) {
      n--;
    } else {
      n--, m--;
      ans = s[n] + ans;
    }
  }

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


Measured memory_bytes: 71936
#include <iostream>

using namespace std;

int main()
{
    string s;
    unsigned int i;
    int count = 0;

    cin >> s;
    for (i = 0; i < s.size() / 2; i++) {
        if (s.at(i) != s.at(s.size() - i - 1)) {
            count++;
        }
    }
    cout << count << endl;

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) cin >> vec.at(i);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j) continue;
      else ans += vec.at(i) * vec.at(j);
    }
  }
  cout << ans / 2 << endl;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define ll long long
#define ld long double
#define ii pair<int,int>
#define heap priority_queue
#define all(k) k.begin(),k.end()
#define rall(k) k.rbegin(),k.rend()
#define len(v) ((int)v.size())
#define fa(a,c) for(auto &a:c)
#define endl '\n'



void p(vector<int>&a){

//  fa(v,a)cout<<v<<' ';cout<<endl;
}

int32_t main(){
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin>>n;
  vector<int> a(n), b(n);

  fa(v,a)cin>>v;
  fa(v,b)cin>>v;
  int res=0;
  if(a>b) a.swap(b);
  p(a);
  while(a!=b){
    next_permutation(all(a));
    p(a);
    res++;
  }


  cout<<res<<endl;

}


Measured memory_bytes: 256
<?php
// Your code here!
$input = trim(fgets(STDIN));
$array = str_split($input);

$cnt = 0;
$cnt2 = 0;

for($i=0;$i<strlen($input);$i++){
    if($i%2==0){
        if($array[$i] != 0){
            $cnt++;
        }else{
            $cnt2++;
        }
    }else{
        if($array[$i] != 1){
            $cnt++;
        }else{
            $cnt2++;
        }
    }
}

if($cnt <= $cnt2){
    $min = $cnt;
}else{
    $min = $cnt2;
}


echo $min;

?>

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

int main() { 	
 int N,M,D,m;
  string S;
 cin >>S;
	N=0; 
  M=0;
  for(int i=0;i<S.size();i++){
  if(S.at(i)=='o'){
    N++;
  }
    M++;
  }

  if(15-M+N>7){
  cout <<"YES"<<endl;
  }else{
  cout <<"NO"<<endl;
  }
}



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

#define BUILDING 4
#define FLOOR 3
#define ROOM 10

void print_tenants(int tenants[BUILDING][FLOOR][ROOM], int building)
{
  for (int floor = 0; floor < FLOOR; floor++)
  {
    for (int room = 0; room < ROOM; room++)
    {
      cout << ' ' << tenants[building][floor][room];
    }
    cout << endl;
  }
}

int main()
{
  int tenants[BUILDING][FLOOR][ROOM] = {{{}}};
  int num;
  cin >> num;

  for (int i = 0; i < num; i++)
  {
    int building, floor, room, people;
    cin >> building >> floor >> room >> people;
    tenants[building - 1][floor - 1][room - 1] += people;
  }
  for (int i = 0; i < BUILDING; i++)
  {
    print_tenants(tenants, i);
    if (i != BUILDING - 1)
    {
      cout << "####################" << endl;
    }
  }
}


Measured memory_bytes: 3100
import sys
from collections import deque

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    ans = []
    while True:
        W, H = map(int, input().split())
        if W == H == 0:
            break
        grid = [list(map(int, input().split())) for _ in range(H)]

        res = 0
        visited = [[False] * W for _ in range(H)]
        for y in range(H):
            for x in range(W):
                if grid[y][x] == 1 and not visited[y][x]:
                    res += 1
                    que = deque([[y, x]])
                    while que:
                        h, w = que.pop()
                        for dh, dw in ((1, 0), (-1, 0), (0, 1), (0, -1), (1, 1), (1, -1), (-1, 1), (-1, -1)):
                            next_h, next_w = h + dh, w + dw
                            if next_h < 0 or next_h >= H or next_w < 0 or next_w >= W or grid[next_h][next_w] == 0:
                                continue
                            else:
                                if not visited[next_h][next_w]:
                                    visited[next_h][next_w] = True
                                    que.append([next_h, next_w])
        ans.append(res)
    print(*ans, sep="\n")


if __name__ == '__main__':
    resolve()



Measured memory_bytes: 6052
#include <stdio.h>
int main()
{
	int k,q,n;
	int correct[100000],r[100000];
	int i;
	scanf("%d %d %d",&n,&k,&q);
	for(i=0;i<n;i++)
	{
		r[i]=0;
	}
	for(i=0;i<q;i++)
	{
		scanf("%d",&correct[i]);
		r[correct[i]-1]++;
	}
	for(i=0;i<n;i++)
	{
		if(q-r[i]>=k) printf("No\n");
		else printf("Yes\n");
	}
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
const int maxn = 1e6+5;
const int mod = 1e9+7;
const double eps = 1e-8;
using namespace std;

void tlfclwx(){ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int k[3];
int main()
{
    cin >> k[0] >> k[1] >> k[2];
    sort(k,k+3);
    if((k[0]==k[1]&&k[0]!=k[2])||(k[1]==k[2]&&k[1]!=k[0]))
    {
        cout << "Yes" << endl;
    }
    else cout <<"No" << endl;
 }


Measured memory_bytes: 256
n = int(input())
shops = [list(input().split()) for i in range(n)]
profits = [list(input().split()) for i in range(n)]

l = []
ans = -10000000000000000000000000000
def f(now, i):
  if i >= 10:
    l.append(list(now))
    return
  
  f(now+"1", i+1)
  f(now+"0", i+1)
f("", 0)

for i in range(len(l)-1):
  temp = 0
  for j in range(len(shops)):
    count = 0
    for k in range(10):
      if shops[j][k] == "1" and l[i][k] == "1":
        count += 1
    temp += int(profits[j][count])
  if temp > ans:
    ans = temp

print(ans)

Measured memory_bytes: 3316
/*input
100
*/
fn read_line() -> String {
    let mut return_ = format!("");
    std::io::stdin().read_line(&mut return_).ok();
    return_
}

fn main() {
    let input: u64 = read_line().trim().parse().expect("");
    let mut two_power: u64 = 1;
    while (two_power << 1) + 1 <= input {
        two_power = (two_power << 1) + 1;
        //println!("{}", two_power);
    }
    println!("{}", two_power.count_ones());
}



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

struct card{char c, value;}; 

void BubbleSort(struct card C[], int N){
     card tmp;
     for(int i=0;i<N;i++){
         for(int j=N-1;j>i;j--){
             if(C[j].value < C[j-1].value){
                 tmp=C[j];
                 C[j]=C[j-1];
                 C[j-1]=tmp;
             }
         }
     }
 }

void SelectionSort(struct card C[], int N){
     card tmp;
     int minj;
     for(int i=0;i<N;i++){
         minj = i;
         for(int j=i;j<N;j++){
             if(C[j].value < C[minj].value)minj = j;
         }
         tmp=C[i]; C[i]=C[minj]; C[minj]=tmp;
     }
 }

void p(struct card C[],int N){
     for(int i=0;i<N;i++){
         if(i!=N-1){
             cout <<C[i].c<<C[i].value<<" ";
         }else{
             cout << C[i].c<<C[i].value<<endl;
         }
     }
 }

 int isStable(struct card Cb[],struct card Cs[],int N){
     for(int i=0;i<N;i++){
         if(Cb[i].c != Cs[i].c) return false;
     }
     return true;
 }

 int main(){
     int N;
     card C[36],Cb[36],Cs[36];
     cin >> N;
     for(int i=0;i<N;i++){
         cin >> C[i].c>>C[i].value;
     }
     for(int i=0;i<N;i++){
         Cb[i]=C[i];
         Cs[i]=C[i];
     }
     BubbleSort(Cb, N);
     SelectionSort(Cs, N);
     
     p(Cb,N);
     cout<<"Stable"<<endl;

     p(Cs,N);
     if(isStable(Cb,Cs,N))cout<<"Stable"<<endl;
     else cout<<"Not stable"<<endl;

     return 0;
 }


Measured memory_bytes: 3096
#include <iostream>
#include <iomanip>
#include <string>
#include <cctype>

using namespace std;

int main()
{
    int K,X;
    cin>>K>>X;
    for(int i=1;i<K;i++){
        X--;
    }
    for(int i=0;i<(2*K)-1;i++){
        cout<<X<<" ";
        X++;
    }
    cout<<endl;
}




Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);


int main(){
  ll N; cin >> N;
  if (N % 2 != 0){
    cout << 0 << endl;
    return 0;
  }

  ll ans = 0;
  while (N > 0){
    ans += N / 5 / 2;
    N /= 5;
  }
  cout << ans << endl;
  
  return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int n, a[50];
int mm = 1145141919, mi;
int mp = -1145141919, pi;

int minu() {
  cout << mi << " " << n << endl;
  cout << mi << " " << n << endl;
  dep(i, n - 1, 1) {
    rep(j, 0, 2) cout << i + 1 << " " << i << endl;
  }
}

int plu() {
  cout << pi << " " << 1 << endl;
  cout << pi << " " << 1 << endl;
  rep(i, 2, n + 1) {
    rep(j, 0, 2) cout << i - 1 << " " << i << endl;
  }
}

signed main() {
  cin >> n;
  rep(i, 0, n) cin >> a[i];
  rep(i, 0, n) {
    if(mm > a[i]) mm = a[i], mi = i;
    if(mp < a[i]) mp = a[i], pi = i;
  }
  mi++;
  pi++;

  if(mm == mp) {
    cout << 0 << endl;
    return 0;
  }
  cout << n * 2 << endl;

  if(abs(mm) > abs(mp)) {
    if(mm <= 0) minu();
    else plu();
  }else {
    if(mp > 0) plu();
    else minu();
  }
}


Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var A, B int
  fmt.Scanf("%d %d", &A, &B)
  
  a := A - 1
  
  q := B / a
  if (B - (a * q)) > 1 {
    q++
  }
  if A == 2 {
    q--
  }
  
  fmt.Println(q)
}

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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		char[] a = nextString().toCharArray();
		char[] b = nextString().toCharArray();
		char[] c = nextString().toCharArray();


		String ans = String.valueOf(a[0]).toUpperCase()+String.valueOf(b[0]).toUpperCase()+String.valueOf(c[0]).toUpperCase();


		System.out.println(ans);

	}

	public static boolean isPalindromicStr(String s) {
		int h = 0;
		int t = s.length() - 1;
		while (h <= t) {
			if (s.charAt(h) != s.charAt(t)) {
				break;
			}
			h++;
			t--;
		}
		if (h > t) {
			return true;
		}
		return false;
	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21204
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextFloat64() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func sum(x []int) int {
	var i int
	for _, v := range x {
		i += v
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	//sc.Buffer(nil, 100000000)

	H, W := nextInt(), nextInt()

	s := make([][]int, H)

	queues := [][]int{}

	for i := 0; i < H; i++ {
		s[i] = make([]int, W)
		vs := nextString()
		for j, v := range vs {
			if v == '#' {
				s[i][j] = 0
				queues = append(queues, []int{i, j})
			} else {
				s[i][j] = -1
			}
		}
	}

	ans := 0
	for len(queues) > 0 {

		queue := queues[0]

		hp, wp := queue[0], queue[1]
		cnt := s[hp][wp]

		dirH := []int{1, -1, 0, 0}
		dirW := []int{0, 0, 1, -1}
		for i := 0; i < 4; i++ {
			thp := hp + dirH[i]
			twp := wp + dirW[i]
			if thp < 0 || thp >= H {
				continue
			}
			if twp < 0 || twp >= W {
				continue
			}
			nextCnt := cnt + 1
			if s[thp][twp] < 0 || s[thp][twp] > nextCnt {
				s[thp][twp] = nextCnt
				queues = append(queues, []int{thp, twp})
				if s[thp][twp] > ans {
					ans = s[thp][twp]
				}
			}
		}

		queues = queues[1:]
	}
	fmt.Println(ans)
}


Measured memory_bytes: 100272
#include<bits/stdc++.h>
#define ll long long
#define rgi register int
#define rgl register ll
#define maxn 20
#define mod 998244353
#define inf 1000000007
namespace lib
{
	using namespace std;
	class fastio
	{
		private:
			#define _NUMLEN 111
			char _num[_NUMLEN],_ch;
			int _f,_head;
		public:
			inline void gc(char & _c) {_c=getchar();}
			template<typename _T> inline fastio & operator - (_T & _x)
			{
				_x=0;
				while(!isdigit(_ch)) _f|=_ch=='-',gc(_ch);
				while(isdigit(_ch)) _x=(_x<<1)+(_x<<3)+(_ch^48),gc(_ch);
				_f&&(_x=-_x,_f=0);
				return *this; 
			}
			inline void pc(char _c) {putchar(_c);}
			template<typename _T> inline fastio & operator + (_T _x)
			{
				_T _k;
				if(_x==0) {pc('0'),pc(' ');return *this;}
				if(_x<0) pc('-'),_x=-_x;
				while(_x>0) _k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
				while(_head>0) pc(_num[_head]),--_head;
				pc(' ');
				return *this; 
			}
			#define endl pc('\n')
		fastio() {_f=0,_head=0,_ch=' ';}
	}io;
}using namespace lib;

int a[maxn][maxn];
int honest[maxn];
signed main()
{
//	freopen("ttin.in","r",stdin);
//	freopen("ttout.out","w",stdout);
//	ios::sync_with_stdio(false);
//	cin.tie(0),cout.tie(0);
	int n,k,x,y,ans=0;
	io-n;
	memset(a,-1,sizeof(a));
	for(rgi i=1;i<=n;++i)
	{
		io-k;
		for(rgi j=1;j<=k;++j)
		{
			io-x-y;
			a[i][x]=y;
		}
	}
//	for(rgi i=1;i<=n;++i)
//	{
//		for(rgi j=1;j<=n;++j)
//			io+a[i][j];
//		io.endl;
//	}
	for(rgl f=0;f<1<<n;++f)
	{
		ll t=f,yes=1;
		for(rgi i=1;i<=n;++i)
			honest[i]=t&1,t>>=1;
		for(rgi i=1;i<=n;++i)
			if(honest[i])
				for(rgi j=1;j<=n;++j)
					if(a[i][j]!=-1&&a[i][j]!=honest[j])
					{
						yes=0;
						break;
					}
		if(yes)ans=max(ans,__builtin_popcount(f));
	}
	io+ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

// https://beta.atcoder.jp/contests/abc074/tasks/abc074_b

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

    int sum = 0;
    int x;
    REP(i, N) {
        cin >> x;
        int da = abs(x - 0);
        int db = abs(x - K);
        sum += min(da, db);
    }

    cout << sum * 2 << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

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

#define REP(i, n) for(ll i = 0; i < n; i++)








 
int main(){
    ll n;
    cin >> n;
    vector<ll> p(n);
    REP(i, n){
        cin >> p[i];
    }
    vector<ll> idx(n);
    iota(idx.begin(), idx.end(), 1);
    sort(idx.begin(), idx.end(), [&p](ll &a, ll &b){
        return p[a-1] > p[b-1];
    });
    /*
    REP(i, n){
        cout << idx[i] << " ";
    }
    cout << endl;
    */
    multiset<ll> st = {0, 0, n + 1, n + 1};
    ll ans = 0;
    for(auto &i : idx){
        auto itr = st.lower_bound(i);
        ll a = *----itr;
        ll b = *++itr;
        ll c = *++itr;
        ll d = *++itr;
        ans += p[i-1] * ((b - a) * (c - i) + (i - b) * (d - c));
        // cerr << a << " " << b << " " << c << " " << d << endl;
        st.insert(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
#define mod 1000000007
#define S second
#define F first
#define int long long
using namespace std;
int a,b,gu=INT_MAX,ki=INT_MAX,ans=0;
signed main(){
	cin>>a;
	f(i,a){
		cin>>b;
		ans+=b;
		if(b%2) ki=min(ki,b);
	}
	if(ans%2) ans-=ki;
	cout<<ans/2<<endl;
	return 0;
}



Measured memory_bytes: 3120
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;


typedef long long i64;
const int inf = (int)1.05e9;


int main()
{
	int n;
	vector<int> as, bs;

	scanf("%d", &n);
	as.resize(n);
	bs.resize(n);
	for(int i = 0; i < n; ++i)
		scanf("%d", &as[i]);
	for(int i = 0; i < n; ++i)
		scanf("%d", &bs[i]);

	int ans = 0;

	for(int k = 0; k < n; ++k) {
		int c = 0;
		for(int i = 0; i <= k; ++i)
			c += as[i];
		for(int i = k; i < n; ++i)
			c += bs[i];
		ans = max(ans, c);
	}

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

	return 0;
}

/* waffle */


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cerr<<#x<<"="<<x<<endl;
#define lgr cerr<<"-------------"<<endl;
#define ms(a,b) memset(a,b,sizeof(a))
typedef long long ll;
const int MAXN=1e5+10;
int main()
{
	int n;
	cin>>n;
	int a[MAXN],b[MAXN],c[MAXN];
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++) cin>>b[i];
	for(int i=0;i<n;i++) cin>>c[i];
	sort(a,a+n);
	sort(c,c+n);
	ll cnt=0,x,y;
	for(int i=0;i<n;i++){
		x=lower_bound(a,a+n,b[i])-a;
		y=n-(upper_bound(c,c+n,b[i])-c);
		//debug(x);debug(y);
		cnt+=x*y;
	}
	cout<<cnt<<endl; 
	return 0;
}

Measured memory_bytes: 1408
# input
sx, sy, tx, ty = map(int, input().split())

for i in range(ty - sy):
    print('U', end = "")

for i in range(tx - sx):
    print('R', end = "")

for i in range(ty - sy):
    print('D', end = "")

for i in range(tx - sx):
    print('L', end = "")

print('L', end = "")

for i in range(ty - sy + 1):
    print('U', end = "")

for i in range(tx - sx + 1):
    print('R', end = "")

print('D', end = "")

print('R', end = "")

for i in range(ty - sy + 1):
    print('D', end = "")

for i in range(tx - sx + 1):
    print('L', end = "")

print('U')

Measured memory_bytes: 4468
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main() {

    int N;
    cin >> N;

    int a;
    int k = 1;
    REP(i, N){
        cin >> a;
        if (k == a){
            k++;
        }
    }
    int ans;
    if (k == 1) ans = -1;
    else ans = N - k + 1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
int xy[110][110];
int main() {
    int W, H, N;
    cin >> W >> H >> N;
    int x[110], y[110];
    int a[110];
    int s = 0;
    for(int i = 0; i < N; i++)
        cin >> x[i] >> y[i] >> a[i];

    for(int i = 0; i < N; i++){
        switch (a[i]){
            case 1:{
                for(int j = 0; j < x[i]; j++){
                    for(int k = 0; k < H; k++){
                        xy[j][k] = 1;
                    }
                }
                break;
            }
            case 2:{
                 for(int j = x[i]; j < W; j++){
                    for(int k = 0; k < H; k++){
                        xy[j][k] = 1;
                    }
                }
                break;
            }
            case 3:{
                 for(int j = 0; j < W; j++){
                    for(int k = 0; k < y[i]; k++){
                       xy[j][k] = 1;
                    }
                }
                break;
            } 
            case 4:{
                for(int j = 0; j < W; j++){
                    for(int k = y[i]; k < H; k++){
                       xy[j][k] = 1;
                    }
                }
                break;
            }
        }
    }
    for(int i = 0; i < W; i++){
        for(int j = 0; j < H; j++){
            if(xy[i][j] == 0) s++;
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
int main(){
  int a,b,sum;
  scanf("%d %d",&a, &b);
  sum=a+b;
  if(a-b>sum){
    sum=a-b;
  }
  if(a*b>sum){
    sum=a*b;
  }
  printf("%d\n",sum);
 return 0;
}

Measured memory_bytes: 128
n=int(input())
a=list(map(int,input().split()))
b=0
ans=-1

while True:
    tmp=0
    for i in range(n):
        if a[i]%2!=0:
            tmp+=1
        if tmp==0:
            a[i]=a[i]//2
    ans+=1
    if tmp!=0:
        break
print(ans)
        

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> a(n);
  REP(i, n) { cin >> a[i]; }
  vector<ll> s(n + 1, 0);
  sort(ALL(a));
  REP(i, n) { s[i + 1] = s[i] + a[n - 1 - i]; }

  // ai + aj m番目の値
  ll ok = 0, ng = 2e5 + 1;
  while (ok + 1 < ng) {
    ll cnt = 0, mid = (ok + ng) / 2;
    // aj >= mid - aiとなるjの個数
    REP(i, n) {
      ll d = max(0LL, (ll)distance(lower_bound(ALL(a), mid - a[i]), a.end()));
      cnt += d;
    }
    (cnt >= m ? ok : ng) = mid;
  }
  ll ans = 0, k = 0;
  REP(i, n) {
    ll d = max(0LL, (ll)distance(lower_bound(ALL(a), ok - a[i]), a.end()));
    ans += d * a[i] + s[d];
    k += d;
  }
  ans -= (k - m) * ok;
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
using namespace std;
#define ll long long int

int main(void)
{
  int a, b, d, g, count = 0;
  string S, T, U;
  cin >> S >> T;
  map<string, int> mp;
  cin >> mp[S] >> mp[T];

  cin >> U;
  mp[U]--;

  cout << mp[S] << " " << mp[T] << endl;
}


Measured memory_bytes: 256
import copy
import sys
from bisect import bisect_left, bisect_right
from collections import ChainMap, Counter, deque, defaultdict, namedtuple
from fractions import gcd
from heapq import heappop, heappush
from itertools import accumulate
from math import ceil, floor, sqrt
from operator import itemgetter

# sys.setrecursionlimit(10**6)


tolerance = 1e-30


def is_dist_int(x, y):
    d = 0
    
    for i in range(len(x)):
        d += (x[i] - y[i]) ** 2

    e = floor(sqrt(d)) ** 2

    return abs(d - e) < tolerance


def main():
    n, d = [int(x) for x in input().split(' ')]

    xs = [[int(x) for x in input().split(' ')] for _ in range(n)]

    count = 0

    for i in range(n):
        for j in range(i + 1, n):
            x = xs[i]
            y = xs[j]
            if is_dist_int(x, y):
                count += 1

    print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5432
#include<iostream>
#define N 200

int main(){
    int A[N];
    int n,flag = 0,ans = 0;

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

    while(true){
        for(int i = 0 ; i < n;i++){
            if((A[i] % 2)==1){
                flag = 1;
            }
        }
        if(flag == 1) break;
        for(int i = 0 ; i < n;i++){
            A[i] /= 2;
        }
        ans++;
    }
    
    std::cout << ans;
}

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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/a.in", "r", stdin);
//  freopen("../IO/a.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}


void solve(std::istream &in, std::ostream &out) {
  int n;
  in >> n;
  vector<int> a(n),b(n);
  for (int &i : a) in >> i;
  for (int &i : b) in >> i;
  int ans = 0;
  for (int i = 0; i <= 28; ++i) {
    vector<int> v = b;
    for (int &k : v) k &= (1 << (i + 1)) - 1;
    sort(v.begin(), v.end());
    int T = 1 << i;
    int cnt = 0;
    for (int k : a) {
      k &= (1 << (i + 1)) - 1;
      cnt += distance(lower_bound(v.begin(), v.end(), T - k), lower_bound(v.begin(), v.end(), 2 * T - k)) % 2;
      cnt += distance(lower_bound(v.begin(), v.end(), 3 * T - k), v.end()) % 2;
    }
    if (cnt % 2) {
      ans |= T;
    }
  }
  out << ans << '\n';
}

Measured memory_bytes: 5552
//正难则反 
#include<cstdio>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<cstring>
#include<iostream>
using namespace std;
#define N 200005
#define LL long long
inline int rd()
{
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+(c^48);c=getchar();}
	return f*x;
}
char n[105];
int k,len;
LL s[N],ans;
LL ksm(LL a,int b)
{
	LL res=1;
	for(int i=1;i<=b;i++)
		res*=a;
	return res;
}
void Pre() 
{
    s[0]=1;
    for(int i=1;i<=105;i++)
        s[i]=s[i-1]*i;
}
/*LL C(int a,int b) 
{
    if(a<0||b<0) return 1;
    return s[a]/s[b]/s[a-b];
}*/
LL C(LL a,int b)
{
	if(b<0) return 0;
	if(b==0) return 1;
	if(b==1) return a;
	if(b==2) return max(a*(a-1)/2,0ll);
	if(b==3) return max(a*(a-1)*(a-2)/6,0ll);
}
int main()
{
    scanf("%s",n+1);
	k=rd();
    //Pre();
    len=strlen(n+1);
    int t=0;
    for(int i=1;i<=len;i++)
    {//减去大于n的数 
    	int x=n[i]-'0';
    	ans+=(9-x)*C(len-i,k-i+t)*ksm(9,k-i+t);
    	//因为要求比n大 所以前面的数都不能为0 除非那一位就是0 就可以为0
		//循环i表示从i这一位开始数位上的数比n大 前面的数位都和n一样
		//所以前面的0要回收 
    	if(!x) t++;
	}
	LL all=C(len,k)*ksm(9,k);//位数有len位的有k个数位恰好不为0的数 
	printf("%lld\n",max(all-ans,0ll));
    return 0;
}
/*#include<cstdio>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<cstring>
#include<iostream>
using namespace std;
#define N 200005
#define LL long long
inline int rd()
{
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+(c^48);c=getchar();}
	return f*x;
}
char n[105];
int k,len;
LL s[N],ans;
LL ksm(LL a,int b)
{
	LL res=1;
	while(b)
	{
		if(b&1) res=res*a;
		a=a*a;
		b>>=1;
	}
	return res;
}
void dfs(int x/*现在到第几位,int y/*已经有y位不为0,LL res,bool f) 
{
	printf("%lld %lld %d\n",res,ans,x); 
	//if(res==-1) printf("%d\n",x);
	if(y>k) return ;
	if(f==1)
	{
		if(y==k) ans+=res;
		return ;
	}
	if(x==len+1)
	{
		if(y==k) ans+=res;
		return ;
	}
	dfs(x+1,y,res,f);//1让这一位为0
	if((n[x]-'0')>1) 
		dfs(x+1,y+1,res*(n[x]-'0'-1)*ksm(9,k-(y+1)),1);//这一位为小于n[x]的数 
	if(n[x]!='0') dfs(x+1,y+1,res,f);//让这一位为n[x] 
	return ;
}
void Pre() 
{
    s[0]=1;
    for(int i=1;i<=N;i++)
        s[i]=s[i-1]*i;
}
LL C(int a,int b) 
{
    if(a<0||b<0) return 1;
    return s[a]/s[b]/s[a-b];
}
int main()
{
    scanf("%s",n+1);
	k=rd();
    Pre();
    len=strlen(n+1);
    int x=n[1]-'0';
    //每个位置都有9个选择 
    if(x!=1) ans=ksm(9,k-1)*C(len-1,k-1)*(x-1);//第1位小于x 可以随便选
    if(len-1>=k) ans+=ksm(9,k)*C(len-1,k);//第1位没有(为0 
	printf("%lld\n",ans);
    dfs(2,1,1,0);//第1位为x 
    printf("%lld\n",ans);
    return 0;
}*/


Measured memory_bytes: 256