akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
/**
******************* Author:Bisnu sarkar ****************************
**/
/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/
#define fRead(x)       freopen(x,"r",stdin)
#define fWrite(x)      freopen (x,"w",stdout)
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define sz(s)          (int)s.size()
#define all(s)         s.begin(),s.end()
#define IO             ios_base::sync_with_stdio(false),cin.tie(NULL);  
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*///
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << ", ";
  err(++it, args...);
}
///*....Input....*///
template <typename T> inline void Int(T &n) {
  n = 0; int f = 1; register int ch = getchar();
  for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
  n = n * f;
}
 
template <typename T, typename TT> inline void Int(T &n, TT &m) { Int(n); Int(m); }
template <typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) { Int(n, m); Int(l);}
double ind(){double x; scanf("%lf",&x);return x;}

///*....Bitmask....*///
int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

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

///*....Constraints....*///
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;


int main()
{
    int n,m,k;
    Int(n,m,k);
    string s[n];
    for(int i=0;i<n;++i)cin>>s[i];

      int res=0;
    for(int i=0;i<(1<<(n+m));++i){
      std::vector<bool> row(n,false),col(m,false);
      for(int j=0;j<(n+m);++j){
        if(check_bit(i,j)){
          if(j<n)row[j]=true;
          else col[j-n]=true;
        }
      }

      int cnt=0;

      for(int r=0;r<n;++r){
        for(int c=0;c<m;++c){
          if(!row[r] and !col[c] and s[r][c]=='#'){
            ++cnt;
          }
        }
      }
      if(cnt==k)++res;
    }
    printf("%d\n", res);

    return 0;
}






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

using namespace std;

static const int INF = 1e9 + 7;

void hawawa()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto&& i : a) {
    cin >> i;
  }
  int ans = 1;
  bool upper = a[0] < a[1];
  bool eq = a[0] == a[1];
  for (int i = 1; i + 1 < n; i++) {
    if (upper != a[i] < a[i + 1] && a[i] != a[i + 1] && !eq) {
      ans++;
      if (i + 2 < n) {
        upper = a[i + 1] < a[i + 2];
        eq = a[i + 1] == a[i + 2];
      }
    }
    else if (a[i] != a[i + 1]) {
      upper = a[i] < a[i + 1];
      eq = false;
    }
  }
  cout << ans << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  hawawa();
}

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

int main(void)
{
	int i;
	double n, s[1000] = { 0 }, a = 0, m = 0;
	scanf("%lf", &n);

	while (n != 0)
	{

		for (i = 0; i < n; i++)
		{
			scanf("%lf", &s[i]);

			m = m + s[i];

		}

		m = m / n;

		for (i = 0; i < n; i++)
		{
			a = a + (s[i] - m)*(s[i] - m);

			s[i] = 0;
		}

		printf("%lf\n", sqrt(a / n));

		a = 0;
		m = 0;

		scanf("%lf", &n);

	}
	return 0;
}


Measured memory_bytes: 2108
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <bits/stdc++.h>
using namespace std;

int main(){
    int a, b, c; cin >> a >> b >> c;
    string ans = "NO";
    
    for(int i = 1; i < a*b; i++){
        if((i*a) % b == c){
            ans = "YES";
            break;
        }
    }
    
    cout << ans << endl;
    
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();

		int dx = x2 - x1;
		int dy = y2 - y1;

		System.out.printf("%d %d %d %d", x2 - dy, y2 + dx, x1 - dy, y1 + dx);
		System.out.println();

		return;
	}
}


Measured memory_bytes: 22740
#include <algorithm>
#include <functional>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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

#ifdef LOCAL
#define show(x) cerr<<__LINE__<<": "<<#x<<(x)<<endl
#else
#define show(x) true
#endif

typedef long long ll;
template<class T> using V=vector<T>;

template<class T, class U>
void chmin(T &t, const U u) { if (t > u) t = u; }

template<class T, class U>
void chmax(T &t, const U u) { if (t < u) t = u; }

const int INF = (1 << 30) - 1;
const ll INFL = (ll) 5e15;
const int MOD = 1e9 + 7;

struct Solve {

    bool solve() {
        int N, M;
        cin >> N >> M;
        if (N == 0) return false;
        vector<ll> high(N);
        vector<ll> low(N);

        for (int i = 0; i < M; ++i) {
            ll s;
            cin >> s;
            int k;
            cin >> k;
            for (int j = 0; j < k; ++j) {
                int c;
                cin >> c;
                c--;
                if (k == 1) {
                    low[c] += s;
                }
                high[c] += s;
            }
        }
        vector<pair<ll, int>> hp(N);
        vector<pair<ll, int>> lp(N);
        for (int i = 0; i < N; ++i) {
            hp[i].first = high[i];
            hp[i].second = i;
            lp[i].first = low[i];
            lp[i].second = i;
        }
        sort(all(hp));
        sort(all(lp));
        ll ans = 0;

        for (auto e : hp) {
            ll H = e.first;
            ll L = lp[0].first;
            if (lp[0].second == e.second) {
                L = lp[1].first;
            }
            ll tmp = H - L + 1;
            chmax(ans, tmp);
        }
        cout << ans << endl;


        return true;
    }

};


