akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) {
    cin >> A[i];
  }

  string s;
  rep(i, N - 1) {
    if (A[i] < A[i + 1])
      s.pb('<');
    else if (A[i] > A[i + 1])
      s.pb('>');
  }

  int ans = 1;
  rep(i, len(s) - 1) {
    if (s[i] != s[i + 1]) {
      ans++;
      i++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1280
import java.util.Scanner;
public class Main {
@SuppressWarnings("resource")
public static void main(String[] args) {
	Scanner sc =new Scanner(System.in);
	int X=sc.nextInt();
	if(X<=2) {
		System.out.println(2);
	}else {

	for(int i=X;;i++) {
		for(int j=2;j<=(X/2)+1;j++) {
			if(i%j==0) {
				break;
			}
			if(j==(X/2)+1) {
				System.out.println(i);
				System.exit(0);
			}
		}
	}
	}
	}
}

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

int main() {

    string s; cin >> s;

    int a, b, c, d;
    a = (int)(s[0] - '0');
    b = (int)(s[1] - '0');
    c = (int)(s[2] - '0');
    d = (int)(s[3] - '0');

    if (a + b + c + d == 7) cout << a << '+' << b << '+' << c << '+' << d << "=7" << endl;

    else if (a + b + c - d == 7) cout << a << '+' << b << '+' << c << '-' << d << "=7" << endl;
    else if (a + b - c + d == 7) cout << a << '+' << b << '-' << c << '+' << d << "=7" << endl;
    else if (a - b + c + d == 7) cout << a << '-' << b << '+' << c << '+' << d << "=7" << endl;
    
    else if (a + b - c - d == 7) cout << a << '+' << b << '-' << c << '-' << d << "=7" << endl;
    else if (a - b + c - d == 7) cout << a << '-' << b << '+' << c << '-' << d << "=7" << endl;
    else if (a - b - c + d == 7) cout << a << '-' << b << '-' << c << '+' << d << "=7" << endl;

    else if (a - b - c - d == 7) cout << a << '-' << b << '-' << c << '-' << d << "=7" << endl;

    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  ll a,b,c;
  cin >> a>>b>>c;
  
  cout << b+min(a+b+1,c) << endl;
  
}


Measured memory_bytes: 256
a,v = map(int, input().split())
b,w = map(int, input().split())
t = int(input())

if(b > a):
    if(b + w*t <= a + v*t):
        print('YES')
    else:
        print('NO')
if(b < a):
    if(b - w*t >= a - v*t):
        print('YES')
    else:
        print('NO')


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

int main(){
    long long a, b;
    cin >> a >> b;
    long long commonfactor = __gcd(a, b);
    long long n = commonfactor;
    long long count = 0;
    for(long long i=2; i*i <= commonfactor; i++){
        if(n % i != 0){
            continue;
        }
        while(n % i == 0){
            n /= i;
        }
        count++;
    }


    if(n != 1){
        count++;
    }
    cout << count+1<< endl;

}


Measured memory_bytes: 384
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

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



int main(void){

	int A,B;
	char op;
	cin >> A >> op >> B;

	if(op == '+') cout << A+B << endl;
	else cout << A-B << endl;


	return 0;

}


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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;
    //abc102 b
    static void solve(InputReader in, PrintWriter out){
        int n = in.ni();
        int[] a = in.ni(n);
        Arrays.sort(a);
        out.println(a[n-1]-a[0]);
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 21460
N, X, Y = map(int, input().split())
distcnt = [0] * (N-1)
for i in range(1, N):
  for j in range(i+1, N+1):
    disttmp = min(j-i, abs(X-i) + 1 + abs(j-Y))
    distcnt[disttmp-1] += 1
for i in range(N-1):
  print(distcnt[i])


Measured memory_bytes: 74440
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000ll
#define LLINF 2000000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int X[200100];
vector<int> vec;
int N;
int main(){
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> X[i];
		vec.pb(X[i]);
	}
	sort(all(vec));
	for(int i=0;i<N;i++){
		if(X[i]<vec[N/2])cout << vec[N/2] << endl;
		else cout << vec[N/2-1] << endl;
	}
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a.at(i);
        a.at(i) -= i + 1;
    }
    sort(a.begin(), a.end());
    int median = a.at(n / 2);
    long long ans = 0;
    for(int i = 0; i < n; i++)
    {
        ans += abs(a.at(i) - median);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
if __name__ == '__main__':
    res = set()
    n_order = int(input())
    for i in range(n_order):
        order = input().split()
        if 'insert' == order[0]: 
            res.add(order[1])
        elif 'find' == order[0]:
            if order[1] in res: print('yes')
            else : print('no')


Measured memory_bytes: 30992
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner (System.in);
		while(sc.hasNext()) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(a==0&&b==0) break;
			
			if(a<b) {
				System.out.printf("%d %d\n",a,b);
			}
			else {
				System.out.printf("%d %d\n",b,a);
			}
		}
	}
}

	


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define REV(x) reverse(ALL((x)))
#define pb push_back

