akhauriyash/Code-Regression huggingface dataset:
//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define X real()
#define Y imag()
#define maxN 200005
#define oo 1000000007
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int n, x[maxN], y[maxN], cnt[maxN];
vector<ii> p;

int main () {
    scanf("%d", &n);
    fto(i, 1, n) {
        scanf("%d%d", &x[i], &y[i]);
        if (x[i] < y[i]) swap(x[i], y[i]);
        p.pb(mp(x[i], i)); p.pb(mp(y[i], i));
    }

    if (n == 1) {
        puts("0");
        return 0;
    }

    sort(p.begin(), p.end());
    //fto(i, 0, sz(p)-1) printf("%d %d\n", p[i].ff, p[i].ss);

    ll ans = 1LL*oo*oo;
    if (p[0].ss != p[sz(p)-1].ss) {
        int r = 0, cntDiff = 0;
        fto(l, 1, sz(p)-2) {
            while (r < sz(p)-2 && cntDiff < n) {
                ++r;
                if (cnt[p[r].ss] == 0) ++cntDiff;
                ++cnt[p[r].ss];
            }
            if (cntDiff == n) ans = min(ans, 1LL*(p[sz(p)-1].ff-p[0].ff)*(p[r].ff-p[l].ff));
            --cnt[p[l].ss];
            if (cnt[p[l].ss] == 0) --cntDiff;
        }
    }

    int minX = oo, maxX = 0, minY = oo, maxY = 0;
    fto(i, 1, n) {
        minX = min(minX, x[i]);
        maxX = max(maxX, x[i]);
        minY = min(minY, y[i]);
        maxY = max(maxY, y[i]);
    }
    ans = min(ans, 1LL*(maxX-minX)*(maxY-minY));

    cout << ans;

    return 0;
}


Measured memory_bytes: 7536
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

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

  int w,a,b;
  cin >> w >> a >> b;
  
  if(a < b) swap(a,b);
  if(a < w+b) cout << 0 << endl;
  else        cout << a-(w+b) << endl; 

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner inp = new Scanner(System.in);
        int n = inp.nextInt();
        int m = inp.nextInt();
        int l = inp.nextInt();

        long aMatrix[][] = new long[n][m];
        long bMatrix[][] = new long[m][l];


        // Matrix A
        for (int k = 0; k < n; k++) {
            for (int j = 0; j < m; j++) {
                aMatrix[k][j] = inp.nextInt();
            }
        }

        // Matrix B
        for (int k = 0; k < m; k++) {
            for (int j = 0; j < l; j++) {
                bMatrix[k][j] = inp.nextInt();
            }
        }

        long total[][] = matrixCalc(aMatrix, bMatrix, n, m, l);

        for (long[] item : total) {
            String s = "";
            for (long secondItem : item) {
                if (s != "") {
                    s += " ";
                }
                s += secondItem;
            }
            System.out.print(s + "\n");
        }
    }

    public static long[][] matrixCalc(long[][] aMatrix, long[][] bMatrix, int n, int m, int l) {
        long totals[][] = new long[n][l];

        long total;

        for(int i = 0; i < n; i++){
            for(int j = 0; j < l; j++){
                total = 0L;
                for(int k = 0; k < m; k++){
                    total += aMatrix[i][k]*bMatrix[k][j];
                }
                totals[i][j] = total;
            }
        }

        return totals;
    }
}



Measured memory_bytes: 87040
#include<iostream>
#include<queue>
#include<map>

using namespace std;

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

int main() {
  int n;
  cin >> n;
  vector<pair<string, int> > gt;
  map<string, int> lb;
  vector<pair<int, int> > edge[n];
  rep (i, n) {
    string str;
    cin >> str;
    if (str == "goto") {
      cin >> str;
      gt.push_back(make_pair(str.substr(0, str.size() - 1), i));
      edge[i].push_back(make_pair(i + 1, 1));
    } else {
      lb[str.substr(0, str.size() - 1)] = i;
      edge[i].push_back(make_pair(i + 1, 0));
    }
  }
  rep (i, gt.size()) {
    edge[gt[i].second].push_back(make_pair(lb[gt[i].first], 0));
  }
  priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > que;
  que.push(make_pair(0, 0));
  int dis[101];
  rep (i, n + 1) dis[i] = 10000000;
  while (!que.empty()) {
    pair<int, int> now = que.top();
    que.pop();
    if (dis[now.second] <= now.first) continue;
    dis[now.second] = now.first;
    if (now.second == n) break;
    rep (i, edge[now.second].size()) {
      que.push(make_pair(now.first + edge[now.second][i].second, edge[now.second][i].first));
    }
  }
  cout << dis[n] << endl;
  return 0;
}

Measured memory_bytes: 1240
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll v[100100];