int main() {
    while (Solve().solve());
    return 0;
}




Measured memory_bytes: 3464
n,m = map(int,input().split())
a = list(map(int,input().split()))
b = sum(a)
d = b/(4*m)
e = 0
for i in range(len(a)):
  if a[i] >= d:
    e += 1
if e >= m:
  print("Yes")
else :
  print("No")

Measured memory_bytes: 9132
package main

import "fmt"

func main() {
	var a, b, sum int
	fmt.Scan(&a, &b)
	if a >= b {
		sum += a
		a = a - 1
		if a >= b {
			sum += a
		} else {
			sum += b
		}
	} else {
		sum += b
		b = b - 1
		if a >= b {
			sum += a
		} else {
			sum += b
		}
	}
	fmt.Println(sum)
}


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

namespace ABC157B
{
    class Program
    {
        static void Main(string[] args)
        {
            int[,] A = new int[3, 3];
            for(int i = 0; i < 3; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                A[i, 0] = int.Parse(input[0]);
                A[i, 1] = int.Parse(input[1]);
                A[i, 2] = int.Parse(input[2]);
            }
            int N = int.Parse(Console.ReadLine());
            int[] b = new int[N];
            for (int i = 0; i < N; i++)
            {
                b[i] = int.Parse(Console.ReadLine());
            }
            bool[,] bingo = new bool[3, 3];
            for(int i = 0; i < 3; i++)
            {
                for(int j = 0; j < 3; j++)
                {
                    if (b.Contains(A[i, j]) == true)
                    {
                        bingo[i, j] = true;
                    }
                }
            }
            bool hantei = false;
            if (bingo[0, 0] == true & bingo[0, 1] == true & bingo[0, 2] == true)
            {
                hantei = true;
            }
            else if (bingo[1, 0] == true & bingo[1, 1] == true & bingo[1, 2] == true)
            {
                hantei = true;
            }
            else if (bingo[2, 0] == true & bingo[2, 1] == true & bingo[2, 2] == true)
            {
                hantei = true;
            }
            else if (bingo[0, 0] == true & bingo[1, 0] == true & bingo[2, 0] == true)
            {
                hantei = true;
            }
            else if (bingo[0, 1] == true & bingo[1, 1] == true & bingo[2, 1] == true)
            {
                hantei = true;
            }
            else if (bingo[0, 2] == true & bingo[1, 2] == true & bingo[2, 2] == true)
            {
                hantei = true;
            }
            else if (bingo[0, 0] == true & bingo[1, 1] == true & bingo[2, 2] == true)
            {
                hantei = true;
            }
            else if (bingo[2, 0] == true & bingo[1, 1] == true & bingo[0, 2] == true)
            {
                hantei = true;
            }
            if (hantei == true)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


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

int main() 
{
    int n;
    cin >> n;
    int ans = 0;
    rep(i,n) {
       int index=i+1;
       int a;
       cin >> a;
       if (index%2==0) continue;        
       if (a%2==0) continue;
       ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
using namespace std;
typedef long long ll;

int main() {
    ll D, N;
    cin >> D >> N;
    ll ans = 1;
    for (int i = 0; i < D; i++) ans *= 100;
    if (D == 0 && N == 100) cout << ans * 100 + 1 << endl;
    else if (D == 1 && N == 100) cout << ans * 100 + 100 << endl;
    else if (D == 2 && N == 100) cout << ans * 100 + 10000 << endl;
    else cout << ans * N << endl;
    return 0;
}

Measured memory_bytes: 256
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N;
ll arr[100005][5];
ll dp[100005][5];

ll rec(int ind, int ctr) {
	if(ind >= N) {
		return 0;
	}
	ll &ans = dp[ind][ctr];
	if(ans != -1) {
		return ans;
	}
	if(ctr == 0) {
		ans = max(arr[ind][1] + rec(ind + 1, 1), arr[ind][2] + rec(ind + 1, 2));
	}
	else if(ctr == 1) {
		ans = max(arr[ind][0] + rec(ind + 1, 0), arr[ind][2] + rec(ind + 1, 2));
	}
	else if(ctr == 2) {
		ans = max(arr[ind][1] + rec(ind + 1, 1), arr[ind][0] + rec(ind + 1, 0));
	}
	// ans = max(arr[ind][0] + rec(ind + 1, 0), max(arr[ind][1] + rec(ind + 1, 1), arr[ind][2] + rec(ind + 1, 2)));
	return ans;
}

int main() {
	scanf("%lld", &N);
	for(int i = 0; i < N; i++) {
		for(int j = 0; j < 3; j++) {
			scanf("%lld", &arr[i][j]);
		}
	}
	ll maxVal = arr[0][0];
	ll maxInd = 0;
	for(int i = 0; i < 3; i++) {
		if(maxVal < arr[0][i]) {
			maxVal = arr[0][i];
			maxInd = i;
		}
	}
	memset(dp, -1, sizeof(dp));
	// cout << maxInd << " " << maxVal << "\n";
	cout << maxVal + rec(1, maxInd);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 14336
;;;; mod
(let ((p 998244353))
  (defun mod+ (a b)
    (mod (+ a b) p))

  (defun mod* (a b)
    (mod (* a b) p))

  (defun mod_expt (a z)
    (loop :with ans := 1
          :with pow := a
          :while (> z 0)
          :do (multiple-value-bind (x y) (floor z 2)
                (setf z x)
                (if (= y 1) (setf ans (mod* ans pow)))
                (setf pow (mod* pow pow)))
          :finally (return ans)))
  (defun mod_inv (a)
    (mod_expt a (- p 2))))
;;;; main
(let* ((n (read))
       (k (read))
       (f (make-array (list (1+ n))))
       (a (make-array (list (1+ n))))
       (s (make-array (list k) :initial-element nil)))
  (loop :for i :from 0 :to (1- k)
        :for l := (read)
        :for r := (read)
        :do (setf (aref s i) (cons l r)))
  ;;
  (setf (aref f 1) 1)
  (setf (aref a 2) -1)
  (loop :for i :from 1 :to (1- n)
        :do (loop :for j :from 0 :to (1- k)
                  :for (l . r) := (aref s j)
                  :if (<= (+ i l) n)
                  :do (setf (aref a (+ i l)) (mod+ (aref a (+ i l)) (aref f i)))
                  :if (<= (+ i r 1) n)
                  :do (setf (aref a (+ i r 1)) (mod+ (aref a (+ i r 1)) (- (aref f i)))))
        :do (setf (aref f (1+ i)) (mod+ (aref f i) (aref a (1+ i)))))
  (format t "~A~%" (aref f n)))


Measured memory_bytes: 27816
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;cin>>h>>w;
  vector<string> s(h);
  for(int i=0;i<h;i++)cin>>s.at(i);
  for(int j=0;j<w+2;j++)cout<<'#';
  cout<<endl;
  for(int k=0;k<h;k++)cout<<"#"<<s.at(k)<<"#"<<endl;
  for(int j=0;j<w+2;j++)cout<<'#';
  cout<<endl;
}


Measured memory_bytes: 256
n = int(input())
result = []
check = True
for i in range(n):
    new = input()
    if new in result:
        check = False
    if i!=0:
        if result[-1][-1]!=new[0]:
            check = False
    result.append(new)

if check:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <stdio.h>

int main()
{
  int A,B,C,X,Y;
  int i=0;
  int result =0;
  scanf("%d %d %d %d %d",&A,&B,&C,&X,&Y);
  if(X<Y && 2*C<B){
    printf("%d\n",2*C*Y);
  }
  else if(Y<X && 2*C<A){
    printf("%d\n",2*C*X);
  }
  else if(X<Y){
    if(A+B>=2*C){
      while(i<X){
        result += 2*C;
        ++i;  --Y;
      }
      while(Y>0){
        result+=B;
        --Y;
      }
      printf("%d\n",result);
    }
    else  printf("%d\n", A*X+B*Y);
  }
  else if(X>Y){
    if(A+B>=2*C){
      while(i<Y){
        result += 2*C;
        ++i;  --X;
      }
      while(X>0){
        result+=A;
        --X;
      }
      printf("%d\n",result);
    }
    else  printf("%d\n", A*X+B*Y);
  }
  else{
    if(A+B>=2*C) printf("%d\n",2*C*X);
    else printf("%d\n",(A+B)*X);
  }
  return 0;
}

Measured memory_bytes: 128
n = gets.to_i
ln=gets.chomp.split(" ").map(&:to_i);
cnt = 0

ln.combination(3).to_a.each do |x|
    a = x[0] + x[1]
    b = x[0] + x[2]
    c = x[1] + x[2]
    if (a > x[2]) && (b > x[1]) && (c > x[0]) && (x.uniq.count - x.count == 0)
        cnt += 1
    end
end

puts cnt


Measured memory_bytes: 29628
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

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

        List<Integer> diff = new ArrayList<Integer>();
        
        for(int i = 1; i < n+1; i++) {
          int value = l+i-1;
          if(value < 0) {
            value = value * -1;
          }
          diff.add(value);
          }
        
        Integer removeK = diff.indexOf(Collections.min(diff)) + 1;
        
        
        System.out.println(n*l + n*(n+1)/2 - n - (l+ removeK -1));
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
const int MAXW = 1e5 + 7;
typedef pair<int, int> PII;
PII th[105];
long long dp[MAXW];
int main()
{
    int n, w;
    cin >> n >> w;
    for(int i = 1; i <= n; i++)
        cin >> th[i].first  >> th[i].second; //weight --> value
    for(int i = 1; i <= n; i++)
        for(int j = w; j >= th[i].first; j--)
            dp[j] = max(dp[j], dp[j - th[i].first] + th[i].second);
    cout << dp[w] << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  for (int i=0; i<n; i++) {
    cout << s[i];
    cout << t[i];
  }
  cout << endl;
  return 0;
}

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

int sorts(int* x,int* y){
  if(*x<*y){
      int temp=*x;
       *x=*y;
       *y=temp;
  }
}
int main(){
    int x,y;
    int ans;
    cin>>x>>y;
    while(x!=y){
      sorts(&x,&y);
      ans=x-y;
      x=ans;
    }
    cout<<x<<endl;
}

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

using namespace std;

    const int INF = 0x3f3f3f3f;
    const int N = 300; 

int d[N][N];

int cost[8][8];
int dp[1<<8][8];

void solve() {
    int n,m, R;
    cin >> n >> m >> R;
    vector<int> a(R);
    for (int i = 0; i < R; i++) {
        cin >> a[i]; a[i]--;
    }
    memset(d, INF, sizeof d);
    for (int _ = 0; _ < m; _++) {
        int x,y,z;
        cin >> x >> y >> z;
        x--;y--;
        d[x][y] = d[y][x] = min(d[x][y], z);
    }
    for (int i = 0; i < n; i++) {
        d[i][i] = 0;
    }

    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (d[i][k] < INF && d[k][j] < INF) {// for negative
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
                }
            }
        }
    }

    for (int i = 0; i < R; i++) {
        for (int j = 0; j < R; j++) {
            cost[i][j] = d[a[i]][a[j]];
        }
    }

    const int MSK = 1<<R; 
    memset(dp, INF, sizeof dp);
    dp[0][0] = 0;
    for (int msk = 0; msk < MSK; msk++) {
        for (int i = 0; i < R; i++) {
            if (msk & (1<<i)) continue;
            for (int j = 0; j < R; j++) {
                if (msk & (1<<j)) {
                    dp[msk ^ (1<<i)][i] = min(dp[msk^(1<<i)][i], dp[msk][j] + cost[j][i]);
                }
            }
            if (msk == 0) dp[1<<i][i] = 0;
        }
    }
    int res = INF;
    for (int i = 0; i < R; i++) {
        res = min(res, dp[MSK-1][i]);
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

int main() {
  int n;
  cin >> n;
  
  int t = n, h = 0;
  while (t > 0){
     h += t % 10;
     t /= 10;
  }
  
  if (n % h == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 256
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

  double T, X;
  cin >> T >> X;
  cout << T / X << endl;
}


Measured memory_bytes: 256
def cmb(n, r, mod):
    c=1
    for i in range(1, r+1):
        c = (c * (n-i+1) * pow(i, mod-2, mod)) % mod
    return c

n, a, b = map(int, input().split())
MOD = 10**9 + 7
print((pow(2, n, MOD) - cmb(n, a, MOD) - cmb(n, b, MOD) - 1) % MOD)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

using ll = long long;
using p = pair<ll, ll>;
constexpr ll RED = 1;
constexpr ll BLUE = -1;
constexpr ll MAX_N = 100;

struct point {
    ll x;
    ll y;
    ll c;
    point() : x(-1), y(-1), c(0) {}
    point(ll x, ll y, ll c) : x(x), y(y), c(c) {}

    /*
    bool operator=(ll& other) {
        return this->x == other.x && this->y == other.y && this->c == other.c;
    }
    */
};

ll N;

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

    cin >> N;
    vector<point> points(2 * N);
    for (ll i = 0; i < N; i++) {
        cin >> points[i].x >> points[i].y;
        points[i].c = RED;
    }

    for (ll i = 0; i < N; i++) {
        cin >> points[i + N].x >> points[i + N].y;
        points[i + N].c = BLUE;
    }

    sort(points.begin(), points.end(), [](point& l, point& r) {
        return l.x < r.x;
    });

    ll ans = 0;
    vector<point> reds;
    for (auto&& pt : points) {
        if (pt.c == RED) {
            reds.push_back(pt);
        } else {
            ll maxy = -1;
            ll idx = -1;
            for (ll i = 0; i < reds.size(); i++) {
                if (reds[i].y < pt.y && maxy < reds[i].y) {
                    maxy = reds[i].y;
                    idx = i;
                }
            }

            if (idx != -1) {
                reds.erase(reds.begin() + idx);
                ans++;
            }
        }
    }

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



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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	int A = a * n;
	cout << min(A,b) << endl;
}


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

int main() {
  int N = 0, sum = 0, mul = 0;
  cin >> N;
  
  sum = N % 10;
  mul = 10;
  
  for (int i = 0; i < 8; i++) {
    sum += (N / mul) % 10;
    mul *= 10;
  }
  
  if (N % sum == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vector<vi>
#define vll vector<ll>
#define vvll vector<vll>
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define sf(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define sff(a,b) scanf("%d%d",&a,&b);
#define sfffl(a,b) scanf("%lld%lld",&a,&b);
#define nwln() printf("\n");
#define prd(a) printf("%d",a);
#define prld(a) printf("%lld",a);
#define space printf(" ");
#define ft cout<<"for test"<<endl;
#define read(v) for(auto &it:v)cin>>it;
#define PI 2*acos(0.0)
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main()
{
    FIO;
    ll x,i,j,a,b;
    cin>>x;
    for(i=-1000; i<=1000; i++)
        for(j=-1000; j<=1000; j++)
            if(pow(i,5)-pow(j,5)==x)
            {
                return cout<<i<<' '<<j<<endl, 0;
            }
}


Measured memory_bytes: 4108
#include<stdio.h>
int main()
{
	int a,b,c[3010][10],i=0,j;
	while(1>0)
	{
		scanf("%d %d",&a,&b);
		if(a==0 && b==0)
			break;
		i++;
		if(a<b)
		{
			c[i][1]=a;
			c[i][2]=b;
		}
		else
		{
			c[i][1]=b;
			c[i][2]=a;
		}
	}	
	for(j=1;j<=i;j++)
		printf("%d %d\n",c[j][1],c[j][2]);
	
}


Measured memory_bytes: 1932
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	int n, k, amin=1;
	cin >> n >> k;
	REP(i, n) {
		amin = min(amin * 2, amin + k);
	}
	cout << amin << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi   = vec<int>;
using vvi  = vec<vi>;
using vvvi = vec<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int n; cin>>n;
  vi a(n);
  rep(i,n) cin >> a[i];
  int sum = 0;
  rep(i,n) sum ^= a[i];
  rep(i,n) cout << (a[i]^sum) << " ";
  cout << endl;
  return 0;
}


Measured memory_bytes: 3976
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath> 

using namespace std;

const int N = 100;
const int M = 8000;
#define ll long long

int n,m,DP[M][N][N],b[2*N][N],a[N][N];

void in(){
	scanf("%d%d",&n,&m);
	for(int i = 1; i <= n*2; i++)
		for(int j = 1; j <= m; j++)
			scanf("%d",&b[i][j]);
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			a[i][j] = abs(b[i][j] - b[i+n][j]);
} 

void _DP(){
	DP[0][1][1] = 1;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			for(int l = 0; l <= 6400; l++){
				if(!DP[l][i][j]) continue;
				DP[l+a[i][j]][i+1][j] = DP[abs(l - a[i][j])][i+1][j] = DP[l+a[i][j]][i][j+1] = DP[abs(l - a[i][j])][i][j+1] = 1;
			}
}

void print(){
	for(int i = 0; i <= 6400; i++)
		if(DP[i][n+1][m] || DP[i][n][m+1]){
			cout << i;
			break;
		}
}

int main(){
	in();
	_DP();
	print();
}

Measured memory_bytes: 253952
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int N, a;

  std::map<int, int> map;

  std::cin >> N;

  for (int i = 0; i < N; i ++) {
    std::cin >> a;

    map[a] ++;
  }

  int c = 0;

  for (const auto& kv : map) {
    if (kv.second < kv.first) {
      c += kv.second;
    }
    else {
      c += kv.second - kv.first;
    }
  }

  std::cout << c << std::endl;

  return 0;
}


Measured memory_bytes: 4736
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    s = input()
    s = s.replace('BC', 'D')
    n = len(s)
    i = 0
    ans = 0
    while i < n:
        while i < n and (s[i] == 'B' or s[i]=='C'):
            i += 1
        st = i
        cnt = 0
        while i < n and (s[i] == 'A' or s[i]=='D'):
            if s[i] == 'A':
                cnt += 1
            i += 1
        ed = i
        for j in range(st, ed):
            if s[j] == 'A':
                cnt -= 1
                ans +=ed-j-cnt-1
    print(ans)

    
    


                
if __name__ == '__main__':
    main()

Measured memory_bytes: 9236
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

ll f[400000];

void calc() {
    f[0] = 1;
    rep(i, 1, 400001) {
        f[i] = f[i - 1] * i;
        f[i] %= mod;
    }
}

ll pow_mod(ll a, ll b, ll m){
    ll ret = 1;
    while (b > 0) {
        if (b & 1) {
            ret = ret * a % m;
        }
        a = a * a % m;
        b >>= 1;
    }
    return ret;
}

ll inv_mod(ll a, ll m){
    return pow_mod(a, m - 2, m);
}

ll comb(ll n, ll r) {
    ll ret = 1;
    for(ll i = n; i >= n - r + 1; i--) {
        ret *= i;
        ret %= mod;
    }
    
    ret *= inv_mod(f[r], mod);
    ret %= mod;
//    cout << n << "," << r << ":" << ret << endl;
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    ll n, a, b;
    cin >> n >> a >> b;
    calc();
    ll ans = pow_mod(2, n, mod);
    ans -= comb(n, a);
    ans %= mod;
    ans -= comb(n, b) + 1;
    ans %= mod;
    ans += mod;
    ans %= mod;
    output(ans);
    
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define clr(a,x) memset(a,x,sizeof(a))
#define SZ(x) ((int)(x).size())
#define lson rt<<1
#define rson rt<<1|1
#define pb push_back
#define fi first
#define se second
#define what_is(x) cerr<<#x<<" "<<x<<endl;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
template <typename T>
inline void _read(T& x){
    cin>>x;
}
void R(){}
template <typename T,typename... U>
void R(T&head,U&... tail){
    _read(head);
    R(tail...);
}

template <typename T>
inline void _write(const T& x){
    cout<<x<<' ';
}
void W(){cout<<endl;}
template <typename T,typename... U>
void W(const T&head,const U&... tail){
    _write(head);
    W(tail...);
}
template<typename T>
void debug(vector<T> V){
    for(auto x:V){
        cout<<x<<" ";
    }
    cout<<endl;
}
void go();
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //cout<<fixed<<setprecision(8);
    go();
    return 0;
}
/*************************************/

void go(){
    ll a,b,c,d;
    R(a,b,c,d);
    a--;
    ll ans=b/c+b/d-b/(c/__gcd(c,d)*d);
    //W(ans);
    ans-=a/c+a/d-a/(c/__gcd(c,d)*d);
    //W(ans);
    ans=b-a-ans;
    W(ans);
}


Measured memory_bytes: 256
#include <stdio.h>
using namespace std;
int main(){
  int A, B, C;
  scanf("%d %d %d", &A, &B, &C);
  if (A==7) {
    if (B==5 && C==5) printf("YES\n");
    else printf("NO\n");
  } else if (B==7) {
    if (A==5 && C==5) printf("YES\n");
    else printf("NO\n");
  } else if (C==7) {
    if (A==5 && B==5) printf("YES\n");
    else printf("NO\n");
  } else {
    printf("NO\n");
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K;
    cin >> K;
    /*auto bfs = [&](auto && self, string S) -> void{
        if(K < 0) return;
        cout << K << " " << S << endl;
        if(S == ""){
            for(char c='1';c<='9';c++){
                string tmp = S + c;
                K--;
                if(K == 0){
                    cout << tmp << endl;
                    return;
                }
                self(self, tmp);
            }
        }
        else{
            for(char c='0';c<='9';c++){
                if(abs((S.back() - '0') - (c - '0')) > 1) continue;
                string tmp = S;
                tmp += c;
                K--;
                if(K == 0){
                    cout << tmp << endl;
                    return;
                }
                self(self, tmp);
            }
        }
    };
    */
    queue<string> q;
    string t = "";
    q.push(t);
    while(!q.empty() && K > 0){
        string cur = q.front();
        q.pop();
        if(cur == ""){
            for(char c='1';c<='9';c++){
                string tmp = cur + c;
                K--;
                if(K == 0){
                    cout << tmp << endl;
                    break;
                }
                q.push(tmp);
            }
        }
        else{
            for(char c='0';c<='9';c++){
                if(abs((cur.back() - '0') - (c - '0')) > 1) continue;
                string tmp = cur;
                tmp += c;
                K--;
                if(K == 0){
                    cout << tmp << endl;
                    break;
                }
                q.push(tmp);
            }
        }
    }
    
}

Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  ll a, b, c;
  cin >> a >> b >> c;
  ll x, y;
  cin >> x >> y;
  ll z = min(x, y);
  ll ans = 0;
  ans = z * min( a + b, 2 * c);
  if (x - z > 0) {
    ans += (x-z) * min(a, 2*c);
  }
  if (y - z > 0) {
    ans += (y-z) * min(b, 2*c);
  }
  cout << ans << endl;
}

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

Measured memory_bytes: 3632
#include <iostream>                                                      
#include <cstring>                                                       
using namespace std;                                                     
                                                                         
int main() {                                                             
  int n, m;                                                              
  cin >> n >> m;                                                         
  int a[n][m];                                                           
  int b[m];                                                              
  for (int i=0; i<n; i++) {                                              
    for (int j=0; j<m; j++) {                                            
      cin >> a[i][j];                                                    
    }                                                                    
  }                                                                      
  for (int i=0; i<m; i++) {                                              
    cin >> b[i];                                                         
  }                                                                      
  int c[n];                                                              
  memset(c,0,sizeof(c));                                                 
  for (int i=0; i<n; i++) {                                              
    for (int j=0; j<m; j++) {                                            
      c[i] += a[i][j]*b[j];                                              
    }                                                                    
  }                                                                      
  for (int i=0; i<n; i++) {                                              
    cout << c[i] << endl;                                                
  }                                                                      
  return 0;                                                              
}                                                                        
                                                                         
                                                                         
                          

Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int mod,n;
const int N = 1e4+5;
int fac[N], ifac[N], h[N], g[N];
inline int qpow(int a,int b){int ret=1;for(;b;b>>=1,a=1ll*a*a%mod)if(b&1)ret=1ll*ret*a%mod;return ret;}

inline void init(int n){
	fac[0]=ifac[0]=1;for(int i=1;i<=n;i++)fac[i]=1ll*fac[i-1]*i%mod;
	ifac[n]=qpow(fac[n],mod-2);for(int i=n-1;i;i--)ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
	g[0]=1;for(int i=1;i<=n;i++)g[i]=1ll*g[i-1]*ifac[3]%mod*2%mod;
	h[0]=1;for(int i=1;i<=n;i++)h[i]=1ll*h[i-1]*ifac[2]%mod;
}
int ans=0;

int main(){
	cin >> n >> mod;
	init(n*3);
	int ans=0;
	for(int i=0;i<=n*3;i++){
		for(int j=0;j*2+i<=n*3&&j<=i;j++){
			if((i+2*j)%3==0){
				int k=(3*n-i-2*j)/3;
				ans = (1ll*ans + 1ll*h[j]*g[k]%mod*ifac[i]%mod*ifac[j]%mod*ifac[k]%mod*fac[n*3]%mod)%mod;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
n = int(input())
x = list(map(int, input().split()))
y = x.copy()
x = sorted(x)
l = x[n//2-1]
r = x[n//2]
for i in y:
    if i <= l:
        print(x[n//2])
    else:
        print(x[n//2-1])


Measured memory_bytes: 25472
#include <iostream>
#include <algorithm>
#include <string>


using namespace std;

string str;

void input() {
  cin >> str;
}

void solve() {
  int price = 700;
  for(auto c : str) {
    if(c=='o') price+=100;
  }
  cout << price << endl;
}

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


Measured memory_bytes: 256
import std.stdio, std.array;

void main() {
  for(int t; readf("%d\n", &t), t != 0;) {
    int x_point = 0, y_point = 0;
    int[] x, y;
    foreach(i; 0..t) {
      int a, b;
      readf("%d %d\n", &a, &b);
      x ~= a;
      y ~= b;
    }
    while(x.length != 0 && y.length != 0) {
      int n = x.front;
      int m = y.front;
      x.popFront; y.popFront;
      if (n == m) {x_point += n; y_point += m;}
      else if (n > m) {
        x_point += (n + m);
      }
      else {
        y_point += (n + m);
      }
    }
    writeln(x_point, " ", y_point);
  }
}

Measured memory_bytes: 1236
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <tuple>
#include <unordered_map>
#include <map>
#include <cmath>

#define endl "\n"
#define eb emplace_back
#define ll long long

using namespace std;

int main() {

    cin.tie(nullptr); cout.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n, w;
    cin >> n >> w;

    ll dp[w+1];
    fill(dp, dp+w+1, 0);

    int vals[n], weights[n];

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

    for (int i = 0; i < n; i++) {
        for (int j = w; j >= weights[i] && j-weights[i] >= 0; j--) {
            dp[j] = max(dp[j], vals[i] + dp[j-weights[i]]);
        }
    }


    cout << dp[w] << endl;

    return 0;

}

Measured memory_bytes: 4332
N = int(input())
MOD = 10**9 + 7

fact = [1]*(N+1)

for i in range(1, N+1):
    fact[i] = r = i*fact[i-1] % MOD

cnts = [0]*(N+1)
rev = 1
for K in range(N-1, (N+1)//2-1, -1):
    cnts[K] = fact[K]*fact[K-1]*rev % MOD
    rev = rev * (2*K-N) * (2*K-N-1) % MOD

ans = 0
for K in range((N+1)//2, N):
    ans += (cnts[K] - cnts[K-1]) * K % MOD
    ans %= MOD
ans = (ans * pow(fact[N-2], MOD-2, MOD)) % MOD
print(ans)

Measured memory_bytes: 68252
#include<iostream>
#include<algorithm>
using namespace std;
static const long long INFTY = (1LL << 32);
int main()
{
	int n, m, p, q, r,i,j,k,a,b,cost,time;
	long long cost_d[101][101], time_d[101][101];
	while (1) {
		cin >> n >> m;
		if (n == 0 && m == 0)break;
		for (i = 1; i <= m; i++) {
			for (j = 1; j <= m; j++) {
				cost_d[i][j] = ((i == j) ? 0 : INFTY);
				time_d[i][j] = ((i == j) ? 0 : INFTY);
			}
		}
		for (i = 0; i < n; i++) {
			cin >> a >> b >> cost >> time;
			cost_d[a][b] = cost;
			cost_d[b][a] = cost;
			time_d[a][b] = time;
			time_d[b][a] = time;
		}
		for (k = 1; k <= m; k++) {
			for (i = 1; i <= m; i++) {
				if (cost_d[i][k] == INFTY)continue;
				for (j = 1; j <= m; j++) {
					if (cost_d[k][j] == INFTY)continue;
					cost_d[i][j] = min(cost_d[i][j], cost_d[i][k] + cost_d[k][j]);
					time_d[i][j] = min(time_d[i][j], time_d[i][k] + time_d[k][j]);
				}
			}
		}
		cin >> k;
		for (i = 0; i < k; i++) {
			cin >> p >> q >> r;
			if (r == 0) {
				cout << cost_d[p][q]<<endl;
			}
			else {
				cout << time_d[p][q] << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
const ll INF = 1LL<<60;

int main()
{
  ll n;cin>>n;
  ll hoge,min=n+1;
  ll ans=0;
  bool flag=true;
  for(ll i=0;i<n;i++){
    cin>>hoge;
    if(chmin(min,hoge))ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstdio>
#include <queue>
using namespace std;

typedef pair<int, int> lake;

int main(void){
  string str;
  stack<int> slashes;
  stack<lake> lakes;
  stack<int> out;
  int sum_area=0;
  getline(cin, str);

  for(int i=0;i<str.length();i++){
    if(str[i] == '\\'){
      slashes.push(i);
    }else if(str[i] == '/'){
      if(!slashes.empty()){
        int sum=0;
        sum_area += i - slashes.top();
        if(!lakes.empty()){
          while(!lakes.empty() && lakes.top().second > slashes.top()){
            sum += lakes.top().first;
            lakes.pop();
          }
        }
        lakes.push(lake(sum+i - slashes.top(), i));
        slashes.pop();
      }
    }
  }
  cout << sum_area << endl;
  cout << lakes.size();
  while(!lakes.empty()){
    out.push(lakes.top().first);
    lakes.pop();
  }
  while(!out.empty()){
    cout << " " << out.top();
    out.pop();
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1312
#include <stdio.h>
#include <string.h>
#define N 1000

void cm(char a[] , char b[]);
int max(int a , int b);
int c[N+1][N+1];

int main()
{
	char a[N];
	char b[N];
	int i , n;
	scanf("%d",&n);
	for(i = 1; i <= n; i++)
	{
		scanf("%s%s",a+1,b+1);
		a[0]=b[0]= ' ';
		cm(a,b);
	}
}

int max(int a , int b)
{
	if(a < b)return b;
	else return a;
}

void cm(char  a[]  , char b[])
{
	int i , j;
	int m1,m2;
	m1 = strlen(a)-1;
	m2 = strlen(b)-1;
	int ma = 0;
	for(i=0;i<m1;i++)
	{
		c[0][i]=0;
	}
	for(j=0;j<m2;j++)
	{
		c[0][j]=0;
	}
	for(int i = 1; i <=m1; i++)
	{
		for(int j = 1; j<=m2; j++)
		{
			if(a[i]==b[j])
			{
				c[i][j]=c[i-1][j-1]+1;
			}
			else{
				c[i][j]=max(c[i-1][j],c[i][j-1]);
			}
			ma = max(ma,c[i][j]);
				
		}
	}
	printf("%d\n",ma);
}



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

#define ll long long
#define INF 1 << 40

using namespace std;

ll N, A, B;
vector<ll> h(100100);

bool check(ll n) {
  ll count = n;
  for (int i = 0; i < N; i++) {
    ll rem = max(h[i] - n * B, 0LL);
    if (rem % (A - B) == 0)
      count = count - (rem / (A - B));
    else
      count = count - (rem / (A - B) + 1);
  }
  if (count >= 0) {
    return true;
  }
  return false;
}

int main() {
  cin >> N >> A >> B;
  ll mx = -1;
  for (int i = 0; i < N; i++) {
    cin >> h[i];
    mx = max(mx, h[i]);
  }

  ll ok = mx / B + 1, ng = 0;
  while (ok - ng > 1) {
    ll mid = (ok + ng) / 2;
    if (check(mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  cout << ok << endl;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.next());
        int M = Integer.parseInt(scanner.next());
        List<Integer>[] edges = new List[N];
        for (int i = 0; i < N; i++) {
            edges[i] = new ArrayList<>();
        }
        for (int i = 0; i < M; i++) {
            int s = Integer.parseInt(scanner.next());
            int t = Integer.parseInt(scanner.next());
            edges[s - 1].add(t - 1);
        }

        double[] dp = new double[N];
        for(int i = N - 2; i >= 0; i--) {
            double sum = 0;
            for (int next: edges[i]) {
                sum += dp[next];
            }
            sum /= edges[i].size();
            sum += 1;
            dp[i] = sum;
        }

        double ans = dp[0];
        for (int ni = 0; ni < N - 1; ni++) {
            if (edges[ni].size() == 1) continue;
            int nj = edges[ni].get(0);
            for (int next: edges[ni]) {
                if (dp[nj] < dp[next]) {
                    nj = next;
                }
            }
            // ignore edge (ni -> nj)

            double[] dp2 = new double[N];
            for(int i = N - 2; i >= 0; i--) {
                double sum = 0;
                for (int next: edges[i]) {
                    if (i == ni && next == nj) continue;
                    sum += dp2[next];
                }
                int deg = edges[i].size();
                if (i == ni) deg--;
                sum /= deg;
                sum += 1;
                dp2[i] = sum;
            }

            ans = Math.min(ans, dp2[0]);
        }

        System.out.printf("%.10f\n", ans);
    }
}


Measured memory_bytes: 67544
#include <bits/stdc++.h>
#define M 1000000007 
#define mod 1000000007
typedef long long ll;
using namespace std;

void solve() 
{ 
    ll n;
    cin>>n;
    vector<ll> A(n);
    for(ll i=0; i<n; ++i) cin>>A[i];
    ll sum = 0;
    ll psum = 0;
    for(auto x: A){
        sum += (psum*x)%M;
        psum += x;
        sum %= M;
        psum %= M;
    }
	cout<<sum%M;
} 



int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int q;
    q=1;
    // cin>>q;
    while(q--) solve();


    return 0;
}


Measured memory_bytes: 4836