int main()
{

    ll A, V, B, W, T;
    cin >> A >> V;
    cin >> B >> W;
    cin >> T;
    bool f = false;
    if(A >= B) {
        if((A-T*V)-(B-T*W) <= 0) f=true;
    }
    else {
        if((B+T*W)-(A+T*V) <= 0) f=true;
    }
    if(f) PR("YES");
    else PR("NO");
    return 0;
}

/*



*/

Measured memory_bytes: 3632
#include <stdio.h>

int
main(void)
{
	int a;
	int b;
	double f;
	
	scanf("%d %d", &a, &b);

	f = 1.0 * a / b;
	
	printf("%d %d %f\n", a / b, a % b, f);

	return 0;
}


Measured memory_bytes: 2080
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long LL;

const int MaxN = 50;
LL K, n;
LL a[MaxN + 5];

int main()
{
	while (~scanf("%lld", &K)) {
		n = 50;
		LL t = K / n, r = K % n;
		for (int i = 1; i <= n; i++) a[i] = n + t - 1;
		for (int i = 1; i <= r; i++) a[i] += n - r + 1;
		for (int i = r + 1; i <= n; i++) a[i] -= r;
		printf("%d\n", n);
		for (int i = 1; i <= n; i++) printf("%lld ", a[i]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 128
N = int(input())

for h in range(1,3501):
    for n in range(1,3501):
        if 4*h*n > N*(n+h) and (N*h*n/(4*h*n-N*(n+h)))%1 == 0:
            print(h,n,N*h*n//(4*h*n-N*(n+h)))
            exit()

Measured memory_bytes: 9220
/*
No matter how long a night, dawn will always break.

Simular saying ... The darkest hour is just before the dawn.
 ***************************************   ************************8   **********************************
*/
#include <bits/stdc++.h>
using namespace std;

 
#define int         long long
#define double      long double
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define sz(x)	    (int)(x).size()
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
#define _init(b)     memset(b,-1,sizeof(b))
#define _init0(b)     memset(b,0,sizeof(b))
#define MOD         1000000007
#define hell        998244353
#define output(x) cout << (x ? "YES" : "NO")<<endl;
 
 
 
 
 
int gcd(int a, int b) {if(a>b)swap(a,b) ;  if (a == 0)  return b; return gcd(b % a, a); }  
bool mod(double a,double b) {return a/b - floor(a/b);}
 

 
 
 
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int i,j,x;
   string s,t;
   cin>>s>>t;
   bool ok=true;
   if(s.length()==t.length()-1){
   		fo(i,0,s.length()){
   			if(s[i]!=t[i])ok=false;
   		}


   }
   else{
   	ok=false;
   }
   if(ok){
   	cout<<"Yes";
   }
   else{
   	cout<<"No";
   }

   
   
   
   
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main(void){

    string s, t, u;
    int a, b;

    cin >> s >> t;
    cin >> a >> b;

    cin >> u;

    if(s == u)
        a -= 1;
    else if (t == u)
        b -= 1;

    cout << a << ' ' << b << endl;

    return 0;
}

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

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int &it : a) cin >> it;
    for (int &it : b) cin >> it;
    reverse(b.begin(), b.end());
    int target = -1;
    vector<int> to_swap, cand;
    for (int i = 0; i < n; i++) {
        if (a[i] == b[i]) {
            target = a[i];
            to_swap.push_back(i);
        }
    }
    if (target != -1) {
        for (int i = 0; i < n; i++) {
            if (a[i] != target && b[i] != target) {
                cand.push_back(i);
            }
        }
        if (cand.size() < to_swap.size()) {
            cout << "No\n";
            return 0;
        }
        for (int i = 0; i < (int)to_swap.size(); i++) {
            swap(b[to_swap[i]], b[cand[i]]);
        }
    }
    cout << "Yes\n";
    for (int i = 0; i < n; i++)
        cout << b[i] << " \n"[i == n - 1];
    return 0;
}

Measured memory_bytes: 6120
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int n = sc.nextInt();
   int x = sc.nextInt();
   int t = sc.nextInt();
  
   int count=0;
   if (n%x != 0){
     count=(n/x)+1;
   }else if (n%x == 0){
     count=(n/x);
   }
   int time = count*t;
   System.out.println(time);
 }

}

