akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int comp(const void *a, const void *b)
{
	return *(int*)a - *(int*)b;
}

int main(void){
	
	char n_str[10];
	int n;
	char p_str[800000];
	char *p_tmp;
	int p[100000];
	int c;
	
	int ans;
	
	fgets(n_str,sizeof(n_str),stdin);	
	fgets(p_str,sizeof(p_str), stdin);

//	printf("n_str = %s\n", n_str);
//	printf("p_str = %s\n", p_str);

	n = strtol(n_str,NULL,10);
	
//	printf("n = %d\n",n);
	
	
//	printf("before sort\n");
	for(c=0;c<n;c++)
	{
		if(c==0)
			p_tmp = strtok(p_str," ");
		else
			p_tmp = strtok(NULL," ");
		p[c] = strtol(p_tmp,NULL,10);
	}
	
//	for(c=0;c<n;c++)
//	{
//		printf("p[%d] = %d\n",c,p[c]);
//	}
	
//	printf("after sort\n");
	
	qsort(p,n,sizeof(int),comp);
	
//		for(c=0;c<n;c++)
//	{
//		printf("p[%d] = %d\n",c,p[c]);
//	}
	
	if(p[n/2] == p[n/2-1])
		ans = 0;
	else{
		ans = p[n/2] - p[n/2-1];
	}
	
	printf("%d",ans);
	
	return 0;
}

Measured memory_bytes: 1532
def run():
    w = [i + 1 for i in range(int(input()))]
    n = int(input())
    for _ in range(n):
        s1, s2 = list(map(int, input().split(',')))
        w[s1-1], w[s2-1] = w[s2-1], w[s1-1]
    print('\n'.join([str(_w) for _w in w]))

if __name__ == '__main__':
    run()




Measured memory_bytes: 5604
import fractions
from functools import reduce

def lcm(a,b):
    return (a*b)//fractions.gcd(a,b)

def list_lcm(*numbers):
    return reduce(lcm,numbers)