int main(void){
	int n,q,i,j=1;
	ll ans,l,r,s=0ll,a,x,t,tmpl,tmpr,d;
	std::cin >> x; l = 0ll; r = x;
	std::cin >> n; ++n;
	for(i=1; i<n; ++i){
		std::cin >> v[i];
	}
	v[n] = INFLL;
	std::cin >> q;
	for(i=0; i<q; ++i){
		std::cin >> t >> a;
		while(!(t<v[j])){
			if(j%2){
				d = (v[j-1]-v[j]);
			}else{
				d = (v[j]-v[j-1]);
			}
			if(d>=x){
				l = x; r = x; s += d; l -= s; r -= s;
			}else if(d<=-x){
				l = 0ll; r = 0ll; s += d; l -= s; r -= s;
			}else{
				s += d;
				tmpl = std::max(d,0ll); tmpr = std::min(x+d,x),0ll;
				l = std::max(l,tmpl-s);  r = std::min(r,tmpr-s);
			}
			if(l>r){
				if(j%2){
					r = l;
				}else{
					l = r;
				}
			}
			// std::cout << l << " " << r << std::endl;
			++j;
		}
		a = std::min(std::max(a,l),r);
		if(j%2){
			ans = std::max(a+s-(t-v[j-1]),0ll);
		}else{
			ans = std::min(a+s+(t-v[j-1]),x);
		}
		std::cout << ans << std::endl;
	}
	return 0;
}


Measured memory_bytes: 2048
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

int main(){

    ll N, A, B;
    cin >> N >> A >> B;
    cout << min(N * A, B) << endl;
    
    return 0;
}

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

#define rep(i,beg,end)   for (int i=(beg);i<(end);i++)
#define rrep(i,beg,end)   for (int i=(beg);i>=(end);i--)
#define all(cont)           begin(cont), end(cont)
#define INFMAX                   LLONG_MAX
#define INFMIN                   LLONG_MIN
typedef long long ll;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll, ll> pii;
typedef pair<ll, string> pis;
typedef pair<string, ll> psi;


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vi a(n);
    rep(i, 0, n) { cin >> a[i]; }
    sort(all(a));
    const int mid = n / 2;
    if (a[mid - 1] == a[mid]) {
        cout << 0 << endl;
    }
    else {
        int diff = a[mid] - a[mid - 1];
        cout << diff << endl;
    }
    return 0;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

#define MAX_N 1000

int n;
string s,t;
int res=0;

int main(){
	cin.sync_with_stdio(false);
	cin>>n;
	cin>>s>>t;
	rep(i,n){
		int l=i;
		while(l<n&&s[l]==t[l-i])l++;
		if(l==n){
			res=n+i;
			break;
		}
	}
	if(res==0)res=2*n;
	cout<<res<<endl;
	return 0;
}


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

int main()
{
  int H, W;
  string input[55];

  cin >> H >> W;
  for (int i = 0; i < H; i++)
  {
    cin >> input[i];
    for (int j = 0; j < W; j++)
      if (input[i][j] == '.') input[i][j] = '0';
  }
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      if (input[i][j] == '#') continue;
      if (i != 0     &&               input[i - 1][j]     == '#') input[i][j]++;
      if (j != 0     &&               input[i][j - 1]     == '#') input[i][j]++;
      if (i != 0     && j != 0     && input[i - 1][j - 1] == '#') input[i][j]++;
      if (i != H - 1 &&               input[i + 1][j]     == '#') input[i][j]++;
      if (j != W - 1 &&               input[i][j + 1]     == '#') input[i][j]++;
      if (i != H - 1 && j != W - 1 && input[i + 1][j + 1] == '#') input[i][j]++;
      if (i != 0     && j != W - 1 && input[i - 1][j + 1] == '#') input[i][j]++;
      if (i != H - 1 && j != 0     && input[i + 1][j - 1] == '#') input[i][j]++;
    }
  }
  for (int i = 0; i < H; i++)
    cout << input[i] << endl;
}


Measured memory_bytes: 3592
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    int n,a;
    cin >> n >> a;
    int C[n];
    long long store[5001];
    long long counter[5001];
    for(int i = 0; i < 5001 ; i++){
        store[i] = 0;
        counter[i] = 0;
    }
    counter[2500] = 1;
    for(int i = 0; i < n; i++){
        int temp;
        cin >> temp;
        C[i] = temp - a;
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 5001; j++){
            if(counter[j] != 0){
                //cout << "test " << j;
                store[j + C[i]] = counter[j] + store[j + C[i]];
            }
        }
        for(int j = 0; j < 5001; j++){
            counter[j] += store[j];
            store[j] = 0;
        }
    }
    cout << counter[2500] - 1 << "\n";
    return 0;
}


Measured memory_bytes: 384
for _ in range(4):
    t,n = map(int,input().split())
    if t == 1:
        print(6000*n)
    elif t == 2:
        print(4000*n)
    elif t == 3:
        print(3000*n)
    elif t == 4:
        print(2000*n)
    


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
  int n;
  string s;
  cin>>n>>s;
  int ans=0;
  int cnt=0;
  rep(i,n){
    if(s[i]=='I'){
      cnt++;
      if(ans<cnt)ans=cnt;
    }
    else{
      cnt--;
    }
  }
  cout<<ans<<endl;
}

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

#define pi 3.141592654
#define fix(n) cout << fixed << setprecision(n)

#define rep(i,a,b) for(int i=a;i<b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)