Measured memory_bytes: 27064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;
using namespace std;

int main() {
    int n,m;
    cin >> n >> m;
    cout << (n-1)*(m-1) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int age = sc.nextInt();
        if(age==1) {
            System.out.println("Hello World");
        } else {
            System.out.println(sc.nextInt()+sc.nextInt());
        }

    }
}

Measured memory_bytes: 21844
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <stdio.h>
#include <math.h>
#include <utility>
#include <algorithm>
#include <sstream>

using namespace std;

int main() {
	int n,m;
	cin >> n >> m;
	int l, r;
	cin >> l >> r;
	for (int i = 0; i < m-1; i++) {
		int templ,tempr;
		cin >> templ >> tempr;
		l = l < templ ? templ : l;
		r = r > tempr ? tempr : r;
	}
	int cnt = r - l + 1;
	if (cnt < 0) {
		cout << 0;
	}
	else {
		cout << cnt;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cmath>

using namespace std;

int main(void){

    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k ;

    if(e-a>k || e-b>k || e-c>k || e-d>k || d-a>k || d-b>k || d-c>k || c-a>k || c-b>k || b-a>k){
        
        cout << ":(" << endl;
    }

    else{
        cout << "Yay!" << endl;
    }

 return 0;   
}

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

int main(){
	int n;
	cin >> n;
	vector<int> h(n);
	vector<int> dp(n);
	for(int i=0;i<n;i++){
		cin >> h.at(i);
	}
	dp.at(0)=0;
	dp.at(1)=max(h.at(0),h.at(1))-min(h.at(0),h.at(1));
	for(int i=2;i<n;i++){
		dp.at(i)=min(dp.at(i-2)+max(h.at(i-2),h.at(i))-min(h.at(i-2),h.at(i)),dp.at(i-1)+max(h.at(i-1),h.at(i))-min(h.at(i-1),h.at(i)));
	}
	cout << dp.at(n-1) << endl;
}


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

#define MOD 1000000007

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


template <class T>
ostream &operator<<(ostream &o, const vector<T>&obj) {
    o << "["; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const vector<vector<T>>&obj) {
    o << "[" << endl; for (int i = 0; i < (int)obj.size(); ++i) o << "  " << obj[i] << endl; o << "]"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U>&obj) {
    o << "(" << obj.first << ", " << obj.second << ")"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const queue<T>&obj) {
    queue<T> obj_cp = obj;
    bool first = true;
    o << "{";
    while (!obj_cp.empty()) { o << (!first ? ", " : "") << obj_cp.front(); obj_cp.pop(); first = false; }
    o << "}"; return o;
}

void print() {
    cout << "\n";
}
template<class Head, class... Body>
void print(Head head, Body... body) {
    cout << head << " ";
    print(body...);
}


map<ll, ll> factorize(ll n) {
    map<ll, ll> ret;
    ll a = 2;
    while (a * a <= n) {
        if (n % a == 0) {
            if (ret.count(a) == 0) {
                ret[a] = 1;
            } else {
                ret[a] += 1;
            }
            n /= a;
        } else {
            a++;
        }
    }
    if (n > 1) {
        if (ret.count(a) == 0) {
            ret[n] = 1;
        } else {
            ret[n] += 1;
        }
    }
    return ret;
}


int main(int argc, char const *argv[]) {
    int N;
    cin >> N;
    vector<ll> A(N), B(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i] >> B[i];
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    
    if (N % 2 == 1) {
        cout << B[N/2] - A[N/2] + 1 << endl;
    } else {
        ll start2, end2;
        start2 = A[N/2-1] + A[N/2];
        end2 = B[N/2-1] + B[N/2];
        cout << end2 - start2 + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 6384
#include <iostream>
#include <queue>
#include <algorithm>
#include <tuple>
using namespace std;
using P = pair<int,int>;

char A[50][50];
bool isB[50][50];
bool isW[50][50];

int main(){
    int w,h;
    deque<P> B,W;
    while(cin>>w>>h,w){
        B.clear();
        W.clear();
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin>>A[i][j];
                if(A[i][j]=='B')B.emplace_back(i,j);
                if(A[i][j]=='W')W.emplace_back(i,j);
            }
        }
        fill(isB[0],isB[50],false);
        fill(isW[0],isW[50],false);
        while(!B.empty()){
            int y,x;
            tie(y,x) = B.front(); B.pop_front();
            isB[y][x]=true;
            int d[5]={0,1,0,-1,0};
            for(int i=0;i<4;i++){
                int yy=y+d[i],xx=x+d[i+1];
                if(yy<0||yy>=h||xx<0||xx>=w) continue;
                if(!isB[yy][xx]&&A[yy][xx]=='.'){
                    B.emplace_back(yy,xx);
                }
            }
        }
        while(!W.empty()){
            int y,x;
            tie(y,x) = W.front(); W.pop_front();
            isW[y][x]=true;
            int d[5]={0,1,0,-1,0};
            for(int i=0;i<4;i++){
                int yy=y+d[i],xx=x+d[i+1];
                if(yy<0||yy>=h||xx<0||xx>=w) continue;
                if(!isW[yy][xx]&&A[yy][xx]=='.'){
                    W.emplace_back(yy,xx);
                }
            }
        }
        int ansB=0,ansW=0;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(A[i][j]=='.'&&isB[i][j]&&!isW[i][j]) ansB++;
                if(A[i][j]=='.'&&!isB[i][j]&&isW[i][j]) ansW++;
            }
        }
        cout<<ansB<<' '<<ansW<<endl;
    }
    return 0;
}