n=int(input())
a=list(map(int,input().split()))
l,ans,mod=list_lcm(*a),0,1000000007
print(sum(l//i for i in a)%mod)

Measured memory_bytes: 6140
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (1e+18) + 7;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

ll mod_pow(ll a, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%mod;
		a = a * a%mod; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 500;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

void solve() {
	string s; cin >> s;
	rep(i, s.size())s[i] = 'x';
	cout << s << endl;
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(10);
	//init_f(); init();
	//int t; cin >> t; rep(i, t)solve();
	//while(cin>>n,n)solve();
	solve();
	stop
		return 0;
}

Measured memory_bytes: 256
H = int(input())
W = int(input())
N = int(input())

if H > W:
    if N % H == 0:
        print(N // H)
    else:
        print(N//H + 1)
else:
    if N % W == 0:
        print(N // W)
    else:
        print(N//W + 1)


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

#define FastRead        ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl            "\n"
#define sq(x)           ((x)*(x))
#define MAX             500005

typedef long long ll;


int main()
{
    FastRead

    ll n,k,sum=0;

    cin>>n>>k;

    vector<ll>v(n);

    for(ll i=0;i<n;i++)
        cin>>v[i];

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

    for(ll i=0;i<k;i++)
        sum+=v[i];

    cout<<sum<<endl;
}


Measured memory_bytes: 3644
using System;

class AtCoder
{
    static void Main(string[] args)
    {
        var x = Console.ReadLine().Split(' ');     
      	var a = int.Parse(x[0]+x[1]);
        
        var s = (int)Math.Sqrt(a);
      	if( s * s == a ){
          Console.WriteLine("Yes");
        }
      else{
        Console.WriteLine("No");
      }
    }
}

Measured memory_bytes: 11092
from fractions import gcd

a,b,c,d=map(int, input().split())
tisai = int(c*d/gcd(c,d))
n=[c,d]
count=0
for k in range(2):
    count += ((b//n[k])-((a-1)//n[k]))
count -= ((b//tisai)-((a-1)//tisai))
print(int((b-a+1)-count))

Measured memory_bytes: 5048
N=int(input())
S=[input() for i in range(N)]
L=dict()
for i in range(N):
  if S[i] in L:
    L[S[i]]+=1
  else:
    L[S[i]]=1
M=max(L.values())
ans=list()
for X in L:
  if L[X]==M:
    ans.append(X)
ans.sort()
for X in ans:
  print(X)


Measured memory_bytes: 152280
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    int k, n; cin >> k >> n;
    vector<int> A(n);
    for(int i = 0; i < n; i++) cin >> A[i];
    A.push_back(k + A.front());
    vector<int> d;
    for(int i = 0; i < n; i++)
    {
        d.push_back(abs(A[i + 1] - A[i]));
    }
    sort(d.begin(), d.end());
    ll sum = 0;
    for(int i = 0; i < d.size() - 1; i++) sum += d[i];
    cout << sum << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

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

int main(){
  int n,i,num,max;
  cin >> n;
  vector<int> vec(n);
  for (i = 0;i < n;i++){
    cin >> vec[i];
  }
  max = vec[0];
  num = 1;
  for (i = 1;i < n;i++){
    if (vec[i] >= max){
      num++;
      max = vec[i];
    }
  }
  cout << num << endl;
}

Measured memory_bytes: 256
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}
 
int32_t main() {
    fio
    
    cout << fixed << setprecision(12);
    
    int l;
    cin >> l;
    double x;
    x=l/3.0;
    
    cout << (x*x*x) << endl;
    


	return 0;
    
}

Measured memory_bytes: 8832
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]

ans, buy = 0, 0
for i, j in sorted(a, key=lambda x:x[0]):
    tmp = min(m-buy, j)
    ans += tmp*i
    buy += tmp
    if buy == m: break

print(ans)

Measured memory_bytes: 29280
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        String s = String.valueOf(N);

        if (s.charAt(0) == '7' || s.charAt(1) == '7' || s.charAt(2) == '7') {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}


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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  reverse(h.begin(), h.end());
  int ans = 0;
  int val = 0;
  for (int i = 1; i < n; i++) {
    if (h[i-1] <= h[i]) val++;
    else val = 0;
    ans = max(ans, val);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3792
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;

const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define PII pair<int, int>
#define pf printf

#define sf scanf

#define ALL(x) x.begin(),x.end()
#define pb push_back

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sz(a) int(a.size())
#define ff first
#define ss second
#define endl "\n"
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
int ext_gcd(int a, int b, int & x, int & y) {
    //for finding modular inverse
    //if its return 1 ,then a has a mod inverse x mod b.
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    int x1, y1;
    int d = ext_gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}
void solve(){

}

int main()

{
    IOS;
    /*#ifndef ONLINE_JUDGE
        freopen ("data.in","r",stdin);
        freopen ("data.out","w",stdout);
    #endif*/
    int n;
    cin>>n;
    vll vec(n+1);
    rep1(i,1,n) cin>>vec[i];
    vll dp(n+1);
    dp[2]=abs(vec[1]-vec[2]);
    dp[1]=0;
    rep1(i,3,n){
        dp[i]=min(abs(vec[i-1]-vec[i])+dp[i-1],abs(vec[i-2]-vec[i])+dp[i-2]);
    }
    cout<<dp[n]<<endl;

     return 0;

}
///Alhamdulillah



Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>













const int N=2e5+10;
int n,a[N],b[N];

void solve()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=n,j=1;i>=1;i-=2,j++)b[j]=a[i];
	for(int i=n-1,j=n;i>=1;i-=2,j--)b[j]=a[i];
	for(int i=1;i<=n;i++)cout<<b[i]<<" ";
	cout<<"\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <map>

using namespace std;

int main() {
    int n;
    multimap<int,int> mp;
    while ( cin>>n,n!=0 ) {
        mp.clear();
        for ( int i=0; i<n; i++ ) {
            int a,b;
            cin>>a>>b;
            mp.insert(make_pair(b,a));
        }
        int s=0;
        bool f=true;
        for ( auto p: mp ) {
            s+=p.second;
            if ( p.first<s ) {
                f=false;
            }
        }
        cout<<(f?"Yes":"No")<<endl;
    }
}

Measured memory_bytes: 2984
import copy

class Cards:
    value = 0
    suit = ""

    def __init__(self,su,val):
        self.suit = su
        self.value = val
    
    def __str__(self):
        return f"{self.suit}{self.value}"

    def __eq__(self,other):
        if not isinstance(other, Cards):
            return NotImplemented
        
        return self.value == other.value and self.suit == other.suit


def cards_stablesort(C):
    lst = copy.deepcopy(C)
    n = len(lst)
    for i in range(1,n):
        j = i
        while(j > 0):
            if lst[j-1].value > lst[j].value:
                lst[j-1],lst[j] = lst[j],lst[j-1] #SWAP
                j -= 1
            else:
                break

    return lst

def cards_bubblesort(C):
    lst = copy.deepcopy(C)
    n = len(lst)

    for i in range(n):
        for j in range(n-1,i,-1):
            if lst[j].value < lst[j-1].value:
                lst[j],lst[j-1] = lst[j-1],lst[j]

    return lst

def cards_selectionsort(C):
    lst = copy.deepcopy(C)
    n = len(lst)

    for i in range(n):
        minj = i

        for j in range(i,n):

            if lst[j].value < lst[minj].value:
                minj = j
        
        lst[i],lst[minj] = lst[minj],lst[i]

    return lst
    


n = int(input())

l = input().split()

C = []
for cd in l:
    C.append(Cards(cd[:1],int(cd[1:])))

stable_list = cards_stablesort(C)
bubble_list = cards_bubblesort(C)
select_list = cards_selectionsort(C)

print(*bubble_list)

if stable_list == bubble_list:
    print("Stable")
else:
    print("Not stable")

print(*select_list)

if stable_list == select_list:
    print("Stable")
else:
    print("Not stable")





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

int main(void)
{
    int n;
    long long a[30] = {1, 2, 4};
    for (int i = 3; i < 30; i++) 
        a[i] = a[i - 1] + a[i - 2] + a[i - 3];
    while (cin >> n && n) 
        cout << 1 + a[n-1] / 3650 << endl;

    return 0;
}

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

using namespace std;

int n, m, r, l, q, w, total;
vector <int> v;
int cnt = 0, mn = 0, mx = 100000;

int main(){
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        cin >> l >> r;
        mn = max(l, mn);
        mx = min(r, mx);
    }
    total = mx - mn + 1;
    if(total < 0){
      cout << "0";
    } else {
      cout << total;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
						
#define fast_cin() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'
#define int long long
				
int32_t main() {
	fast_cin();  
	int n; cin >> n;
	cout << (1000 - (n % 1000)) % 1000;
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <map>
#include <string>

using namespace std;

int main(int argc, char const *argv[]) {
  string str;

  cin >> str;

  int total = 0;
  int flag = 0;

  for(auto it = str.begin(); it != str.end(); it++) {
    if(*it == 'S') flag++;
    if(flag == 0) total++;
    if(flag != 0 && *it == 'T') flag--;
  }

  cout << total + flag << endl;

  return 0;
}


Measured memory_bytes: 640
#include <map>
#include <iostream>

using namespace std;

class Dice
{

	const static int NUM_S = 6;
	int a[NUM_S];

public:
	Dice(void) {}

	void set(int _a[]) {
		a[0] = _a[0];
		a[1] = _a[1];
		a[2] = _a[2];
		a[3] = _a[3];
		a[4] = _a[4];
		a[5] = _a[5];
	}

	bool isEqual(int _a[]) {
		return a[0] == _a[0] && a[1] == _a[1] &&
			a[2] == _a[2] && a[3] == _a[3] &&
			a[4] == _a[4] && a[5] == _a[5];
	}

	int rs(void) {
		int tmp = a[1];
		a[1] = a[0]; a[0] = a[4];
		a[4] = a[5]; a[5] = tmp;
		return a[0];
	}

	int re(void) {
		int tmp = a[0];
		a[0] = a[3]; a[3] = a[5];
		a[5] = a[2]; a[2] = tmp;
		return a[0];
	}

	int rn(void) {
		int tmp = a[1];
		a[1] = a[5]; a[5] = a[4];
		a[4] = a[0]; a[0] = tmp;
		return a[0];
	}

	int rw(void) {
		int tmp = a[0];
		a[0] = a[2]; a[2] = a[5];
		a[5] = a[3]; a[3] = tmp;
		return a[0];
	}

};

int main()
{
	Dice dc;
	int st[6];
	cin >> st[0] >> st[1] >> st[2] >> st[3] >> st[4] >> st[5];
	dc.set(st);

	cin >> st[0] >> st[1] >> st[2] >> st[3] >> st[4] >> st[5];
	bool ans = false;

	ans = dc.isEqual(st);
	if ( ! ans) {
		dc.rs();
		ans = dc.isEqual(st);
	}
	if ( ! ans) {
		dc.rs();
		ans = dc.isEqual(st);
	}
	if ( ! ans) {
		dc.rs();
		ans = dc.isEqual(st);
	}
	if ( ! ans) {
		dc.rw();
		ans = dc.isEqual(st);
	}
	if ( ! ans) {
		dc.rs();
		ans = dc.isEqual(st);
	}
	if ( ! ans) {
		dc.rs();
		ans = dc.isEqual(st);
	}
	if ( ! ans) {
		dc.rs();
		ans = dc.isEqual(st);
	}
	if ( ! ans) {
		dc.rw();
		ans = dc.isEqual(st);
	}
	if ( ! ans) {
		dc.rs();
		ans = dc.isEqual(st);
	}
	if ( ! ans) {
		dc.rs();
		ans = dc.isEqual(st);
	}
	if ( ! ans) {
		dc.rs();
		ans = dc.isEqual(st);
	}
	if ( ! ans) {
		dc.re();
		ans = dc.isEqual(st);
	}
	if ( ! ans) {
		dc.rs();
		ans = dc.isEqual(st);
	}
	if ( ! ans) {
		dc.rs();
		ans = dc.isEqual(st);
	}
	if ( ! ans) {
		dc.rs();
		ans = dc.isEqual(st);
	}
	if ( ! ans) {
		dc.re();
		ans = dc.isEqual(st);
	}
	if ( ! ans) {
		dc.rs();
		ans = dc.isEqual(st);
	}
	if ( ! ans) {
		dc.rs();
		ans = dc.isEqual(st);
	}
	if ( ! ans) {
		dc.rs();
		ans = dc.isEqual(st);
	}
	if ( ! ans) {
		dc.rw();
		ans = dc.isEqual(st);
	}
	if ( ! ans) {
		dc.rs();
		ans = dc.isEqual(st);
	}
	if ( ! ans) {
		dc.rs();
		ans = dc.isEqual(st);
	}
	if ( ! ans) {
		dc.rs();
		ans = dc.isEqual(st);
	}

	if (ans)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}



Measured memory_bytes: 3128
n = int(input())
A = sorted(map(int, input().split()))
MOD = 10 ** 9 + 7
if n % 2:
    if A[0] != 0:
        print(0)
        exit()
    for i in range(1, n-1, 2):
        if A[i] != i + 1 or A[i] != A[i+1]:
            print(0)
            exit()
else:
    for i in range(0, n-1, 2):
        if A[i] != i + 1 or A[i] != A[i+1]:
            print(0)
            exit()
M = (max(A) + 1) // 2
print(2 ** M % MOD)


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

int main(void) {
  int n;
  scanf("%d", &n);
  auto a = vector<int>(n);
  int xor_all = 0LL;
  for(int i = 0;i < n;++i) {
    scanf("%d", &a[i]);
    xor_all ^= a[i];
  }
  for(int i = 0;i < n;++i) {
    if(i != 0){
      printf(" ");
    }
    printf("%d", xor_all ^ a[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 3964
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	string s;
	cin>>n>>s;
	if (n%2!=0)
	{
		cout<<"No"<<endl;
	}
	else
	{
		bool f=1;
		for (int i=0,j=n/2;j<n;j++,i++)
			if (s[i]!=s[j])
			{
				f=0;
				break;
			}
		if (f==0)
			cout<<"No"<<endl;
		else
			cout<<"Yes"<<endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 256
/**
 * Author: AcFunction
 * Date:   2019-09-04 21:48:14
 * Email:  3486942970@qq.com
**/

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ull unsigned long long
#define db double
#define ldb long double 

#define fi first
#define se second
#define MP make_pair
#define pii pair <int, int>
#define pil pair <int, ll> 
#define pli pair <ll, int>
#define pll pair <ll, ll>  

#define All(x) x.begin(), x.end()
#define pb push_back
#define pf push_front

#define ms0(x) memset(x, 0, sizeof(x))
#define ms1(x) memset(x, -1, sizeof(x))

#define oiu cerr << "Yes!" << endl; 
#define O(x) cerr << #x << ": " << x << endl;  

template <typename T> void printarr(T a[], int b, int e) {
  if(b > e) return ; 
  for(int i = b; i < e; i++) cout << a[i] << " "; 
  cout << a[e] << " " << endl; 
} 

template <typename T> int chkmax(T &x, const T &y) {
  return x < y ? x = y, 1 : 0; 
}

template <typename T> int chkmin(T &x, const T &y) {
  return x > y ? x = y, 1 : 0; 
}

const int N = 2000100; 
const int mod = 998244353; 

int n, m;
int fac[N], ivf[N]; 

int addp(int x, int y) {
  return (x += y) >= mod ? x - mod : x; 
}

int fpw(int x, int k, int p) {
  int ret = 1; 
  while(k) {
    if(k & 1) ret = 1ll * ret * x % p; 
    x = 1ll * x * x % p; k >>= 1; 
  }
  return ret; 
}

void prework() {
  fac[0] = 1; 
  for(int i = 1; i < N; i++) fac[i] = 1ll * fac[i - 1] * i % mod; 
  ivf[N - 1] = fpw(fac[N - 1], mod - 2, mod); 
  for(int i = N - 2; i >= 0; i--) ivf[i] = 1ll * ivf[i + 1] * (i + 1) % mod; 
}

int C(int x, int y) {
  if(x < y) return 0; 
  return 1ll * fac[x] * ivf[x - y] % mod * ivf[y] % mod; 
}

int calc(int len, int S) {
  int ret = 0; 
  for(int i = 0; i <= min(min(m, len), S); i++) {
    if((S - i) % 2 != 0) continue ; 
    ret = addp(ret, 1ll * C(len, i) * C(len + (S - i) / 2 - 1, len - 1) % mod); 
  }
  return ret; 
}

int main() {
  prework(); 
  scanf("%d %d", &n, &m); 
  printf("%d\n", addp(calc(n, 3 * m), mod - 1ll * n * addp(calc(n, m), mod - calc(n - 1, m)) % mod)); 
  return 0; 
}


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

int main() {
  int A,B,C;
  cin >> A >> B >> C ;
  
  if ( C > A - B ){
  cout << C - ( A - B ) << endl;
  }
  
  else if ( C <= A - B ){
    cout << 0 << endl;
  }
  
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

//////////////////////////

int main(){fastio
    ll n,m,x;cin>>n>>m>>x;
    ll c[n];
    ll a[n][m];
    rep(i,0,n-1){
        cin>>c[i];
        rep(j,0,m-1)cin>>a[i][j];
    }
    ll ans=inf;
    rep(i,0,(1<<n)-1){
        ll sum[m];memset(sum,0,sizeof(sum));
        ll cos=0;
        rep(j,0,n-1){
            if((i>>j)&1){
                rep(k,0,m-1)sum[k]+=a[j][k];
                cos+=c[j];
            }
        }
        bool f=true;
        rep(j,0,m-1){
            if(sum[j]<x)f=false;
        }
        
        if(f){
            chmin(ans,cos);
        }
    }
    
    if(ans==inf)ans=-1;
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 3588
int main(int argc, const char * argv[]) {
    int a,b,c,count;
    int i=1;
    scanf("%d %d %d",&a,&b,&c);
    if(1<=a&&a<=10000&&1<=b&&b<=10000&&1<=c&&c<=10000){
        if(a<=b){
            for(i=a;i<=b;i++){
                if(c%i==0){
                    count++;
                }
            }
        }
    }printf("%d\n",count);
        return 0;
}

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

int main() {
    double A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    double ans_water = 0, ans_sugar = 0, ans_p = 0, max_p = 100 * E / (100 + E);
    for (int a = 0; 100 * A * a < F + 1; a++) {
        for (int b = 0; 100 * (A * a + B * b) < F + 1; b++) {
            for (int c = 0; 100 * (A * a + B * b) + c < F + 1; c++) {
                for (int d = 0; 100 * (A * a + B * b) + (C * c + D * d) < F + 1; d++) {
                    double water = 100 * (A * a + B * b);
                    double sugar = C * c + D * d;
                    double sum = water + sugar;
                    double p = 100 * sugar / sum;
                    if (ans_p <= p && p <= max_p) {
                        ans_p = p;
                        ans_water = water;
                        ans_sugar = sugar;
                    }
                }
            }
        }
    }
    cout << ans_water + ans_sugar << " " << ans_sugar << endl;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
from collections import deque
q=deque([(-1,0,-2,0)])
ans=-10**18
for i,a in enumerate(A):
    d={}
    while q and q[0][0]<i:
        j,n,r,x=q.popleft()
        if r<-1:
            if n==N//2-1:
                ans=max(ans,x+a)
            elif n not in d:
                d[n]=x
            elif d[n]<x:
                d[n]=x
        if (j+1)//2<=n:
            q.append((i,n,r-1,x))
    for n,x in d.items():
        q.append((i,n+1,-1,x+a))
print(ans)

Measured memory_bytes: 94632
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main(){
   string s,t;
   cin >> s>>t;
   int a,b;
   cin >> a >> b;
   string u;
   cin >>u;

   if(s == u)a--;
   else b--;
   cout << a<<" "<<b<<endl;
   return 0;
}




Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#include <cassert>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
#define vi vector<int>
using namespace std;
using ll = long long;

const int MAX = 1000000;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

struct s{
  int p,i,r;
};

//比較関数（降順）
bool cmpP(const s &a, const s &b){
  return a.p > b.p;
}

//比較関数（昇順）
bool cmpI(const s &a, const s &b){
  return a.i < b.i;
}

int tax(int p, int x){
  return p*(100+x)/100;
}

int X,Y,S;

int solve() {
  int answer=0;
  for(int i=1; i<S; i++){
    for(int j=1; j<S; j++){
      if (tax(i,X)+tax(j,X)==S){
        answer=max(answer,tax(i,Y)+tax(j,Y));
      }
    }
  }
  return answer;
}

int main()
{

  //cout << fixed << setprecision(10);
  while (cin >> X >> Y >> S && X>0){
    cout << solve() << endl;
  }


  return 0;
}



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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    sort(p.begin(),p.end());
    int ret = 0;
    for (int i = 0; i < k; i++) {
        ret += p[i];
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) 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 operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	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;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////

bool cmp(pair<ll, ll> x, pair<ll, ll> y) {
	return (x.first - 1) * y.second > (y.first - 1) * x.second;
}

int main() {
	ll N, T;
	cin >> N >> T;


	vector<ll> a(N + 1), b(N + 1);
	vector<pair<ll, ll>> p;
	vector<ll> q;

	repn(i, N) {
		cin >> a[i] >> b[i];
		if (a[i] > 0) {
			p.push_back({ a[i] + 1,a[i] + b[i] + 1 });
		}
		else {
			q.push_back(b[i] + 1);
		}
	}

	ll M = p.size();
	sort(p.begin(), p.end(), cmp);
	//rep(i, M) cout << p[i].first <<" "<< p[i].second<< endl;

	vector<vector<ll>> dp(M + 1, vector<ll>(40, T+1));
	rep(i, M+1) dp[i][0] = 0;

	repn(i, M)repn(j, 39) {
		dp[i][j] = min(dp[i - 1][j], p[i - 1].first*dp[i - 1][j - 1] + p[i - 1].second);
		if (dp[i][j] > T) { dp[i][j] = T + 1; }
		//else { cout << i << j <<" "<< dp[i][j] << endl; }
	}

	ll L = q.size();
	sort(q.begin(), q.end());

	ll ans = 0;

	rep(j, 40) {
		
		if (dp[M][j] > T) { continue; }
		
		ll c = 0;
		while (c<L&&dp[M][j] + q[c] <= T) {
			dp[M][j] += q[c];
			c++;
		}
		

		ans = max(j+c, ans);
	}

	cout << ans;

	


	
	system("PAUSE");
}


Measured memory_bytes: 77164
n = int(input())
A = [int(i) for i in input().split()]
B = A.copy()
B.sort()
ans = 0
for i in B:
    ixB = B.index(i)
    counter = 0
    while(True):
        ixA = A.index(i)
        if ixA == ixB:
            break
        else:
            counter += 1
            num = B[ixA]
            ixN = A.index(num)
            A[ixA],A[ixN] = A[ixN],A[ixA]
            ans += A[ixA] + A[ixN]
    tmp = (B[0] - i)*counter + (B[0]+i)*2
    if tmp < 0:
        ans += tmp
print(ans)


Measured memory_bytes: 5624
#include<iostream>
using namespace std;
bool flag;
int w,h,x,y,r;
char ans[2][10]={
    "No",
    "Yes"
};
int solve(){
    if(x<=0||y<=0)return flag=0;
    if(r>h-r||r>w-r)return flag=0;
    if(x>=r&&x<=w-r){
        if(y>=r&&y<=h-r)return flag=1;
    }
    return flag=0;
}
int main()
{
    flag=0;

    cin>>w>>h>>x>>y>>r;
    solve();
    cout<<ans[flag]<<endl;
}

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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

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

// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vec x(n), y(n);
    init(x, y);
    if (n == 1) {
        print(1);
        return 0;
    }
    map<P, int> mp;
    rep (i, n) {
        rep (j, n) {
            if (i == j) continue;
            P p = {x[j] - x[i], y[j] - y[i]};
            mp[p]++;
        }
    }

    int ma = -INF;
    repall (d, mp)
        ma = max(ma, d.second);
    print(n - ma);

    return 0;
}


Measured memory_bytes: 384
from heapq import heappush, heappop

X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

h = []
minus_value = -(A[0] + B[0] + C[0])
heappush(h, (minus_value, 0, 0, 0))
searched = set()
cnt = 0
while cnt < K:
    minus_value, ia, ib, ic = heappop(h)
    if (ia, ib, ic) in searched:
        continue
    cnt += 1
    searched.add((ia, ib, ic))
    print(-minus_value)
    if ia < X - 1:
        heappush(h, (minus_value + A[ia] - A[ia + 1], ia + 1, ib, ic))
    if ib < Y - 1:
        heappush(h, (minus_value + B[ib] - B[ib + 1], ia, ib + 1, ic))
    if ic < Z - 1:
        heappush(h, (minus_value + C[ic] - C[ic + 1], ia, ib, ic + 1))


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

using namespace std;

const int mod = 1e9 + 7;

vector<int> cnt(1e3 + 1, 1);

int calc(int t)
{
	int i = 2;
	while (1 < t)
		if (t % i == 0)
		{
			cnt[i]++;
			t /= i;
		}
		else
			i++;
	return 0;
}

int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
		calc(i);
	long long ans = 1;
	for (int i = 1; i <= n; i++)
		ans = ans * cnt[i] % mod;
	cout << ans << 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;
    int N_t=C/B;
    int N_a=A/D;
    if (A-N_a*D>0) N_a++;
    if (C-N_t*B>0) N_t++;

    if (N_t<=N_a) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

# 方針：二分探索

# 最後の一匹になれれば True
def check(mid, A):
    x = A[mid]

    # 自分以下を全て吸収
    for i in range(mid):
        x += A[i]

    # 自分より大きいヤツを貪欲に吸収していって最後までいけたら True
    for i in range(mid+1, len(A)):
        if A[i] <= x*2:
            x += A[i]
        else:
            return False
    return True

def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.append(0) # 二分探索のため、確実に最後の一匹になれないヤツを入れておく
    A.sort()

    lb,ub = 0,N
    while ub - lb > 1:
        mid = (lb + ub)//2
        if check(mid, A):
            ub = mid
        else:
            lb = mid
    # lb が最後の一匹になれない最大のモンスター
    print(N-lb)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14572
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace atcorder_Nikkei_2019
{
    class Program
    {
        static void Main(string[] args)
        {
            int len = int.Parse(Console.ReadLine());
            List<string> dataList = new List<string>();

            for (int i = 0; i < 3; i++)
            {
                dataList.Add(Console.ReadLine());
            }

            int ret = 0;
            for (int i = 0; i < len; i++)
            {
                bool flg01 = false;
                bool flg02 = false;
                bool flg12 = false;
                if (dataList[0].Substring(i, 1) == dataList[1].Substring(i, 1)) flg01 = true;
                if (dataList[0].Substring(i, 1) == dataList[2].Substring(i, 1)) flg02 = true;
                if (dataList[1].Substring(i, 1) == dataList[2].Substring(i, 1)) flg12 = true;

                if (flg01 && !flg02) ret += 1;
                else if (flg02 && !flg01) ret += 1;
                else if (flg12 && !flg01) ret += 1;
                else if (!flg01 && !flg02 && !flg12) ret += 2;
            }

            Console.WriteLine(ret);

        }
    }
}


Measured memory_bytes: 11092
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	Scanner scan = new Scanner(System.in);
	
	private void compute() {
		int N = scan.nextInt();
		int K = scan.nextInt();
		
		int[] nums = new int[2000];
		
		long cnt = 0;
		
		for (int i=0;i<N;i++) {
			int num = scan.nextInt();
			nums[num-1]++;
			for (int j=num;j<2000;j++) {
				cnt += nums[j];
			}
		}
		
		long cnt2 = 0;
		int remain = N;
		
		for (int i=2000-1;i>=0;i--) {
			remain -= nums[i];
			cnt2 += remain * nums[i];
		}
		
		long ans = (cnt+0l) * K + cnt2 * ((K-1l) * K / 2l % 1000000007l);
		ans %= 1000000007l;
		
		System.out.println(ans);
	}
	
	public static void main(String...arg) {
		new Main().compute();
	}

}


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

int main() {
  string S;
  int K;
  cin >> S >> K;
  int N = S.size();
  vector<vector<vector<int>>> DP(N + 1, vector<vector<int>>(K + 1, vector<int>(2)));
  DP.at(0).at(0).at(0) = 1;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < 2; k++) {
        int d = S.at(i) - '0';
        for (int nd = 0; nd < 10; nd++) {
          int ni = i + 1, nj = j, nk = k;
          if (!k) {
            if (nd > d) continue;
            if (nd < d) nk = 1;
          }
          if (nd) nj++;
          if (nj > K) continue;
          DP.at(ni).at(nj).at(nk) += DP.at(i).at(j).at(k); 
        }
      }
    }
  }
  cout << DP.at(N).at(K).at(0) + DP.at(N).at(K).at(1) << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
using Graphl = vector<vector<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define FOR(itr, v) for (auto itr = (v).begin(); itr != (v).end(); ++itr)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
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<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const long long minusINF = -(1LL << 40);
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};


int main()
{
    int n; cin >> n;
    vector<int> c;
    c.push_back(1);
    for (int i = 6; i <= n; i *= 6) c.push_back(i);
    for (int i = 9; i <= n; i *= 9) c.push_back(i);

    vector<ll> dp(110000, INF);
    dp[0] = 0;
    rep(i, n + 1)
    {
        rep(j, c.size())
        {
            if (i >= c[j])
            {
                chmin(dp[i], dp[i - c[j]] + 1);
            }
        }
    }
    // rep(i, n + 1)
    // {
    //     cout << dp[i] << " ";
    //     if (i == n) cout << endl;
    // }

    cout << dp[n] << endl;
}

Measured memory_bytes: 4048
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
#define lun(x) (int)x.size()
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<60);
const int inf=(1<<30);
const int nmax=1e7+50;
const ll mod=1e9+7;
using namespace std;
int n,lp[nmax],l,x,nr,cur,i,j;
ll rs;
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n;
	lp[1]=1;
	for(i=2;i<=n;i++)
	{
		if(lp[i])continue;
		lp[i]=i;
		for(j=2*i;j<=n;j+=i)if(!lp[j])lp[j]=i;
	}
	for(i=1;i<=n;i++)
	{
		nr=1;
		x=i,cur=0,l=-1;
		while(lp[x]!=1)
		{
			if(lp[x]!=l)
			{
				l=lp[x];
				nr*=(cur+1);
				cur=1;
			}
			else cur++;
			x/=lp[x];
		}
		nr*=(cur+1);
		rs+=1LL*nr*1LL*i;
	}
	cout<<rs<<endl;
	return 0;
}


Measured memory_bytes: 42680
use proconio::input;
fn main() {
    input! {
      n: usize
    }

    let mut count = 0;
    for _ in 0..n {
        input! {
          a: usize,
          b: usize
        }
        if a == b {
            count += 1;
            if count == 3 {
                println!("Yes");
                return;
            }
        } else {
            count = 0;
        }
    }
    println!("No");
}


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



//“Remember, Hope is a good thing, maybe the best of things, and no good thing ever dies.”

//― Stephen King

const int MOD = 1e9 + 7;
#define ll long long int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define eb emplace_back
#define in insert
#define ff first
#define ss second
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define si set<int>
#define mpii map<int, int>
#define prq priority_queue
#define sz(s) (int) s.size()
#define pf(a) printf("%d ",a)
#define si1(a) scanf("%d",&a)
#define si2(a,b) scanf("%d%d",&a,&b)
#define si3(a,b,c) scanf("%d%d%d",&a,&b,&c)
//#define scan(v) for(int i = 0; i<n; i++){int x;cin>>x;v.pb(x);}
#define pi 2 * acos (0.0)
#define inf 1e9
#define co cout
#define en '\n'
#define re return
#define con continue
#define dbg cout<<"___________ok____________"<<endl;
#define yes() printf("YES\n")
#define no() puts("NO\n")
#define FOR(i, j, k) for(int i=(j); i<(k); i++)
#define REV(i, j, k) for(int i=(n-1); i>=k; i--)
#define all(v) v.begin(), v.end()
#define unq(a) sort(all(a)), a.erase(unique(all(a)),a.end())
#define rnd(a, b) ((((rand()<<15)^rand())%((b)-(a) + 1))+(a))
#define FAST_IO ios_base::sync_with_stdio(false),cin.tie(NULL)
#define mem(x, y) memset(x, y, sizeof(x))
#define prn(v) for(auto x: v)cout<<x<<" ";
const double EPS = 1e-9;
const int MXX = 4e3 + 5;


int main ()
{
    FAST_IO;
    string s, t;
    cin>>s>>t;;
    int ans = inf + 7;
    int n = sz(s);
    for(int i = 0; i<sz(s); i++)
    {
        if(i + sz(t)>n)break;
        string curr = "";
        FOR(j, i, i + sz(t))
        {
            curr+=s[j];
        }
       // co<<curr<<en;
        //con;
        int cnt = 0;
        FOR(j, 0, sz(t))
        {
            if(curr[j]!=t[j])cnt++;
        }
        ans = min(ans, cnt);
    }
    co<<ans<<en;
    return 0;
}


Measured memory_bytes: 3664
#include "bits/stdc++.h"
using namespace std;
double Distance(double x1, double x2, double y1, double y2) {
	double dis1 = (x1 - x2) * (x1 - x2), dis2 = (y1 - y2) * (y1 - y2);
	double ans = sqrt(dis1 + dis2);
	return ans;
}
int main() {
	double N;
	cin >> N;
	vector<double>P(N);
	for (double i = 0; i < N; i++) {
		P.at(i) = i;
	}
	vector<double>X(N), Y(N);
	for (double i = 0; i < N; i++) {
		cin >> X.at(i) >> Y.at(i);
	}
	double ans = 0;
	int num = 0;
	do {
		double sum = 0;
		for (double i = 1; i < N; i++) {
			sum += Distance(X.at(P.at(i)), X.at(P.at(i - 1)), Y.at(P.at(i)), Y.at(P.at(i - 1)));
		}
		ans += sum;
		num++;
	} while (next_permutation(P.begin(), P.end()));
	ans /= num;
	printf("%.10lf\n", ans);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int s = sc.nextInt();
			int a = s / 100;
			int b = s % 100;

			if ((a == 0 && b == 0) || (a == 0 && b > 12) || (a > 12 && b == 0) || (a > 12 && b > 12)) {
				System.out.println("NA");
			} else if ((a == 0 || a > 12) && 1 <= b && b <= 12) {
				System.out.println("YYMM");
			} else if (1 <= a && a <= 12 && (b == 0 || b > 12)) {
				System.out.println("MMYY");
			} else if (1 <= a && a <= 12 && 1 <= b && b <= 12) {
				System.out.println("AMBIGUOUS");
			}
		}
	}
}

Measured memory_bytes: 21844