#define si(d)  scanf("%d",&d)
#define sll(d) scanf("%lld",&d)
#define pin(d) printf("%d\n",d)
#define pln(d) printf("%lld\n",d)
#define nl 	   printf("\n")

#define ll long long
#define ull unsigned long long

#define mp make_pair
#define pb push_back
#define fi first
#define se second

#define vi vector<int>
#define pii pair<int,int> 
#define piii pair<pair<int,int>,int> 
#define all(v) v.begin(), v.end()

#define chalne_de continue
int mod=1000000007;
const int N = 1000005;

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	int r, g, b;
	cin >> r >> g >> b;
	int sum = r * 100 + g * 10 + b;
	if ( sum % 4 == 0)
		cout << "YES";
	else
		cout << "NO";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

int main(){
    int D; ll G; cin >> D >> G;
    vector<int> p(D), c(D);
    rep(i,D) cin >> p[i] >> c[i];

    ll ans = INF;    
    rep(b, 1<<D){
        ll point = 0;
        ll count = 0;
        vector<bool> Used(D,false);
        rep(i, D){
            int bit = (b >> i);
            if ((bit & 1) == 1){
                point += (i+1)*100*p[i]+c[i];
                count += p[i];
                Used[i] = true;
            }
        }

        if (point >= G){
            ans = min(ans, count);
        }
        else{
            for(int i = D-1; i >= 0; i--){
                if (Used[i]) continue;
                int p_count = p[i];
                while (p_count > 1){
                    point += (i+1)*100;
                    count += 1;
                    p_count--;
                    if (point >= G){
                        ans = min(ans, count);
                        break;
                    }
                }
                if (point >= G){
                    break;
                }
            }
        }
    }

    cout << ans << endl;
}



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

int n,m,k,p;
int t_p , b_p ;
int card[201]={};
int top[201]={} , bottom[201]={} ;

void shuffle( int x ){
	t_p=1 ;  b_p=1 ;
	for( p=1 ; p<=x ; p++ ){
		top[t_p] = card[p] ;
		t_p++;
	}
	for( ; p<=n*2 ; p++ ){
		bottom[b_p] = card[p] ;
		b_p++;
	}
	
}

int main(){
	
	cin >> n >> m ;
	
	for( int i=1 ; i<=n*2 ; i++ ) card[i] = i ;
	for( int i=0 ; i<m ; i++ ){
		cin >> k ;
		if( k==0 ){
			shuffle( n ) ;
			t_p=1 ;  b_p=1 ;
			for( int j=1 ; j<=n*2 ; j++ ){
				if( j%2 == 1 ){
					card[j] = top[t_p] ;
					t_p++;
				}else{
					card[j] = bottom[b_p] ;
					b_p++;
				}
			}
		}else{
			shuffle( k ) ;
			t_p=1 ;  b_p=1 ;
			for( p=1 ; p<=n*2-k ; p++ ){
				card[p] = bottom[b_p] ;
				b_p++;
			}
			for( ; p<=n*2 ; p++ ){
				card[p] = top[t_p] ;
				t_p++;
			}
		}
	}
	
	for( int i=1 ; i<=n*2 ; i++ ) cout << card[i] << endl ;
	
return 0;
}

Measured memory_bytes: 1160
import sys

n = int(input())
a = list(map(int, input().split()))

check = 0
check_tmp = 0
cnt = 1
tmp = 0
for i in range(n):
    if i == 0:
        tmp = a[i]    
    else:
        if tmp < a[i]:
            check = 1
        elif tmp > a[i]:
            check = -1
        else:
            check = 0

        if check_tmp != 0:
            if check == 1 and check_tmp == -1:
                cnt += 1
                check_tmp = 0
            elif check == -1 and check_tmp == 1:
                cnt += 1
                check_tmp = 0
            tmp = a[i]
        else:
            check_tmp = check
            tmp = a[i]
        

print("{}".format(cnt))