Measured memory_bytes: 3024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  bool flag = true;
  if(s.length() % 2 == 1) cout << "No" << endl;
  else{
    for(int i = 0; i < s.length() - 1; i += 2){
      if(s[i] != 'h' || s[i+1] != 'i'){
        flag = false;
        break;
      }
    }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  }
}

Measured memory_bytes: 256
n=int(input())
v=list(map(int,input().split()))

v1=v[::2]
v2=v[1::2]

n1=[0 for i in range(10**5+1)]
n2=[0 for i in range(10**5+1)]

for a in v1:
    n1[a]+=1
for a in v2:
    n2[a]+=1
    
import numpy as np

i1=np.argsort(np.argsort(-np.array(n1)))
i2=np.argsort(np.argsort(-np.array(n2)))

zero1=list(i1).index(0)
zero2=list(i2).index(0)

if zero1!=zero2:
    print(n-n1[zero1]-n2[zero2])
else:
    one1=list(i1).index(1)
    one2=list(i2).index(1)
    if n1[zero1]-n1[one1]>n2[zero2]-n2[one2]:
        print(n-n1[zero1]-n2[one2])
    else:
        print(n-n1[one1]-n2[zero2])


Measured memory_bytes: 24096
a=list(map(int,input().split()))
b=list(map(int,input().split()))
t=int(input())
sa=a[1]-b[1]
d=abs(a[0]-b[0])
if sa<=0:
    print('NO')
elif sa*t<d:
    print('NO')
else:
    print('YES')


Measured memory_bytes: 61628
program main
      implicit none
      integer(4) :: n, x, y, k
      integer(4) :: i, j, k1, k2, k3
      integer(4), allocatable :: d(:)

      read(*,*) n, x, y

      allocate( d(n-1) )
      d(:) = 0
      do i = 1, n-1
        do j = i+1, n
          k1 = abs(i-j)
          k2 = abs(i-x) + 1 + abs(j-y)
          k3 = abs(i-y) + 1 + abs(j-x)
          k = min(k1,k2,k3)
          d(k) = d(k) + 1
        end do
      end do

      do k = 1, n-1
        print *, d(k)
      end do
end program main


Measured memory_bytes: 256
#line 1 "../lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>

using namespace std;

#line 2 "tmp.cpp"

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

  int n, q;
  cin >> n >> q;
  vector<pair<int, pair<int, int>>> es;
  REP(i, n) {
    int s, t, x;
    cin >> s >> t >> x;
    es.push_back({s - x, {x, 1}});
    es.push_back({t - x, {x, -1}});
  }

  sort(ALL(es));

  multiset<int> ms;
  int itr = 0;
  REP(i, q) {
    int d;
    cin >> d;
    while (itr < (int)es.size() && es[itr].first <= d) {
      if (es[itr].second.second == 1) {
        ms.insert(es[itr].second.first);
      } else {
        ms.erase(es[itr].second.first);
      }
      itr++;
    }
    if (ms.empty()) {
      cout << -1 << endl;
    } else {
      cout << *ms.begin() << endl;
    }
  }
  return 0;
}


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

#define loop(lp) for(int i = 0; (i) < (lp); (i) ++)
#define ascent(i, a, b) for(int i = (a); (i) < (b); (i) ++)
#define descent(i, a, b) for(int i = (a); (i) > (b); (i) --)

#define pb push_back

using namespace std;

