akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <tuple>
#include <queue>
#include <deque>
using namespace std;
using ll=long long;
#define INF 2100000000

int main(){
  int N;
  cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());

  int n=a.at(N-1);
  if(a.at(0)==n){
    if(n==N-1||n<=N/2){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }else if(a.at(0)+1!=n){
    cout<<"No"<<endl;
  }else{
    int count=lower_bound(a.begin(),a.end(),n)-a.begin();
    if(n<=count){
      cout<<"No"<<endl;
    }else if(2*(n-count)<=N-count){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }
}


Measured memory_bytes: 640
/*input
8 5 22
100 3 7 5 3 1
164 4 5 2 7 8
334 7 2 7 2 9
234 4 7 2 8 2
541 5 4 3 3 6
235 4 8 6 9 7
394 3 6 1 6 2
872 8 4 3 7 2
*/
#include <bits/stdc++.h>
using namespace std; 
#define int long long int
#define max(x, y) ((x) > (y) ? (x) :(y))
#define pii pair< int , int> 
#define vi vector<int>
#define fore( i ,st) for ( int i= 0 ; i < (int)(st) ; i ++)
#define REP( i , st , en ) for ( int i =st; i < (int)en; i++)
#define REPD( i , en , st ) for ( int i =en; i >= (int)st; i--)
#define SZ(a) (int)a.size()
#define all(v) v.begin() , v.end()
#define pb push_back
#define F first
#define S second
#define bitch_i_m_on_fiyaah_yeahhhh ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// const int mod = 998244353;
const int mod = 1e9+7;
ostream& operator << ( ostream&  o, vector<int> s){for ( int i = 0;  i < (int)s.size() ; i++)o << s[i] << " ";o << "\n";return o;}
void  add( int &a, int b){a = a + b;if ( a< 0 ) a += mod; if ( a> mod ) a-= mod;}
void sub( int &a, int b){a = a - b;if ( a < 0) a += mod;}
int mul( int a , int b){return ((a %mod) * (b %mod) ) %mod;}
int exp( int a , int pow){ return (pow == 0 ? 1 : ( pow & 1  ? mul ( a ,exp( mul(a, a) , pow /2) ) : exp(mul(a ,a) , pow/2)));}
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
// const int inf = 1e18;

const int maxn = 2e5 + 5;
int n;
int cost[20];
vector<int> know[20];

void solve(int test ) 
{	
	int n , m , x ; 
	cin >> n  >> m >> x ;
	fore( i , n ){
		cin >> cost[i];
		fore( j , m) {
			int x ; cin >> x;
			know[i].push_back(x);
		}
	}
	int mn =INT_MAX;
	fore ( i ,  (1 << n )){
		int curr = 0; 
		vector<int> k(m);
		fore ( j , n ){
			if ( i & ( 1 << j )){
				curr += cost[j];
				fore(l ,m){
					k[l] += know[j][l];
				}
			}
		}
		bool ok =true;
		fore( l , m){
			if ( k[l] < x) {
				ok = false;
				break;
			};
		}
		if (ok) mn = min( mn , curr);
		

	} 
	cout << ( mn == INT_MAX ? -1 : mn);
	
	


}
signed main(){
	// bitch_i_m_on_fiyaah_yeahhhh
	int t =1; 
	// cin >> t;
	for ( int i = 0 ; i < t; i++)
	solve(i+1);
}

Measured memory_bytes: 3644
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long x = sc.nextLong();
    long[] a = new long[n];
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextLong();
    }
    long ans = 0;
    for(int i = 0; i < n - 1; i++) {
      if(a[i] >= x) {
        ans += (a[i] + a[i + 1] - x);
        a[i + 1] = 0;
        a[i] = x;
      } else {
        ans += Math.max(0, (a[i] + a[i + 1] - x));
        a[i + 1] -= Math.max(0, (a[i] + a[i + 1] - x));
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 50856
//https://atcoder.jp/contests/dp/tasks/dp_c
#include<bits/stdc++.h>
using namespace std;
int dp[100001][3];
int n;
int main()
{
    cin>>n;
    int arr[n][3];
    for(int i=0;i<n;i++)
        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    dp[0][0]=arr[0][0],dp[0][1]=arr[0][1],dp[0][2]=arr[0][2];
    for(int i=1;i<n;i++)
    {
        dp[i][0]=arr[i][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=arr[i][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=arr[i][2]+max(dp[i-1][1],dp[i-1][0]);
    }
    cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<'\n';
}


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

const int mod = 998244353;
struct mint {
    long long x;
    mint(long long x = 0) : x ((x%mod + mod)%mod) { }
    mint operator- () const { return mint(-x); }
    mint& operator+= (const mint a) {
        if (mod <= (x += a.x)) {
            x -= mod;
        }
        return *this;
    }
    mint& operator-= (const mint a) {
        if (mod <= (x += mod - a.x)) {
            x -= mod;
        }
        return *this;
    }
    mint& operator*= (const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+ (const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator- (const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator* (const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(long long t) const {
        if (!t) {
            return 1;
        }
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) {
            a *= *this;
        }
        return a;
    }
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/= (const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/ (const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

vector<int> to[200005];

mint dfs(int v) {
    mint res = 1;
    for (int u : to[v]) {
        res *= dfs(u);
    }
    return res + 1;
}

int main() {
    int n; cin >> n;
    vector<pair<int, int>> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i].first >> p[i].second;
    }
    sort(p.begin(), p.end());
    set<pair<int, int>> s;
    for (int i = n-1; 0 <= i; i--) {
        int x = p[i].first, d = p[i].second;
        while (s.size() && s.begin()->first < x+d) {
            to[i].push_back(s.begin()->second);
            s.erase(s.begin());
        }
        s.emplace(x, i);
    }

    mint ans = 1;
    for (auto x : s) {
        int v = x.second;
        ans *= dfs(v);
    }
    cout << ans.x << endl;
    return 0;
}

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

int main(){
    string S;
    int Q;
    int i;
    int T;
    int F;
    int count = 0;
    char C;
    cin >> S;
    cin >> Q;
    for(int i=0;i<Q;i++){
        cin >> T;
        if(T==1)count++;
        if(T==2){
            cin >> F >> C;
            if((F==1 && count%2==0) || (F==2 && count%2==1))S.insert(S.begin(),C);
            if((F==2 && count%2==0) || (F==1 && count%2==1))S.insert(S.end(),C);
            }
        }
    if(count%2==1)reverse(S.begin(),S.end());
    cout << S << endl;
    }

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

int main()
{
	string s;
	cin >> s;
	rep(i,3){
		if(s[i] == '7'){
			puts("Yes");
			return 0;
		}
	}
	puts("No");
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define len(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "YES" << endl
#define pyes cout << "Yes" << endl
#define POK cout << "OK" << endl
#define PNO cout << "NO" << endl
#define pno cout << "No" << endl
#define PNG cout << "NG" << endl
#define ret return 0

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  string s; cin >> s;
  int month = ctoi(s[5])*10+ctoi(s[6]);
  int day = ctoi(s[8])*10+ctoi(s[9]);
  if(month<=4) cout << "Heisei" << endl;
  else cout << "TBD" << endl;
  ret;
}


Measured memory_bytes: 3628
#include<stdio.h>
int main(){
  int a;
  int b;
  scanf("%d%d",&a,&b);
  if (a < b) {
    printf("a < b\n");
  } else if (a > b) {
    printf("a > b\n");
  } else if (a == b) {
    printf("a == b\n");
  }
  return 0;
}

Measured memory_bytes: 580
#define _CRT_SECURE_NO_WARNINGS

#define N (1<<6)
#define MODULO (1000000007)

#include <cstdio>
#include <iostream>
#include <fstream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <deque>
#include <vector>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
using namespace std;

int n, p;
int t1, t2;
long long Ans;

inline long long ToChoose(int xx, int yy)
{
	int cur1 = xx, cur2 = 1, cur3 = 1;
	long long Res = 1LL;
	while (cur1 >= 2 || cur2 <= yy || cur3 <= (xx - yy))
	{
		while (cur2 <= yy&&Res % (long long)cur2 == 0)
		{
			Res /= (long long)cur2;
			cur2++;
		}
		while (cur3 <= (xx - yy) && Res % (long long)cur3 == 0)
		{
			Res /= (long long)cur3;
			cur3++;
		}
		Res *= cur1;
		cur1--;
	}
	return Res;
}

int main()
{
	scanf("%d%d", &n, &p);
	//printf("%lld\n", ToChoose(5, 2));
	//printf("%lld\n", ToChoose(5, 3));
	for (int i = 0;i < n;i++)
	{
		int tmp;
		scanf("%d", &tmp);
		if (tmp & 1)
		{
			t2++;
		}
		else
		{
			t1++;
		}
	}
	Ans = 1LL;
	while (t1--)
	{
		Ans *= 2LL;
	}
	if (p)
	{
		if (!t2)
		{
			printf("0\n");
		}
		else
		{
			long long Tmp = 0LL;
			for (int i = 1;i <= t2;i += 2)
			{
				Tmp += ToChoose(t2, i);
			}
			Ans *= Tmp;
			printf("%lld\n", Ans);
		}
	}
	else
	{
		long long Tmp = 1LL;
		for (int i = 2;i <= t2;i += 2)
		{
			Tmp += ToChoose(t2, i);
		}
		Ans *= Tmp;
		printf("%lld\n", Ans);
	}
	//system("pause");
	return 0;
}



Measured memory_bytes: 256
import sys

mod = 10 ** 9 + 7
n, m, *a = [int(x) for x in sys.stdin.read().split()]

safe = sorted(set(range(1,n+1)) - set(a))
dp = [0] * (n + 2)
dp[0] = 0
dp[1] = 1
for i in safe:
    dp[i+1] = (dp[i] + dp[i-1]) % mod

print(dp[-1])

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int main() {
	vector<int> p;
	incII(i, 2, 100) {
		int c = 0;
		inc1(j, i) { if(i % j == 0) { c++; } }
		if(c == 2) { p.PB(i); }
	}
	int s = p.size();
	vector<int> b(s);
	
	int n;
	cin >> n;
	
	incII(i, 2, n) {
		int k = i;
		inc(j, s) {
			while(k % p[j] == 0) { k /= p[j]; b[j]++; }
		}
		assert(k == 1);
	}
	
	// inc(j, s) { cout << b[j] << " "; } cout << endl;
	
	inc(i, s) { b[i]++; }
	
	int ans = 0;
	inc(i, s) {
	inc(j, s) { if(j == i) { continue; }
	inc(k, s) { if(k == i || k == j) { continue; }
		if(k < j) { continue; }
		if(b[i] >= 3 && b[j] >= 5 && b[k] >= 5) { ans++; }
	}
	}
	}
	inc(i, s) {
	inc(j, s) {
		if(i == j) { continue; }
		if(b[i] >= 3 && b[j] >= 25) { ans++; }
		if(b[i] >= 5 && b[j] >= 15) { ans++; }
	}
	}
	inc(i, s) { if(b[i] >= 75) { ans++; } }
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,i,j;
  scanf("%d",&n);
  long long c,max=0,cal[2*n+2][2];
  scanf("%lld",&c);
  cal[n][0]=0;
  cal[n][1]=0;
  for(i=0;i<n;i++){
    scanf("%lld%lld",&cal[i+n+1][0],&cal[i+n+1][1]);
    cal[i][0]=c-cal[i+n+1][0];
    cal[i][1]=cal[i+n+1][1];
  }
  long long cal1[2*n+1],cal2[2*n+1];
  cal1[n]=0;
  cal2[n]=0;
  for(i=n+1;i<=2*n;i++)
    cal[i][1]+=cal[i-1][1];
  for(i=n-1;i>=0;i--)
    cal[i][1]+=cal[i+1][1];
  for(i=n+1;i<=2*n;i++){
    cal1[i]=cal[i][1]-cal[i][0];
    if(cal1[i]<cal1[i-1])
      cal1[i]=cal1[i-1];
    cal2[i]=cal[i][1]-2*cal[i][0];
    if(cal2[i]<cal2[i-1])
      cal2[i]=cal2[i-1];
  }
  for(i=n-1;i>=0;i--){
    cal1[i]=cal[i][1]-2*cal[i][0];
    if(cal1[i]<cal1[i+1])
      cal1[i]=cal1[i+1];
    cal2[i]=cal[i][1]-cal[i][0];
    if(cal2[i]<cal2[i+1])
      cal2[i]=cal2[i+1];
  }
  for(i=0;i<=n;i++){
    c=cal1[i]+cal1[n+i];
    if(max<c)
      max=c;
    c=cal2[i]+cal2[n+i];
    if(max<c)
      max=c;
  }
  printf("%lld\n",max);
  return 0;
}


Measured memory_bytes: 6400
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;

int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    vector<int> coin(m);
    for(auto&e:coin){
        scanf("%d",&e);
    }
    vector<int> dp_coin(n+1);
    fill(dp_coin.begin(), dp_coin.end(), n);
    dp_coin[n]=0;
    for(int i=n;i>0;i--){
        for(int j=0;j<m;j++){
            if(i>=coin[j]){
                dp_coin[i-coin[j]]=min(dp_coin[i]+1,dp_coin[i-coin[j]]);
            }
        }
    }
    printf("%d\n",dp_coin[0]);
    return 0;
}

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

int main() {
  
  long long N, A, B, C, D, E;
  cin >> N >> A >> B >> C >> D >> E;
  
  long long minn= min({A, B, C, D, E});
  long long num_group=0;
  if(minn==1){ num_group=N/minn; }
  else{ num_group=N/minn+1; }
  
  cout << num_group+4 << endl;
  
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	char a[3][3];
	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)
			cin>>a[i][j];
	cout<<a[0][0]<<a[1][1]<<a[2][2];
	return 0;
}


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

using namespace std;

#define Vi vector<int>
#define FOR(i,s,e) for (int i=s; i<e; i++)
#define ITER(v) v.begin(), v.end()

constexpr int N_MAX = 100;

int weight[N_MAX][N_MAX];
int dis[N_MAX];

void set_shortest_distance(const int n) {
    bool ismember[n] = {false};

    int newmember = 0;
    dis[newmember] = 0;
    ismember[newmember] = true;

    FOR(t,0,n-1) {
        FOR(i,0,n) {
            if (weight[newmember][i] < 0) { continue; }
            if (ismember[i]) { continue; }
            const int d = dis[newmember] + weight[newmember][i];
            if (dis[i] < 0 || d < dis[i]) {
                dis[i] = d;
            }
        }
        int min_i = -1, min_d = -1;
        FOR(i,0,n) {
            if (dis[i] < 0) { continue; }
            if (ismember[i]) { continue; }
            if (min_d < 0 || dis[i] < min_d) {
                min_i = i;
                min_d = dis[i];
            }
        }
        newmember = min_i;
        ismember[newmember] = true;
        //cout << "#" << min_i << " " << min_d << endl;
    }
}

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

    int n;
    cin >> n;

    FOR(i,0,n) {
        dis[i] = -1;
        FOR(j,0,n) {
            weight[i][j] = -1;
        }
    }

    int u, k, v, c;
    FOR(i,0,n) {
        cin >> u >> k;
        FOR(j,0,k) {
            cin >> v >> c;
            weight[u][v] = c;
        }
    }

    set_shortest_distance(n);

    for (int i = 0; i < n; ++i) {
        cout << i << " " << dis[i] << endl;
    }

    return 0;
}

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

#define sf scanf
#define pf printf
#define endl "\n"
#define off ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fr freopen("in.txt", "r", stdin)
#define fw freopen("out.txt", "w", stdout)
#define pb push_back
#define eb emplace_back
#define PII pair<int, int>
#define watch(x) cout<<(#x)<<" is "<<(x)<<endl
#define pass printf("Passed Here\n")

typedef long long ll;
typedef unsigned int ui;
int mod = 1000000007;

int main()
{
    int a, b;
    cin>>a>>b;
    if(abs(a-b)<=2) cout<<"Yay!"<<endl;
    else cout<<":("<<endl;   
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <math.h>
#include <algorithm>
using namespace std;

long long s[1000000], t[1000000];

int T(int x, long long s[], int l, int d)
{
    int sr=0;
    while( l <= d)
    {
        sr= (l+d)/2;
        if(s[sr]==x)
            return x;
        else
            if(s[sr]<x)
                l=sr+1;
            else
                d=sr-1;
    }
    return -1;

}

int main()
{
    int n, q, m=0, x=0;

    scanf("%d\n", &n);
    for(int i=1; i<=n; i++)
            scanf("%lld\n", &s[i]);

    scanf("%d\n", &q);
    for(int j=1; j<=q; j++)
        scanf("%lld", &t[j]);

    for(int i=1; i<=q; i++)
    {
        x=T(t[i], s, 1, n);
        if(x!=-1)
            m++;
    }

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




    return 0;
}

Measured memory_bytes: 3736
N = int(input())
l = []
for i in range(0, N):
  S, P = input().split(" ")
  l.append((S, int(P), i + 1))

l.sort(key=lambda x:-x[1])
l.sort(key=lambda x:x[0])

for i in range(0, N):
  print(l[i][2])


Measured memory_bytes: 3060
N, M = map(int,input().split())
PNs = [list(map(int,input().split())) for _ in range(N)]
#price_and_number_of_drinks

PNs.sort(key=lambda x: x[0])

ans = 0
sum_drinks = 0 #sum of drinks which Takahashi has bought
for i in range(N):
    drinks_at_shop = PNs[i][1] #number of drinks at i_th shop
    ans += drinks_at_shop*PNs[i][0]
    sum_drinks += drinks_at_shop
    
    over = sum_drinks-M
    if over>=0:
        ans -= (over)*PNs[i][0]
        break

print(ans)

Measured memory_bytes: 29028
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=j; i<=k; i++)
#define FFOR(i, j, k) for(int i=j; i<k; i++)
#define DFOR(i, j, k) for(int i=j; i>=k; i--)
#define bug(x) cerr<<#x<<" = "<<x<<'\n'
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "A"
int n;
int main(){
    #ifdef Megumin
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Megumin
    cin>>n;
    cout<<((n%10==n/100)?"Yes":"No");
    return 0;
}

Measured memory_bytes: 764
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []
    M = 256
    sq = [i**2 for i in range(M)]
    nkss = [[sq[abs(x-nk)] for nk in range(M)] for x in range(M)]
    ML = list(range(M))

    def f(m, n):
        cs = [I() for _ in range(m)]
        xs = [I() for _ in range(n)]
        ml = list(range(m))
        d = [inf] * M
        nd = [inf] * M
        d[128] = 0
        ckl = list(map(lambda x: (max(min(x[0]+x[1], 255), 0), x[1]), (itertools.product(cs, ML))))
        for i in range(n):
            nd = [inf] * M
            for nk,k in ckl:
                if nd[nk] > d[k]:
                    nd[nk] = d[k]
            d = [nn + kk for nn,kk in zip(nd, nkss[xs[i]])]
        return min(d)

    while True:
        n,m = LI()
        if m == 0 and n == 0:
            break
        rr.append(f(m,n))

    return '\n'.join(map(str,rr))




print(main())



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

#define MP make_pair
#define PB push_back
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define PB push_back

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVi;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;

int main(){
	ios::sync_with_stdio(false);
    int n,l;
    cin>>n>>l;
    VS v(n);
    rep(i,n){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    rep(i,n){
        cout<<v[i];
    }
    cout<<endl;
    
    return 0;
}


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

#define PB push_back
#define F first
#define S second
#define MP make_pair
#define LL long long
#define ULL unsigned long long
#define LB lower_bound
#define MOD1 1000000007
#define MOD2 1000000009
int n;
vector<int> ht;
vector<int> dp;
int solve(int pos)
{
    if (pos < 0)
    {
        return 0;
    }

    if (dp[pos] != -1)
    {
        return dp[pos];
    }

    int op1 = solve(pos - 1) + abs(ht[pos] - ht[pos - 1]);
    int op2 = solve(pos - 2) + abs(ht[pos] - ht[pos - 2]);

    return dp[pos] = min(op1, op2);
}
int main()
{
    static const int _ = []() {
        ios::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        return 0;
    }();

    cin >> n;
    ht.resize(n + 1);
    dp.resize(n + 1);
    fill(dp.begin(), dp.end(), -1);
    dp[0] = 0;
    dp[1] = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> ht[i];
    }
    dp[2] = abs(ht[2] - ht[1]);

    cout << solve(n);

    return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define F first
#define S second
#define pss pair<string,string>
#define pcc pair<char,char>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define vs vector<string>
#define vl vector<ll>
#define vs vector<string>
#define vll vector<pll>
#define vss vector<pss>
#define vcc vector<pcc>
#define MP make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=n-1;i>=0;i--)
#define Very_fast std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int N = 1e5+5;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
inline ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll lowbit(ll x){return (x&-x);}
inline ll kissme(ll x,ll y)
{
	ll res=1;
	if(x==0)return 1;
	if(x==1)return y;
	res=kissme(x/2,y);
	res=res*res%mod;
	if(x%2==1)res=res*y%mod;
	return res;
}
double a,b,h,m;
signed main()
{
	Very_fast;
	cin>>a>>b>>h>>m;
	m=m+60*h;
	double degree=(m*6-m*0.5);
	while(degree>=360)degree-=360;
	degree=min(degree,360.0-degree);
	double ans=sqrt(a*a+b*b-2*a*b*cos(degree*3.1415926535897932384624633/180.0));
	printf("%.10f",ans);
	return 0;
}

Measured memory_bytes: 4156
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    ll n;cin>>n;
    map<ll,ll> mp;
    for(int x=1;x<200;x++){
        for(int y=1;y<200;y++){
            for(int z=1;z<200;z++){
                ll buf=x*x+y*y+z*z+x*y+y*z+z*x;
                mp[buf]++;
            }
        }
    }
    for(int i=1;i<=n;i++){
        cout<<mp[i]<<endl;
    }
}

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

using namespace std;

typedef long long ll;
const ll inf=1e12;


ll a[4],n,f[20];
int main(){
    for(int i=0;i<4;i++) cin>>a[i];
    cin>>n;
    n<<=2;
//    cout<<n<<'\n';
    fill(f+1,f+17,inf);
    for(int i=1;i<=16;i++)
        for(int j=0;j<4;j++) if (i>=(1<<j))
            f[i]=min(f[i],f[i-(1<<j)]+a[j]);
    cout<<(n/16)*f[16]+f[n%16];
}


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

class Main {

    public static void main(String[] args) {

	Scanner stdin = new Scanner(System.in);
	while ( stdin.hasNextLine() ) {
	    char[][] map = new char[12][];
	    for ( int i = 0; i < 12; i++ ) {
		map[i] = stdin.nextLine().toCharArray();
	    }

	    boolean[][] visited = new boolean[12][12];

	    int count = 0;
	    for ( int i = 0; i < 12; i++ ) {
		for ( int j = 0; j < 12; j++ ) {
		    if ( !visited[i][j] && map[i][j] == '1' ) {
			dfs( visited, i, j, map );
			count++;
		    }
		}
	    }
	    System.out.println( count );
	    if ( stdin.hasNextLine() ){
		stdin.nextLine();
	    }
	}
    }

    static int[] dx = { 1, 0, -1, 0 };
    static int[] dy = { 0, -1, 0, 1 };
	
    static void dfs( boolean[][] visited, int y, int x, char[][] map ) {
	visited[y][x] = true;
	for ( int i = 0; i < 4; i++ ) {
	    final int nx = x + dx[i];
	    final int ny = y + dy[i];

	    if ( 0 <= nx && nx < 12 && 0 <= ny && ny < 12 &&
		 !visited[ny][nx] && map[ny][nx] == '1') {

		dfs( visited, ny, nx, map );
	    }
	}	
    }
    
}

Measured memory_bytes: 17364
import bisect

n = int(input())
a = list(map(int, input().split()))
a.sort()
k = len(a)
ok = [0] * k
for i in range(k):
    if i < k - 1 and a[i] == a[i + 1]:
        ok[i] = 1
        ok[i + 1] = 1
        continue
    if a[i] < 2 * 100:
        for j in range(i + 1, k):
            if a[j] % a[i] == 0:
                ok[j] = 1
    else:
        times = 2
        while a[i] * times < a[-1]:
            l = bisect.bisect_left(a, a[i] * times)
            r = bisect.bisect_right(a, a[i] * times)
            if r != l:
                for idx in range(l, r):
                    ok[idx] = 1
            times += 1
# print(ok)
print(len([i for i in ok if i == 0]))
# print(ok) WAはどこ？


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

#define ll long long
#define pb push_back

const int maxn = 1e5 + 20;

string s;

int mkay()
{
	int n = s.size();

	s[n - 1]++;
	for(int j = n - 1; j >= 0; j--)
	{
		if(s[j] <= '9')
			return j;

		s[j - 1]++;
		s[j] = '0';
	}
}

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

	cin >> s;

	int n = s.size() , res = 0;
	for(int i = 0; i < n; i++)
	{
		res++;
		int n = s.size();
		int last = i , j = i + 1;

		while(j < n && s[j] >= s[j - 1])
		{
			if(s[j] > s[j - 1])
				last = j;
			j++;
		}

		if(j == n)
			break;

		while(i < last + 1)
			s[i] = '0' , i++;
		i--;

		if(mkay() <= j)
			continue;

		i++;
		while(i < j)
		{
			s[i] = '0';
			res++;
			i++;

			if(mkay() <= j)
				break;
		}
		i--;

	}

	cout << res << endl;
}










Measured memory_bytes: 1172
#include<bits/stdc++.h>
#define int         int long long
#define pb          push_back
#define pii         pair<int,int>
#define vi	        vector<int>
#define mii        map<int,int>
#define fs           first
#define sc          second
#define  M        1000000007
#define fr for(int i=0;i<n;i++)
#define f(i,a,b) for(int i=a;i<b;i++)
#define fm(i,a,b) for(int i=a;i>b;i--)
    
using namespace std;

signed main()
{	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int test=1;
    //cin>>test;
    while(test--){
        int n;
        cin>>n;
        if(n%2) cout<<n/2+1;
        else cout<<n/2;
    }
    return 0;
}       

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,x,s,ss,i;
	
	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<9;i++){
			scanf("%d",&x);
			n-=x;
		}
		printf("%d\n",n);
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 1028
# code-festival-2017-qualaB - fLIP
def main():
    N, M, K = tuple(map(int, input().split()))
    cand = {i * (M - j) + j * (N - i) for i in range(N + 1) for j in range(M + 1)}
    flg = K in cand
    print("Yes" if flg else "No")


if __name__ == "__main__":
    main()

Measured memory_bytes: 20900
import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional, std.meta;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    int n, m;
    readf("%s %s", &n, &m);
    readln;
    
    writeln(n == m ? "Yes" : "No");
    return;
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  ll flag; cin >> flag;
  if(flag == 1)
  {
    puts("Hello World");
  }
  else
  {
    ll a, b; cin >> a >> b;
    fin(a+b)
  }
  
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);

	int[] north = { 2, 6, 3, 4, 1, 5 };

	int[] east = { 4, 2, 1, 6, 5, 3 };

	int[] west = { 3, 2, 6, 1, 5, 4 };

	int[] south = { 5, 1, 3, 4, 6, 2 };

	int[] right = { 1, 3, 5, 2, 4, 6 };

	int[] left = { 1, 4, 2, 5, 3, 6 };



	int[] rotate(int[] before, int[] direction) {

		int[] after = new int[6];

		for (int i = 0; i < 6; i++) {

			after[i] = before[direction[i]];

		}

		return after;

	}



	void run() {

		HashMap<String, int[]> map = new HashMap<String, int[]>();

		map.put("North", north);

		map.put("West", west);

		map.put("South", south);

		map.put("East", east);

		map.put("Right", right);

		map.put("Left", left);

		for (int[] d : map.values()) {

			for (int i = 0; i < d.length; i++) {

				d[i]--;

			}

		}

		for(;;){

			int  n = sc.nextInt();

			if(n==0){

				break;

			}

			int[] dice = {1,2,3,4,5,6};

			int sum = 0;

			for(int i = 0; i < n;i++){

				dice = rotate(dice,map.get(sc.next()));

				sum += dice[0];

			}

			System.out.println(sum+1);

		}

	}



	public static void main(String[] args) {

		Main m = new Main();

		m.run();

	}

}

Measured memory_bytes: 12000
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var w = Console.ReadLine();
            var result = 0;
            switch (w)
            {
                case "SUN":
                    result = 7;
                    break;
                case "MON":
                    result = 6;
                    break;
                case "TUE":
                    result = 5;
                    break;
                case "WED":
                    result = 4;
                    break;
                case "THU":
                    result = 3;
                    break;
                case "FRI":
                    result = 2;
                    break;
                case "SAT":
                    result = 1;
                    break;
            }

            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 25792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1001001001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    int n;
    cin >> n;
    if (n >= 30)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
};

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    ll N, T; cin >> N >> T;
    ll A[N]; rep(i, N) cin >> A[i];
    ll minv[N + 1], maxv[N + 1];
    minv[0] = INF, maxv[N] = 0;
    rep(i, N) {
        minv[i + 1] = min(minv[i], A[i]);
        maxv[N - 1 - i] = max(maxv[N - i], A[N - 1 - i]);
    }
    ll ans = 0;
    rep(i, N) {
        ans = max(maxv[i] - minv[i], ans);
    }

    ll cnt = 0;
    bool flg = false;
    rep(i, N) {
        if(flg && ans == maxv[i] - minv[i]) continue;
        flg = false;
        if(ans == maxv[i] - minv[i])
            ++cnt, flg = true;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 2560
A,B,C,D=map(int,input().split())

x=100
y=100
while (x or y >= 0):
	x=C-B
	if (x<=0):
		print("Yes")
		break
	else:
		C=x
	y=A-D
	if (y<=0):
		print("No")
		break
	else:
		A=y

Measured memory_bytes: 9184
#include <cstdio>

using namespace std;

int main(void){
	int i, j, k, l, ans, n;
	while(scanf("%d",&n) != EOF){
		ans = 0;
		for(i = 0;i < 10;i++){
			for(j = 0;j < 10;j++){
				for(k = 0;k < 10;k++){
					for(l = 0;l < 10;l++){
						if(i + j + k + l == n){
							ans++;
						}
					}
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1024
r,c = map(int,input().split())
data = []
for i in range(r):
	data.append(list(map(int,input().split())))
for k in range(r):
	su = sum(data[k])
	an = data[k].copy()
	an = list(map(str,an))
	print(" ".join(an),su)
las = []
for kk in range(c):
	ans = 0
	for s in range(r):
		ans += data[s][kk]
	las.append(ans)
total = sum(las)
last = list(map(str,las))
print(" ".join(last),total)


Measured memory_bytes: 5692
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int A, B;
    cin >> A >> B;
    if (A >= 13)
    {
        cout << B << endl;
    }
    else if (A >= 6)
    {
        cout << B / 2 << endl;
    }
    else
    {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Text;
using static Scanner;

class Program
{
    static void Main(string[] args) {
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Solve();
        Console.Out.Flush();
    }
    static void Solve() {
        _ = Scan();
        var c = Scan();
        var red = c.Length - c.Replace("R", "").Length;
        var answer = 0;
        for (int i = 0; i < red; i++) {
            if (c[i] == 'W') answer++;
        }
        Console.WriteLine(answer);
    }
}

public static class Scanner
{
    static readonly Stream stream = Console.OpenStandardInput();
    static readonly byte[] buffer = new byte[1024];
    static int length, p;
    static bool isEof;
    private static byte ConsoleIn() {
        if (isEof) return 0;
        if (p < length) return buffer[p++];
        p = 0;
        if ((length = stream.Read(buffer, 0, 1024)) > 0) return buffer[p++];
        isEof = true;
        return 0;
    }
    public static char GetChar() {
        var by = ConsoleIn();
        while ((by < '!' || '~' < by) && !isEof) by = ConsoleIn();
        return (char) by;
    }
    public static string Scan() {
        var sb = new StringBuilder();
        for (var ch = GetChar(); '!' <= ch && ch <= '~'; ch = (char) ConsoleIn()) {
            sb.Append(ch);
        }
        return sb.ToString();
    }
}

Measured memory_bytes: 26568
#include<stdio.h>
 
int main(){ 
    int Num, zikan, hun, byou;
     
    scanf("%d", &Num);
     
    zikan = Num   / 3600;
    Num  -= zikan * 3600;
    hun   = Num / 60;
    Num  -= hun * 60;
    byou  = Num;
     
    printf("%d:%d:%d\n", zikan, hun, byou);
    return 0;
}

Measured memory_bytes: 1848
#include "bits/stdc++.h"
using namespace std;
using ll=long long;

#include <vector>
#include <functional>

// 単一要素更新
template <typename T,typename E>
struct SegmentTree{
   using F=std::function<T(T,T)>;
   using G=std::function<T(T,E)>;

   int n;
   std::vector<T> dat;
   F f;
   G g;
   T d1;

   SegmentTree(){}
   SegmentTree(int n_,F f,G g,T d1):f(f),g(g),d1(d1)
   {
      n=1;
      while(n_>n) n<<=1;
      dat.assign(2*n,d1);
   }
   void set(int k,T x){
      dat[n+k]=x;
   }
   void build(){
      for(int i=n-1;i>=1;--i){
         dat[i]=f(dat[2*i],dat[2*i+1]);
      }
   }
   void change(int k,E x){
      k+=n;
      dat[k]=g(dat[k],x);
      while(k>>=1){
         dat[k]=f(dat[2*k],dat[2*k+1]);
      }
   }
   inline T query(int a,int b,int k=1,int l=0,int r=-1){
      if(r<0) r=n;
      if(b<=l||r<=a) return d1;
      if(a<=l&&r<=b) return dat[k];
      T vl=query(a,b,2*k,l,(l+r)/2);
      T vr=query(a,b,2*k+1,(l+r)/2,r);
      return f(vl,vr);
   }
};

int main(){
   auto f=[](int l,int r){return min(l,r);};
   auto g=[](int l,int r){return r;};
   int n,q;
   cin>>n>>q;
   SegmentTree<int,int> seg(n,f,g,INT_MAX);
   seg.build();
   for(int i=0;i<q;++i){
      int com,x,y;
      cin>>com>>x>>y;
      if(com==0){
         seg.change(x,y);
      }else{
         cout<<seg.query(x,y+1)<<endl;
      }
   }
}


Measured memory_bytes: 3872
/****************************************************************************************************
                                        SUBMITTED BY-

                                                AISH_07

****************************************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define ll long long
#define sl set<ll>
#define vs vector<string>
#define pb push_back
#define vl vector<ll>
#define vi vector<int>
#define PI  3.14159265
#define mod 998244353
int main()
{
    int a[3];
    cin>>a[0]>>a[1]>>a[2];

    sort(a,a+3);
    cout<<(a[0]*a[1])/2<<"\n";
    return 0;
}


Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

int main() {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define x first
#define y second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
const int oo = 1e9;
const int LOGN = 18;
const int MAX_VAL = 10000000;
const int MAX_N = 200000;
const int MOD = 1000000007;

int n;
int res = oo;

int sum(int d){
	int res = 0;
	while(d){
		res += d%10;
		d/=10;
	}
	return res;
}
int main() {
	cin >> n;
	for(int i = 1 ; i <= n ; ++i){
		int sc = n-i;
		if(sc){
			res = min(res,sum(sc)+sum(i));
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
def main(): 
    
    N,M = map(int, input().split())

    A = [int(input()) for _ in range(M)]

    stair_status = [True for _ in range(N+1)]

    for i in A:
        stair_status[i] = False 

    dp = [0 for _ in range(N+1)]

    dp[0] = 1

    for i in range(N):
        if i +1 <= N and stair_status[i + 1]:
            dp[i+1] += dp[i]
        if i + 2 <= N and stair_status[i + 2]:
            dp[i+2] += dp[i]

    print(dp[N] % 1000000007)

        


    
if __name__ == "__main__":
    main() 

Measured memory_bytes: 463512
#include <stdio.h>

int main()
{
	int n;
	int a[200000];

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

	int s = 1;
	for ( int i = 0 ; i < n ; i++ ) {
		if ( s == a[i] ) {
			s++;
		}
	}
	if ( s==1 )
		printf( "-1" );
	else
		printf( "%d",n-s+1 );
}


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

int main(){
  double s[1000];
  int n;
  
  while(true){
    cin>>n;
    double sum=0;
    if(n==0)break;
    for(int i=0; i<n; i++){
      cin>>s[i];
      sum+=s[i];
    }
    double bunsan=0;
    sort(s,s+n);
    for(int i=0; i<n; i++){
      bunsan += (s[i]-(sum/n))* (s[i]-(sum/n));
    }
    bunsan /= n;
    cout<<fixed<<pow(bunsan,0.5)<<endl;
  }
  
}




Measured memory_bytes: 3440
#include <bits/stdc++.h>
const int MAX=1e3+10;
const int modn=1e9+7;
typedef long long ll ;
#define int ll
#define endl '\n'
#define cwk     freopen("D:\\workplace\\CLion\\in.in","r",stdin),freopen("D:\\workplace\\CLion\\out.out","w",stdout)
using namespace std;
int h,w,beginx,beginy,endx,endy;
char room[MAX][MAX];
string v;
int dis[MAX][MAX];
bool b[MAX][MAX];
int dir[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
#define CHECK(x,y) (x>=0&&x<h&&y>=0&&y<w)
struct node{
    int x,y;
    node(int x=0,int y=0):x(x),y(y){}
};
vector<node>vv;
queue<node>q;
bool BFS() {
    vv.clear();
    node next, start;
    while (!q.empty()) {
        start = q.front();
        vv.push_back(start);
        q.pop();
        for (int i = 0; i < 4; i++) {
            next = node(start.x + dir[i][0], start.y + dir[i][1]);
            if (CHECK(next.x, next.y) && !b[next.x][next.y] && room[next.x][next.y] == '.') {
                dis[next.x][next.y] = dis[start.x][start.y];
                q.push(next);
                b[next.x][next.y] = true;
                if (b[endx][endy])
                    return true;
            }
        }
    }
    for (int hh = 0; hh < vv.size(); hh++) {
        start=vv[hh];
        for (int i = -2; i <= 2; i++) {
            for (int j = -2; j <= 2; j++) {
                next = node(start.x + i, start.y + j);
                if (CHECK(next.x, next.y) && !b[next.x][next.y] && room[next.x][next.y] == '.') {
                    q.push(next);
                    b[next.x][next.y] = true;
                    if (dis[next.x][next.y] == 1)
                        dis[next.x][next.y] = dis[start.x][start.y] + 1;
                    else dis[next.x][next.y] = min(dis[start.x][start.y] + 1, dis[next.x][next.y]);
                    if (b[endx][endy])
                        return true;
                    //cout << start.x << " " << start.y << " " << next.x << " " << next.y << " " << dis[next.x][next.y]<< " " << dis[start.x][start.y] << "\n";
                }
            }
        }
    }
    return false;
}
void solve(){
    cin>>h>>w>>beginx>>beginy>>endx>>endy;
    beginx--;beginy--;endy--;endx--;
    for(int i=0;i<h;i++){
        cin>>v;
        for(int j=0;j<w;j++){
            dis[i][j]=1;
            room[i][j]=v[j];
        }
    }
    b[beginx][beginy] = true;
    vv.push_back(node(beginx,beginy));
    q.push(node(beginx,beginy));
    while (vv.size()) {
        if(BFS())
            break;
        if(q.empty())
            break;
    }
    //cout<<dis[endx][endy]<<"\n";
    if(dis[endx][endy]!=1)
        cout<<dis[endx][endy]-1;
    else if(b[endx][endy]==false)
        cout<<"-1";
    else cout<<"0";
}
signed main() {
    //ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    //cwk;
    int _=1;
    //cin>>_;
    while(_--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 13528
n, m = list(map(int, input().split()))

import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

tmp = 0 if n < 2 else combinations_count(n, 2)
tmp2 = 0 if m < 2 else combinations_count(m, 2)
print(tmp + tmp2)

Measured memory_bytes: 3064