Measured memory_bytes: 14428
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    map<char, ll> m;
    rep(i,n){
        m[s[i][0]]++;
    }
    vector<char> c = {'M', 'A', 'R', 'C', 'H'};
    ll ans = 0;
    for(int i = 0; i < c.size(); i++){
        for(int j = i+1; j < c.size(); j++){
            for(int k = j+1; k < c.size(); k++){
                ans += m[c[i]] * m[c[j]] * m[c[k]];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 6352
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
long k;
long calc(long n){
    long result = abs(n-k);
    if(n<result) return n;
    return calc(result);
}

int main() {
    long n;
    cin >> n >> k;
    
        while(n>k){
        n=n%k;
        }
        cout << calc(n) << endl;
    
}


Measured memory_bytes: 256
n=int(input())
h=list(int(x) for x in input().split())

length=0
max_length=0

for i in range(n-1):
  if h[i]>=h[i+1]:
    length+=1
    if length>max_length:
      max_length=length
  else:
    length=0
print(max_length)

Measured memory_bytes: 15020
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000000

bool comp(vector<int> &a, vector<int> &b){
    return a.back() > b.back();
}

int main(void){
    
    int n, d;
    while(1){
        cin >> n >> d;
        if(n == 0) break;
        vector<vector<int> > missiles(n);
        for(int i = 0; i < n; i++){
            int m; cin >> m;
            int sum = 0;
            for(int j = 0; j < m; j++){
                int input; cin >> input;
                sum += input;
                missiles[i].push_back(input);
            }
            missiles[i].push_back(sum);
        }
        
        bool flag;

        while(1){

            int aaa = 1;
            /*for(int i = 0; i < n; i++){
                for(int j = 0; j < missiles[i].size(); j++){
                    cout << missiles[i][j] << " ";
                }
                cout << endl;
            }
            cout << endl;
            */

            int sum = 0;
            for(int i = 0; i < n; i++){
                sum += missiles[i].size();
            }
            if(sum == 0){
                cout << "Yes" << endl;
                return 0;
            }
            
            flag = false;

            sort(missiles.begin(), missiles.end(), comp);

            /*for(int i = 0; i < n; i++){
                for(int j = 0; j < missiles[i].size(); j++){
                    cout << missiles[i][j] << " ";
                }
                cout << endl;
            }*/
            int first = missiles[0].back();
            for(int i = 0; i < n; i++){
                first = max(first, missiles[i].back());

                if(i == 0){
                    while(missiles[1].back() - ( missiles[0].back() - missiles[0][missiles[0].size() - 2]) <= d){
                        missiles[0].back() -= missiles[0][missiles[0].size() - 2];
                        missiles[0][missiles[0].size() - 2] = missiles[0].back();
                        missiles[0].pop_back();
                        flag = true;
                    }
                    first = missiles[0].back();
                }else{
                    while(first - ( missiles[i].back() - missiles[i][missiles[i].size() - 2]) <= d){
                        missiles[i].back() -= missiles[i][missiles[i].size() - 2];
                        missiles[i][missiles[i].size() - 2] = missiles[i].back();
                        missiles[i].pop_back();
                        flag = true;
                    }
                }

            }

            int r  = 1;

            for(int j = 0; j < n; j++){
                if(missiles[j].back() != 0) r = 0;
            }

            
            if(r == 1){
                cout << "Yes" << endl;
                aaa = 0;
            }


            if(flag == false){
                cout << "No" << endl;
                aaa = 0;
            }

            if(aaa == 0) break;

        }
        
    }

    return 0;
}

Measured memory_bytes: 3076
#include <stdio.h>

#define MAX 500000
void merge(int A[],int l,int m,int r);
void mergesort(int A[],int l,int r);

int n,c=0;
int L[MAX/2+2],R[MAX/2+2];

int main(){
  int i;
  int A[MAX];

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

  mergesort(A,0,n);

  for(i=0;i<n;i++){
    if(i>0) printf(" ");
    printf("%d",A[i]);
  }

  printf("\n");

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

  return 0;
}

void merge(int A[],int l,int m,int r){
  int n1,n2,i,j,k;
  n1=m-l;
  n2=r-m;
  for(i=0;i<n1;i++) L[i]=A[l+i];
  for(i=0;i<n2;i++) R[i]=A[m+i];
  L[n1]=R[n2]=2000000000;
  i=0,j=0;
  for(k=l;k<r;k++){
    c++;
    if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
    }else{
      A[k]=R[j];
      j++;
    }
  }
}
void mergesort(int A[],int l,int r){
  if(l+1<r){
    int m;
    m=(l+r)/2;
    mergesort(A,l,m);
    mergesort(A,m,r);
    merge(A,l,m,r);
  }
}



Measured memory_bytes: 5676
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	
	int n;
	cin>>n;
	
	int arr[n];
	
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		x--;
		arr[i]=x;
	}
	int vis[n]={0};
	int c=0;
	
	int st=0;
	
	while(st!=1){
		if(vis[st]){
			cout<<"-1";
			return 0;
		}
		vis[st]=1;
		st=arr[st];
		c++;
	}
	
	cout<<c;



}


Measured memory_bytes: 1024
function Main(input) {
  input = Number(input);
  for(var i = 1; i <= input; i++){
      if(i % 3 === 0) process.stdout.write(' ' + i);
      else if(i.toString().indexOf('3') >= 0) process.stdout.write(' ' + i);
  }
  console.log();
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main()
{
    int a, b;
    char op;
    bool flag = true;

    while (flag)
    {
        cin >> a >> op >> b;
        switch (op)
        {
        case '+':
            cout << a + b << endl;
            break;
        case '-':
            cout << a - b << endl;
            break;
        case '/':
        if(b == 0)
        {
            cout << "Please enter except 0" << endl;
            break;
        }
            cout << a / b << endl;
            break;
        case '*':
            cout << a * b << endl;
            break;
        default:
            flag = false;
        }
}
    return 0;
}



Measured memory_bytes: 3096
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;


void main() {
	auto n = to!int(readln().strip());
	while(n > 0){
		string[] s;
		for(int i; i < n; ++i){
			s ~= readln().chomp();
		}
		int[][] yoko = new int[][](n+1,n+1);
		int[][] tate = new int[][](n+1,n+1);
		int[][] square = new int[][](n+1,n+1);
		int maxSquare = 0;
		for(int i = n-1; i >= 0; --i) {
			for(int j = n-1; j >= 0; --j) {
				if(s[i][j] == '.') {
					yoko[i][j] = yoko[i][j+1]+1;
					tate[i][j] = tate[i+1][j]+1;
					square[i][j] = min(yoko[i][j],tate[i][j],square[i+1][j+1]+1);
					maxSquare = max(maxSquare, square[i][j]);
				}else{
					yoko[i][j] = 0;
					tate[i][j] = 0;
					square[i][j] = 0;
				}
			}
		}
		writeln(maxSquare);
		n = to!int(readln().strip());
	}
}

Measured memory_bytes: 33348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(abs(c-a)<=d||(abs(b-a)<=d&&abs(c-b)<=d))cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        String s = in.next().trim();
        boolean a=false,b=false;
        for(int i=0;i<3;i++) if(s.charAt(i)=='A') a=true;
        for(int i=0;i<3;i++) if(s.charAt(i)=='B') b=true;
        out.println((a&&b)?"Yes":"No");
    }
    
    /************* SOLUTION ENDS HERE **********/
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