int main() {
  int n, p;
  while(true) {
    cin >> n >> p;
    if(n == 0 && p == 0) break;

    int stone[50];
    ascent(i, 0, 50) {
      stone[i] = 0;
    }
    
    //  stone[0] = p;
    int i = 0;
    while(true) {
      if(p > 0) {
	stone[i] ++;
	p --;
	
	if(p == 0) {
	  bool flg = true;
	  ascent(j, 0, n) {
	    if(j != i && stone[j] > 0) flg = false;
	  }
	  if(flg) break;
	}
      }
      else if(p == 0) {
	p += stone[i];
	stone[i] = 0;
      }
      
      i ++;
      i = i%n;
    }
    
    cout << i << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
def main():
    N,X = map(int,input().split())
    L = list(map(int,input().split()))
    jump = [0]*(N**4)
    jump[0] = 1
    d = 0
    for i in range(N):
        d += L[i]
        jump[d] = 1
    
    print(sum(jump[:X+1]))
    


if __name__=="__main__":
    main()

Measured memory_bytes: 784372
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

struct Store
{
	int a,b;
	Store() {}
	bool operator<(const Store& x)const {
		return (x.a)*(b+1) < (a)*(x.b+1);
	}
};

signed main() {
	int n,t;
	std::cin >> n >> t;
	std::vector<Store> stores(n),s;
	std::vector<int> zeros;
	rep(i,n) std::cin >> stores[i].a >> stores[i].b;
	rep(i,n) {
		if(stores[i].a!=0) s.emplace_back(stores[i]);
		else zeros.emplace_back(stores[i].b);
	}
	std::sort(all(s));

	std::sort(all(zeros));
	std::vector<int> ac(zeros.size()+1,0);
	rep(i,zeros.size()) ac[i+1] = ac[i]+zeros[i]+1;
	const int INF = t+1;
	std::vector<int> dp(32,INF);
	dp[0]=0;
	for(int i=0;i<s.size();i++) {
		for(int j=30;j>=0;j--) {
			if(dp[j]==INF) continue;
			dp[j+1] = std::min(dp[j+1], (dp[j]+1)*(s[i].a+1)+s[i].b);
			if(dp[j+1]>t) dp[j+1]=INF;
		}
		debug(dp);
	}
	int max = 0;
	for(int i=31;i>=0;i--) {
		if(dp[i]!=INF) {
			int x = t-dp[i];
			int l=-1,r=ac.size();
			while(r-l>1) {
				int o = (r+l)/2;
				if(ac[o]>x) r=o;
				else l=o;
			}
			debug(i,l,dp[i]);
			max = std::max(max, i+l);
		}
	}
	print(max);

	return 0;
}


Measured memory_bytes: 9072
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int ans = 0;
  for(int i = a; i <= b; i++){
    if(c % i == 0) ans++;
  }
  cout << ans << endl;

}


Measured memory_bytes: 3112
import java.io.*;
import java.math.*;
import java.util.*;
import java.lang.*;

// import java.text.DecimalFormat; 
// import java.text.DecimalFormatSymbols; 
/*
 
 
 
 */

public class Main {

    public static void main(String args[] ) throws Exception {
        PrintWriter pw=new PrintWriter(System.out);
        FastScanner sc = new FastScanner();
        
        int t=1;
        //t = sc.ni();
        while(t-->0) {
        	solve(pw,sc);
        }
       
        pw.close();
    }
  
   
    private static void solve(PrintWriter pw, FastScanner sc) {
    	StringBuffer st = new StringBuffer();
    	String s = "ACL";
    	int k = sc.ni();
    	while(k-->0) {
    		st.append(s);
    	}
    	pw.print(st.toString());
	}

	static <T> void deb(T x,int o){
       System.out.print(x);
       if(o==0) {
    	   System.out.println();
    	   
       }
    }
   
   
   static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String ne() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		public String ne(int k) {
			try {
				return br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return "Not able to read";
		}
		
		int ni() {
			return Integer.parseInt(ne());
		}
		
		long nl() {
			return Long.parseLong(ne());
		}
		
		double nd() {
			return Double.parseDouble(ne());
		}
		
	    
	}
   
}

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

#define SENTINEL 1000001000

int count = 0;

void mergeSort(int A[], int left, int right) {
	int i, mid;
	if (left + 1 < right) {
		mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}



void merge(int A[], int left, int mid, int right) {
	int n1, n2, i, j, k;
	int *L, *R;
	n1 = mid - left;
	n2 = right - mid;
	L = (int *)malloc(sizeof(int)*(n1 + 1));
	R = (int *)malloc(sizeof(int)*(n2 + 1));
	for (i = 0; i <= n1 - 1; i++) {
		L[i] = A[left + i];
	}
	for (j = 0; j <= n2 - 1; j++) {
		R[j] = A[mid + j];
	}
	L[n1] = SENTINEL;
	R[n2] = SENTINEL;
	i = 0;
	j = 0;
	for (k = left; k <= right - 1; k++) {
		if (L[i] <= R[j]) {
			A[k] = L[i];
			i++;
			count++;
		}
		else {
			A[k] = R[j];
			j++;
			count++;
		}
	}
	free(L);
	free(R);
}
long long int min(long long int n, long long int tmp[], long long int *num, long long int *M) {
	long long int min_memo = tmp[0];
	long long int min_num = 0;
	for (int i = 1; i < n; i++) {
		if (min_memo > tmp[i]) {
			min_memo = tmp[i];
			min_num = i;
		}
	}
	*num = min_num;
	*M = min_memo;
	return 0;
}

main() {
	int A[500000];
    int k;
	long long int n,num,m;
	long long int s[500000] = {};
	scanf("%d%d", &n,&k);
	for (int i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}
	mergeSort(A, 0, n);
	for (int i = n-1; i >= k-1; i--) {
		s[i - k+1] = A[i] - A[i - k+1];
     
		
	}
	min(n-k+1, s, &num, &m);
	printf("%lld", m);
	return 0;
}
	


Measured memory_bytes: 6528
#include <cstdio>

int main() {
    int N;
    int fx = 0;
    scanf("%d", &N);

    for (int a = N ; a > 0; a /= 10) {
        fx += a%10;
    }
    // printf("%d\n", fx);
    if (N%fx == 0) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**7)
#import numpy as np
# n = int(input())
# a, b = map(int, input().split())
# int_list = list(map(int, input().split()))
# l = list(input().split())

def solve():
    s = input()

    # A と BC と それ以外に分ける
    s = s.replace("A", "1")
    s = s.replace("BC", "2")
    s = s.replace("B", "0")
    s = s.replace("C", "0")
    s_split = s.split("0")

    total_count = 0
    for subs in s_split:
        # subs は 12111212122 のような0を含まない文字列
        count_1 = 0

        for i in range(len(subs)):
            if subs[i] == "1":
                count_1 += 1
            elif subs[i] == "2":
                total_count += count_1

    print(total_count)

solve()

Measured memory_bytes: 5540
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin, (x).rend()
#define endl '\n'
#define first F
#define second S
typedef long long ll;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, k;
	cin>>n>>k;
	string s; cin>>s;
	s[k-1] = tolower(s[k-1]);
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 3608
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text.RegularExpressions;

namespace ConsoleApp23
{
    class Program
    {
        private static string[][] _board;

        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int h = line[0];
            int w = line[1];
            _board = new string[h][];

            for (int i = 0; i < _board.Length; i++)
            {
                _board[i] = Regex.Split(
                    Console.ReadLine(), string.Empty).Where(s => s != string.Empty).ToArray();
            }

            for (int i = 0; i < _board.Length; i++)
            {
                for (int j = 0; j < _board[i].Length; j++)
                {
                    if(_board[i][j] == ".")
                    {
                        var count = CountArroundBombPoint(i, j);
                        Console.Write(count.ToString());
                    }
                    else
                    {
                        Console.Write(_board[i][j]);
                    }
                }

                if (i != h - 1)
                {
                    Console.WriteLine("");
                }
            }

        }

        static int CountArroundBombPoint(int rowPoint, int colPoint)
        {
            int result = 0;
            for (int i = rowPoint - 1; i <= rowPoint + 1; i++)
            {
                if (i < 0 || i >= _board.Length)
                {
                    continue;
                }

                for (int j = colPoint - 1; j <= colPoint + 1; j++)
                {
                    if (j < 0 || j >= _board[0].Length)
                    {
                        continue;
                    }


                    if (_board[i][j] == "#")
                    {
                        result++;
                    }
                }
            }
            return result;
        }

    }
}


Measured memory_bytes: 16344
import itertools
N = int(input())
L = list(map(int,input().split()))
res = 0
for i in itertools.combinations(L,3):
    i = list(i)
    i.sort()
    if i[0] != i[1] and i[1] != i[2]: 
        if i[2] < i[0]+i[1]:
            res += 1
print(res)

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

using ll = long long;
using ull = unsigned long long;
using namespace std;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;


int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    string s;
    cin>>s;
    
    if(s == "RRR")cout << 3 << endl;
    else if(s == "RRS" or s == "SRR")cout << 2 << endl;
    else if(s != "SSS")cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
    
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,R; cin >> N >> R;
    if (N>=10) cout << R << endl;
    else cout << R+100*(10-N) << endl;
}

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << " : " << x << endl;
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

