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

int main()
{
	int n,d;
	while(cin>>n>>d)
	{
		int x = n/(2*d+1);
		int y = n%(2*d+1);
		
		if(y==0)
		cout<<x<<endl;
		else
		cout<<x+1<<endl;
	}
	return 0;
 } 

Measured memory_bytes: 256
function main()
    a, b, h, m = parse.(Int, split(readline()))
    
    angle_m = m / 60 * 2pi
    angle_h = (60h + m) / (12 * 60.0) * 2pi
    d = sqrt(a^2 + b^2 - 2a * b * cos(angle_h - angle_m))

    println(d)
end

main()

Measured memory_bytes: 212876
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)

#define vll    vector<ll>
#define vvll   vector<vector<ll>>
#define all(x) (x).begin(),(x).end()


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

	string S;
	cin >> S;

	map<char, int> counts;

	rep(i, S.size())
	{
		counts[S[i]]++;
	}

	ll ans = 1;

	for (auto x : counts)
	{
		ans *= (x.second + 1);
		ans %= mod;
	}

	cout << ans - 1 << endl;

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <list>
#include <map>

#define rep(i, n) for(int i=0; i<n; i++)

using namespace std;

int MAX = 100000;

int main(void){

  //iが素数かどうか
  bool flag[MAX+1];
  rep(i, MAX+1)
    flag[i] = false;

  int count[MAX+1];
  rep(i, MAX+1)
    count[i] = 0;

  //素数でないものにフラグを立てる
  for(int n=2; n<=MAX; n++)
    if(!flag[n] )
      for(int m=n+n; m<=MAX; m+=n)
	flag[m] = true;

  //n以下の数字の中に「2017に似た数」がいくつあるか
  for(int n=3; n<=MAX; n+=2)
    if(!flag[n] && !flag[(n+1)/2])
      count[n]++;

  //累積和
  for(int i=3; i<=MAX; i++)
    count[i] = count[i]+count[i-1];

  //入力
  int Q;
  cin >> Q;

  int l, r;
  rep(i, Q){
    cin >> l >> r;
    //累積和を利用したカウント
    cout << count[r] - count[l-1] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 4132
n = int(input())
A =list(map(int, input().split()))
d = {}
for i in range(n):
    if A[i] not in d:
        d[A[i]] = 1
    else:
        d[A[i]] += 1
ans = 0
l = []
for k, v in d.items():
    if v >= 4:
        ans = max(ans, k**2)
        l.append(k)
    elif v >= 2:
        l.append(k)
    else:
        continue
if len(l) <= 1:
    print(ans)
else:
    l.sort(reverse=True)
    ans = max(ans, l[0]*l[1])
    print(ans)


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

using namespace std;

int main(void){
	int a[3],b[3],gone[4],used[3],now,ans=0;
	for(int i=0;i<3;i++)cin >> a[i] >> b[i];
	for(int k=0; k<6;k++){
		if(k%2==1)now = b[k/2];
		else now = a[k/2];
		for(int i=0;i<3;i++){
			gone[i] = 0;
			used[i] = 0;
		}
		gone[3] = 0;
		gone[now-1] = 1;
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				if(used[j] == 0){
					if(b[j] == now && a[j] != now && gone[a[j]-1] == 0){
						gone[a[j]-1] = 1;
						used[j] = 1; 
						now = a[j];
					}else if(b[j] != now && a[j] == now && gone[b[j]-1] == 0){
						gone[b[j]-1] = 1; 
						used[j] = 1; 
						now = b[j];
					}else if(gone[a[j]-1] == 1 && gone[b[j]-1] == 1){
						i=100;
					}
				}
			}
		}
		for(int i=0;i<3;i++){
			ans+=used[i] + gone[i];
		}
		ans += gone[3];
		if(ans == 7){
			cout << "YES" << endl;
			return 0;
		}
		ans=0;
	}
	cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 384
n = int(input())

def prime_factor(n):
	factor = []
	for i in range(2, int(n ** 0.5) + 1):
		while (n % i == 0):
			factor.append(i)
			n //= i
	if n != 1:
		factor.append(n)
	return factor

def Euler_phi(n):
	divisors = prime_factor(n)
	divisors = set(divisors)
	res = n
	for factor in divisors:
		res = res * (factor - 1) // factor
	return res

print(Euler_phi(n))


Measured memory_bytes: 5636
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7;
const int MAX_N=10000;
int n,a;

int main(){
	cin >> n >> a;
	
	cout << n*n-a << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a+b>c+d) cout << "Left" << endl;
	if (a+b==c+d) cout << "Balanced" << endl;
	if (a+b<c+d) cout << "Right" << endl;
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;

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

    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;

    if(m1 + 1 == m2){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }


    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main (){
	int a,b;
	cin >> a >> b;
	if (a==b)cout << "Draw\n";
	else{
		if (a==1)cout << "Alice\n";
		else if (b==1)cout << "Bob\n";
		else{
			if (a<b)cout << "Bob\n";
			else cout << "Alice\n";
		}
	}
	
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<complex>
#include<iomanip>

using namespace std;

#define REP(i,s,e) for(int i=int(s);i<=int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)
#define pi 3.14159265358979
#define INF 1000010


int main(void){

	int n,a,b;
	vector<pair<int,int> >p;
	cin >> n;

	rep(i,n){
		cin >> a >> b;
		p.push_back(make_pair(b,a));
	}

	sort(p.begin(),p.end());

	int t[n+2][n+2];
	rep(i,n+2) rep(j,n+2) t[i][j]=INF;
	t[0][0]=0;

	REP(i,0,n){
		REP(j,0,n){
			t[i+1][j]=min(t[i][j],t[i+1][j]);
			if(t[i][j]+p[i-1].second<=p[i-1].first && i-1>=0)
			t[i+1][j+1]=min(t[i][j+1],t[i][j]+p[i-1].second);
		}
	}

	for(int j=n;j>=0;j--)
		if(t[n+1][j]!=INF){

			cout << j << endl;  break;
		}

	return 0;
}

Measured memory_bytes: 1204
import java.util.*;


public class Main {
    static void solve() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        ArrayList<Integer> a = new ArrayList<>();
        int min = 0;
        int max = 0;
        int minIndex = 0;
        int maxIndex = 0;
        for(int i = 0; i < n; i++){
            int na = sc.nextInt();
            if (na < min) {
                min = na;
                minIndex = i;
            }else if(na > max) {
                max = na;
                maxIndex = i;
            }
            a.add(na);
        }
        ArrayList<String> ans = new ArrayList<>();

        if(Math.abs(max) > Math.abs(min)){
            for(int i = 0; i < n; i++){
                if(a.get(i) < 0){
                    ans.add(String.valueOf(maxIndex+1) + " " + String.valueOf(i+1));
                }
            }
            for(int i = 0; i < n-1; i++){
                ans.add(String.valueOf(i+1) + " " + String.valueOf(i+2));
            }
        }else{
            for(int i = 0; i < n; i++){
                if(a.get(i) > 0){
                    ans.add(String.valueOf(minIndex+1) + " " + String.valueOf(i+1));
                }
            }
            for(int i = n-1; i >= 1; i--){
                ans.add(String.valueOf(i+1) + " " + String.valueOf(i));
            }
        }

        System.out.println(ans.size());
        for(String s : ans){
            System.out.println(s);
        }
    }

    public static void main(String[] args) {
        solve();
    }
}


Measured memory_bytes: 21844
while(true)
    n,x=gets.split.map(&:to_i)
    if n==0 && x==0
      exit
    end
    cnt=0
    for i in 1..n
        for j in (i+1)..n
            for k in (j+1)..n
                if i+j+k==x
                    cnt+=1
                end
            end
        end
    end
    p cnt
end


Measured memory_bytes: 6848
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace __gnu_pbds;  
using namespace std;

typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set; 
//defines
typedef long long ll;
typedef long double ld;

ll a,b,c,n,m,k;

ll t=1;

void solve()
{
   string s;cin>>s;
   if(s[s.size()-1]=='s')cout<<s<<"es";
   else cout<<s<<'s';
 if(t>0)cout<<"\n";
}

int32_t main()
{
#ifdef ONPC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    
   //cin>>t;
    while(t--)
    {
        solve();
    }
  //cout<<sum;
        
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;

vector<int> d;

int main() {
	string str;
	cin >> str;
	FOR (i, str.sz)
		d.pb(str[i] - '0');
	LL ret = 0;
	FOR (mask, 1 << (d.sz - 1)) {
		LL sum = 0;
		FOR (i, d.sz) {
			sum = sum * 10LL + d[i];
			if (mask & (1 << i)) {
				ret += sum;
				sum = 0;
			}
		}
		ret += sum;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

// chmax, chmin
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;
}

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T &data, vector<int> &iter)
{
  cout << data << " ";
}
template <typename T>
void dump(const vector<T> &data, vector<int> &iter)
{
  for (auto elem : data)
    dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>> &data, vector<int> &iter)
{
  for (auto elem : iter)
  {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++)
  {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T> &data, int dummy)
{
  for (int i = 0; i < data.size(); i++)
  {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T &data)
{ // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(long long N)
{

  int k = N % 10;
  string ans = "hon";
  if (k == 3)
    ans = "bon";
  if (k == 0 || k == 1 || k == 6 || k == 8)
    ans = "pon";
  cout << ans << endl;
}

int main()
{
  cout << setprecision(10);
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
string s="aaaaaaaaaa";
int n;
void dfs(int i,int j)
{
	if(i>=n)
	{
		for(int k=0;k<n;k++)putchar(s[k]);
		putchar(10);
		return;
	}
	s[i]='a'-1;
	for(int k=0;k<=j;k++)
	{
		++s[i];
		dfs(i+1,max(k,j-1)+1);
		
	}
}
int main()
{
	scanf("%d",&n);
	dfs(0,0);
	return 0;
}//D


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define int long long
using namespace std;
int knapsack(vector<int> &weight, vector<int> &value, int w)
{
    int dp[2][w + 1];
    memset(dp, 0, sizeof(dp));
    for (int i = 1; i <= w; i++)
        if (i >= weight[0])
            dp[0][i] = value[0];

    int n = weight.size();
    for (int i = 1; i < n; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            dp[i % 2][j] = dp[(i + 1) % 2][j];
            if (j >= weight[i])
                dp[i % 2][j] = max(dp[i % 2][j], dp[(i + 1) % 2][j - weight[i]] + value[i]);
        }
    }
    if ((n - 1) % 2 == 0)
        return dp[0][w];
    return dp[1][w];
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, w;
    cin >> n >> w;
    vector<int> weight(n);
    vector<int> value(n);
    for (int i = 0; i < n; i++)
    {
        cin >> weight[i] >> value[i];
    }
    cout << knapsack(weight, value, w);
    return 0;
}

Measured memory_bytes: 1792
using System;


	class Gcd
	{
		public static void Main(string[] args)
		{
			string data=Console.ReadLine();
			string[] xy=data.Split();
			int x=int.Parse(xy[0]);
			int y =int.Parse(xy[1]);
			Console.WriteLine(gcd(x,y));
		}
		public static int gcd(int a, int b)
		{   
			if(a<b)
			{
				int temp=a;
				a=b;
				b=temp;
			}
			
			int c=a%b;
			while(c!=0)
			{
				a=b;
				b=c;
				c=a%b;
			}		
				
			return b;
		}
	}

Measured memory_bytes: 9152
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<math.h>
#include <string>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;
ll mod=1e9+7;

int main(){
	int n; cin >>n;
	vector<ll> a(n);
	map<ll,int> mp;
	for(int i=0;i<n;i++){
		cin >>a[i];
		mp[a[i]]++;
	}
	sort(a.begin(),a.end());
	int ans=0;
	for(int i=n-1;i>=0;i--){
		ll b=a[i];
		int cnt=0;
		while(b>1){
			b/=2;
			cnt++;
		}
		if(mp[a[i]]==0)continue;
		if(pow(2,cnt)==a[i]){
			if(mp[pow(2,cnt+1)-a[i]]>1){
				ans++;
				mp[pow(2,cnt+1)-a[i]]-=2;
			}
		}
		else if(mp[pow(2,cnt+1)-a[i]]>0){
			ans++;
			mp[pow(2,cnt+1)-a[i]]--;
			mp[a[i]]--;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 27008
/*   --------------------
    |       LOSER        |
    |     ~NOOBOSS~      |
     --------------------
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define      inl(x)              scanf("%lld",&x)
#define      in(x)               scanf("%d",&x)
#define      mxx                 10000000000000
#define      mnn                 -10000000000000
#define      Y()                 cout<< "YES" <<endl
#define      N()                 cout << "NO"<<endl
#define      endl                "\n"
#define      max_3(a,b,c)        max(a, max(b,c))
#define      max_4(a,b,c,d)      max(a,max(b,max(c,d)))
#define      min_3(a,b,c)        min(a, min(b,c))
#define      min_4(a,b,c,d)      min(a,min(b,min(c,d)))
#define      gcd(a,b)            __gcd(a,b)
#define      lcm(a,b)           (a*b)/gcd(a,b)
#define      loser               return 0
#define      ll                  long long
#define      PI                  acos(-1)
#define      mem(a,v)            memset(a,v,sizeof(a))
#define      SORT(v)             sort(v.begin(),v.end())
#define      REV(v)              reverse(v.begin(),v.end())
#define      O(x)                cout<<x<<endl
#define      B                   begin()
#define      E                   end()
#define      V                   vector
#define      F                   first
#define      S                   second
#define      PSB                 push_back
#define      EMB                 emplace_back
#define      MP                  make_pair
#define      PII                 pair<int,int>
#define      MII                 map<int,int>
#define      InTheNameOfGod      ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;//*(x.find_by_order(i)),x.order_of_key(k)
//const ll MOD = 998244353;
constexpr ll mod = 1e9  + 7;
//auto it=std:: unique(v.B,v.E);
//v.resize(std::distance(v.B,it));
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
/*-----*/
#define bug1(a)  cout<<a<<endl;
#define bug2(a,b)  cout<<a<<" "<<b<<endl;
#define bug3(a,b,c)  cout<<a<<" "<<b<<" "<<c<<endl;
/*----*/
ll power(ll n,ll p){if(p==0) return 1;if(p==1)return n;if(p%2)return power(n,p-1)*n;else{ll x=power(n,p/2);return x*x;}}
ll modpow(ll a,ll b,ll m){ll ans=1;while(b){if(b&1)ans=(ans*a)%m;b/=2;a=(a*a)%m;}return ans;}
ll binpow(ll a, ll b){ll res = 1;while (b > 0) {if (b & 1)res*=a;a*=a;b>>=1;}return res;}
ll fact(ll num){ll fac=1;while(num!=1){fac=fac*num;num--;}return fac;}
string to_binary(int x) {string s;while(x > 0) {s += (x % 2 ? '1' : '0');x /= 2;}reverse(s.begin(), s.end());return s;}
ll nsum(ll num){return (num*(num+1))/2;}
/*-----*/
const int N=2e5+5;

/*-----*/
//vector<int> v[202];

/*-----*/
int main(){
   InTheNameOfGod

   ll test=1;
   //cin>>test;
   while(test--){
     ll n,a,ans=0;
     string s;
     cin>>n;
     for(ll i=1;i<=n;i++){
        cin>>a;
        if(i%2 && a%2 ) ans++;
     }
     cout<<ans<<endl;

    }
  loser;
}
///////LeArN MoRe AnD Wait FoR ThE Result///////


Measured memory_bytes: 3612
import java.util.Scanner;
public class Main {
   public static final int MAPSIZE = 10;
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      /*we prepare bigger field*/
      int[][] field = new int[MAPSIZE + 4][MAPSIZE + 4];
      
      while(sc.hasNext()) {
         /*get coordinates and magnitude of the ink*/
         String[] input = sc.nextLine().split(",");      
         
         /*if null input, break the loop*/
         if(input.length == 1) {
            break;
         }         
         
         /*parse the input data to integer*/
         int x = Integer.parseInt(input[0]);
         int y = Integer.parseInt(input[1]);
         int size = Integer.parseInt(input[2]);
         
         /*drop the ink*/
         drop(field, x, y, size);         
      }// end of while loop
      
      /*only go through valid part of the field and count value with 0*/
      int count = 0;
      int max = 0;
      for(int i = 2; i <= MAPSIZE + 1; i ++) {
         for(int j = 2; j <= MAPSIZE + 1; j ++) {
            if(field[i][j] == 0) {
               count ++;
            } else if(field[i][j] > max) {
               max = field[i][j];
            }
         }
      }
      
      /*print out the reuslt*/
      System.out.println(count);
      System.out.println(max);
   }// end of main method
   
   
   public static void drop(int[][] field, int x, int y, int size) {
      switch(size) {
         case 1:
            dropMin(field, y, x); //because the array is configured differently, x and y are switched.
            break;
         case 2:
            dropMiddle(field, y, x);
            break;
         case 3:
            dropMax(field, y, x);
            break;
      }
   }
   
   
   public static void dropMin(int[][] field, int x, int y) {
         field[x + 2][y + 2] ++; //center
         field[x + 2][y + 1] ++; //up
         field[x + 2][y + 3] ++; //down
         field[x + 1][y + 2] ++; //left
         field[x + 3][y + 2] ++; //right
   }
   
   public static void dropMiddle(int[][] field, int x, int y) {
      dropMin(field, x, y);
      field[x + 3][y + 3] ++;
      field[x + 3][y + 1] ++;
      field[x + 1][y + 1] ++;
      field[x + 1][y + 3] ++;
   }
   
   public static void dropMax(int[][] field, int x, int y) {
      dropMiddle(field, x, y);
      field[x + 2][y] ++;
      field[x + 2][y + 4] ++;
      field[x][y + 2] ++;
      field[x + 4][y + 2] ++;
   }

}// end of class


Measured memory_bytes: 26088
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll mod = 1e9 + 7;


string S[100000];
ll N, M,ans;
pair<ll,ll> A[100001];
ll dp[100001];
priority_queue<ll> que;
int main() {

	cin >> N>>M; 
	FOR(i, 0, N) {
		cin >> A[i].first>>A[i].second;
	}
	sort(A, A + N);
	int cur = 0;

	FOR(i, 1, M+1) {
		while (cur < N&&A[cur].first <= i) {
			
			que.push(A[cur].second);
			cur++;
		}
		if (que.empty())continue;
		ans += que.top();
		que.pop();
	}

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

Measured memory_bytes: 3704
m, n = gets.split.map(&:to_i)

a = gets.split.map(&:to_i)
count = 0

a.each do |i|
  m = m - i
  count += 1

  if m <= 0
    break
  end
end

if m <= 0
  puts count > n ? "No" : "Yes"
elsif m > 0
  puts "No"
end

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

ll dp[3010][3010][4];
ll tab[3010][3010];

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int R,C,K; cin>>R>>C>>K;
    rep(i,K){
        int r,c; cin>>r>>c; ll v; cin>>v;
        tab[r-1][c-1] = v;
    }
    rep(i,R)rep(j,C)rep(k,4){
        if (k>0) chmax(dp[i+1][j+1][k], dp[i+1][j][k-1] + tab[i][j]);
        chmax(dp[i+1][j+1][k], dp[i+1][j][k]);
        if (k==0){
            rep(l,4){
                chmax(dp[i+1][j+1][1], dp[i][j+1][l] + tab[i][j]);
                chmax(dp[i+1][j+1][0], dp[i][j+1][l]);
            }
        }
    }
    ll ans=0;
    rep(i,4) chmax(ans,dp[R][C][i]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 356224
(defun create-data ()
  (let ((n (read)) 
        (p)
        (q))
    (dotimes (i n)
      (push (read) p)) 
    (dotimes (i n) 
      (push (read) q))
    (values n (reverse p) (reverse q))))

 

(defun permutation (fn xs &optional a)
  (if (null xs)
      (funcall fn (reverse a))
      (dolist (x xs)
        (permutation fn (remove x xs) (cons x a)))))

(defun permutation-list (xs)
  (let (zs)
    (permutation (lambda (ys) (push ys zs)) xs)
    (nreverse zs))) 

(defun permutation-list1 (n)
  (let ((x))
    (dotimes (i n)
      (push (1+ i) x)) 
    (permutation-list (reverse x))))


(defun count-order (n p q)
  (let ((a 0) 
        (b 0)
        (x))
    (setf x (permutation-list1 n))
    (dolist (i x)
      (if (equal p i) 
        (return)
        (incf a)))
    (dolist (i x)
      (if (equal q i)
          (return) 
          (incf b)))
    (abs (- a b))))

(multiple-value-bind (n p q) (create-data)
  (format t "~D~%" (count-order n p q))) 


Measured memory_bytes: 16740
N, Ma, Mb = gets.split.map(&:to_i)
A, B, C = [nil], [nil], [nil]
readlines.each{|l| a, b, c = l.split.map(&:to_i); A << a; B << b; C << c}

INF = 1 << 30
Wmax = 40 * 10
dp = Array.new(N + 1){Array.new(Wmax + 1){Array.new(Wmax + 1, INF)}}
dp[0][0][0] = 0
(1 .. N).each do |i|
  (0 .. Wmax).each do |j|
    (0 .. Wmax).each do |k|
      next if dp[i - 1][j][k] == INF
      dp[i][j][k] = [dp[i][j][k], dp[i - 1][j][k]].min
      dp[i][j + A[i]][k + B[i]] = [dp[i][j + A[i]][k + B[i]], dp[i - 1][j][k] + C[i]].min
    end
  end
end
ans = INF
(1 .. Wmax).each do |i|
  (1 .. Wmax).each do |j|
    next if i*Mb != j*Ma
    ans = [ans , dp[N][i][j]].min
  end
end
puts ans == INF ? -1 : ans


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

int main(){
    int N, M;
    cin >> N >> M;

    vector<queue<int>> lanes(N);
    for(int i = 0; i < M; i++){
        int b, n;
        cin >> b >> n;
        if(b == 0){
            n--;
            cout << lanes[n].front() << endl;
            lanes[n].pop();
        } else {
            int lane = 0;
            int len = 1e9;
            for(int l = 0; l < N; l++) {
                if(len > lanes[l].size()){
                    lane = l;
                    len = lanes[l].size();
                }
            }
            lanes[lane].push(n);
        }
    } 
}


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

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  
int da = abs(x - a), db = abs(x - b);
	if (da < db) {
		puts("A");
	} 
  else {
		puts("B");
	}
}


Measured memory_bytes: 256
from sys import stdin

#a = int(input())
#b = int(input())
#c = int(input())

a,b,c = [int(x) for x in stdin.readline().rstrip().split()]


ab_c = 10 * a + b + c
#ac_b = 10 * a + c + b
ba_c = 10 * b + a + c
#bc_a = 10 * b + c + a
ca_b = 10 * c + a + b
#cb_c = 10 * c + b + b

ret = max(ab_c, ba_c, ca_b)

print(ret)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
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; }


int main(void){
    int N,K;
    cin>>N>>K;
    if(K==1){
        cout<<0<<endl;
    }
    else cout<<N-K<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int A[100000];

int getGCD(int a, int b)
{
	int r, tmp;

	if (a < b) return getGCD(b, a);
	
	r = b;
	b = a;

	while (r) {
		tmp = b;
		b = r;
		r = tmp % r;
	}

	return b;
}

int main()
{
	int N;
	int HPmin;

	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];

	HPmin = getGCD(A[0], A[1]);

	for (int i = 2; i < N; i++) {
		HPmin = getGCD(HPmin, A[i]);
	}

	cout << HPmin << endl;

	return 0;
}

Measured memory_bytes: 640
<?php

 $N = trim(fgets(STDIN));

$Ai = explode(" ", trim(fgets(STDIN)));


for ($i = 1; $i <= $N; $i++){

      $array["$i"] = $Ai[$i-1]; 

}

asort($array);


   foreach ($array as $a => $b){

      echo $a." ";
      

}

?>

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

int main() {
  int N,X; cin >> N >> X;
  int m[101];
  int MIN = 100000000;
  for ( int i = 0; i < N; i++ ) {
    cin >> m[i];
    MIN = min(m[i],MIN);
  }
  for ( int i = 0; i < N; i++ ) {
    X -= m[i];
  }
  int cnt = N;
  while(X>=0) {
    X -= MIN;
    cnt++;
  }
  cout << cnt-1 << endl;
  return 0;
}


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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;
    //abc067 d
    public static Edge[] e;
    public static int[][] dist;
    static void solve(InputReader in, PrintWriter out){
        int n = in.ni();
        e = new Edge[n];
        for (int i = 0; i < n; i++) e[i] = new Edge();
        for (int i = 0; i < n - 1; i++) {
            int from = in.ni()-1, to = in.ni()-1;
            e[from].add(to);
            e[to].add(from);
        }
        dist = new int[n][2];
        dfs(0,-1, 0);
        dfs(n-1,-1, 1);

        int fen = 0, snu = 0;
        for (int i = 0; i < n; i++) {
            if(dist[i][0]<=dist[i][1]) fen++;
            else snu++;
        }

        out.println((fen>snu)?"Fennec":"Snuke");
    }
    public static void dfs(int now, int from, int player){//0->fennec
        for(Integer to: e[now]){
            if(to!=from){
                dist[to][player] = dist[now][player]+1;
                dfs(to, now, player);
            }
        }
    }
    public static class Edge extends ArrayList<Integer>{}

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

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

using namespace std;

int main(void)
{
	string s;
	cin >> s;
	bool flag[26]={};
	for(int i=1;i<=s.size();i++)
	{
		if(flag[s[i-1]-'a']==true)
		{
			cout << "no" << endl;
			return 0;
		}
		flag[s[i-1]-'a']=true;
	}
	cout << "yes" << endl;
}

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

int main(){
	int s=0,k=0,n,m,l,p,i;
	
	cin>>n>>m>>l;
	
	for(i=1;i<=n;i++){
		p=i;
		while(p!=0){
			k+=p%10;
			p=p/10;
		}
		if(k>=m&&k<=l){
			s+=i;
		}
		k=0;
	}
	
	cout<<s<<endl;
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            return 48 - ReadLong();
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 27484
import sys
input = sys.stdin.readline

n, m = [int(x) for x in input().split()]
g = [[] for _ in range(n)]
for _ in range(m):
    a, b = [int(x) for x in input().split()]
    g[a - 1].append(b - 1)
    g[b - 1].append(a - 1)

mae = [-1]*n
from collections import deque
def bfs(v):
    queue = deque([])
    d = [None]*n
    d[v] = 0
    queue.append(v)
    while queue:
        u = queue.popleft()
        for i in g[u]:
            if d[i] is None:
                d[i] = d[u] + 1
                mae[i] = u
                queue.append(i)
    return d
d = bfs(0)
print("Yes")
for i in mae[1:]:
    print(i + 1)


Measured memory_bytes: 94396
#include<cstdio>
#include<iostream>
using namespace std;
int a,b,c,d;
int doe,n;
long long ans;
int main()
{
	scanf("%d%d%d%d",&a,&b,&c,&d);
	scanf("%d",&n);
	doe=min(a*4,b*2);
	doe=min(doe,c);
	if (doe*2<=d)
		ans=(long long)n*doe;
	else
	{
		int kkk=n/2;
		ans=(long long)kkk*d;
		if (kkk*2!=n) ans+=doe;
	}
	printf("%lld\n",ans);

	return 0;
}

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

#define For(i,a,b) for(int (i) = (a);(i) < (b);i++)
#define Rep(i,n) For((i),0,(n))
#define All(a) (a).begin(),(a).end()
#define sp " "
#define INF 1e18
#define INT_INF 1e9

typedef long long ll;
const ll MOD = 1000000007;
const ll MOD_9 = 998244353;

vector<char> boin = {'a','i','u','e','o'};
vector<char> alphabet = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

int main(){
    string S;
    int N;
    int ans = 0;
    cin >> N >> S;
    Rep(i,N-2){
        if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C')ans++;
    }
    cout << ans << endl;
    cin >> N;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
ll n,a[N];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	ll res=0,pre=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]>=i)
		{
			res=-1;
			break;
		}
		if(a[i]>pre)
		{
			if(a[i]-pre>1)
			{
				res=-1;
				break;
			}
			res++;
		}
		else
			res+=a[i];
	//	cout<<i<<' '<<res<<'\n'; 
		pre=a[i];		
	}
	cout<<res<<'\n';
	return 0;
} 

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

#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define v(t) vector<t>
#define vv(t) vector<vector<t>>
#define vn(t,n,val) vector<t>(n,val)
#define vvn(t,r,c,val) vector<vector<t>>(r, vector<t>(c,val))
#define vvv(t) vector<vector<vector<t>>>
#define vvvn(t,l,b,h,val) vector<vector<vector<t>>>(l,vector<vector<t>>(b,vector<t>(h)))

int main() {
	sp;

	////////////////To Remove//////////////
	// freopen("../../input.txt", "r", stdin);
	// freopen("../../output.txt", "w", stdout);
	///////////////////////////////////////

	long long x;
	cin>>x;

	long long result = (x/500ll)*(1000);
	x = x%500;
	result += (x/5ll)*5;
	cout<<result;

  	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL))
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

int main()
{
    fastread();

  ll a,b;

  cin>>a>>b;

  if(a<6)cout<<0<<endl;
  else if(12<a)cout<<b<<endl;
  else cout<<b/2<<endl;



}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a, b;
	cin>>a>>b;
	if(b < a){
		if(a - 1 < 0)cout<<0<<endl;
		else cout<<a-1<<endl;
	}
	else{
		cout<<a<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
a = int(raw_input())
curr_x = 0
curr_y = 0
old_t = 0
for i in range(a):
    t, x, y = map(int, raw_input().split())
    diff_x = abs(x - curr_x)
    diff_y = abs(y - curr_y)
    diff_xy = diff_x + diff_y
    result = 0
    t2 = t - old_t
    #t = t - old_t

    if diff_xy > t2:
        result += 1
        break
    elif diff_xy == t2:
        #print "Yes"
        result += 0
        curr_x = x
        curr_y = y
        old_t = t
    elif (t2 - diff_xy) % 2 == 0:
        #print "Yes"
        result += 0
        curr_x = x
        curr_y = y
        old_t = t
    else:
        result += 1
        break

if result == 0:
    print "Yes"
else:
    print "No"

Measured memory_bytes: 5764
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int N;
ll r=1;
int main()
{
	scanf("%d",&N);
	for(ll i=2;i<=N;i++)
			r=(r*i)%1000000007;
	printf("%lld\n",r);
	return 0;
}


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

#define int long long
#define rep(i,l,r) for(register int i=(l);i<=(r);++i)
const int maxn=1e6+5;
const int mod=998244353;
int n,m,a[maxn],vis[maxn],pri[maxn],cnt,mu[maxn],c[maxn],sum,s[maxn],ans;

void sieve(){
	rep(i,2,n){
		if(!vis[i])pri[++cnt]=i,mu[i]=-1;
		for(register int j=1;j<=cnt&&i*pri[j]<=n;++j){
			vis[i*pri[j]]=1;
			if(i%pri[j]==0)break;
			mu[i*pri[j]]=-mu[i];
		}
	}
}

int qpow(int x,int k){
	int res=1;
	for(;k;x=x*x%mod,k>>=1)if(k&1)res=res*x%mod;
	return res;
}

signed main(){
	scanf("%lld",&n);
	rep(i,1,n)scanf("%lld",&a[i]),c[a[i]]++,sum=(sum+a[i])%mod,m=max(m,a[i]);
	n=m;mu[1]=1;sieve();
	rep(i,1,n)for(register int j=i;j<=n;j+=i)s[j]+=mu[i]*i;
	rep(t,1,n){
		int tmp=0;
		rep(i,1,n/t)tmp=(tmp+c[i*t]*i+mod)%mod;
		ans=(ans+t*tmp%mod*tmp%mod*s[t]%mod+mod)%mod;
	}
	printf("%lld\n",(ans-sum+mod)%mod*qpow(2,mod-2)%mod);
	return 0;
}

Measured memory_bytes: 37128
from collections import defaultdict
def gen_bound(x,B):
	if x < 3: lb = 2
	else: lb = x - 1
	if x > B-2: ub = B-1
	else: ub = x + 1
	return lb,ub+1
def solve():
	count = defaultdict(int)
	ans = [0]*10
	H,W,N = map(int,raw_input().split())
	ans[0] = (H-2)*(W-2)
	for i in xrange(N):
		a,b = map(int,raw_input().split())
		xlb,xub = gen_bound(a,H)
		ylb,yub = gen_bound(b,W)
		for x in xrange(xlb,xub):
			for y in xrange(ylb,yub):
				k = (x,y)
				bef_c = count[k]
				count[k] += 1
				ans[bef_c] -= 1
				ans[bef_c+1] += 1
	for c in ans:
		print c
solve()

Measured memory_bytes: 149540
#include <iostream>
#include <cstdio>
#include <cmath>
#include <climits>
#include <vector>
#include <queue>

#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
#include <iterator>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF (1<<30)
#define ALEN(ARR) (sizeof(ARR) / sizeof((ARR)[0]))
#define MP make_pair
#define mp make_pair
#define pb push_back
#define PB push_back

#if DEBUG
#define _DEBUG(x) cout<<#x<<": "<<x<<endl
#define _DDEBUG(x,y) cout<<#x<<": "<<x<<", "<<#y<<": "<<y<<endl
#else
#define _DEBUG(x) ;
#define _DDEBUG(x,y) ;
#endif

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

/** FOR VECTOR DEBUG */
template <typename T>
ostream& operator<< (ostream& out, const vector<T>& v) {
    if ( !v.empty() ) {
        out << '[';
        copy (v.begin(), v.end(), ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


/* template end */


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.precision(16);

    int a, b, q;
    cin >> a >> b >> q;
    vector<int> va(a), vb(b);
    vector<int> vq(q);
    REP(i, a) {
        cin >> va[i];
    }
    REP(i, b) {
        cin >> vb[i];
    }
    sort(va.begin(), va.end());
    sort(vb.begin(), vb.end());
    REP(i, q) {
        int t;
        cin >> t;
        ll ans = LLONG_MAX;
        for(int i = 0; i < 4; i++) {
            ll d1 = i & 1
            ? *upper_bound(va.begin(), va.end(), t)
            : *upper_bound(va.begin(), va.end(), t) == va.front()
                ? va.front()
                : *(upper_bound(va.begin(), va.end(), t) - 1);
            ll d2 = i & 2
            ? *upper_bound(vb.begin(), vb.end(), d1)
            : *upper_bound(vb.begin(), vb.end(), d1) == vb.front()
                ? vb.front()
                : *(upper_bound(vb.begin(), vb.end(), d1) - 1);
            ll tt1 = llabs(t - d1) + llabs(d1 - d2);

            ll d4 = i & 1
            ? *upper_bound(vb.begin(), vb.end(), t)
            : *upper_bound(vb.begin(), vb.end(), t) == vb.front()
                ? vb.front()
                : *(upper_bound(vb.begin(), vb.end(), t) - 1);
            ll d3 = i & 2
            ? *upper_bound(va.begin(), va.end(), d4)
            : *upper_bound(va.begin(), va.end(), d4) == va.front()
                ? va.front()
                : *(upper_bound(va.begin(), va.end(), d4) - 1);
            ll tt2 = llabs(t - d4) + llabs(d4 - d3);

            ans = min(ans, min(tt1, tt2));
        }
        cout << ans << endl;
    }


#if DEBUG
    cout << "** RESULT **" << endl; // debug
#endif

    return 0;
}


Measured memory_bytes: 3712
import numpy as np
card = np.array([list(map(int,input().split())) for i in range(3)])
num = [int(input()) for i in range(int(input()))]

def check():
    if np.count_nonzero(card[0] == 0) == 3:
        return True
    elif np.count_nonzero(card[1] == 0) == 3:
        return True
    elif np.count_nonzero(card[2] == 0) == 3:
        return True
    elif np.count_nonzero(card.T[0] == 0) == 3:
        return True
    elif np.count_nonzero(card.T[1] == 0) == 3:
        return True
    elif np.count_nonzero(card.T[2] == 0) == 3:
        return True
    elif [card[0][0],card[1][1],card[2][2]].count(0) == 3:
        return True
    elif [card[0][2],card[1][1],card[2][0]].count(0) == 3:
        return True
for i in range(len(num)):
    for x in [0,1,2]:
        for y in [0,1,2]:
            if card[x][y] == num[i]:
                card[x][y] = 0
                if check():
                    print("Yes")
                    exit()

print("No")

Measured memory_bytes: 21180
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    ll P[1000000];
    for(ll i = 0; i < N; i++) cin >> P[i];
    pair<ll, ll> itv[N];
    for(ll i = 0; i < N; i++) {
        itv[i].first = P[i];
        itv[i].second = i+1;
    }
    sort(itv, itv + N);

    ll ans = 0, t = N+1;
    for(ll i = 0; i < N; i++) {
        if(t > itv[i].second) {
            ans++;
            t = itv[i].second;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6912
n=gets.to_i
as=gets.split(" ").map(&:to_i)

rabbits={}
as.each_with_index do |a, idx|
  key = a < idx+1 ? "#{a},#{idx+1}" : "#{idx+1},#{a}"
  rabbits[key] = 0 unless rabbits[key]
  rabbits[key] += 1
end

puts rabbits.select{|k,v| v > 1}.length



Measured memory_bytes: 22788
A = list(input().split())
S = []*100
def push(i):
    S.append(i)
def pop(S):
    n = S.pop()
    return(n)

cnt = len(A)

for i in range(cnt):
    if A[i] == "+" :
        a = int(pop(S))
        b = int(pop(S))
        out = a + b
#        print("+",out)
        push(out)

    elif A[i] == "-" :
        a = int(pop(S))
        b = int(pop(S))
        out = b - a
        push(out)
#        print("-",out)

    elif A[i] == "*" :
        a = int(pop(S))
        b = int(pop(S))
        out = a * b
        push(out)
 #       print("*",out)
    else:
        push(int(A[i]))
#        print("push",int(A[i]))

print(pop(S))




Measured memory_bytes: 5600
#include <stdio.h>
#define swap(a, b) {int tmp;tmp = a;a=b;b=tmp;}
int main(){
	int amida[31];
	int w,n;
	int a,b;
	int i;
	scanf("%d %d", &w, &n);
	for(i = 1;i <=w;i++)
		amida[i]=i;
	for(i = 0;i < n;i++){
		scanf("%d,%d",&a,&b);
		swap(amida[a], amida[b]);
	}
	for(i = 1;i <=w; i++){
		printf("%d\n",amida[i]);
	}
	return 0;
}

Measured memory_bytes: 596
(defun judge (s)
  (let* ((k (floor (length s) 2))
	 (s1 (subseq s 0 k))
	 (s2 (subseq s k)))
    (equal s1 s2)))

(defun solve (s)
  (cond
    ((null s)  -1)
    ((judge s) (length s))
    (t         (solve (butlast s 2)))))

(defun main()
  (let ((s (concatenate 'list (read-line))))
    (princ (solve (butlast s 2)))
    (fresh-line)))

(main)


Measured memory_bytes: 24688
import heapq as hq
def inp():
	return (int(input()))


def inlt():
	return (list(map(int,input().split())))


def insr():
	s=input()
	return (list(s[:len(s)]))


def invr():
	return (map(int,input().split()))


def subset_sum_count(arr,n,sum):
	dp=[[0 for _ in range(sum+1)] for _ in range(n+1)]
	for i in range(n+1):
		for j in range(sum+1):
			if j==0:
				dp[i][j]=1
			elif arr[i-1]<=j:
				dp[i][j]=dp[i-1][j-arr[i-1]]+dp[i-1][j]
			else:
				dp[i][j]=dp[i-1][j]
	return dp[n][sum]


def prefix(a):
	pre=[]
	pre.append(a[0])
	for i in range(1,len(a)):
		pre.append(pre[i-1]+a[i])
	return pre

def str_to_integer_list(n):
	a=[]
	for i in range(len(n)):
		a.append(int(n[i]))
	return a
def list_to_str(l):
	s=""
	for i in l:
		s+=str(i)
	return s
def binarySearch(arr,low,high,x):
	if (high>=low):
		mid=low+(high-low)//2
		if x==arr[mid]:
			return (mid)
		elif (x>arr[mid]):
			return binarySearch(arr,(mid+1),high,x)
		else:
			return binarySearch(arr,low,(mid-1),x)
	
	return -1


def right_shift(a,s):
	return a[s:]+a[:s]


def dijkstra(s,N,E):
	visited=set()
	dist={}
	for i in range(1,N+1):
		dist[i]=1<<29
	queue=[(dist[i],i) for i in range(1,N+1)]
	hq.heappush(queue,(0,s))
	dist[s]=0
	while queue:
		d,u=hq.heappop(queue)
		if u in visited:
			continue
		#Relax all the neighbours of u
		for t in E[u]:
			v,r=t
			if dist[v]>d+r:
				dist[v]=d+r
				hq.heappush(queue,(dist[v],v))
		#Node u has been processed
		visited.add(u)
	return dist


def path(start,end,parent):
	path=[end]
	while path[-1]!=start:
		path.append(parent[path[-1]])
	path.reverse()
	return path


def bfs(graph,start,end):
	parent={}
	queue=[]
	queue.append(start)
	while queue:
		node=queue.pop(0)
		if node==end:
			return path(start,end,parent)
		for next in graph.get(node,[]):
			if node not in queue:
				parent[next]=node
				queue.append(next)


'''for _ in range(int(input())):
	n,m=list(map(int,input().split()))
	graph=[[]for _ in range(n+1)]
	distance=[-1]*(n+1)
	visited=[False]*(n+1)
	for _ in range(m):
		x,y=list(map(int,input().split()))
		graph[x].append(y)
		graph[y].append(x)'''
'''T = int(input())
for i in range(0, T):
	N, M = map(int, input().split(' '))
	graph = {}
	for j in range(1, N+1):
		graph[j] = []
	for j in range(0, M):
		x, y, r = map(int, input().split(' '))
		graph[x].append((y,r))
		graph[y].append((x,r))'''
s=insr()
t=insr()
c=0
for i in range(len(s)):
	if s[i]!=t[i]:
		c+=1
print(c)



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

#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<ll>
#define all(x) x.begin() , x.end()
#define mod(x,m) ((x%m + m )%m)

using namespace std;
void OJ();
const int MAX = 1e4 + 9;

int n , m; string s;

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); //OJ();

    string s; cin >> s; int counter = 0 , flag;
    if ( s[0] == '0' && s[1] >  '0' ) counter++ , flag = 1;
    if ( s[0] == '1' && s[1] <= '2' ) counter++ , flag = 1;


    if ( s[2] == '0' && s[3] >  '0' ) counter++ , flag = 2;
    if ( s[2] == '1' && s[3] <= '2' ) counter++ , flag = 2;

    if      ( counter == 0 ) cout << "NA";
    else if ( counter == 1 ){
        cout << (flag == 1 ? "MMYY" : "YYMM" );
    }
    else{
        cout << "AMBIGUOUS";
    }
    return  0;
}

void OJ(){
#ifndef ONLINE_JUDGE
    freopen( "inp.c" , "r" , stdin  );
    //freopen( "out.txt", "w" , stdout );
#endif // ONLINE_JUDGE
}
ll binEXP( ll x , ll pw , ll MOD )
{ ll res=1; while(pw>0){ pw%2 ? res *= x : 0; x *= x; x%=MOD; pw /= 2; res%= MOD; } return res%=MOD; }


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String line = in.nextLine();
		if (line.length() == 2) {
			System.out.println(line);
		} else {
			for (int i = 0; i < 3; ++i) {
				System.out.print(line.charAt(2 - i));
			}
			System.out.println("");
		}
		in.close();
	}
}


Measured memory_bytes: 23252
import java.util.Scanner;

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

    while (in.hasNext()) {
      long A = in.nextInt();
      long B = in.nextInt();
      long C = in.nextInt();
      
      if (A + B >= C) {
        System.out.println(B + C);
      } else {
        System.out.println(2 * (A + B) + 1 - A);
      }
    }
  }
}

Measured memory_bytes: 23252