const int M = 100100;

int n, a[M];

void read() {
  cin >> n;
  for (int i = 0; i < M; ++i)
    cin >> a[i];
}

void kill() {
  ll ans = 0;
  int k = 1;
  for (int i = 0; i < n; ++i) {
    if (a[i] > k) {
      ans += (a[i] - 1) / k;
      a[i] = max(1, k - 1);
    }
    if (a[i] == k) {
      ++k;
    }
  }

  cout << ans << endl;
}

int main() {
  cout.precision(20);
  cout << fixed;
  ios_base::sync_with_stdio(false);
  read();
  kill();
}


Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = Long.parseLong(in.next());
            }
            Arrays.sort(a);
            BigDecimal ans = new BigDecimal(String.valueOf(a[0]));
            for (int i = 1; i < n; i++) {
                if (a[i] == 0) {
                    ans = BigDecimal.ZERO;
                    break;
                }
                BigDecimal b = new BigDecimal(String.valueOf(a[i]));
                ans = ans.multiply(b);
                if (ans.compareTo(BigDecimal.valueOf(1000000000000000000L)) > 0) {
                    ans = new BigDecimal(-1);
                    break;
                }
            }

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 61700
def prime(n):
    p_list=[2]
    for i in range(3,n+1):
        flag=True
        for p in p_list:
            if i%p==0:
                flag=False
                break
        if flag:
            p_list.append(i)
    return p_list
    
p_list=prime(1000)
N=int(raw_input())
p_count = [1 for i in range(len(p_list))]
for i in range(len(p_list)):
    j=1
    p=p_list[i]
    count=0
    while p**j <=N:
        count+=int(N/(p**j))
        j+=1
    p_count[i]+=count

ans=1
for c in p_count:
    ans= (ans*c)%(10**9+7)
print ans

Measured memory_bytes: 2692
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	String h = sc.next();
    String x = sc.next();
    String m = x.substring(0,1);
    System.out.println("A"+m+"C");
  }
}

Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i=1;i<=n;i++){
			if(i%3 == 0){
				System.out.printf(" %d",i);
			}else{
				func(i,i);
			}
		}
		System.out.printf("\n");
	}
	
	public static void func(int i,int j){
		if(j%10 == 3){
			System.out.printf(" %d",i);
		}else if(j>0){
			func(i,j/10);
		}
	}

}

Measured memory_bytes: 39484
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using INT=mp::cpp_int;
using namespace std;
using ll=long long;
using vec=vector<ll>;
using vect=vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}
INT LCM(INT x,INT y){
  INT z=gcd(x,y);
  return x*y/z;
}
ll primejudge(ll n){
  if(n<2)return 0;
  else if(n==2)return 1;
  else if(n%2==0)return 0;
  double sqrtn=sqrt(n);
  Loop(i,3,sqrtn+1){
     if(n%i==0){
        return 0;
     }
     i++;
  }
  return 1;
}
INT modinv(INT a, INT m) {
    INT b = m, u = 1, v = 0;
    while (b) {
        INT t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int main() {
  cout << fixed << setprecision(30);
  ll n;
  cin>>n;
  vector<string> s(n);
  loop(i,n)cin>>s[i];
  sort(all(s));
  map<string,ll> count;
  loop(i,n)count[s[i]]++;
  ll M=0;
  loop(i,n)M=max(M,count[s[i]]);
  vector<string> list(n);
  loop(i,n){
    if(count[s[i]]==M)list[i]=s[i];
  }
  sort(all(list));
  string now="";
  loop(i,n){
    if(list[i]==""||list[i]==now)continue;
    putout(list[i]);
    now=list[i];
  }
}


Measured memory_bytes: 28288
#include <bits/stdc++.h>
using namespace std;
 
int main(void)
{
	string s;
	long long count=0;
	long long sum=0;
	cin >>s;
	vector<char> r(s.size());
	for(long long i=s.size()-1;i>=0;i--){
	    if(s.at(i)=='B') {
	        sum+=s.size()-1-i-count;
	        count++;
	    }
	}
    cout << sum;
}


Measured memory_bytes: 772
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

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

  vector<int> costs(n);
  for(int i=0; i<n; ++i) {
    cin >> costs[i];
  }

  vector<int> dp(n);
  for (int i=0; i<n; ++i) {
    if (i==0) dp[0] = 0;
    else if (i==1) {
      dp[1] = abs(costs[0] - costs[1]);
    } else {
      int step_1 = dp[i-1] + abs(costs[i-1] - costs[i]);
      int step_2 = dp[i-2] + abs(costs[i-2] - costs[i]);
      dp[i] = min(step_1, step_2);
    }
    // cout << dp[i] << endl;
  }
  cout << dp.back() << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        System.out.println( solve(S) );
    }

    private static int solve(String S) {
        int p_at = S.length() / 2;
        int p_top = 0;
        for (int i = 0; i < S.length(); i++) {
            if( S.charAt(i) == 'p' ) {
                p_top++;
            }
        }
        return p_at - p_top;
    }
}