template<class T,class U> void chmax(T& a, U b) {if(a<b)a=b;}
template<class T,class U> void chmin(T& a ,U b) {if(b<a)a=b;}

ll dp[10][10];

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin>>n;

    for(int i = 1; i < 10; i++) {
        for(int j = 1; j < 10; j++) {
            ll s = 0;
            if (i == j and i <= n) s++;
            if (stoi(to_string(i) + to_string(j)) <= n) s++;
            // if (stoi(to_string(i) + to_string(j)) <= n and stoi(to_string(j) + to_string(i)) <= n) s++;
            for(int k = 0; k < 10000; k++) {
                string sx = to_string(i) + to_string(k) + to_string(j);
                // string sy = to_string(j) + to_string(k) + to_string(i);
                int x = stoi(sx);
                // int y = stoi(sy);
                if(x <= n) {
                    // cout << x << endl;
                    s++;
                }
            }
            for(int k = 0; k < 1000; k++) {
                string sx = to_string(i) + "0" + to_string(k) + to_string(j);
                // string sy = to_string(j) + to_string(k) + to_string(i);
                int x = stoi(sx);
                // int y = stoi(sy);
                if(x <= n) {
                    // cout << x << endl;
                    s++;
                }
            }
            for(int k = 0; k < 100; k++) {
                string sx = to_string(i) + "00" + to_string(k) + to_string(j);
                // string sy = to_string(j) + to_string(k) + to_string(i);
                int x = stoi(sx);
                // int y = stoi(sy);
                if(x <= n) {
                    // cout << x << endl;
                    s++;
                }
            }
            for(int k = 0; k < 10; k++) {
                string sx = to_string(i) + "000" + to_string(k) + to_string(j);
                // string sy = to_string(j) + to_string(k) + to_string(i);
                int x = stoi(sx);
                // int y = stoi(sy);
                if(x <= n) {
                    // cout << x << endl;
                    s++;
                }
            }
            dp[i][j] = s;
        }
    }

    ll ans = 0;
    for(int i = 1; i < 10; i++) {
        for(int j = 1; j < 10; j++) {
            // cout << i << " " << j << " " << dp[i][j] << endl;
            ans += dp[i][j] * dp[j][i];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n,m = inpm()
    x = inpl()
    x.sort()
    ans = 0
    y = [0 for _ in range(n)]
    dic = defaultdict(int)
    dic2 = defaultdict(int)
    dic3 = defaultdict(int)
    for i in range(n):
        y[i] = x[i]%m
        dic[y[i]] += 1
        dic2[x[i]] += 1
    for e in dic2:
        if dic2[e]>1:
            dic3[e%m] += dic2[e]//2
    for i in range(m):
        if i > m-i:
            break
        elif i == 0:
            ans += dic[i]//2
        elif i == m/2:
            ans += dic[i]//2
        else:
            ans += min(dic[i],dic[m-i])
            if dic[i] == dic[m-i]:
                continue
            elif dic[i] > dic[m-i]:
                a = (min(dic[i]-dic[m-i],dic3[i]*2))//2
                if a>0:
                    ans += a
            elif dic[i] < dic[m-i]:
                a = (min(dic[m-i]-dic[i],dic3[m-i]*2))//2
                if a>0:
                    ans += a
    print(ans)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 27544
N, K = map(int, input().split())
x = [int(xi) for xi in input().split()]
best = float('inf')
for i in range(N - K + 1):
    start = x[i]
    end = x[i+K-1]
    near = min(start, end)
    if end <= 0:
        dist = abs(start)
    elif 0 <= start:
        dist = abs(end)
    else:
        if abs(start) < abs(end):
            dist = abs(start) * 2 + abs(end)
        else:
            dist = abs(end) * 2 + abs(start)
    best = min(dist, best)
if best == float('inf'):
    print(0)
else:
    print(best)




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

int main(){
  
  int h, w;
  cin >> h >> w;

  int dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
  int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};  
  
  vector<vector<char>> v(h, vector<char>(w));
  
  rep(i, h){
    rep(j, w){
      cin >> v[i][j];
    }
  }

  vector<vector<int>> ans(h, vector<int>(w, 0));
  rep(i, h){
    rep(j, w){
      if(v[i][j] == '#') ans[i][j] = -1;
      else{
        int yy = i, xx = j;
        rep(k, 8){
          if(yy + dy[k] < 0 || xx + dx[k] < 0) continue;
          if(yy + dy[k] >= h || xx + dx[k] >= w) continue;
          if(v[yy + dy[k]][xx + dx[k]] == '#') ans[i][j]++;
        }

      }

    }
  }

  for(auto y : ans){
    for(int x : y){
      if(x == -1) cout << '#';
      else cout << x;
    }
    cout << endl;
  }
}


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

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	cout << (A == B && B == C ? "Yes" : "No");
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

*/

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

from collections import Counter

n = int(input())
s = [0] * n
for i in range(n):
    s[i] = input().strip()
s = Counter(s)
m = int(input())
t = [0] * m
for i in range(m):
    t[i] = input().strip()
t = Counter(t)

ans = 0
for k in s:
    tmp = s[k]
    if k in t:
        tmp -= t[k]
    ans = max(ans, tmp)
print(ans)


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

using namespace std;

int main()
{
    multimap<long long int,long long int>m;
    multimap<long long int,long long int>::iterator it;
    long long int n,mcan,i,j,a,b,count_can,money=0;
    cin>>n>>mcan;
    for(i=1;i<=n;++i){

        cin>>a>>b;
        m.insert(make_pair(a,b));

    }
    for (it=m.begin();it!=m.end();++it){

        if ((it->second)>=mcan){

            money+=(mcan*(it->first));
            break;

        }
        else{

           mcan-=(it->second);
           money+=((it->second)*(it->first));
           if (mcan==0)break;

        }

    }
    cout<<money<<endl;
    return 0;
}


Measured memory_bytes: 6528
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int A, B, X;
    cin >> A >> B >> X;
    if (A <= X && A + B >= X) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int ans = 0;
		string s = Console.ReadLine();
		int[]NA = new int[N];
		for(var i=0;i<N;i++){
			string s1 = s.Substring(i,1);
			if(s1=="R"){
				NA[i] = 1;
			}
		}
		int a1 = 0;
		int b1 = N-1;
		while(true){
			while(NA[a1]==1){
				a1++;
				if(a1>=b1){
					break;
				}
			}
			while(NA[b1]==0){
				b1--;
				if(a1>=b1){
					break;
                }
			}
          if(a1>=b1){
					break;
				}
			ans++;
			a1++;
			b1--;
			if(a1>=b1){
				break;
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 22712
from itertools import permutations
 
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
 
perm = list(permutations(range(1, N + 1)))
 
for i, pe in enumerate(perm, start=1):
    if P == pe:
        a = i
    if Q == pe:
        b = i
print(abs(a - b))

Measured memory_bytes: 8052
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second

int arr[200000];
int n,k;

int fn(int x){
	int c=0;
	for(int i=0; i<n; i++){
		c += (arr[i]+x-1)/x-1;
	}
	return c;
}

signed main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	//int n,k;
	cin >> n >> k;
	//int arr[n];
	for(int i=0; i<n; i++){
		cin >> arr[i];
	}

	int l=1, r=1000000000;
	while(r-l>1){
		int m = (l+r)/2;
		if(fn(m)<=k){
			r=m;
		}
		else
			l=m;
	}

	int ans;
	if(fn(l)<=k)
		ans=l;
	else
		ans=r;

	cout << ans;	
	

	return 0;
}

Measured memory_bytes: 5184
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define sz(x) int(x.size())
using ll = long long;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;

int main()
{
    int N,M;
    cin >> N >> M;
    vector<ll> H(N);

    for(int i=0;i<N;i++){
        cin >> H[i];
    }
    
    vector<int> A[N+1];
    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >> b;
        A[a].push_back(b);
        A[b].push_back(a);  
    }
    int ans=0;
    for(int i=1;i<=N;i++){
        
        if(A[i].size() == 0){
            // cout <<"a" << i <<endl;
            ans++;
            continue;
        }
        bool flag=true;
        for(int j : A[i]){
            if(H[i-1] <= H[j-1]){
                flag = false;
            }
        }
        if(flag){
            //cout <<"aaa" << i <<endl;
            ans++;
        }

    }
    cout << ans;

    return 0;
}

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

using namespace std;

using ll = long long;
const int mod = 1e9 + 7;

ll silnia[1000005];

ll pot(int x, int y) {
    int xdd = 1;
    while(y > 0) {
        if(y % 2 == 1) xdd = ((ll)xdd * x) % mod;
        x = ((ll)x * x) % mod;
        y /= 2;
    }
    return xdd;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int x, y;
    cin >> x >> y;
    if ((x + y) % 3 || x * 2 < y || y * 2 < x){
        cout << "0\n";
        return 0;
    }
    int pom = (x + y) / 3 * 2 - x;
    silnia[0] = 1;
    for (ll i = 1; i <= (x + y) / 3; i++)
        silnia[i] = (silnia[i - 1] * i) % mod;
    cout << (silnia[(x + y) / 3] * pot(((ll)silnia[pom] * silnia[(x + y) / 3 - pom]) % mod, mod - 2)) % mod << "\n";
}

Measured memory_bytes: 6400