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

int main(){
  int N;
  cin >> N;
  int64_t n[100];
  n[0] = 2;
  n[1] = 1;
  
  for(int i = 2 ; i <= N;i++){
	n[i] = n[i-1] + n[i-2];
  }
  
  cout << n[N] << endl;
}

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

#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define all(x) x.begin(), x.end()
#define f(x) for(int i = 0; i < x; ++i)

using namespace std;
using namespace chrono;

int main(){
    ios::sync_with_stdio(0);

    int n ;

    string s;

    cin >> s;

    sort(all(s));

    if(s[1] == s[0] and s[2] == s[3] and s[0] != s[3]) cout << "Yes\n" ;
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
///#pragma GCC optimize ("O2") ///G++ÓÃ£¬
///#pragma comment(linker, "/STACK:36777216")///C++ÓÃ
///#pragma comment(linker, "/STACK:102400000,102400000")///C++ÓÃ£¬·ÀÖ¹Õ»Òç³ö
#include <bits/stdc++.h>
//#include <unordered_map>
//#include <unordered_set>
using namespace std;


#define debug       cout << "***********************" << endl
#define Bug(s)      cout << "s = " << s << endl
#define mem(a,b)    memset(a, b, sizeof(a))
#define lson        l, mid, rt<<1
#define rson        mid + 1, r, rt<<1|1
#define For(i, x, n)  for(int i = (x) ; i < (n) ; ++i)
#define Forr(i, x, n) for(int i = (x) ; i <= (n) ; ++i)
#define Rep(i, x, n)  for(int i = (x) ; i > (n) ; --i)
#define Repp(i, x, n) for(int i = (x) ; i >= (n) ; --i)
#define highint( n )  ceil( n )
#define lowint( n )   floor( n )
#define SERU(x)       floor((double) x + 0.5 )
#define lowbit(x)     (x & (-x))

#define all(x)      (x).begin(), (x).end()
#define SZ(x)       (int)(x).size()
#define FA(i, a, x) for (__typeof((x).begin()) i=(a); i!=(x).end(); ++i)
#define RA(i, x)    FA(i, (x).begin(), x)
#define FDA(i, a, x)  for (__typeof((x).rbegin()) i=(x).rbegin(); i!=(a); ++i)
#define RDA(i, x)   FDA(i, (x).rend(), x)
#define P(v, x)     (v.find(x) != v.end())
#define Pos(v, x)   (find(all(v), x) != v.end())
#define UN(a)       sort(all(a)), a.erase(unique(all(a)), a.end())
#define REV(a)      reverse(all(a))
#define mp(a, b)    make_pair(a, b)
#define p(a, b)     pair<int, int>(a, b)
#define sf1i(x)     scanf("%d", &x)
#define sf1l(x)     scanf("%I64d", &x)
#define sf2i(x, y)  scanf("%d%d", &x, &y)
#define sf2l(x, y)  scanf("%I64d%I64d", &x, &y)
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ll long long
#define eps 1e-8



int a[111];
bool v[123456];
int main(){
    int n;
    cin >> n;
    int res = 0;
    int c = 0;
    memset(v, 0, sizeof(v));
    v[0] = 1;
    For(i, 0, n){
        cin >> a[i];
    }
    for(int i = 0; i < n; ++i){
        for(int j = c; j >= 0; j --){
            if(v[j]){
                    v[j + a[i]] = 1;
            }
        }
        c += a[i] ;
    }
    for(int i = c; i > 0; --i)
    if(v[i] && (i % 10 != 0)){
        res = i;
        break;
    }
    if(res % 10 == 0)cout << 0 << endl;
    else cout << res << '\n';
    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#define SIZE 105

using namespace std;

int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	queue <int> odd,even;
	for(int i=0;i<m;i++)
	{
		int a;
		scanf("%d",&a);
		if(a%2==1) odd.push(a);
		else even.push(a);
	}
	if(odd.size()>=3)
	{
		puts("Impossible");
		return 0;
	}
	vector <int> vec,A;
	if(!odd.empty())
	{
		int f=odd.front();odd.pop();
		A.push_back(f);
		if(f>1) vec.push_back(f-1);
	}
	else
	{
		int f=even.front();even.pop();
		A.push_back(f);
		vec.push_back(f-1);
	}
	while(!even.empty())
	{
		int f=even.front();even.pop();
		A.push_back(f);
		vec.push_back(f);
	}
	if(!odd.empty())
	{
		int f=odd.front();odd.pop();
		A.push_back(f);
		vec.push_back(f+1);
	}
	else vec.push_back(1);
	for(int i=0;i<A.size();i++)
	{
		if(i!=0) printf(" ");
		printf("%d",A[i]);
	}puts("");
	printf("%d\n",vec.size());
	for(int i=0;i<vec.size();i++)
	{
		if(i!=0) printf(" ");
		printf("%d",vec[i]);
	}puts("");
	return 0;
}


Measured memory_bytes: 256
//h12-3 夜店
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#include <boost/multiprecision/cpp_int.hpp>
namespace boost_multiprecision = boost::multiprecision;
#define LL long long
#define CINT boost_multiprecision::cpp_int
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while (true)

int N,S,T;
vector<pair<int,int>> A;

int dp[3000][3000];

int solve(int t, int place){
    if(t == T) return 0;
    if(place >= N) return 0;
    if(dp[t][place] != INT_MIN) return dp[t][place];
    int re = 0;
    if(t < S){
        if(t+A[place].second <= S) re = max(re, solve(t+A[place].second, place+1) + A[place].first);
        re = max(re, solve(t, place+1));
        re = max(re, solve(S, place));
    }
    else{
        if(t+A[place].second <= T) re = max(re, solve(t+A[place].second, place+1) + A[place].first);
        re = max(re, solve(t, place+1));
    }
    dp[t][place] = re;
    return re;
}

int main(){
    cin >> N >> T >> S;
    for(int i=0; i<N; i++){
        int a,b;
        cin >> a >> b;
        A.push_back(make_pair(a,b));
    }

    for(int i=0; i<N; i++){
        for(int j=0; j<T; j++){
            dp[j][i] = INT_MIN;
        }
    }

    cout << solve(0,0) << endl;


    return 0;
}


Measured memory_bytes: 38520
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

using state = string::const_iterator;


int formula(state &cur);

int factor(state &cur){
    if(*cur == '-'){
        cur++;
        return 2-factor(cur);
    }
    if(isdigit(*cur)) {
        return *(cur++)-'0';
    }
    cur++;
    int ans = formula(cur);
    cur++;
    return ans;
}



int formula(state &cur) {
    int ans = factor(cur);
    while(true){
        if(*cur == '*'){
            cur++;
            ans = min(ans, factor(cur));
        }else if(*cur == '+'){
            cur++;
            ans = max(ans, factor(cur));
        }else break;
    }
    return ans;
}


int main() {
    string s;
    while(cin >> s, s != "."){
        int ans = 0;
        for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 3; ++j) {
                for (int k = 0; k < 3; ++k) {
                    string t = s;
                    for (auto &&l : t) {
                        if(l == 'P') l = '0'+i;
                        if(l == 'Q') l = '0'+j;
                        if(l == 'R') l = '0'+k;
                    }
                    state cur = t.begin();
                    if(formula(cur) == 2) ans++;
                }
            }
        }
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
set<pair<long long, long long>> st;
long long sum = 0;
int main() {
	long long n, m;
	cin >> n >> m;
	long long ans = 0;
	st.insert(make_pair(0, 1));
	for (int i = 0; i < n; i++) {
		long long a;
		cin >> a;
		sum = (sum + a) % m;
		pair<long long, long long> pa;
		if (st.lower_bound(make_pair(sum, 0)) != st.end()) {
			pa = *st.lower_bound(make_pair(sum, 0));
			if (sum == pa.first) {
				ans += pa.second;
				st.erase(*st.lower_bound(make_pair(sum, 0)));
				st.insert(make_pair(sum, pa.second + 1));
			}
			else {
				st.insert(make_pair(sum, 1));
			}
		}
		else {
			st.insert(make_pair(sum, 1));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7308
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int mh=0;
  int H[N];
  int sum=0;
  for (int i=0;i<N;i++){
    cin >> H[i];
    if(H[i]>=mh){
      mh=H[i];
      sum+=1;
    }
  }
  cout << sum << endl;
}

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

#define ll long long
#define tc(t) int t;cin >> t; while(t--)
#define pb push_back
#define fi first
#define se second
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);

void solve() {
    int n;
    cin >> n;
    ll ans = 0;
    string s;
    cin >> s;
    map<char, ll> mp;
    for(auto ch: s) {
        mp[ch] ++;
    }
    mp[s[0]] --;
    for(int j = 1; j<n-1; j++) {
        mp[s[j]] --;
        for(int i = j-1; i>=0; i--) {
            if(s[j] != s[i]) {
                int r = 0, b = 0, g = 0;
                if(s[i] == 'R' || s[j] == 'R') r = 1;
                if(s[i] == 'G' || s[j] == 'G') g = 1;
                if(s[i] == 'B' || s[j] == 'B') b = 1;
                if(b == 0) {
                    ans += mp['B'];
                    int idx = (j-i);
                    if(j+idx < n && s[j + idx] == 'B') ans --;
                }
                else if(g == 0) {
                    ans += mp['G'];
                    int idx = (j-i);
                    if(j+idx < n && s[j + idx] == 'G') ans --;
                }
                else if(r == 0) {
                    ans += mp['R'];
                    int idx = (j-i);
                    if(j+idx < n && s[j + idx] == 'R') ans --;
                }
            }
        }
    }
    cout << ans;
}

int main() {_
    int t = 1;
    //cin >> t;
    // Please remember to uncomment for taking test cases
    for(int i = 1; i<=t; i++) {
        solve();
    }
    return 0;
}


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

class _Class
{
	void _()
	{
		var _ = _Ns();

		int x1 = 0;
		int x2 = _[0];
		int y1 = 0;
		int y2 = _[1];

		for (int i = 0; i < _[2]; i++)
		{
			var _N = _Ns();

			if (_N[2] == 1)
			{
				var n = _N[0];
				x1=Math.Max(x1,n);
			}
			if (_N[2] == 2)
			{
				var n = _N[0];
				x2 = Math.Min(x2, n);
			}
			if (_N[2] == 3)
			{
				var n = _N[1];
				y1 = Math.Max(y1, n);
			}
			if (_N[2] == 4)
			{
				var n = _N[1];
				y2 = Math.Min(y2, n);
			}
		}

		var x = x2 - x1;
		var y = y2 - y1;

		if (x <= 0 || y <= 0)
		{
			Console.WriteLine(0);
			return;
		}

		Console.WriteLine(x*y);
	}

	static void Main(string[] args)
  {
    new _Class()._();
  }

  #region

  string _S()
  {
    return Console.ReadLine();
  }

  string[] _Ss()
  {
    return Console.ReadLine().Split();
  }

  int[] _N(int n)
  {
    var x = new int[n];
    for (var i = 0; i < n; i++)
    {
      x[i] = int.Parse(Console.ReadLine());
    }
    return x;
  }

  int[] _Ns()
  {
    var ss = Console.ReadLine().Split();

    var x = new int[ss.Length];
    for (var i = 0; i < ss.Length; i++)
      x[i] = int.Parse(ss[i]);

    return x;
  }
  #endregion
}


Measured memory_bytes: 2648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll i = 1;
    while (i * 10 < (ll)1e11) {
        cout << "? " << i << endl;
        char c;
        cin >> c;
        if (c % 2 == 0) {
            i /= 10;
            break;
        }
        i *= 10;
    }
    debug(i);
    if (i == (ll)1e10) {
        i = 1;
        ll j = 2;
        for (int k = 0; k < 11; k++) {
            cout << "? " << j << endl;
            char c;
            cin >> c;
            if (c % 2 == 1) {
                cout << "! " << i << endl;
                break;
            }
            i *= 10;
            j *= 10;
        }
        return 0;
    }
    ll j = i * 10 - 1;
    while (i + 1 < j) {
        ll mid = (i + j) / 2;
        ll t = mid * 10 + 1;
        cout << "? " << t << endl;
        char c;
        cin >> c;
        if (c % 2 == 0) {
            i = mid;
        } else {
            j = mid;
        }
    }
    cout << "! " << j << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

#define INF (1<<(4*4-1))
#define MOD 1000000007

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

   string S;
   cin>>S;

   vector<int>a(S.size());
   for(int i=0;i<S.size();i++)a[i] = atoi(S.substr(i,1).c_str());
   int bit = pow(2,S.size()-1);
   ll res = 0;
   for(int i=0;i<bit;i++){
      ll buf = a[0];
      ll ans = 0;
      for(int j=0;j<S.size()-1;j++){
         if(i&(1<<j)){
            ans += buf;
            buf = a[j+1];
         }
         else{
            buf = 10*buf + a[j+1];
         }
      }
      ans += buf;
      res += ans;
   }

   cout<<res<<endl;
   return 0;
}


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

long long x,k,d,p,q,kurang;

long long absol(long long a){
	if(a<0){
		return a*=-1;
	}else {
		return a;
	}
}

int main(){
	cin >> x >> k >> d;
	kurang = min(k,absol(x/d));
	if(x>0){
		k = k-kurang;
		x = x-kurang*d;
	} else{
		k = k-kurang;
		x = x+kurang*d;
	}
	
	if(k>0){
		if(x>0){
			if(k%2==1){
				x = min(absol(x+d),absol(x-d));
			}
		}else {
			if(k%2==1){
				x = min(absol(x+d),absol(x-d));
			}
		}
	}
	
	cout << absol(x) <<endl;
}

Measured memory_bytes: 3632
# Aizu Problem ITP_1_7_A: Grading
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


while True:
    m, f, r = [int(_) for _ in input().split()]
    score = m + f
    if m == f == r == -1:
        break
    elif m == -1 or f == -1:
        print('F')
    elif score >= 80:
        print('A')
    elif score >= 65:
        print('B')
    elif score >= 50 or (score >= 30 and r >= 50):
        print('C')
    elif score >= 30:
        print('D')
    else:
        print('F')

Measured memory_bytes: 7740
inp = list(map(int, input().split()))


def factorize(n):
    arr = []
    tmp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if tmp % i == 0:
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            arr.append([i, cnt])

    if tmp != 1:
        arr.append((tmp, 1))

    if not arr and n != 1:
        arr.append((n, 1))

    return arr


re = 0

for _, c in factorize(inp[0]):
    tmp1 = c
    tmp2 = 1
    while tmp1 >= tmp2:
        re += 1
        tmp1 -= tmp2
        tmp2 += 1


print(re)


Measured memory_bytes: 63264
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int LCM(int a, int b) { int g = gcd(a, b); return a / g * b; }
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int r; cin >> r;
    int a = 0,b = 0;
    if(r % 2 == 0){
        cout << (r / 2) * (r / 2) << endl;;
    }else{
        cout << (r / 2) * (r / 2 + 1) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
class Dice{
public:
    int num[6];
    void setRoll(int a, int b, int c, int d, int e, int f){
        num[0] = a;
        num[1] = b;
        num[2] = c;
        num[3] = d;
        num[4] = e;
        num[5] = f;
    }
    void roll(char c){
        if(c == 'N') setRoll(num[1], num[5], num[2], num[3], num[0], num[4]);
        else if(c == 'E') setRoll(num[3], num[1], num[0], num[5], num[4], num[2]);
        else if(c == 'W') setRoll(num[2], num[1], num[5], num[0], num[4], num[3]);
        else if(c == 'S') setRoll(num[4], num[0], num[2], num[3], num[5], num[1]);
        else if(c == 'R') setRoll(num[0], num[3], num[1], num[4], num[2], num[5]);
    }
};
int main(){
    Dice d1, d2;
    for(int i = 0; i < 6; i++) cin >> d1.num[i];
    for(int i = 0; i < 6; i++) cin >> d2.num[i];
    bool flag = false;
    for(int i = 0; i < 6; i++){
        if(i == 1) d2.roll('N');
        else if(i == 2){
            d2.roll('S');
            d2.roll('E');
        }
        else if(i == 3){
            d2.roll('W');
            d2.roll('W');
        }
        else if(i == 4){
            d2.roll('E');
            d2.roll('S');
        }
        else if(i == 5) d2.roll('S');
        for(int j = 0; j < 4; j++){
            int count = 0;
            for(int k = 0; k < 6; k++){
                // cout << d2.num[k] << " ";
                if(d1.num[k] == d2.num[k]) count++;
                else break;
            }
            // cout << ": " << count << endl;
            if(count == 6){
                flag = true;
                break;
            }
            d2.roll('R');
        }
        // cout << endl;
        if(flag) break;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}



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


int main(){

  char a;
  cin>>a;
  if(isupper(a))cout<<'A'<<endl;

  else cout<<'a'<<endl;

}


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

using namespace std;

#define int 		long long
#define endl		"\n"
#define mod			1000000007
#define inf			1e12
#define IOS			ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int32_t main() {

	IOS;

	int n, d;
	cin >> n >> d;

	int ans = 0, x, y;
	int dis = d * d;

	for(int i = 0; i < n; i++) {
		cin >> x >> y;
		if(x*x + y * y <= dis)
			ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3492
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A,B,C,K;
    cin>>A>>B>>C>>K;
    if(K<A) cout<<K<<endl;
    else if(K>=A&&K<=(A+B)) cout<<A<<endl;
    else cout<<-K+2*A+B<<endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>

using namespace std;

int main (void)
{
  int n;
  string s,t;
  
  cin>>n;
  cin>>s>>t;
  
  string ans;
  
  for(int i=0;i<n;i++)
  {
    ans.push_back(s[i]);
    ans.push_back(t[i]);
  }
  
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstdio>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)2e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

#define MAX 100010
ll fac[MAX];
ll finv[MAX];
ll inv[MAX];

void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    repr(i,2,MAX){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}



int main(){
	int N; cin >> N;
	string S; cin >> S;
	rep(i,2*N){
		if(i % 2 == 0){
			if(S[i] == 'W') S[i] = 'B';
			else S[i] = 'W';
		}
	}
	ll cnt = 0;
	ll cnt2 = 0;
	ll now = 0;
	ll ans = 1;
	rep(i,2*N){
		if(S[i] == 'W'){
			cnt++;
			now++;
		}
		if(S[i] == 'B'){
			cnt2++;
			ans *= now;
			ans %= MOD;
			now--;
		}
	}
	if(cnt != cnt2){
		cout << 0 << endl;
		return 0;
	}
	COMinit();
	ans *= fac[N];
	ans %= MOD;
	cout << ans << endl;

}


Measured memory_bytes: 2948
#include <bits/stdc++.h>
using namespace std;
 
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}


//2
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){

ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin>>n;

long long int p[n];

long long int mini=1000000001;
long long res=0;
for(int i=0;i<n;i++){
cin>>p[i];
mini=min(mini,p[i]);
if(p[i]==mini){
res++;
}

}

cout<<res<<endl;

}

//cout << fixed << setprecision(5) <<(n*2)*M_PI << endl;



Measured memory_bytes: 1792
#include<cstdio>
#include<vector>

using namespace std;

using vi=vector<int>;


int main(void)
{
	vi v(6);

	while(scanf("%d%d%d%d%d%d", &v[0], &v[1], &v[2], &v[3], &v[4], &v[5])==6)
	{
		vi c(4+1);
		for(int mv:v)
		{
			c[mv]++;
		}
		int odd=0;
		for(int mc:c)
		{
			if(mc&1) odd++;
		}
		int ans=(odd<=2);
		printf("%s\n", ans?"YES":"NO");
	}

	return 0;
}


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

orig = A[:]
ans = float("inf")

for k in range(N):
    tmp = k * X  
    for i in range(3*N):
        j = (i-k+N*6) % N
        i = i % N
        A[i] = min(A[i], orig[j])

    tmp += sum(A)
    ans = min(ans, tmp)
    
print(ans)


Measured memory_bytes: 42076
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 100000
int prime[MAX_N];
bool is_prime[MAX_N+1];

int sieve(int n){
  int p=0;
  for(int i=0;i<=n;i++)is_prime[i]=true;
  is_prime[0]=is_prime[1]=false;
  for(int i=2;i<=n;i++){
    if(is_prime[i]){
      prime[p++]=i;
      for(int j=2*i;j<=n;j+=i)is_prime[j]=false;
    }
  }
  return p;
}

int main(){
  int n;
  cin>>n;
  int size=sieve(55555);
  int cnt=0;
  for(int i=0;i<size;i++){
    if(prime[i]%5==1){
       if(cnt)cout<<" ";
      cout<<prime[i];
      cnt++;
    }
    if(cnt==n){
      cout<<endl;
      return 0;
    }
  }
}


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

//関数
    
    
//main関数
int main() {
    
    
    //入力
    long N;
    cin>>N;
    vector<long> a(N);
    for(int i=0;i<N;i++){
        cin>>a.at(i);
    }
    
    //計算
    set<long> remain;
    for(int i=-1;i<=N;i++){
        remain.insert(i);
    }
    
    vector<long> highrank(N);
    for(int i=0;i<N;i++){
        highrank.at(N-a.at(i))=i;
    }
    
    vector<long> r(N),l(N);
    
    set<long>::iterator ite;;
    
    long ans=0;
    for(int i=0;i<N;i++){
        long h=highrank.at(i);
        ite=remain.find(h);
        set<long>::iterator ite2=remain.upper_bound(h);;
        r.at(h)=*ite2-h;
        ite2--;
        ite2--;
        l.at(h)=h-*ite2;
        
        //cout<<h<<" "<<l.at(h)<<" "<<r.at(h)<<endl;
        remain.erase(h);
        
        ans+=l.at(h)*r.at(h)*a.at(h);
    }
    
    
    //出力
    cout<<ans<<endl;
}

Measured memory_bytes: 15872
while True:
    try:
        l = map(int, raw_input().split(','))
        v1, v2 = float(l[10]), float(l[11])
        a = sum(l[0:10])
        d = 0
        for i in range(10):
            d += l[i]
            t = d / v1
            if (d + t * v2) >= a:
                print i + 1
                break
    except EOFError:
        break

Measured memory_bytes: 4232
N = int(input())
p=list(map(int, input().split()))

count=0
i=0
while True:
  if p[i]!=i+1:
    count+=1
  if i>=N-1:
    break
  i+=1

if count==2 or count==0:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3060
#include<stdio.h>
int main()

{
  int a,b;
  scanf("%d%d",&a,&b);

  //a以上b以下の数字が回数であるかを調べる//

  int h=0;
  for(int i=a;i<=b;i++)
  {
    int s=i/10000;   //5桁目//
    int t=i/1000%10; //4桁目//
    int u=i%100/10;  //2桁目//
    int v=i%10;      //1桁目//

    if(s==v && u==t) h++;

  }

  printf("%d",h);
}


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

int main()
{
  int w,h,x,y,r;
  cin >> w >> h >> x >> y >>r;
  if(x>0 && x<w && y>0 && y<h && x-r>=0 && x+r<=w && y-r>=0 && y+r<=h){ 
      cout << "Yes" <<endl;
  } else{
    cout << "No" <<endl;
  }
return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define P pair<int,int>
#define PP pair<P,P>
#define F first
#define S second
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define rep(i,n) FOR(i,0,n)
#define PB push_back


int m,ans=0;

void num(vector<PP> v){
  int ret=0;
  rep(i,v.size()){
    FOR(j,i+1,v.size()){
      int xi=v[i].F.F-v[i].S.F;
      int yi=v[i].F.S-v[i].S.S;
      int xj=v[j].F.F-v[j].S.F;
      int yj=v[j].F.S-v[j].S.S;
      if(xi<0){
        xi*=-1;
        yi*=-1;
      }
      if(xj<0){
        xj*=-1;
        yj*=-1;
      }
      if(xi*yj==xj*yi) ret++;
    }
  }

  ans=max(ans,ret);
}

void comb(vector<P> v,bool b[],vector<PP> res){
  int s=-1;
  rep(i,m){
    if(!b[i]){
      s=i;
      b[i]=true;
      break;
    }
  }
  if(s==-1){
    num(res);
    return;
  }

  rep(i,m){
    if(!b[i]){
      b[i]=true;
      res.PB(PP(v[s],v[i]));
      comb(v,b,res);
      b[i]=false;
      res.erase(res.begin()+res.size()-1);
    }
  }

  b[s]=false;

  
}

signed main(){

  cin>>m;
  vector<P> v;
  rep(i,m){
    int x,y;
    cin>>x>>y;
    v.PB(P(x,y));
  }

  bool b[20]={};
  comb(v,b,vector<PP>());

  cout<<ans<<endl;

}


Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
  int H,W;
  cin >> H >> W;
  string S[H];
  for(int i=0;i<H;i++){
    cin >> S[i];
  }
  int L[H][W],R[H][W],D[H][W],U[H][W];
  for(int n=0;n<H;n++){
    for(int m=0;m<W;m++){
      if(S[n][m]=='#'){
	L[n][m]=0;
      }else if(m==0){
	L[n][m]=1;
      }else {
	L[n][m]=L[n][m-1]+1;
      }
      if(S[H-1-n][W-1-m]=='#'){
	R[H-1-n][W-1-m]=0;
      }else if(m==0){
	R[H-1-n][W-1-m]=1;
      }else {
	R[H-1-n][W-1-m]=R[H-1-n][W-m]+1;
      } 
    }
  }
  for(int m=0;m<W;m++){
    for(int n=0;n<H;n++){
      if(S[n][m]=='#'){
	D[n][m]=0;
      }else if(n==0){
	D[n][m]=1;
      }else {
	D[n][m]=D[n-1][m]+1;
      }
      if(S[H-1-n][W-1-m]=='#'){
	U[H-1-n][W-1-m]=0;
      }else if(n==0){
	U[H-1-n][W-1-m]=1;
      }else {
	U[H-1-n][W-1-m]=U[H-n][W-1-m]+1;
      }
    }
  }
  int ans = 0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      ans=max(ans,L[i][j]+R[i][j]+D[i][j]+U[i][j]-3);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 71732
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int k = sc.nextInt();
		int s = sc.nextInt();

		int count = 0;
		for (int x = 0; x <= k; x++) {
			for (int y = 0; y <= k; y++) {
				int z = s - x - y;
				if (0 <= z && z <= k) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 9684
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))

#define INF 1000000000

int array_min_max(int* p, int n,bool f)  //f: true→min false→max
{
	int tmp;

	if (f)
		tmp = INF;
	else
		tmp = 0;

	for (int i = 0; i < n; i++)
	{
		if (f)
		{
			if (p[i] < tmp)
				tmp = p[i];
		}
		else
		{
			if (p[i] > tmp)
				tmp = p[i];
		}
	}
	return tmp;
}

int main()
{
	int A, B, T;

	scanf("%d%d%d", &A, &B, &T);

	printf("%d", (T / A) * B);
}

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

typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7;
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)

ll A,B,C;
ll dp[105][105][105];
ll ans=mod;

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>A>>B>>C;

if(A==B&&B==C){
	cout<<0<<endl;
	return 0;
}

dp[A][B][C]=0;
for(ll a=A; a<100; a++){
	for(ll b=B; b<100; b++){
		for(ll c=C; c<100; c++){
			if(dp[a][b][c]>0||(a==A&&b==B&&c==C)){
				dp[a+1][b+1][c]=dp[a][b][c]+1;
				dp[a+1][b][c+1]=dp[a][b][c]+1;
				dp[a][b+1][c+1]=dp[a][b][c]+1;

				dp[a+2][b][c]=dp[a][b][c]+1;
				dp[a][b+2][c]=dp[a][b][c]+1;
				dp[a][b][c+2]=dp[a][b][c]+1;
			}
		}
	}
}

for(ll i=max(A,max(B,C)); i<100; i++){
	if(dp[i][i][i]) ans=min(ans,dp[i][i][i]);
}
cout<<ans<<endl;

}
	


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

using namespace std;

long long sum[2][100005], a[100005], n, q;
pair <long long, int> qu[100005];
long long ans[100005];

int valid(int l, int r, long long x) {
    if (l > r) return 1;
    if (l - 1 >= 0 && abs(x - a[l - 1]) <= abs(x - a[r])) return 0;
    if (r + 1 < n && abs(x - a[r + 1]) < abs(x - a[l])) return 2;
    return 1;
}

int main() {

    scanf("%d%d", &n, &q);

    for (int i = 0; i < n; i++) {
        scanf("%lld", &a[i]);
    }

    for (int i = 0; i < q; i++) {
        scanf("%lld", &qu[i].first);
        qu[i].second = i;
    }

    sort(qu, qu + q); 

    for (int i = 0; i < n; i++) {
        sum[i & 1][i] = a[i];
        if (i - 1 >= 0) {
            sum[0][i] += sum[0][i - 1];
            sum[1][i] += sum[1][i - 1];
        }
    }

    int p = q - 1;
    long long tot = 0;

    for (int i = n - 1; i >= 0; i--) {
        //A take last ith number
        tot += a[i];

        int l = 2 * i - n;
        int r = i - 1;
        if (l < -1) break;


        while (p >= 0) {
            long long x = qu[p].first;
            int id = qu[p].second;

            if (l == -1) {
                if (valid(l + 1, r, x) == 1) {
                    ans[id] = tot;
                }
                else break;
            }
            else {
                if (valid(l, r, x) == 1) {
                    ans[id] = tot;
                    long long add = 0;
                    if (l - 1 >= 0) add = sum[(l - 1) & 1][l - 1];
                    ans[id] += add;
                }
                else if (valid(l, r, x) == 2 && valid(l + 1, r, x) == 1) {
                    ans[id] = tot;
                    long long add = 0;
                    if (l - 1 >= 0) add = sum[(l - 1) & 1][l - 1];
                    ans[id] += add;
                }
                else break;
            }

            p--;
        }


    }

    for (int i = 0; i < q; i++) printf("%lld\n", ans[i]);
}


Measured memory_bytes: 6400
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define MAXN 2000
using namespace std;
vector<int> G[MAXN+5];
int N,K,tot=0;
void DFS(int u,int fa,int depn)
{
	if(depn>K)
		return;
	tot++;//可以计算深度小于等于K/2的，然后用总数来减，比较好想。
	for(int i=0;i<(int)G[u].size();i++)
	{
		int v=G[u][i];
		if(v==fa)
			continue;
		DFS(v,u,depn+1);
	}
}
int main()
{
	scanf("%d %d",&N,&K);
	int u,v,typ;
	for(int i=1;i<N;i++)
	{
		scanf("%d %d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	if(K%2==0)	typ=1;
	else		typ=0;
	int ans=N;
	K/=2;
	if(typ==1)//分情况讨论
	{
		for(int i=1;i<=N;i++)
		{
			tot=0;
			DFS(i,-1,0);//把一个点放在深度0.
			ans=min(ans,N-tot);
		}
	}
	else if(typ==0)
	{
		for(u=1;u<=N;u++)
			for(int j=0;j<(int)G[u].size();j++)
			{
				v=G[u][j];
				tot=0;
				DFS(v,u,0);//把一条边的两个点都放在深度0.
				DFS(u,v,0);
				ans=min(ans,N-tot);
			}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); }
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

struct mi {
  int val; static const int MOD = 1e9+7; static_assert(MOD > 0, "Modulus not set!");
  mi(int v=0) : val(v) { if ((val %= MOD) < 0) val += MOD; }
  mi& operator += (const mi& b) { (val += b.val) %= MOD; return *this; }
  mi& operator -= (const mi& b) { return (*this) += MOD-b.val; }
  mi& operator *= (const mi& b) { val = ((ll)val*(ll)b.val) % MOD; return *this; }
  mi& operator /= (const mi& b) { return (*this) *= b.pow(MOD-2); }
#define _op(op, op2) mi operator op (const mi& b) const { mi ans = *this; return ans op2 b; }
  _op(+, +=); _op(-, -=); _op(*, *=); _op(/, /=);
#undef _op
  mi pow(ll e) const { mi res(1), b(*this); for (; e>0; e/=2, b*=b) { if (e&1) res*=b; } return res; }
  int toInt() const { return val; }
};

const int N = 2e6+10;
mi f[N];

void pre() {
  f[0] = 1;
  for (int i = 1; i < N; ++i) {
    f[i] = f[i-1] * i;
  }
}

mi p(int r, int c) {
  return f[r+c-1] / (f[r] * f[c-1]);
}

int main() { // Emily <3
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  pre();
  int r[2], c[2];
  for (int i = 0; i < 2; ++i) {
    cin >> r[i] >> c[i];
  }
  mi ans = 0;
  for (int row = r[0]+1; row <= r[1]+1; ++row) {
    ans += p(row, c[1]+1) - p(row, c[0]);
  }
  cout << ans.toInt() << nl;

  return 0;
}



Measured memory_bytes: 11612
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * Alphametic
 */
public class Main {

	static int[][] nums;
	static boolean[] used;

	static int[][] pos = {
			{0, 2},
			{1, 1}, {1, 2},
			{2, 0}, {2, 1}, {2, 2},
			{3, 0}, {3, 1}, {3, 2},
	};

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		words = br.readLine().split(" ");

		nums = new int[4][3];
		used = new boolean[10];

		for (int i = 0; i < words.length; i++) {
			int n = parseInt(words[i]);
			if (n != -1) used[n] = true;
			nums[pos[i][0]][pos[i][1]] = n;
		}

		System.out.println(solve(0));
	}

	static int solve(int idx) {

		if (idx == pos.length) {
			if (check()) return 1;
			else return 0;
		}

		//
		int i = pos[idx][0];
		int j = pos[idx][1];
		
		int ret = 0;

		outer:
		if (nums[i][j] == -1) {
			for (int k = 1; k <= 9; k++) {
				if (!used[k]) {
					nums[i][j] = k;
					used[k] = true;
					ret += solve(idx + 1);
					nums[i][j] = -1;
					used[k] = false;
				}
			}
		} else {
			ret = solve(idx + 1);
		}

		return ret;
	}

	static boolean check() {

		int[] a = new int[4];

		for (int i = 0; i < 4; i++) {
			a[i] = nums[i][0] * 100 + nums[i][1] * 10 + nums[i][2];
		}

		return a[0] + a[1] + a[2] == a[3];
	}
}

Measured memory_bytes: 38088
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define all(v) v.begin(),v.end()
#define mem(v,x) memset(v,x,sizeof(v))
#define N 1000005

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
    int n;
    cin>>n;
    int a[n-1];
    ll ans[n+1]={0};
    for(int i=0;i<n-1;i++){
        cin>>a[i];
        ans[a[i]]++;
    }
    for(int i=1;i<=n;i++)
        cout<<ans[i]<<'\n';
	return 0;
}


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

int main() {
	while(true){
		int n,p,b=0;
		cin>>n>>p;
		if(n==0&&p==0) return 0;
		vector<int>h(n);
		b=p;
		while(true){
			for(int i=0;i<n;i++){
				if(b==0){
					b=h[i];
					h[i]=0;
				}
				else{
					b--;
					h[i]++;
					if(h[i]==p){
						cout<<i<<endl;
						goto e;
					}
				}
			}
		}
		e:;
	}
	return 0;
}


Measured memory_bytes: 3052
import sys

def main():
    N = int(input())
    A = list(map(int, input().split()))

    t = 0
    while True:
        for i in range(N):
            if A[i] % 2 == 0:
                A[i] = A[i]/2
            else:
                print(t)
                sys.exit()
        t += 1

main()

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

using namespace std;

int main(){
    int n;
    cin >> n;
    
    vector<int> x(n);
    for (int i = 0; i < n; i++) cin >> x[i];
    
    vector<int> y = x;
    sort(y.begin(),y.end());
    
    for (int i = 0; i < n; i++){
        if (x[i] < y[n/2]){
            cout << y[n/2] << endl;
        }
        else{
            cout << y[n/2 - 1] << endl;
        }
    }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
priority_queue <int> qua;
vector <int> vec;
char s[55];
int ans;

bool chk(char c) {
	if(c == 'A' || c == 'T' || c == 'C' || c == 'G') return 1;
	return 0;
}

int main() {
	scanf("%s", s + 1);
	int n = strlen(s + 1);
	int cnt = 0;
	s[n + 1] = 'Z';
	for(int i = 1; i <= n + 1; i++) {
		if(chk(s[i])) cnt++;
		else {
			ans = max(ans, cnt);
			cnt = 0;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 764
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

struct Trie {
  Trie *children[2];
  Trie() {
    fill(children, children+2, nullptr);
  }
  void add(const string &s) {
    Trie *cur = this;
    for (char ch : s) {
      int d = ch - '0';
      if (!cur->children[d]) {
        cur->children[d] = new Trie();
      }
      cur = cur->children[d];
    }
  }
};

long long dfs(Trie *r, int lv, long long L) {
  if (lv == L) {
    return 0;
  }
  if (!r->children[0] && !r->children[1]) {
    return 0;
  }
  long long Xor = 0;
  for (int d = 0; d < 2; d++) {
    if (r->children[d]) {
      Xor ^= dfs(r->children[d], lv + 1, L);
    } else {
      long long h = L - lv;
      int p = 0;
      while (h % 2 == 0) {
        p++;
        h /= 2;
      }
      Xor ^= (1LL << p);
    }
  }
  return Xor;
}

const int N = int(1e5);
char s[N+1];

int main(void) {
  int n; long long L;
  scanf("%i %lld", &n, &L);
  
  Trie *tree = new Trie();
  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    tree->add(string(s));
  }
  
  puts(dfs(tree, 0, L) ? "Alice" : "Bob");
  
  return 0;
}

Measured memory_bytes: 9856
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    ll K,S;
    cin>>K>>S;
    int cnt=0;
    rep(x,K+1){
        rep(y,K+1){
            ll z=S-x-y;
           //cout<<x<<" "<<y<<" "<<z<<"\n";
            if(z>=0 && z<=K) cnt++;
        }
    }
    cout<<cnt<<endl;
}

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



int Count(char *szBuf) {
	for (int x = 0; x < 99; x++)if (szBuf[x] == '\0')return x;
	return 99;
}
int main()
{
	int l;
	char szBuf[99] = { 0 };
	cin >> szBuf;
	l = Count(szBuf);
	for (int x = 0; x < (l / 2) + 1; x++) {
		if (szBuf[x] != szBuf[l - 1 - x]) {
			cout << "No" << endl;
			return 0;
		}
	}
	for (int x = 0; x < (l / 4) + 1; x++) {
		if (szBuf[x] != szBuf[l / 2 - 1 - x]) {
			cout << "No" << endl;
			return 0;
		}
	}
	for (int x = (l / 2); x < (l / 4) + 1; x++) {
		if (szBuf[x] != szBuf[l - 1 - x]) {
			cout << "No" << endl;
			return 0;
		}
	}cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int maxn = 1e5+5;
int a[maxn],b[maxn];
ll sum[maxn][55];

int main()
{
    int n, m;
    cin >> n >> m;
    int sum = 0;
    for (int i = 0; i < n; i ++){
       cin >> a[i];
       sum+=a[i];
    }
    sort(a, a+n);
    reverse(a, a+n);
    int res = 0;

    for (int i = 0;i <n; i ++)
    {
        if(a[i] * 4 * m >= sum) res++;
    }

    if(res >= m) cout << "Yes";
    else cout <<"No";
    return 0;
}


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

int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	int a, b;
	vector<bool>v1(n,false);
	vector<bool>vn(n,false);//あえて多くメモリを確保し、中継点の番号を一致させ、O(N)を実現
	for (int i = 0; i < m; ++i) {
		scanf("%d %d", &a, &b);
		if (a == 1)v1[b]=true;
		else if (b == n)vn[a]=true;
	}
	for (int i = 0; i < n; ++i) {
		if (v1[i]==true && vn[i]==true) {
				printf("POSSIBLE\n");
				return 0;
			}
	}
	printf("IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#ifndef LOCAL_PROJECT
#define cerr if(0)cerr
#endif
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef __int128 lll;
const lll ONE=1;
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
const int mn=2e6+10;
const ll inf=0x3f3f3f3f3f3f3f3f;
const ll mod=998244353;
struct nd{
    map<char,int>c,num;
    nd():c{},num{}{};
};
vector<nd>v(1);
int nnd(){
    v.push_back(nd());
    return v.size()-1;
}
void add(int x,string& s,int i){
    if(i==s.size()-1)v[x].num[s[i]]++;
    else{
        if(!v[x].c.count(s[i]))v[x].c[s[i]]=nnd();
        add(v[x].c[s[i]],s,i+1);
    }
}
int cs[26];
ll ans=0;
void go(int x,string&s,int i){
    if(i==s.size())return;
    for(auto p:v[x].num){
        if(cs[p.first-'a'])ans+=p.second;
    }
    cs[s[i]-'a']--;
    if(v[x].c.count(s[i]))go(v[x].c[s[i]],s,i+1);
}
int main(){
#ifdef LOCAL_PROJECT
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("error.txt","w",stderr);
#else
    cin.tie(0);
    cin.sync_with_stdio(0);
#endif
    vector<string>ss;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        reverse(s.begin(),s.end());
        ss.push_back(s);
    }
    sort(ss.begin(),ss.end(),[](auto a,auto b){return a.size()<b.size();});
    for(string&s:ss){
        memset(cs,0,sizeof(cs));
        for(char c:s)cs[c-'a']++;
        go(0,s,0);
        add(0,s,0);
    }
    printf("%lld",ans);
}





Measured memory_bytes: 144700
def main():
    n = int(input())
    P = [list(map(int, input().split())) for _ in range(n)]
    C0, C1 = [], []
    ans = 0

    for pi in P:
        C0.append(pi[0] - pi[1])
        C1.append(pi[0] + pi[1])

    C0min = min(C0)
    C0max = max(C0)
    C1min = min(C1)
    C1max = max(C1)

    print(max(C0max - C0min, C1max - C1min))


if __name__ == '__main__':
    main()


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

int main()
{
    int H, W;
    cin >> H >> W;
    vector<string> a(H);
    for (int i = 0; i < H; i++)
    {
        cin >> a.at(i);
    }

    for (int i = 0; i < W + 2; i++)
    {
        cout << "#";
    }
    cout << endl;

    for (int i = 0; i < H; i++)
    {
        cout << "#" << a[i] << "#" << endl;
    }

    for (int i = 0; i < W + 2; i++)
    {
        cout << "#";
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cfloat>
#include <stack>
#include <cstdlib>
using namespace std;

#define MAX_N 15

int n;
int idx[MAX_N], dst[MAX_N], num[MAX_N];
double dp[MAX_N][1 << MAX_N];
int prv[MAX_N][1 << MAX_N];
double spd[1 << MAX_N];


int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; ++i){
		scanf("%d%d%d", &idx[i], &dst[i], &num[i]);
	}

	int M = 1 << n;
	for(int S = 0; S < M; ++S){
		int c = 0;
		for(int i = 0; i < n; ++i){
			prv[i][S] = -1;
			dp[i][S] = DBL_MAX;

			if(S >> i & 1){
				c += num[i];
			}
		}
		spd[S] = (7 + 2 * c) / 200.0;
	}

	for(int i = 0; i < n; ++i){
		dp[i][1 << i] = 0.0;
	}

	for(int S = 1; S < M; ++S){
		for(int i = 0; i < n; ++i){
			if(!(S >> i & 1)){ continue; }
			for(int j = 0; j < n; ++j){
				if(S >> j & 1){ continue; }

				double tm = dp[i][S] + abs(dst[i] - dst[j]) * spd[S];
				int T = S | 1 << j;
				if(dp[j][T] > tm){
					dp[j][T] = tm;
					prv[j][T] = i;
				}
			}
		}
	}

	int x = 0;
	for(int i = 1; i < n; ++i){
		if(dp[x][M - 1] > dp[i][M - 1]){
			x = i;
		}
	}

	stack<int> st;
	int U = M - 1;
	while(x != -1){
		st.push(idx[x]);
		int y = prv[x][U];
		U ^= 1 << x;
		x = y;
	}

	printf("%d", st.top());
	st.pop();
	while(!st.empty()){
		printf(" %d", st.top());
		st.pop();
	}
	puts("");
}

Measured memory_bytes: 7056
import Control.Monad
import Data.List

-- [a,b) -> a .. f aがTrueとなる最大のa, f bはFalse
-- aとbは評価しないので、範囲が0..(n-1)のとき、(a,b)=(-1,n)で呼んで良い
bsearch f (a,b)
    | a+1 == b = a
    | f m  = bsearch f (m,b)
    | True = bsearch f (a,m)
    where m = (a + (b-a)`div`2)

f x a = a*(a+1) < x

main=do
    x<-readLn :: IO Int
    print $ (+) 1 $ bsearch (f (x*2)) (-1,x)


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
  string s,t;
  cin>>s>>t;
  int ans=0;
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i]) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3920
#include<iostream>
using namespace std;
   
int main(){
int W,H,x,y,r;
cin >> W >> H >>x>>y>>r;

     if ( x < r || x + r > W  || y < r || y + r > H )    cout << "No" << endl;
else if ( x >= r && x + r <= W && y >= r && y + r <= H ) cout << "Yes" << endl;
   
return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include <cstring>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
const int nmax = 3010;
ll dp[nmax][nmax];
bool visited[nmax][nmax];
int n;
ll ary[nmax];

ll rec(int x, int y)
{
    // [x,y)におけるX-Yを求める
    if (visited[x][y]) return dp[x][y];
    if (y-x==1)
    {
        visited[x][y] = true;
        return dp[x][y] = ary[x];
    }

    visited[x][y] = true;
    return dp[x][y] = max(ary[x]-rec(x+1,y), ary[y-1]-rec(x, y-1));
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n;
    rep(i,n) cin >> ary[i];
    rep(i,nmax) rep(j,nmax) visited[i][j] = false;

    cout << rec(0, n) << endl;
}


Measured memory_bytes: 78592
#include <bits/stdc++.h>
using namespace std;
int main() {
	char c;
	cin >> c;
	if (c >= 'A' && c <= 'Z') {
		cout << "A" << endl;
	}
	else if (c >= 'a' && c <= 'z') {
		cout << "a" << endl;
	}
	return 0;
}

Measured memory_bytes: 3580
#include <cstdio>
#include <climits>
#include <algorithm>

const int MAXN = 405;

long long a[MAXN], f[MAXN][MAXN];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
    for (int i = 1; i < n; i++) a[i] += a[i - 1];

    for (int len = 2; len <= n; len++) for (int l = 0; l + len - 1 < n; l++) {
        int r = l + len - 1;
        f[l][r] = LLONG_MAX;
        for (int k = l; k < r; k++) f[l][r] = std::min(f[l][r], f[l][k] + f[k + 1][r]);
        f[l][r] += a[r] - (l ? a[l - 1] : 0);
    }

    printf("%lld\n", f[0][n - 1]);
    
    return 0;
}

Measured memory_bytes: 1408
n, k, q = map(int, input().split())
a = [int(input()) for i in range(q)]

points = [k - q] * n

for answerer in a:
    points[answerer - 1] += 1

for i in range(n):
    if points[i] <= 0:
        points[i] = 'No'
    else:
        points[i] = 'Yes'

print('\n'.join(points))


Measured memory_bytes: 9772
#include <bits/stdc++.h>   
using namespace std;   
typedef long long ll;
int main()  
{   
    cin.tie(0); ios::sync_with_stdio(false);  
	//freopen("input.txt", "rt", stdin);
	int a, b, c; cin >> a >> b >> c;
	if (a == b)
		cout << c <<"\n";
	else if (a == c)
		cout << b << "\n";
	else if (b == c)
		cout << a << "\n";
	
	

	return 0;   
}  

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
int x[100010];
int main()
{
    int n, a, b;
    scanf("%d %d %d",&n,&a,&b);
    for(int i=1;i<=n;i++)
        scanf("%d",&x[i]);
    long long ans = 0;
    for(int i=2;i<=n;i++)
        ans += min((long long)b, (long long)a*(x[i]-x[i-1]));
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 640