Measured memory_bytes: 24948
#include <bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i, a, n) for ( i = a; i < (n); i++)
#define fill(a,v)                    memset(a, v, sizeof(a))
#define sz(a)                       ((int)(a.size()))
#define x first
#define y second
#define mp make_pair
#define pb push_back
using namespace std;

int main(){
	fast;
	ll i,j,W,k,tc,q,m,n,flag;	
	string s,t;
	cin >> s;
	cin >> t;
	m=sz(s),n=sz(t);

	ll dp[3001][3001];

	rep(i,0,m+1){
		rep(j,0,n+1){
			if( i==0 || j==0 )
				dp[i][j] = 0;
			else if( s[i-1]==t[j-1])
				dp[i][j] = 1 + dp[i-1][j-1] ;
			else dp[i][j] = max(dp[i][j-1],dp[i-1][j]);
		}
	}


	
	// rep(i,0,m+1){
	// 	rep(j,0,n+1){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	
	string ans;
	i=m;j=n;
	while(i>0&&j>0){
		if(s[i-1]==t[j-1]){
			ans.pb(s[i-1]);
			i--;
			j--;
		}
		else if(dp[i-1][j]>dp[i][j-1])
			i--;
		else j--;

	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 70784
import java.util.Scanner

import scala.collection.mutable

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val m = sc.nextInt()
    val ab = Array.fill(m)((sc.nextInt(), sc.nextInt()))

    val g = (ab ++ ab.map(_.swap)).groupBy(_._1).map(x => {
      x._1 -> x._2.map(_._2)
    })

    val x = Array.fill(n)(false)
    val y = Array.fill(n)(0)
    val q = new mutable.Queue[Int]()
    x(0) = true
    q += 1

    while (q.nonEmpty) {
      val v = q.dequeue()
      g(v).foreach { i =>
        if (!(x(i - 1))) {
          x(i - 1) = true
          y(i - 1) = v
          q.enqueue(i)
        }
      }
    }

    println("Yes")
    println(y.tail.mkString("\n"))

  }
}


Measured memory_bytes: 120700
n=input()
i=0
a=n[i].replace('1', '9') if n[i]=='1' else n[i].replace('9', '1')
i=1
b=n[i].replace('1', '9') if n[i]=='1' else n[i].replace('9', '1')
i=2
c=n[i].replace('1', '9') if n[i]=='1' else n[i].replace('9', '1')
print(a+b+c)

