akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  for(int i = 0; i < h; ++i)
  {
    cin >> a[i];
  }

  vector<int> erased_h;
  vector<int> erased_w;
  for(int i = 0; i < h; ++i)
  {
    if (a[i] == string(w, '.')) 
    {
      erased_h.emplace_back(i);
    }
  }
  erased_h.emplace_back(1000);

  for(int i = 0; i < w; ++i)
  {
    bool ok = true;
    for(int j = 0; j < h; ++j)
    {
      ok &= (a[j][i] == '.');
    }
    if(ok) erased_w.emplace_back(i);
  }

  reverse(erased_w.begin(), erased_w.end());
  for(int i = 0; i < h; ++i)
  {
    for(const auto& e : erased_w)
    {
      a[i].erase(a[i].begin() + e);
    }
  }

  int eh = 0;
  for(int i = 0; i < h; ++i)
  {
    if (erased_h[eh] == i)
    {
      eh++;
      continue;
    }
    cout << a[i] << endl;
  }
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

double check(double ax,double ay, double bx, double by){
  return ax*by - ay*bx;
}

int main(){
  double x[4],y[4];
  char c;

  while( cin>>x[0]>>c>>y[0] && c ){
    for( int i=1;i<4;i++ )
      cin >> c >>  x[i] >> c >> y[i];

    bool f=true;
    for( int i=0;i<4;i++ ){
      int j = (i+1)%4, k=(i+2)%4, l=(i+3)%4;

      double ax=x[i]-x[j], ay=y[i]-y[j];
      if( check(ax,ay,x[j]-x[k],y[j]-y[k]) *
	  check(ax,ay,x[j]-x[l],y[j]-y[l]) > 0 ){
      }else{
	f=false;
	break;
      }
    }
    if( f )
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_f(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_f2(const void* a, const void* b) {
    return *((uint64_t*)a) > * ((uint64_t*)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

int main(void) {
    size_t r, D;
    uint64_t x2000;

    scanf("%zu %zu %"PRIu64, &r, &D, &x2000);

    for (size_t i = 0; i < 10; i++) {
        x2000 = (uint64_t)r * x2000 - (uint64_t)D;

        printf("%"PRIu64"\n", x2000);
    }

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  ll x;
  cin >> x;

  ll ans = 0;
  ans += (x / 500) * 1000;
  x %= 500;
  ans += (x / 5) * 5;

  cout << ans << endl;

  return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N+1, 0);
  for(int i=1; i<=N; i++){
    cin >> A.at(i);
  }
  int Ans=0;
  for(int i=1; i<=N; i++){
    if(A.at(A.at(i))==i){
      Ans++;
    }
  }
  cout << Ans/2 << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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





int main(){
  ll A,B;
  cin >> A >> B;
  ll cm = gcd(A,B);
  ll ans = 0;
  for(ll i = 2; i <sqrt(cm); i++){
    if(cm % i == 0) ans++;
    while(cm % i == 0) cm /= i;
  }
  if(cm != 1) ans++;
  cout << ans+1 << endl;
  
  return 0;
}




Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String tmp = sc.next();
        StringBuffer sb = new StringBuffer();
        sb.insert(0, tmp);
        int[] tmp2 = new int[sb.length()];
        for (int i = 0; i < sb.length(); i++) {
            tmp2[i] = sb.charAt(i);
        }
        String ans;
        if (sb.charAt(0) == sb.charAt(1)) {
            ans = "Bad";
        } else if(sb.charAt(1) == sb.charAt(2)){
            ans = "Bad";
        } else if (sb.charAt(2) == sb.charAt(3)) {
            ans = "Bad";
        } else {
            ans = "Good";
        }
        System.out.println(ans);
        
    }
}

Measured memory_bytes: 25172
/* Problem

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

// Data Type
#define ull     			unsigned long long int
#define ll      			long long int
#define ld					long double

// Loops
#define loop(i,s,e)     	for(ll i=(s);i<(e);i++)
#define rloop(i,s,e)    	for(ll i=(s);i>=(e);i--)

// Stl
#define pb      			push_back
#define eb      			emplace_back
#define pf      			push_front
#define popb    			pop_back
#define popf    			pop_front
#define mp      			make_pair
#define F      				first
#define S      				second
#define vl 					vector<ll>
#define pl  				pair<ll,ll>
#define ub 					upper_bound				
#define lb 					lower_bound
#define bs 					binary_search		
#define all(x) 				(x).begin(),(x).end()

// Maths
#define PI          		(2*acos(0.0))
#define gcd(a,b)    		__gcd((a),(b))
#define lcm(a,b)    		(((a)*(b))/(__gcd((a),(b))))
#define log(x,b)    		(log(x)/log(b))
#define INF         		LLONG_MAX

// Big data
const int Mod = 1e9+7;
#define mul(a,b)         	((a%Mod)*(b%Mod))%Mod
#define sum(a,b)         	((a%Mod)+(b%Mod))%Mod

// Bit-Manipulation
#define setbit(n,pos)       n |= (1LL<<pos)
#define resetbit(n,pos)     n &= (~(1LL<<pos))
#define toogle(n,pos)       n ^= (1LL<<pos)
#define atpos(n,pos)        ((n&(1LL<<pos))!=0)

// Extra
#define fast 				ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test 				int t = 1; while(t--)
#define scan(any)       	for(auto &i:any) cin>>i;
#define print(any)      	for(auto i:any) cout<<i<<" "; nl;
#define ppair(any)      	for(auto i:any) cout<<i.F<<" "<<i.S<<endl;
#define flush 				cout.flush()
#define nl              	cout<<'\n'
#define endl            	'\n'

void solve()
{
	ll n;
	cin>>n;

	vl x(n);
	vl y(n);
	scan(x);
	scan(y);

	vl a(n);
	loop(i,0,n)
		a[i] = i+1;

	ll a1 = 0, a2 = 0;
	ll ind = 1;
	do
	{
		if(x==a) a1 = ind;
		if(y==a) a2 = ind;
		if(a1 && a2) break;
		ind++;
	}
	while(next_permutation(all(a)));

	cout<<abs(a1-a2);
}

int main()
{
	#ifdef Dhiraj
		freopen("D:/dhiraj/Programming/input.txt","r",stdin);
		freopen("D:/dhiraj/Programming/output.txt","w",stdout);
	#endif
	
	fast;
	test
	solve();
	return 0;
}
/*
greater<int>()
fill(start,end,value);
fill_n(array,size,value);
getline(cin,string);
cin.getline(char array,size);
LLONG_MAX
DBL_MAX
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    ll n,m,k; cin>>n>>m>>k;
    vector<ll> a(n),b(m), sa(n+1), sb(m+1);
    rep(i,n) cin>>a[i];
    rep(i,m) cin>>b[i];
    rep(i,n) sa[i+1] = sa[i]+a[i];
    rep(i,m) sb[i+1] = sb[i]+b[i];

    ll ans = 0;
    rep(i,n+1) {
        ll tmp = i;
        ll x = k-sa[i];
        if (x <= 0) continue;
        auto itr = upper_bound(sb.begin(), sb.end(), x);
        tmp += (itr-(sb.begin()+1));
        chmax(ans, tmp);
    }

    rep(i,m+1) {
        ll tmp = i;
        ll x = k-sb[i];
        if (x<=0) continue;
        auto itr = upper_bound(sa.begin(), sa.end(), x);
        tmp += (itr-(sa.begin()+1));
        chmax(ans,tmp);
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 9564
#include <bits/stdc++.h>
    using namespace std;
     
    int main()
    {
      int n; long long k; cin >> n >> k;
      vector<long long> num(100001, 0);
      for (int i = 0; i < n; ++i)
      {
        int a, b; cin >> a >> b;
        num[a] += b;
      }
      
      long long count = 0;
      for (auto itr = num.begin(); itr != num.end(); ++itr)
      {
        count += *itr;
        if (count >= k)
        {
          cout << itr - num.begin() << endl;
          return 0;
        }
      }
    }

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(){
    string s1,s2;
    cin >> s1;
    cin >> s2;
    int i,count=0;
    rep(i,3){
        if(s1[i]==s2[i]){
            count++;
        }
    }
    cout << count;

}

Measured memory_bytes: 256
#!/usr/bin/env python3
def main():
    N = int(input())

    ans = 0
    for x in range(1, N + 1):
        y = N // x
        # ans += y * (2 * x + (y - 1) * x) // 2
        ans += (x * y * (y + 1)) // 2
    print(ans)


if __name__ == '__main__':
    main()


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

int main()
{
  int n;
  static long long x[100000];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%lld",x+i);
  }
  int m;
  long long K;
  scanf("%d%lld",&m,&K);
  static int L[100000];
  for(int i=0;i<n-1;i++){
    L[i]=i;
  }
  for(int i=0;i<m;i++){
    int a;
    scanf("%d",&a);
    swap(L[a-2],L[a-1]);
  }
  static bool B[100000]={0};
  static int KL[100000],T[100000];
  for(int i=0;i<n-1;i++){
    if(B[i]){
      continue;
    }
    B[i]=1;
    T[0]=i;
    int j=L[i],k=1;
    //printf("%d %d %d\n",i,j,L[j]);
    while(j!=i){
      T[k]=j;
      B[j]=1;
      j=L[j];
      k++;
    }
    int r=K%k;
    for(int t=0;t<k;t++){
      KL[T[t]]=T[(t+r)%k];
    }
  }
  long long X=x[0];
  printf("%lld\n",X);
  for(int i=0;i<n-1;i++){
    int y=KL[i];
    //printf("%d %d\n",i,y);
    X+=x[y+1]-x[y];
    printf("%lld\n",X);
  }
  return 0;
}



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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
ll A[int(2e5+5)], sum[int(2e5+5)];

int main(){
  cin >> N;
  for (int i = 1; i <= N; i++) cin >> A[i];
  for (int i = N; i >= 1; i--){
    sum[i] = sum[i+1] + A[i];
    sum[i] %= MOD;
  }

  ll ans = 0;
  for (int i = 1; i <= N; i++){
    ll now = A[i] * sum[i+1] % MOD;
    ans += now; ans %= MOD;
  }
  cout << ans << endl;

  return 0;
}


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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;

int a, b, c;
LL k;

void init ();
void input ();
void work ();



int main ()
{
	init ();
	input ();
	work ();
}



void init ()
{
	// Init Everything Here

	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method

	cin >> a >> b >> c >> k;
}

void work ()
{
	// main work

	if ( k & 1 ) cout << b - a << endl;
	else cout << a - b << endl;
}

Measured memory_bytes: 384
// Created by arvybhatt

#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define p_b push_back
#define m_p make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)

#define ll long long int
using namespace std;


ll power(ll x, ll y) { ll temp; if( y == 0) return 1; temp = power(x, y/2); if (y%2 == 0) return temp*temp; else return x*temp*temp; } 

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

	sort(a,a+n,greater<int>());

	int i=1;
	ll sum=a[0];

	for(int j=2; j<n; j++)
	{
		//cout<<sum<<"\n";
		sum+=a[i];
		if(j+1<n)
		{
			sum+=a[i];
			j++;
			i++;
		}
	}
	cout<<sum<<"\n";



}


Measured memory_bytes: 5176
from functools import lru_cache


def solve(n, aaa):
    @lru_cache(maxsize=None)
    def search_min(li, ri, lc, rc):
        w = ri - li
        base = aaa[li] * lc
        if w == 1:
            return base
        lrc = lc + rc
        if w == 2:
            return base + aaa[li + 1] * lrc
        if w == 3:
            a1, a2 = aaa[li + 1], aaa[li + 2]
            return base + (a1 + a2) * lrc + min(a1 * lc, a2 * rc)
        ret = min(search_min(li, i, lc, lrc) + search_min(i, ri, lrc, rc) for i in range(li + 1, ri))
        return ret

    return search_min(0, n - 1, 1, 1) + aaa[-1]


n = int(input())
aaa = list(map(int, input().split()))
print(solve(n, aaa))


Measured memory_bytes: 72960
def base_k(n, k=26):
    ret = []
    ny = n
    while ny:

        ret.append(ny % k)
        ny //= k
    return ret[::-1]


def letter(i):
    return chr(i+97)


def solve(n):
    check = 26
    cnt = 1
    k = n
    while True:
        if n <= check:
            break
        check *= 26
        check += 26
        cnt += 1
    k -= check//26 - 1
    t = base_k(k-1)
    ans = ""
    if not t:
        ans = "a" * cnt
    else:
        for _ in range(cnt):
            if not t:
                ans += "a"
                continue
            ans += letter(t.pop())

    return ans[::-1]


n = int(input())
print(solve(n))


Measured memory_bytes: 9216
import sys
read = sys.stdin.readline


# 下の桁から貪欲に見ていくと解ける
# 1の位が4以下ならそのまま紙幣で支払うのが得→自身をそのまま答えに採用 (枚数として加算)
# 6以上ならばお釣り狙いのほうが得→自身は0にセットして、上位桁を+1する (枚数として10-自身を加算)
# 5ちょうどのときは、お釣りもそのまま払っても枚数は変わらない。だけど555みたいに、上位桁に+1すると得になる可能性がある。
# 555→15枚, 1000-445→15枚
# つまり5が出たときは更に上位の桁を見て、4以下ならそのまま払うほうが得,5以上なら桁上りのほうが得

# 5ちょうどのときは？ #お釣りもそのまま払っても同じ。だけど上位 お釣り狙いだと上の桁が多くなって支払う金額が増える可能性がある？
# 5ピッタリのときに上位桁に+1すると悪くなる場合が存在する 455 とは 15にってしまう
# 5ピッタリのときはどうするのがよいのか？

N = '00' + read()[:-1]

N = N[::-1]
ans = 0
i = 0

lo = int(N[i])
while i < len(N) - 1:
    hi = int(N[i + 1])
    if lo == 5:  # 5のときは上の桁の大きさによってお釣りが得になるかそのまま払うのが良くなるか変化する
        ans += lo
        if hi < 5:
            pass
        else:
            hi += 1
    elif lo < 5:
        # loが5以外のとき (お釣りが良いか、そのまま払うのが良いか考えるだけ)
        ans += lo
    else:
        ans += 10 - lo
        hi += 1  # 上の桁が繰り上がる
    lo = hi  # 桁を一つずらす
    i += 1


print(ans)


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

using namespace std;
using ll = long long;
ll gcd(ll x, ll y) {
    x = (x >= 0) ? x : -x;
    y = (y >= 0) ? y : -y;
    if (x > y) {
        return gcd(y, x);
    }
    if (x == 0) {
        return y;
    }
    return gcd(y % x, x);
}

const ll Mod = 1000000007;

ll val(ll n) {
    ll sq = 2LL;
    ll res = 1LL;
    while (n > 0) {
        if (n % 2 == 1) {
            res = (res * sq) % Mod;
        }
        n /= 2;
        sq = (sq * sq) % Mod;
    }
    return res;
}
int main() {
    assert(val(0) == 1);
    assert(val(1) == 2);
    assert(val(2) == 4);
    assert(val(3) == 8);
    assert(val(4) == 16);

    int n;
    cin >> n;
    map<pair<ll, ll>, int> counts;
    int n_zeros = 0;
    for (int i = 0; i < n; ++i) {
        ll a, b;
        cin >> a >> b;
        if (a == 0 && b == 0) {
            ++n_zeros;
        } else {
            if (a < 0 || (a == 0 && b < 0)) {
                a *= -1;
                b *= -1;
            }
            const ll g = gcd(labs(a), labs(b));
            a /= g; b /= g;
            counts[make_pair(a, b)]++;
        }
    }
    for (auto p: counts) {
        ll a, b;
        tie(a, b) = p.first;
        if (b > 0) {
            counts[make_pair(b, -a)];
        } else if (b == 0) {
            counts[make_pair(0, 1)];
        } else {
            counts[make_pair(-b, a)];
        }
    }
    ll ans = 1;
    for (auto p: counts) {
        ll a, b;
        tie(a, b) = p.first;
        if (b <= 0)
            continue;
        const ll factor =val(counts[make_pair(a, b)]) + val(counts[make_pair(b, -a)]) - 1 ;
//        cout << a << " " << b << " " << factor << "\n";
        ans = (ans * factor) % Mod;
    }
    ans = (ans + n_zeros) % Mod;
    ans = (ans - 1 + Mod) % Mod;
    cout << ans << "\n";
    return 0;
}


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

int main()
{
	int a = 0, b = 0, count = 0, d[1000] = { 0 };
	string c;
	while (1){
		cin >> a >> c >> b;
		if (c == "?") break;
		else if (c == "+") d[count] = a + b, count++;
		else if (c == "-") d[count] = a - b, count++;
		else if (c == "*") d[count] = a * b, count++;
		else               d[count] = a / b, count++;
	}
	for (int i = 0; i < count; i++) cout << d[i] << endl;
	return 0;
}

Measured memory_bytes: 1208
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	
		int n = sc.nextInt();
		
		int []h = new int [n];
		
		for(int i = 0 ; i < n ;i++) {
			h[i] = sc.nextInt();
		}
		
		int []dp = new int [n];
		
		dp[0] = 0;
		dp[1] = Math.abs(h[1] - h[0]);
		
		for(int i = 2 ;i < n ; i++) {
			dp[i] = Math.min(dp[i-1]+Math.abs(h[i] - h[i-1]),dp[i-2] + Math.abs(h[i] - h[i-2]));
		}
		
		System.out.println(dp[n-1]);


	}

}


Measured memory_bytes: 50504
#include<iostream>
using namespace std;
int main()
{
	int n,a,b,tmp=0;
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++)
	{
		int q,k=0;
		q=i;
		do{
			k=k+(q%10);
			q=q/10;
		}while(q>0);
		if(k<=b&&k>=a) 
		{
			tmp+=i;
		}
	}
	cout<<tmp<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int N, X; cin >> N >> X;
    vector<int>m(N);
    rep(i, N) {
        cin >> m[i];
        X -= m[i];
    }
    sort(m.begin(), m.end());
    cout << N + X / m[0] << endl;
}

Measured memory_bytes: 3564
import java.util.*
fun main(args:Array<String>) {
  val N = readLine()!!.toInt()
  val s = (1..N).map {
    readLine()!!
  }
  val M = readLine()!!.toInt()
  val f = (1..M).map {
    readLine()!!
  }

  var s_map = HashMap<String, Int>()

  for(str in s) {
    s_map.put(str, s_map.get(str)?.let{it + 1} ?: 1 )
  }

  for(str in f) {
    s_map.put(str, s_map.get(str)?.let{it - 1} ?: 0 )
  }
  println(s_map.values.max()?.let { if (it>0) { it} else {0}} ?: 0)
}




Measured memory_bytes: 33784
N = int(input())
A = list(map(int,input().split()))

ans = 0
temp = 0
for n in range(N):
  x = 0
  temp = A[n]
  while x == 0:
    if temp % 2 == 0:
      ans += 1
      temp = temp //2
    else:
      x = 1
print(ans)

Measured memory_bytes: 4148
#include<bits/stdc++.h>
#include<vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MAX 200005
#define MOD 998244353
#define NIN -100000000
#define EPS 0.0000000001
int main()
{
    int x,y;
    scanf("%d %d",&x,&y);
    if(y%2==0&&y>=x*2&&y<=x*4)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    return 0;
}


Measured memory_bytes: 3824
#include<bits/stdc++.h>
using namespace std;
#define IO ios::sync_with_stdio(false),cin.tie(0);
#define ll long long
#define inf 0x3f3f3f3f
const int N=2e5+5;
//set<string>b;
//set<string>::iterator it;
int f[N],c[N];
int getfa(int u)
{
	return f[u]==u?u:f[u]=getfa(f[u]);
}
void merge(int u,int v)
{
	int f1,f2;
	f1=getfa(u);f2=getfa(v);
	if(f1!=f2) f[f2]=f1;
}
int main()
{
	IO;
	int n,m,i,u,v,ans=0;
	cin>>n>>m;
	for(i=1;i<=n;i++) f[i]=i;
	for(i=1;i<=m;i++)
	{
		cin>>u>>v;
		merge(u,v);
	}
	for(i=1;i<=n;i++)
	{
		c[getfa(i)]++;
	}
	for(i=1;i<=n;i++)
	{
		ans=max(ans,c[i]);
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5136
import bisect
n = int(input())
s = input()
R = []
G = []
B = []
for i in range(n):
  if s[i] == 'R':
    R.append(i)
  elif s[i] == 'G':
    G.append(i)
  else:
    B.append(i)
Rs = set(R)
Bs = set(B)
Gs = set(G)
res = 0
for i in range(n):
  if s[i] == 'R':
    x = bisect.bisect_left(G, i)
    sss = set()
    for j in range(x, len(G)):
      y = bisect.bisect_left(B, G[j])
      res += len(B) - y
      sss.add(2*G[j]-i)
    res -= len(sss & Bs)
    x = bisect.bisect_left(B, i)
    sss = set()
    for j in range(x, len(B)):
      y = bisect.bisect_left(G, B[j])
      res += len(G) - y
      sss.add(2*B[j]-i)
    res -= len(sss & Gs)
  elif s[i] == 'G':
    x = bisect.bisect_left(B, i)
    sss = set()
    for j in range(x, len(B)):
      y = bisect.bisect_left(R, B[j])
      res += len(R) - y
      sss.add(2*B[j]-i)
    res -= len(sss & Rs)
    x = bisect.bisect_left(R, i)
    sss = set()
    for j in range(x, len(R)):
      y = bisect.bisect_left(B, R[j])
      res += len(B) - y
      sss.add(2*R[j]-i)
    res -= len(sss & Bs)
  else:
    x = bisect.bisect_left(G, i)
    sss = set()
    for j in range(x, len(G)):
      y = bisect.bisect_left(R, G[j])
      res += len(R) - y
      sss.add(2*G[j]-i)
    res -= len(sss & Rs)
    x = bisect.bisect_left(R, i)
    sss = set()
    for j in range(x, len(R)):
      y = bisect.bisect_left(G, R[j])
      res += len(G) - y
      sss.add(2*R[j] - i)
    res -= len(sss & Gs)
print(res)


Measured memory_bytes: 87444
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;

int main(){
	int n,t; cin >> n >> t;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	int cnt=0;
	int ma=0;
	int ans=0;
	priority_queue<int,vector<int>,greater<int>> q;
	for(int i=0;i<n;i++){
		q.push(a[i]);
		if(a[i]-q.top()==ma&&ma){
			cnt++;
		}
		else if(a[i]-q.top()>ma){
			ma=a[i]-q.top();
			ans=max(ans,cnt);
			cnt=1;
		}
	}
	ans=max(ans,cnt);
	cout << ans << endl;
}

Measured memory_bytes: 1276
import collections
n, m = map(int, input().split())
c = 0
B = []
C = []
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        B.append(b)
    elif b == n:
        B.append(a)
C = collections.Counter(B)
for i in C:
    if C[i] > 1:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Measured memory_bytes: 29788
use std::io;
fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    let v: Vec<u8> = s.trim().split_whitespace().map(|x| x.parse().unwrap()).collect();
    let (l, r, d) = (v[0], v[1], v[2]);

    let cnt = (l..r+1).filter(|x| x%d == 0).collect::<Vec<u8>>().len();
    println!("{}", cnt);
}

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


int main(){
  ll ans=0;
  ll n;
  cin >>n;
  ll k=n;
  queue<int> p;
  for(ll i = 2; i*i<=k; i++){
    int g=0,top=1;
    while(n%i==0){
      n/=i;
      g++;
      if(g==top){ans++;top++;g=0;}
      }
  }
  if(n!=1)ans++;
  cout << ans << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 200005;

struct disj{
  int pa[MAXN];
  void init(int n){
    iota(pa, pa + n + 1, 0);
  }
  int find(int x){
    return pa[x] = (pa[x] == x ? x : find(pa[x]));
  }
  bool uni(int p, int q){
    p = find(p); q = find(q);
    if(p == q) return 0;
    pa[q] = p; return 1;
  }
}disj;

struct edg{
  int s, e, x;
  bool operator<(const edg &e)const{
    return x < e.x;
  }
};

vector<edg> v;
int ret[MAXN]; // (i - i + 1)
vector<pi> ev[MAXN];
priority_queue<pi, vector<pi>, greater<pi> > pq;

void up(int s, int l, int x){
  ev[s].emplace_back(x - s * 2, s + l);
}

int main(){
  int n, q; scanf("%d %d",&n,&q);
  memset(ret, 0x3f, sizeof(ret));
  for(int i=0; i<q; i++){
    int a, b, c; scanf("%d %d %d",&a,&b,&c);
    v.push_back({a, b, c});
    up(a, n - a, c + 1);
    up(b, n - b, c + 2);
    up(0, a, c + 1 + (n - a) * 2);
    up(0, b, c + 2 + (n - b) * 2);
  }
  for(int i=0; i<n; i++){
    for(auto &j : ev[i]) pq.push(j);
    while(!pq.empty() && pq.top().second <= i) pq.pop();
    v.push_back({i, (i+1)%n, pq.top().first + i * 2});
  }
  sort(v.begin(), v.end());
  lint ret = 0;
  disj.init(n);
  for(auto &i : v){
    if(disj.uni(i.s, i.e)) ret += i.x;
  }
  cout << ret << endl;
}


Measured memory_bytes: 31384
#include<stdio.h>

int main(void){
    int ns;
    int h=0,m=0,s=0;
    scanf("%d",&ns);
    
    while(ns>=60*60){
        h++;
        ns-=60*60;
    }
    while(ns>=60){
        m++;
        ns-=60;
    }
    s=ns;
    
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


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

using namespace std;

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

#define int ll


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

	if(k%2==0 || k%5==0){
		cout << "-1" << endl;
		return 0;
	}
	
	int cnt = 7;
	for(int i=0;i<k;i++){
		if(cnt%k==0){
			cout << i+1 << endl;
			return 0;
		}
		cnt *= 10;
		cnt += 7;
		cnt = cnt%k;
	}

	cout << "-1" << endl;
	return 0;
}


Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		char []s = sc.next().toCharArray();
		
		int n = s.length;
		
		int []t = new int [n];
		for(int i = 0 ; i < n ;i++) {
			t[i] = s[i] - '0';
		}
		
		int[][]dp = new int [n+1][2]; 
		for(int i = 0 ; i <= n ;i++) {
			dp[i][0] = 1000000000;
			dp[i][1] = 1000000000;
		}
		dp[1][0] = t[0];
		dp[1][1] = 11 - t[0];
		
		for(int i = 1 ; i < n ;i++) {
			dp[i+1][0] = Math.min(dp[i][0] + t[i], dp[i][1] + t[i]);
			dp[i+1][1] = Math.min(dp[i][0] + 11 - t[i], dp[i][1] + 9 - t[i]);
		}

		System.out.println(Math.min(dp[n][0],dp[n][1]));
		
		

	}

}


Measured memory_bytes: 67020
#include <cstdio>
#include <cstring>
#include <map>
#include <algorithm>

using namespace std;

int n,a[100003];
int ans;
map<int,int> mp;

int main() {
    while(1==scanf("%d",&n)) {
        mp.clear();
        for(int i=1;i<=n;++i) {
            scanf("%d",a+i);
            mp[a[i]]=i;
        }
        sort(a+1,a+1+n);
        ans=0;
        for(int i=1;i<=n;++i) {
            if((mp[a[i]]&1)!=(i&1)) {
                ++ans;
            }
        }
        printf("%d\n",ans>>1);
    }
    return 0;
}


Measured memory_bytes: 5248
import sys
from collections import deque
input=sys.stdin.readline
sys.setrecursionlimit(10**6)
from itertools import combinations_with_replacement

n,m,q=map(int,input().split())
A=[[int(i) for i in input().split()] for _ in range(q)]

ans=0
for i in combinations_with_replacement(range(1,m+1),n):
    tmp=0
    for j in A:
        a,b,c,d=j
        if i[b-1]-i[a-1]==c: tmp+=d
    ans=max(ans,tmp)
print(ans)

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

#define gap " "
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ok cout<<"ok"<<endl
#define dbg(x) cout<<(#x)<<" is "<<x<<endl
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int N=1000009;
vector<string>vec;
int fx[]={-1,1,0,0};
int fy[]={0,0,-1,1};

int row,col,k;
int level[N],vis[N];
int id(int r,int c)
{
	 return (r*col)+(c+1);
}
int bfs(int x1, int y1,int x2,int y2)
{
   int idx,lv,i,sx,sy,tx,ty,j,lx,ly;
	 queue<pii> final;
   final.push(mp(x1,y1));
   idx=id(x1,y1);
   level[idx]=0;
   vis[idx]=1;
   pii u;
   while(!final.empty())
   {
      u=final.front(); final.pop();
      lx=u.ff; ly=u.ss;
      lv=level[id(lx,ly)]+1;
      
      for(i=0; i<4; i++)
      {
      	 sx=lx; sy=ly;
      	 for(j=1; j<=k; j++)
      	 {
      	 	 tx=sx+fx[i]; ty=sy+fy[i];
      	 	 idx=id(tx,ty);
      	 	 if(tx>=0 && tx<row && ty>=0 && ty<col && vec[tx][ty]=='.' && (level[idx]<1 || level[idx]>=lv))
      	 	 {   
              level[idx]=lv;
              if(vis[idx]==0)  final.push(mp(tx,ty));
              if(tx==x2 && ty==y2) return level[idx];
              sx=tx; sy=ty;
              vis[idx]=1;
      	 	 }
      	 	 else
      	 	 {
      	 	 	 break;
      	 	 }
      	 	 
      	 }
      }
   }

   return -1;
}
void print()
{
	int i,j,idx;
	for(i=0; i<row; i++)
	{
		for(j=0; j<col; j++)
		{
			 if(vec[i][j]=='.')
			 {
         idx=id(i,j);
         cout<<level[idx];
			 }
			 else cout<<vec[i][j];
		}
		cout<<endl;
	}
}
int main()
{
  fastio; 
  string s;
  char ch;
  int i,ans,x1,y1,x2,y2,j;
  // scanf("%d %d %d",&row,&col,&k);//
   cin>>row>>col>>k;
  // scanf("%d %d %d %d",&x1,&y1,&x2,&y2);// 
  cin>>x1>>y1>>x2>>y2;

  x1--; y1--; x2--; y2--; //for 0 based
  for(i=0; i<row; i++)
  {
     cin>>s;	
  	 vec.pb(s);
  }
   ans=bfs(x1,y1,x2,y2);
   // print();
   cout<<ans<<'\n';
  return 0;
}


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

int main(void)
{
    int N,K,i,j;
    cin >> N >> K;
    int scores[N];
    for (i = 0; i < N; i++){
        cin >> scores[i];
    }
    for (j = K; j < N; j++){
        if(scores[j-K]<scores[j])
            printf("Yes\n");
        else 
            printf("No\n");
    }

}

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


int p[2];
string s[2][10];
int ans[10],par[2][11][3],sp[10],pos,tmp;
bool f;

int main(){
  while(cin >> p[0] >> p[1], p[0]||p[1]){
    for(int i=0;i<p[0];i++)cin >> s[0][i];
    for(int i=0;i<p[1];i++){
      cin >> s[1][i];
      ans[i] = -1;
    }

    for(int i=0;i<2;i++){
      for(int j=0;j<3;j++)par[i][0][j] = 0;
      for(int j=0;j<p[i];j++){
	pos = 0;
	if(!i){
	  while(pos<s[i][j].size() && s[i][j][pos] == '.')pos++;
	  sp[j] = pos;
	}
	for(int k=0;k<3;k++)par[i][j+1][k] = par[i][j][k];
	while(pos<s[i][j].size()){
	  if(s[i][j][pos] == '(')par[i][j+1][0]++;
	  else if(s[i][j][pos] == '{')par[i][j+1][1]++;
	  else if(s[i][j][pos] == '[')par[i][j+1][2]++;
	  else if(s[i][j][pos] == ')')par[i][j+1][0]--;
	  else if(s[i][j][pos] == '}')par[i][j+1][1]--;
	  else if(s[i][j][pos] == ']')par[i][j+1][2]--;
	  pos++;
	}
      }
    }
    
    for(int R=1;R<=20;R++){
      for(int C=1;C<=20;C++){
	for(int S=1;S<=20;S++){
	  f = true;
	  for(int i=0;i<p[0];i++){
	    if(R*par[0][i][0] + C*par[0][i][1] + S*par[0][i][2] != sp[i]){
	      f = false; break;
	    }
	  }
	  if(!f)continue;
	  
	  for(int i=0;i<p[1];i++){
	    tmp = R*par[1][i][0] + C*par[1][i][1] + S*par[1][i][2];
	    if(ans[i] == -1)ans[i] = tmp;
	    else if(ans[i] != tmp)ans[i] = -2;
	  }
	}
      }
    }

    for(int i=0;i<p[1];i++)
      cout << ((ans[i]<0)?-1:ans[i]) << ((i==p[1]-1)?"\n":" ");
  }
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long N,L;
  cin >> N >> L;
  long long wa=0,sa=10000000000;
  for(int i=0; i<N; i++){
    long long kaage = L+i;
    wa += kaage;
    if(abs(sa) > abs(kaage)){
      sa = kaage;
    }
  }
    cout << wa-sa << endl;
}


Measured memory_bytes: 3620
#include<stdio.h>
#define MAX 100
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[MAX][MAX];

int prim(){
  int i,v,u,minv;
  int d[MAX],p[MAX],color[MAX];

  for(i = 0;i<n;i++){
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }

  d[0] = 0;

  while(1){
    minv = INFTY;
    u = -1;
    for(i = 0; i<n; i++){
      if(minv>d[i] && color[i]!=BLACK){
	u = i;
	minv = d[i];
      }
    }
    if(u == -1) break;
    color[u] = BLACK;
    for(v = 0; v < n; v++){
      if(color[v] != BLACK && M[u][v] != INFTY){
	if(d[v] > M[u][v]){
	  d[v] = M[u][v];
	  p[v] = u;
	  color[v] = GRAY;
	}
      }
    }
  }
  int sum = 0;
  for(i = 0; i<n; i++){
    if(p[i]!=-1) sum+=M[i][p[i]];
  }
  return sum;
}

int main(){
  int i,j;
  scanf("%d",&n);

  for(i = 0; i<n;i++){
    for(j = 0; j<n; j++){
      int e;
      scanf("%d",&e);
      M[i][j] = (e==-1)?INFTY:e;
    }
  }

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

  return 0;
}





Measured memory_bytes: 2056
#include <stdio.h>
int main(){
	int n;
	scanf("%d",&n);
	if(n%111!=0){
		n=n/111;
		n=n+1;
	}
	else if(n%111==0){
		n=n/111;
	}
	printf("%d%d%d",n,n,n);
}

Measured memory_bytes: 128
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 String solve(String S) {
        boolean yymm = false;
        boolean mmyy = false;

        int pre = Integer.parseInt(S.substring(0, 2));
        if (pre > 0 && pre <= 12) mmyy = true;

        int post = Integer.parseInt(S.substring(2, 4));
        if (post > 0 && post <= 12) yymm = true;


        if (yymm && mmyy) {
            return "AMBIGUOUS";
        } else if (yymm && !mmyy) {
            return "YYMM";
        } else if (!yymm && mmyy) {
            return "MMYY";
        } else {
            return "NA";
        }
    }
}


Measured memory_bytes: 25044
n,a,b,c=map(int,input().split())
x=list(int(input()) for _ in range(n))

import itertools
import numpy as np

f=[0,1,2,3]

pt=list(itertools.product(f, repeat=n))

mpl=[]

for i in range(len(pt)):
	if (1 in pt[i]) and (2 in pt[i]) and (3 in pt[i]):
		rl1=0;rc1=0
		rl2=0;rc2=0
		rl3=0;rc3=0
		mp=0
		for j in range(n):
			if pt[i][j]==1:
				rl1+=x[j]
				rc1+=1
			if pt[i][j]==2:
				rl2+=x[j]
				rc2+=1
			if pt[i][j]==3:
				rl3+=x[j]
				rc3+=1
		mp=abs(rl1-a)+abs(rl2-b)+abs(rl3-c)
		if rc1>1:
			mp+=(rc1-1)*10
		if rc2>1:
			mp+=(rc2-1)*10
		if rc3>1:
			mp+=(rc3-1)*10
		mpl.append(mp)

print(min(mpl))

Measured memory_bytes: 22044
#include <stdio.h>
int main(void)
{
    int n,m;
    scanf("%d %d",&n,&m);
    int a[m*2];
    for(int p=0;p<m;p++)
        scanf("%d %d",&a[p],&a[p+m]);
    int ans;
    for(int q=1;q<n+1;q++)
    {
        ans=0;
        for(int r=0;r<m*2;r++)
        {
            if(a[r]==q)
              ans++;
        }
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  vector<ll> a(n);
  for(int i = 0;i < n;i++)cin >> a[i];
  sort(a.rbegin(),a.rend());
  ll res = 0;
  res += a[0];
  for(int i = 1;i < n - 1;i++){
    res += a[(i + 1) / 2];
  }
  cout << res << endl;
}

Measured memory_bytes: 4844
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long  
#define all(x) x.begin(),x.end()

int const N = 3e5+1;
int n, a,b, point[N], A , B , C;


int main(){
     scanf("%d%d%d",&n,&a,&b);
     for(int i=0;i<n;++i){
        scanf("%d",point+i);
        if(point[i] <= a)++A;
        if(point[i] >= a+1 && point[i] <= b)++B;
        if(point[i] >= b+1)++C;
     }
     cout << min(A, min(B,C));
}
    

Measured memory_bytes: 256
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut  input:Vec<i32> = s.split_whitespace().map(|x| x.parse::<i32>().unwrap()).collect();

    input.sort();
    let ans = input[2] - input[0];
    println!("{}",ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    std::vector<int> cnt(n + 2);
    for (int i = 0; i < n; i++) {
        int a; std::cin >> a;
        cnt[a]++;
    }
    std::sort(cnt.rbegin(), cnt.rend());
    int pos = 0, res = n;
    int w = 1e9;
    for (int i = 1; i <= n; i++) {
        w = std::min(w, n / i);
        while (w > 0) {
            while (cnt[pos] > w) {
                res -= cnt[pos++];
            }
            if (pos + res / w >= i) {
                std::cout << w << std::endl;
                break;
            }
            w--;
        }
        if (w == 0) {
            std::cout << 0 << std::endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2048
#include<iostream>
#include<utility>
#include<algorithm>
using namespace std;
/*
int main(){
    int n;
    cin >> n;
}
*/
typedef long long ll;

int main(){
    ll n,x;
    cin >> n >> x;
    ll m[n];
    ll ans = 0;
    int i;
    ll mn = 1000000000;
    for(i = 0;i < n;i++){
        cin >> m[i];
        x-=m[i];
        mn = min(mn,m[i]);
    }
    ans = i;
    
    while(x-mn >= 0){
        x-=mn;
        ans++;
    }

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


Measured memory_bytes: 256
def solve():
    path_dict = {}
    N, M = list(map(int, input().split(" ")))
    for i in range(M):
        a, b = list(map(int, input().split(" ")))
        if a in path_dict.keys():
            path_dict[a] += 1
        else:
            path_dict[a] = 1
        if b in path_dict.keys():
            path_dict[b] += 1
        else:
            path_dict[b] = 1
    for i in range(1,N+1):
        if i in path_dict.keys():
            print(path_dict[i])
        else:
            print(0)
    
solve()


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
 
int main() {
    int r, c;
    cin >> r >> c;
    int x[r][c];
    for (int i=0;i<r;i++) {
        for (int j=0;j<c;j++) {
            cin >> x[i][j];
        }
    }

    int s;
    for (int i=0;i<r;i++) {
        s = 0;
        for (int j=0;j<c;j++) {
            cout << x[i][j] << " ";
            s += x[i][j];
        }
        cout << s << endl;
    }
    int t;
    t = 0;
    s = 0;
    for (int j=0;j<c;j++) {
        s = 0;
        for (int i=0;i<r;i++) {
            s += x[i][j];
        }
        cout << s << " ";
        t += s;
    }
    cout << t << endl;
    return 0;
}



Measured memory_bytes: 3044
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int A,B;
    cin >> A>> B;
    cout<<A*B-(B+A-1) << endl;
}

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

using namespace std;

typedef vector<int> vi;

vi mul(const vi &a, const vi &b, int p) {
    vi r(p, 0);
    for (int i = 0; i < p; i++) {
        for (int j = 0; j < p; j++) {
            int t = i + j;
            if (t >= p) {
                t -= p - 1;
            }
            r[t] = (r[t] + a[i] * b[j]) % p;
        }
    }
    return r;
}

vi bexp(const vi &a, int x, int p) {
    if (x == 0) {
        vi t(p, 0);
        t[0] = 1;
        return t;
    }
    if (x % 2 == 1) {
        return mul(a, bexp(a, x - 1, p), p);
    }
    vi t = bexp(a, x / 2, p);
    return mul(t, t, p);
}

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

    vi b(p + 1, 0);
    b[0] = 1;
    for (int i = 0; i < p; i++) {
        int a;
        cin >> a;
        if (a == 0) {
            for (int j = p; j >= 0; j--) {
                b[j] = (b[j] * (p - i) + (j == 0 ? 0 : b[j-1])) % p;
            }
        }
    }
    b[1] = (b[1] + b[p]) % p;
    b.pop_back();

    b = bexp(b, p - 1, p);

    for (int i = 0; i < p; i++) {
        cout << b[i] << (i == p - 1 ? '\n' : ' ');
    }

    return 0;
}


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

char map[14][14];
int dir[12][2]={{-1,0},{1,0},{0,-1},{0,1},
                {-2,0},{2,0},{0,-2},{0,2},
                {-3,0},{3,0},{0,-3},{0,3}};

void solve(int i,int j){
  int k,ni,nj;

  map[i][j] = '0';
  for(k=0;k<12;k++){
    ni = i + dir[k][0];
    nj = j + dir[k][1];
    if(map[ni][nj] == '1'){
      solve(ni,nj);
    }
  }
}

int main(void){
  int set,i,j,n;

  scanf("%d",&n);
  for(set=1;set<=n;set++){
    memset(map,'0',sizeof(map));
    for(i=3;i<11;i++){
      scanf("%s",&map[i][3]);
      map[i][11] = '0';
    }
    scanf("%d%d",&j,&i);
    solve(i+2,j+2);
    printf("Data %d:\n",set);
    for(i=3;i<11;i++){
      for(j=3;j<11;j++){
	putchar(map[i][j]);
      }
      putchar('\n');
    }
  }

  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define im imag()
#define re real()
#define r(I, N) for(int I=0;I<N;I++)
#define f(I, A, B) for(int I=A;I<B;I++)
#define fd(I, A, B) for(int I=A;I>=B;I--)
#define ite(x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define sz(x) ((int)(x).size())
#define clr(x) memset(x, 0, sizeof(x))

typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
typedef complex<ld> Point;
typedef Point Vector;

const double pi = acos(-1.0);
const double eps = 1e-12;

inline int sgn(double u)
{
      if(u > eps) return 1;
      else if(u < -eps) return -1;
      else return 0;
}

int main()
{
      ios::sync_with_stdio(false);
      double U;
      while (cin >> U)
      {
            if (sgn(U) == 0) break;
            int n, d = 0;
            r(i, 3000000)
            {
                  d++;
                  n = (int)((double)d * pi);
                  if(sgn(fabs((double)(n + 1) / d - pi) - fabs((double)n / d - pi)) < 0) n++;
                  if(fabs((double)n / d - pi) < U) break;
            }
            cout << n << '/' << d << endl;
      }
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define FOR(i,b,e) for (common_type_t<decltype(b),decltype(e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define rep(i,n)   FOR (i, size_t{}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;
constexpr ll inf = 2e18;
constexpr ll MOD = 998244353;

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  size_t n;
  cin >> n;
  vector <size_t> d (n);
  rep (i, n) cin >> d [i];

  ll ans = 1;
  vector <ll> cnt (n, 0);
  rep (i, n) ++ cnt [d [i]];

  if (d [0] != 0)
  {
    ans = 0;
    goto finish;
  }

  FOR (i, 1, n)
  {
    if (d [i] == 0)
    {
      ans = 0;
      goto finish;
    }
    auto t = cnt [d [i] - 1];
    ans *= t;
    ans %= MOD;
  }
finish:
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define MP make_pair
#define PB push_back

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

int main() {
	vector<char> ans;
	while (true) {
		int m, f, r;
		cin >> m >> f >> r;
		if (m == -1 && f == -1 && r == -1)break;

		char c; int sum = m + f;
		if (m == -1 || f == -1)c = 'F';
		else if (80 <= sum)c = 'A';
		else if (65 <= sum && sum < 80)c = 'B';
		else if (50 <= sum && sum < 65)c = 'C';
		else if (30 <= sum && sum < 50 && 50 <= r)c = 'C';
		else if (30 <= sum && sum < 50)c = 'D';
		else if (sum < 30)c = 'F';
		ans.PB(c);
	}
	for (auto n : ans) {
		cout << n << endl;
	}
}


Measured memory_bytes: 3104