Measured memory_bytes: 9140
#include <stdio.h>
int main(void){
  int w,h,n,i;
  int x[100],y[100],a[100];
  scanf("%d%d%d",&w,&h,&n);
  int w1=0,w2=w,h1=0,h2=h;
  for(i=0;i<n;i++){
    scanf("%d %d %d",&x[i],&y[i],&a[i]);
  }
  for(i=0;i<n;i++){
    if(a[i]==1){
      if(w1<=x[i]) w1=x[i];
    }
    else if(a[i]==2){
      if(w2>=x[i]) w2=x[i];
    }
    else if(a[i]==3){
      if(h1<=y[i]) h1=y[i];
    }
    else if(a[i]==4){
      if(h2>=y[i]) h2=y[i];
    }
  }
  int sum=(h2-h1)*(w2-w1);
  if(w1>=w2||h1>=h2) sum=0;
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 128
fun main(){
    val k = readLine()!!.toInt()

    var ans = 0L
    for(a in 1 until k+1){
        for(b in 1 until k+1){
            for(c in 1 until k+1) {
                ans += gcd(a, b, c)
            }
        }
    }
    println(ans)
}

fun gcd(a: Int, b: Int): Int {
    if (a < b) return gcd(b, a)
    if (b == 0) return a
    return gcd(b, a % b)
}

fun gcd(a: Int, b:Int, c:Int): Int {
    return gcd(a, gcd(b, c))
}

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

int main(){
    int H, W;
    while(cin >> H >> W && H || W){
        for(int j=0; j<W; j++){cout << "#";} 
        cout << endl;
        for(int i=1; i<H-1; i++){
            cout << "#";
            for(int j=1; j<W-1; j++){cout << ".";}
            cout << "#" << endl;}
        for(int j=0; j<W; j++){cout << "#";}
        cout << endl <<endl;
    }
    return 0;
}




Measured memory_bytes: 3068
#include<cstring>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
using namespace std;
const long long Maxn=1e6;
typedef long long ll;


ll a[Maxn],b[Maxn];

int main(){
	ll n;
	scanf("%lld",&n);
	ll op=n/2;
	for(ll i=1;i<=n;i++){
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	sort(a+1,a+1+n);
	for(ll i=1;i<=n;i++){
		if(a[op]>=b[i]) printf("%lld\n",a[op+1]);
		else printf("%lld\n",a[op]);
	}
}

Measured memory_bytes: 7808
#include<iostream>
#include<math.h>
using namespace std;

int main(){
    int N,T;
    cin >> N >> T;
    long long output = 0;
    int* t;
    t = new int[N];
    for(int i = 0;i<N;i++) cin>>t[i];
    for(int i = 0;i<N - 1;i++){
        output += (int)fmin(t[i+1] - t[i],T);
    }
    output += T;
    cout << output << endl;

    return 0;
}

Measured memory_bytes: 1024
/* ***********************************************
Author        :taciturnity
Created Time  :2020/2/3 22:02:32
File Name     :main.cpp
************************************************ */
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include<random>
#include<ctime>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define ll long long
#define INF 1e9
#define bug puts("--------------")
const ll N = 2e5 + 10;
const ll mod = 1e9 + 7;
const ll Max_n = 1e6 + 10;
using namespace std;
map<int,int> hap;
int main(){
    int n;
    cin >> n;
    for(int i = 1; i<= n;++i){
        int a;
        cin >> a;
        if(hap.count(a)) return cout <<"NO",0;
        hap[a] = 1;
    }
    cout << "YES";
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e10;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
using pll = pair<ll, ll>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string number to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n; cin >> n;
    string s; cin >> s;
    map<ll, ll> mp;
    ll cnt = 0;
    priority_queue<ll> pq;
    rep(i, n){
        if(s[i] == 'R'){
            mp[i]++;
            cnt++;
            //pq.push(i);
        }
    }
    ll ans = 0;
    for(ll i = 0; i < cnt; i++){
        if(mp[i] == 0){
            ans++;
        }
    }
    cout << ans << endl;

    /*
    ll ans = 0;
    ll flag = 0;
    vector<ll> 
    rep(i, n){
        if(s[i] == 'W'){
            ans++;
            flag++;
        }
        if(s[i] == 'R'){

        }
    }
    */

}

Measured memory_bytes: 16048
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n, x;
	cin >> n >> x;

	while (n != 0) {
		int ans = 0;
		for (int i = 1; i < n; i++) {
			for (int j = i + 1; j <= n; j++) {
				int k = x - i - j;
				if (k > j && k <= n && i != k) {
					ans++;
				}
			}
		}
		cout << ans << endl;
		cin >> n >> x;
	}

	return 0;
}


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

int main(){
    //入力
    int N, M, C;
    int B[20];
    int A[20][20];

    cin >> N >> M >> C;
    for(int i=0; i<M; i++){
        cin >> B[i];
    }
    for(int i=0;i<N;i++){
        for(int j=0; j<M;j++){
            cin >> A[i][j];
        }
    }


    //処理
    int D[20]; //和を計算させる

    for(int i=0; i<N;i++){
        D[i]=0;
        for(int j=0; j<M; j++){
            D[i]=D[i]+(A[i][j]*B[j]);
        }
    }


    int ans;
    ans =0;
    for (int i=0; i<N; i++){
        if((D[i]+C)>0){
            ans++;
        }
    }

    cout << ans << endl;



}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace abc087_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int A = int.Parse(Console.ReadLine());
            int B = int.Parse(Console.ReadLine());
            int C = int.Parse(Console.ReadLine());
            int X = int.Parse(Console.ReadLine());

            var ptn = from a in Enumerable.Range(0, A + 1)
                      from b in Enumerable.Range(0, B + 1)
                      from c in Enumerable.Range(0, C + 1)
                      select a * 500 + b * 100 + c * 50;

            Console.WriteLine(ptn.Count(m => m == X));
        }
    }
}


Measured memory_bytes: 13268
#include "bits/stdc++.h"
using namespace std;

int main() {
    double A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    double ans1 = 0.0;
    double ans2 = 0.0;
    double water = 0.0;
    double sugar = 0.0;
    double per = 0.0;
    double ans = 0.0;
    for (double x = 0.0; x * 100.0 * A <= F; x++) {
        for (double y = 0.0; y * 100.0 * B <= F - x * 100.0 * A; y++) {
            water = x * 100.0 * A + y * 100.0 * B;
            for (double z = 0.0; z * C <= F - water; z++) {
                for (double w = 0.0; w * D <= F - water - z * C; w++) {
                    sugar = z * C + w * D;
                    per = sugar * 100.0 / (sugar + water);
                    if (E * (water + sugar) >= (100.0 + E) * sugar) {
                        if (per >= ans) {
                            ans = per;
                            ans1 = sugar + water;
                            ans2 = sugar;
                        }
                    }
                }
            }
        }
    }

    std::cout << ans1 << " " << ans2 << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(4100000)
import collections
from math import factorial
from operator import mul
from functools import reduce
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n = int(input())
A = [str(input()) for _ in range(n)]
for i in range(len(A)):
    A[i] = "".join(sorted(A[i]))
A = sorted(A)
temp = A[0]
counter = 1
ans = 0
for i in range(1,len(A)):
    if temp != A[i]:
        if counter >= 2:
            # ans += factorial(counter) / factorial(2) / factorial(counter-2)
            ans += cmb(counter,2)
        temp = A[i]
        counter = 1
    else:
        counter += 1
if counter >= 2:
    # ans += factorial(counter) / factorial(2) / factorial(counter-2)
    ans += cmb(counter,2)
print(int(ans))


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

int power(int x,int y)
{
    int res=1;
    while(y>0)
    {
        if(y&1)
        res*=x;
        x*=x;
        y/=2;
    }
    return res;
}

int main()
{
    int h,w,k,ans=0;
    cin>>h>>w>>k;
    string a[h];
    char b[h][w];
    for(int i=0;i<h;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<power(2,h);i++)
    {
        for(int j=0;j<power(2,w);j++)
        {
            for(int ii=0;ii<h;ii++)
            {
                for(int jj=0;jj<w;jj++)
                {
                    b[ii][jj]=a[ii][jj];
                }
            }
            int l=i,it=0;
            while(l>0)
            {
                if(l%2)
                {
                    for(int k=0;k<w;k++)
                    {
                        b[it][k]='.';
                    }
                }
                l/=2;
                it++;
            }
            l=j,it=0;
            while(l>0)
            {
                if(l%2)
                {
                    for(int k=0;k<h;k++)
                    {
                        b[k][it]='.';
                    }
                }
                l/=2;
                it++;
            }
            long int k2=0;
            for(int ii=0;ii<h;ii++)
            {
                for(int jj=0;jj<w;jj++)
                {
                    if(b[ii][jj]=='#')
                    k2++;
                }
            }
            if(k2==k)
            ans++;
        }
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<iomanip>
#include<algorithm>
using namespace std;
double dp[100][100],g[100][100];
int main(){
  int n, m;
  while(cin >> n >> m , n){
    for(int i = 0 ; i < n ; i ++ ){
      for(int j = 0 ; j < n ; j++ ){
        cin >> g[i][j];
      }
    }
    fill_n( dp[0], n, 1.0);
    fill_n( dp[1], 9900, 0);
    for(int i = 1 ; i < m ; i++ ){ //回数
      for(int prev = 0 ; prev < n ; prev++ ){ // prev
        for(int now = 0 ; now < n ; now++ ){ // now
          dp[i][now] = max( dp[i][now], dp[i - 1][prev] * g[prev][now]);
        }
      }
    }
    cout << fixed << setprecision(2) << *max_element( dp[m - 1], dp[m - 1] + n ) << endl;
  }
}

Measured memory_bytes: 1440
#include <iostream>
#include <string>
 
using namespace std;
 
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    int temp = k;
    int snake[n];
    int Di;
    
    for(int i=0;i<n;i++)
        snake[i] = 0;
        
    while(temp--){
        cin>>Di;
        int safe[Di];
        for(int j=0; j<Di; j++){
            cin>>safe[j];              //these are the safe snakes
            snake[safe[j] - 1] = 1;
        }
            
    }
    
    int count = 0;
    for(int i=0;i<n;i++){
        if(snake[i] == 0)
            count++;
    }
    
    cout<<count;
   return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  ll n;
  cin >> n;
  
  vector<ll> b(n);
  for (int i = 0; i < n; i++){
    cin >> b[i];
  }

  int ok = 1;
  for (int i = 0; i < n; i++){
    if (i + 1 < b[i])
      ok = 0;
  }
  if (ok){
    vector<ll> c(n);
    vector<ll> res(n);
    for (int i = 0; i < n; i++){
      c[i] = b[i];
    }
    for (int i = 0; i < n; i++){
      int id = 0;
      for (int j = 0; j < n - i; j++){
        if (c[j] == j + 1){
          id = j;
        }
      }
      res[n - i - 1] = id + 1;
      for (int j = id; j < n - i - 1; j++){
        c[j] = c[j + 1];
      }
    }
    for (int i = 0; i < n; i++){
      cout << res[i] << endl;
    }
  } else {
    cout << -1 << endl;
  }

  return 0;
}


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

const int N = 1000;
char s[N];

int main() {
    scanf("%s", s + 1);
    int n = strlen(s + 1);
    while (n--) printf("x"); puts("");
    return 0;
}


Measured memory_bytes: 256
sx,sy,tx,ty=map(int,input().split())
X,Y=tx-sx,ty-sy
print(X*"R"+Y*"U"+X*"L"+Y*"D"+"D"+(X+1)*"R"+(Y+1)*"U"+"L"+"U"+(X+1)*"L"+(Y+1)*"D"+"R")

Measured memory_bytes: 3060