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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int n;
  cin >> n;
  multiset<ll> mst;
  ll res = 0;
  rep(i,n){
    ll x;cin >> x;
    mst.insert(x);
  }
  for(ll i = 32;i > 0;i--){
    ll f = *mst.begin();
    for(auto iter = mst.begin();iter != mst.end();){
      f = *iter;
      auto au = mst.find((1ll << i)-f);
      if(au == mst.end()){
        iter++;
        continue;
      }
      if(au == iter){
        au++;
        if(au == mst.end() || (au != mst.end() && (*au) != (*iter))){
          iter++;
          continue;
        }
      }
      res++;
      mst.erase(iter);
      mst.erase(au);
      iter = mst.lower_bound(f);
    }

  }
  cout << res << endl;
  

  return 0;
}


Measured memory_bytes: 12920
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll A,B;
    cin>>A>>B;
    ll gcd = __gcd(A,B);
    int c=0;
    for(ll i=2; i*i<=gcd; i++)
    {
        if(gcd%i==0)
        {
            while(gcd%i==0)gcd/=i;
            c++;
        }
    }
    if(gcd>1)c++;
    cout<<c+1<<endl;
}


Measured memory_bytes: 384
from bisect import bisect,bisect_left,insort
dic = {}
l = []
for i in range(int(input())):
    order = list(input().split())

    if order[0] == "0":
        if order[1] in dic:
            dic[order[1]] = int(order[2])
        else:
            dic[order[1]] = int(order[2])
            insort(l,order[1])
    elif order[0] == "1":
        if order[1] in dic:
            print(dic[order[1]])
        else:
            print(0)
    elif order[0] == "2":
        if order[1] in dic:
            dic[order[1]] = 0
    elif order[0] == "3":
        L = bisect_left(l,order[1])
        R = bisect(l,order[2])
        for i in range(L,R):
            if dic[l[i]]:
                print(l[i],dic[l[i]])


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

using namespace std;

struct point {
    int left, right, block, id;
};

bool cmp(const point &lhs, const point &rhs) {
    if (lhs.block < rhs.block)
        return true;
    else if (lhs.block > rhs.block)
        return false;
    else
        return lhs.right < rhs.right;
}

int main(){
    int n, q;
    scanf("%d", &n);
    scanf("%d", &q);
    vector<int> A(n);
    for (int i = 0; i < n; i++)
        scanf("%d", &A[i]);

    int block_size = sqrt(n);

    
    vector<point> query(q);
    for (int i = 0; i < q; i++) {
        scanf("%d %d", &query[i].left, &query[i].right);
        query[i].left--, query[i].right--;
        query[i].block = query[i].left / block_size;
        query[i].id = i;
    }

    sort(query.begin(), query.end(), cmp);

    vector<int> solution(q);
    vector<int> hash(1000100);

    int left = 0, right = 0, answer = 1;
    hash[A[0]] = 1;

    for (const point &task : query) {
        while (left < task.left) {
            hash[A[left]]--;
            answer -= (hash[A[left]] == 0);
            left++;
        }
        while (left > task.left) {
            left--;
            hash[A[left]]++;
            answer += (hash[A[left]] == 1);
        }
        while (right < task.right) {
            right++;
            hash[A[right]]++;
            answer += (hash[A[right]] == 1);
        }
        while (right > task.right) {
            hash[A[right]]--;
            answer -= (hash[A[right]] == 0);
            right--;
        }
        solution[task.id] = answer;
    }

    for (int answer : solution)
        printf("%d\n", answer);

    return 0;
}

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

int main() {
  std::string s;
  std::cin >> s;
  std::vector<long> ansVec(s.size());

  long rCounter = 0;
  for (long i = 0; i < (long)s.size(); ++i) {
    if (s[i] == 'R') {
      ++rCounter;
      if (s[i + 1] == 'L') {
        ansVec[i] += (rCounter + 1) / 2;
        ansVec[i + 1] += rCounter / 2;
        rCounter = 0;
      }
    }
  }

  long lCounter = 0;
  for (long i = s.size() - 1; i >= 0; --i) {
    if (s[i] == 'L') {
      ++lCounter;
      if (s[i - 1] == 'R') {
        ansVec[i] += (lCounter + 1) / 2;
        ansVec[i - 1] += lCounter / 2;
        lCounter = 0;
      }
    }
  }

  std::cout << ansVec[0];
  std::for_each(ansVec.begin() + 1, ansVec.end(), [](auto x){
    std::cout << ' ' << x;
  });
  std::cout << std::endl;

  return 0;
}

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

int m_k(int A,int k){
  if(A < k){
    return 0;
  }
  else{
    return (A/k)%10;
  }
}

int main(){
  int n;
  cin >> n;
  int i;
  int c = 100000;
  for(i=1;i<=n/2;i++){
    int A = i;
    int B = n - i;
    int a = m_k(A,1) + m_k(A,10) + m_k(A,100) + m_k(A,1000) + m_k(A,10000);
    int b = m_k(B,1) + m_k(B,10) + m_k(B,100) + m_k(B,1000) + m_k(B,10000);
    if(a+b < c){
      c = a+b;
    }
  }
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <climits>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,int> P1;
typedef pair<P,P> P2;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

#define INF 1000000000
#define mod 1000000007
#define MAX5 100001

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

// cout << setfill('0') << setw(5) << number < endl;
// while(getline(cin, s)) { .. } | `s` is a string


const int N = 10000000;
// int lp[N+1];
// vector<int> pr;

// void si() {
// 	for (int i=2; i<=N; ++i) {
// 	    if (lp[i] == 0) {
// 	        lp[i] = i;
// 	        pr.push_back (i);
// 	    }
// 	    for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
// 	        lp[i * pr[j]] = pr[j];
// 	}
// }

// bool notPrime(int n) {
// 	auto iter = lower_bound(pr.begin(), pr.end(), n);
// 	return !(iter != pr.end() && *iter == n);
// }

// vector<int> pr;

// void sivOld() {
// 	std::vector<bool> primes(N, true);
// 	vector<char> is_prime(N+1, true);
// 	is_prime[0] = is_prime[1] = false;
// 	for (int i = 2; i <= N; i++) {
// 	    if (is_prime[i] && (long long)i * i <= N) {
// 	    	pr.push_back(i);
// 	        for (int j = i * i; j <= N; j += i)
// 	            is_prime[j] = false;
// 	    }
// 	}
// }

// int gcd(int a, int b) {
// 	while (b != 0) {
// 		int old_a = a;
// 		int old_b = b;

// 		a = old_b;
// 		b = old_a % old_b;
// 	}

// 	return a;
// }

// int returnPrime(int num, int a) {
// 	// cout << "?" << endl;
// 	for (int i = 0; i < pr.size(); ++i) {
// 		if (gcd(num, pr[i]) == 1 && gcd(a, pr[i]) == 1)
// 			return pr[i];
// 	}
// 	return -1;
// }


void solve() {
	int k;
	string x;
	cin >> k >> x;
	if (x.size() <= k)
		cout << x;
	else {
		for (int i = 0; i < k; ++i) {
			cout << x[i];
		}
		cout << "..." << endl;
	}
}

int main(){
	IOS;
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif
	    // return 0;
	    // cout << "gcd(10, 15) : " << gcd(1, 1) << endl;
	
	int t;
	solve();
}

/*
11 
4 4 
-2 -2 
-3 -4 
-1 3 
2 3 
-4 0 
1 1 
-1 -1 
3 -1 
-4 2 
-2 4
*/

















Measured memory_bytes: 3636
a,b,m=map(int,input().split())
list_a=list(map(int,input().split()))
list_b=list(map(int,input().split()))
ans=min(list_a)+min(list_b)
for i in range(m):
  A,B,C=map(int,input().split())
  ans=min(ans,list_a[A-1]+list_b[B-1]-C)
  
print(ans)

Measured memory_bytes: 18612
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define	IPSILON	1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  ll W, H, x, y;
  cin >> W >> H >> x >> y;;
  int method;
  if(fabs((double)W/2- x) < IPSILON  && fabs((double)H/2- y) < IPSILON){
    method = 1;
  }else{
    method = 0;
  }
  double area = (double)(W*H)/2;
  cout << area << " " << method;
  return 0;
}

Measured memory_bytes: 256
use std::io;

fn read_line()-> String {
    let mut s = String::new();
    let _ = io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
	let s = read_line();
	let s = s.split("").collect::<Vec<&str>>();
	let mut vec = vec!();
	for i in 0..s.len() {
		if i % 2 != 0 {
			vec.push(s[i]);
		}
	}
	println!("{}",vec.join(""));
}


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

def main():
    n, m = map(int, input().split())
    A = []
    B = [''] * m
    for i in range(m):
        p, y = map(int, input().split())
        A += [[p, y, i]]
    A.sort()
    count = 0
    i, x = 1, 1
    for a in A:
        if a[0] == i:
            B[a[2]] = '{:06}{:06}'.format(a[0], x)
        else:
            i, x = a[0], 1
            B[a[2]] = '{:06}{:06}'.format(a[0], x)
        x += 1
    print('\n'.join(B))


if __name__ == '__main__':
    main()

Measured memory_bytes: 33836
/*Made by Shivam Solanki*/
#include<bits/stdc++.h> 
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define ll long long int
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<pii> vp;
typedef vector<pll> vpll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef set<int> sii;
typedef set<ll> sll;
typedef priority_queue<int> pq;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
typedef queue<int> qii;
#define rep(i,k,n) for (int i = k; i < n; ++i) 
#define repr(i,k,n) for (int i = n; i>=k; --i)
#define repll(i,k,n) for (ll i = k; i < n; ++i) 
#define repllr(i,k,n) for (ll i = n; i >= k; --i) 
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int INF = 1e9+5;
const int MOD = 1e9+7;
 
void solve(){
	int a,b,c;
	cin>>a>>b>>c;
	sii s;
	s.insert(a);
	s.insert(b);
	s.insert(c);
	cout<<(s.size()==2?"Yes\n":"No\n");
}
    
int main(){
    // #ifndef ONLINE_JUDGE  
        // freopen("input.txt", "r", stdin); 
        // freopen("output.txt", "w", stdout); 
    // #endif 
    // fastio;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;

int main(){
    ll n,k;
    cin>>n>>k;
    ll cnt=n/k;
    ll c=cnt+1;
    cout<<min(abs(n-k*cnt),abs(n-c*k))<<endl;
    }
//ペナルティ出しても焦らない　ACできると信じろ！！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
(全探索できるなら全探索しろ)
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'\n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え(=でもエラー出ない)
*/

Measured memory_bytes: 256
#pragma comment(linker, "/STACK:102400000,102400000") 
#pragma warning(disable:4996)
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define eps 1e-10
#define LL_INF 0x33ffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int maxn = 2e5 + 1;
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);

ll po(ll x, ll y)
{ 
	ll res = 1; 
	x %= mod;
	while (y)
	{
		if (y & 1)
			res = res*x%mod;
		x = x*x%mod;
		y >>= 1;
	}
	return res;
}

ll fac[maxn], inv[maxn];
void init()
{
	int i, j, k;
	fac[0] = 1;
	inv[0] = 1;
	int up = 2e5;
	for (i = 1; i <= up; i++)
	{
		fac[i] = fac[i - 1] * i%mod;
		inv[i] = po(fac[i], mod - 2);
	}
}

int h, w, x, y;
ll c(ll x, ll y)
{
	return fac[x] * inv[y] % mod*inv[x - y] % mod;
}

void solve()
{
	sa(h), sa(w), sa(x), sa(y);
	int i, j, k;
	int row = h - x;
	ll res = 0;
	int u, v;
	for (i = y + 1; i <= w; i++)
	{
		u = row, v = i;
		res = res + (c(u + v - 2, u - 1)*c(h + w - (u + 1 + v), h - u - 1)) % mod;
		res %= mod;
	}
	printf("%lld\n", res);
}

int main()
{

	init();
	solve();
	return 0;
}


Measured memory_bytes: 3328
#include<iostream>
using namespace std;
int main(){
	long long n; cin>>n;
	long long a[n+1], b[n]; for(int i=0; i<=n; i++) cin>>a[i];
	for(int i=0; i<n; i++) cin>>b[i];
	long long count=0;
	for(int i=0; i<n; i++){
		if(a[i]<=b[i]){
			count+=a[i];
			b[i]-=a[i]; a[i]=0;
			count+=min<long long>(a[i+1], b[i]);
			long long temp = a[i+1];
			a[i+1] = max<long long>(0, a[i+1]-b[i]); 
			b[i] = max<long long>(0, b[i]-temp);
		}
		else{
			count+=b[i];
			a[i]-=b[i]; b[i]=0;
		}
	}
//	for(int i=0; i<n; i++) cout<<a[i]<<' '<<b[i]<<endl;
	cout<<count<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int a[100005];
int dp[100005];
int n;
int inf = 1e9;
int solve(int i)
{
    if(i>=n)
    return inf;
    if(i==n-1)
    return 0;
    if(dp[i]!=-1)
    return dp[i];
    int ans = inf;
    ans = min(ans,abs(a[i]-a[i+1])+solve(i+1));
    ans = min(ans,abs(a[i]-a[i+2])+solve(i+2));
    return dp[i]=ans;
}
int main() {
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        dp[i]=-1;
    }
    cout<<solve(0);
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  string S; cin >> S;
  string result = (S[2]==S[3]&&S[4]==S[5]) ? "Yes" : "No";
  cout << result << endl;
  return 0;
}

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

#define vi vector<int>
#define p pair<int, int>
#define REP(i, n) for(int i = 0;i < n; i++)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define BR cout << endl;
#define INF  2000000000

int main(){
    int c[10][10], h, w, a[200][200], mc[10], d[10];

    cin >> h >> w;
    REP(i, 10) REP(j, 10){
        cin >> c[i][j];
    }
    REP(i, h) REP(j, w){
        cin >> a[i][j];
    }
    REP(k, 10){
    REP(i, 10) mc[i] = INF;
    mc[k] = 0;
    while(1){
        bool f = false;
        REP(i, 10) REP(j, 10){
            if(mc[i] != INF && mc[j] > mc[i] + c[i][j]){
                mc[j] = mc[i] + c[i][j];
                f = true;
            }
        }
        if(!f) break;
    }
    d[k] = mc[1];
    }
    int ans = 0;
    REP(i, h) REP(j, w) if(a[i][j] != -1) ans += d[a[i][j]];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
	public static void main(String[] args) {  
  		Scanner sc = new Scanner(System.in);
		int hour = sc.nextInt();
      	int price1 = sc.nextInt();
      	int price2 = sc.nextInt();
      	price1 *= hour;
      	
      	if(price1 < price2) {
        	System.out.println(price1); 
        } else {
          	System.out.println(price2); 
        }
    }
}

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

int main()
{

  int n;
  int x[105];
  int sum, ans = 100000007;

  cin >> n;

  for(int i=0; i<n; i++) cin >> x[i];

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

    sum = 0;

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

      sum = sum + ( (x[j] - i) * (x[j] - i));

    }

    ans = min(ans, sum);

  } 

  cout << ans << endl;

  return 0;

}


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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 10;
const int maxK = 1e5 + 10;
const ll mod = 1e9 + 7;

int n, k;
//f(i): number of sequence of length n consisting of integers from 1 to i having gcd equal 1.
ll f[maxK], ans = 0;

ll power(ll a, ll b)
{
    ll r = 1;
    while (b)
    {
        if (b & 1)
        {
            r = r * a % mod;
        }
        b /= 2;
        a = a * a % mod;
    }
    return r;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> k;
    for1(i, k)
    {
        //calculating number of sequence of length n consisting of integers from 1 to i having some values equal i
        f[i] = (f[i] + power(i, n) - power(i - 1, n) + mod) % mod;
        for (int j = i * 2; j <= k; j += i)
        {
            f[j] = (f[j] - f[i] + mod) % mod;
        }
    }
    //then calculate prefix sum
    for1(i, k)
    {
        f[i] = (f[i] + f[i - 1]) % mod;
    }
    //fix GCD value
    for1(g, k)
    {
        ans += g * f[k / g] % mod;
        ans %= mod;
    }
    cout << ans;
    return 0;
}


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

int main(){
  char s[11];
  cin >>s;
  int m=0;
  int count=0;
  for(int i=0;i<10;i++){
    if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
      count++;
    }else{
      count = 0;
    }
    m = max(m,count);
  }
  cout<<m<<endl;
}
      

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int ans = 0;
	string w, t;
	cin >> w;
	transform(w.begin(), w.end(), w.begin(), ::tolower);
	while (1) {
		cin >> t;
		if (t.find("END_OF_TEXT", 0) != string::npos)
			break;
		transform(t.begin(), t.end(), t.begin(), ::tolower);
		if (t == w)
			ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1184
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		boolean[][] map;
		while(scan.hasNext()){
			int n = scan.nextInt();
			if(n == 0){
				break;
			}
			map = new boolean[21][21];
			for(int i = 0;i < n;i++){
				map[scan.nextInt()][scan.nextInt()] = true;
			}
			int m = scan.nextInt();
			int x = 10;
			int y = 10;
			int t = 0;
			int count = 0;
			for(int i = 0;i < m;i++){
				String op = scan.next();
				t = scan.nextInt();
				if(op.equals("N")){
					for(int j = 0;j < t;j++){
						if(checkTresure(map,x,++y)){
							count++;
						}
					}
				}else if(op.equals("S")){
					for(int j = 0;j < t;j++){
						if(checkTresure(map,x,--y)){
							count++;
						}
					}
				}else if(op.equals("E")){
					for(int j = 0;j < t;j++){
						if(checkTresure(map,++x,y)){
							count++;
						}
					}
				}else if(op.equals("W")){
					for(int j = 0;j < t;j++){
						if(checkTresure(map,--x,y)){
							count++;
						}
					}
				}
			}
			System.out.println((count==n)?"Yes":"No");
		}
	}
	public static boolean checkTresure(boolean[][] map,int x,int y){
		boolean a = (map[x][y])?true:false;
			map[x][y] = false;
		return a;
	}
}

Measured memory_bytes: 33008
# coding: utf-8

import sys
import math

import array
import bisect
import collections
from collections import Counter, defaultdict
import fractions
import heapq
import re

sys.setrecursionlimit(1000000)


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

def argsort(l, reverse=False):
    return sorted(range(len(l)), key=lambda i: l[i], reverse=reverse)

def argmin(l):
    return l.index(min(l))

def YESNO(ans, yes="YES", no="NO"):
    print([no, yes][ans])

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIS = lambda: input().split()


def main():
    M, K = MI()

    if M == 1 and K == 1:
        return -1
    if K >= 2**M:
        return -1
    if K == 0:
        ans = []
        for i in range(0, 2**M):
            ans.append(i)
            ans.append(i)
        return " ".join(map(str, ans))

    ans = []
    ans.append(K)
    for i in range(0, 2**M):
        if i != K:
            ans.append(i)
    ans.append(K)
    for i in range(2**M - 1, -1, -1):
        if i != K:
            ans.append(i)
    return " ".join(map(str, ans))


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 33996
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin >> n;
	int p[n]; rep(i,n) cin >> p[i];
	int mini = INF;
	int ans = 0;
	rep(i,n) {
		if(p[i] <= mini) ++ans;
		mini = min(mini, p[i]);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String n = sc.next();
		String ans = "";
		for(int i = 0; i < n.length(); i++) {
			if(n.substring(i, i + 1).equals("1")) {
				ans += "9";
			} else if(n.substring(i, i + 1).equals("9")){
				ans += "1";
			} else {
				ans += n.substring(i, i + 1);
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	int n, k;
	cin >> n >> k;
	if (n >= 2 * k - 1)
		cout << "YES\n";
	else
		cout << "NO\n";
	return 0;
}




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


int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	int a[33]={0,1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int n;
	cin>>n;
	cout<<a[n];
	
	
	
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1000000007;
int p(int A,int B){
  if(!B)return 1;
  if(B&1)return p(A,B-1)*A%mod;
  int C=p(A,B/2);
  return C*C%mod;
}
int k[2000100];
int C(int A,int B){
  return k[A+B]*p(k[A]*k[B]%mod,mod-2)%mod;
}
signed main(){
  k[0]=1;
  for(int i=1;i<=2000002;i++)k[i]=k[i-1]*i%mod;
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  c++,d++;
  cout<<(C(c,d)+C(a,b)-C(a,d)-C(c,b)+mod*2)%mod<<endl;
}

Measured memory_bytes: 19192
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
 
 
#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000
 
using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;
typedef string::const_iterator State;
 
int dy[5] = { 0,0,1,-1,0 };
int dx[5] = { 1,-1,0,0 ,0 };
 
 
int main(void) {
	
	int n;
	int count = 0;
	
 
 
	cin >> n;
	FOR(i, 105, n) {
		if (i == 105 || i == 135 || i == 165 || i == 189 || i == 195) {
			count++;
		}
	}
 
	cout << count << endl;
	return 0;
}

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

string s;
int n;
string str[4];
bool dfs(int idx){
    if(idx==n)return true;
    if(s[idx]!='d' && s[idx]!='e')  return false;
    bool ans=false;
    if(s[idx]=='d'){
        if(s.substr(idx,5)=="dream"){
            
            ans|=dfs(idx+5);
        }
        if(s.substr(idx,7)=="dreamer"){
            
            ans|=dfs(idx+7);
        }
    }
    else if(s[idx]=='e') {
        if(s.substr(idx,5)=="erase") {
            //cout<<s;
            ans|=dfs(idx+5);
        }
        if(s.substr(idx,6)=="eraser") {
            //cout<<s.substr(idx,6);
            
            ans|=dfs(idx+6);
        }
    }
    return ans;
}
int main(){

    cin>>s;
    n=s.length();
    str[0]="dream";
    str[1]="dreamer";
    str[2]="erase";
    str[3]="eraser";
    bool ans=dfs(0);
    if(ans){
        printf("YES\n");
    }
    else {
        printf("NO\n");
    }
  //  getchar();
    //getchar();
    return 0;
}

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

int binarySearch(int l, int r, function<bool(int)> eval) {
  int ok = r, ng = l - 1;
  while(ok - ng > 1) {
    int mid = (ok + ng) >> 1;
    if(eval(mid)) ok = mid; else ng = mid;
  }
  return ok;
}

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n; cin >> n;
  vector<ll> a(n), asum(n);
  for(int i = 0; i < n; i++) cin >> a[i], a[i] -= 1 + i;
  sort(begin(a), end(a));
  asum[0] = a[0];
  for(int i = 1; i < n; i++) asum[i] = asum[i - 1] + a[i];
  auto f = [&](int x) {
    ll res = (x + 1) * a[x] - asum[x];
    res += asum[n - 1] - asum[x] - (n - x - 1) * a[x];
    return res;
  };
  cout << f(binarySearch(0, n - 1, [&](int x) {
      return f(x + 1) - f(x) > 0;
      })) << endl;
  return 0;
}


Measured memory_bytes: 3456
#include<stdio.h>
#include <algorithm>
#include<iostream>
#include<string.h>
#include<vector>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<deque>
#include<ctype.h>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<algorithm>
#define INF 0x3f3f3f3f
#define FAST_IO ios::sync_with_stdio(false)
const double PI = acos(-1.0);
const double eps = 1e-6;
const int MAX=1e5+10;
const int mod=1e9+7;
typedef long long ll;
using namespace std;
#define gcd(a,b) __gcd(a,b)
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll qpow(ll a,ll b){ll r=1,t=a; while(b){if(b&1)r=(r*t)%mod;b>>=1;t=(t*t)%mod;}return r;}
inline ll inv1(ll b){return qpow(b,mod-2);}
inline ll exgcd(ll a,ll b,ll &x,ll &y){if(!b){x=1;y=0;return a;}ll r=exgcd(b,a%b,y,x);y-=(a/b)*x;return r;}
inline ll read(){ll x=0,f=1;char c=getchar();for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;for(;isdigit(c);c=getchar()) x=x*10+c-'0';return x*f;}
//freopen( "in.txt" , "r" , stdin );
//freopen( "data.txt" , "w" , stdout );


int main()
{
    ll a,b;
    char s[5];
    scanf("%lld %s %lld",&a,s,&b);
    if(s[0]=='+')
        printf("%lld\n",a+b);
    else
        printf("%lld\n",a-b);

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt();
 
        if (a < b){
            System.out.println("a < b");
        } else if (a > b){
            System.out.println("a > b");
        } else {
            System.out.println("a == b");
        }
    }
}

Measured memory_bytes: 25996
k = int(input())
if k == 0:
	print(2)
	print("1 1")
elif k == 1:
	print(2)
	print("2 0")
elif k <= 50:
	print(k)
	print(*[k for _ in range(k)])
else:
	print(50)
	div = k // 50 - 1
	mod = k % 50
	if mod == 0:
		ans = [50 + div] * 50
		print(*ans)
	else:
		ans = [50 + div + 50 - (mod - 1)] * mod + [50 + div - mod] * (50 - mod)
		print(*ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#define gc getchar()
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define lint long long
#define N 2010
#define debug(x) cerr<<#x<<"="<<x
#define sp <<" "
#define ln <<endl
using namespace std;
inline int inn()
{
	int x,ch;while((ch=gc)<'0'||ch>'9');
	x=ch^'0';while((ch=gc)>='0'&&ch<='9')
		x=(x<<1)+(x<<3)+(ch^'0');return x;
}
int h[N][N],s[N],L[N],R[N],a[N][N];char str[N];
int main()
{
	int n=inn(),m=inn();lint ans=max(n,m);
	rep(i,1,n) { scanf("%s",str+1);rep(j,1,m) a[i][j]=(str[j]=='#'); }
	rep(j,1,m-1) h[n][j]=1;
	for(int i=n-1;i;i--) for(int j=m-1;j;j--)
		if((a[i][j]==a[i][j+1])==(a[i+1][j]==a[i+1][j+1])) h[i][j]=h[i+1][j]+1;
		else h[i][j]=1;
	for(int i=1,t,*v;i<=n;i++)
	{
		t=0,v=h[i];
		for(int j=1;j<=m-1;s[++t]=j++)
			while(t&&v[j]<v[s[t]]) R[s[t--]]=j;
		for(int j=1;j<=t;j++) R[s[j]]=m;
		t=0,v=h[i];
		for(int j=m-1;j>=1;s[++t]=j--)
			while(t&&v[j]<=v[s[t]]) L[s[t--]]=j+1;
		for(int j=1;j<=t;j++) L[s[j]]=1;
		for(int j=1;j<m;j++) ans=max(ans,(R[j]-L[j]+1ll)*v[j]);
	}
	return !printf("%lld\n",ans);
}

Measured memory_bytes: 31872
#include<bits/stdc++.h>
using namespace std;
# define ll long long
# define int long long
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
# define mo 1000000007

 signed main(){
    gok
    int n;
    cin>>n;
    cout<<(n+1)/2;

    return 0;
}


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

using namespace std;
int main (){
    int n;
    cin >> n;
    int a[n];
    int count=0;
    int max=0;
    int l=0;
    bool flag=true;
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    int search=1;
    for (int i = 0; i < n; i++){
        if(a[i]==search) search++;
        else count++;
    }
    if(search==1) cout << "-1\n";
    else     cout << count <<"\n";
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
 
using namespace std;
using S = set<long long>;
using D = deque<long long>;
using L = vector<long long>;
using M = map<int,long long>;
using A = vector<vector<long long>>;
using Q = priority_queue<long long>;
using U = unordered_map<int,long long>; //mapとの違いはkeyの順番を保持していない

#define sorted(vector) sort(vector.begin(),vector.end()) //O(nlongn)
#define vmin(vector) *min_element(vector.begin(),vector.end()) //O(N)
#define vmax(vector) *max_element(vector.begin(),vector.end()) //O(N)
#define vsum(vector) accumulate(vector.begin(),vector.end(),0) //O(N)
#define vcount(vector,a) count(vector.begin(), vector.end(),a) //O(N)
#define bisect_left(vector,a) (lower_bound(vector.begin(),vector.end(),a)-vector.begin())
#define bisect_right(vector,a) (upper_bound(vector.begin(),vector.end(),a)-vector.begin())
#define vfind(vector,a) find(vector.begin(), vector.end(), a) != vector.end() //遅いからあんまり使うな
//存在確認はmap!!!!!!!!!!!!!
//__gcd(a,b)はコンパイラがGCC時のみ

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    long long n;
    cin>>n;
    L l(n,0);
    for(int i=0  ;i<n  ;i++){
        cin>>l[i];
    }
    L a;
    a=l;
    sorted(l);
    long long m=l[n-1];
    long long m2=l[n-2];
    for(int i=0  ;i<n  ;i++){
        if (a[i]==m){
            cout<<m2<<endl;
        }else{
            cout<<m<<endl;
        }
    }
}
    


Measured memory_bytes: 4736
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>

int main(void) {
  int d, n;
  long ans;

  if(scanf("%d %d", &d, &n) == 1);

  if(n == 100) {
    n++;
  }

  ans = (long)pow(100, d) * n;

  printf("%ld", ans);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, res, xa, bx, ba;
string S;

int main() {
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> S;
		if (S.front() == 'B') {
			if (S.back() == 'A') {
				++ba;
			}
			else {
				++bx;
			}
		}
		else if (S.back() == 'A') {
			++xa;
		}
		bool f = false;
		for (int j = 0; j < S.size(); ++j) {
			if (S[j] == 'A')f = true;
			else if (S[j] == 'B'&&f) {
				f = false;
				++res;
			}
			else {
				f = false;
			}
		}
	}
	if (ba) {
		res += ba - 1;
	}
	if (ba && xa >= 1 && bx >= 1) {
		--xa;
		--bx;
		res += 2;
		res += min(xa, bx);
	}
	else {
		if (ba) {
			if (xa || bx) {
				++res;
			}
		}
		else {
			res += min(xa, bx);
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

int f(vi &A, int n) {
    int res = 0;
    int l=A[0], r=A[0];
    n--;
    int tl=1, tr=A.size()-1;
    while(n > 0) {
        //右処理
        if(n-1==0) {
            res += max(abs(l-A[tr]), abs(r-A[tr]));
            break;
        }
        if(abs(l-A[tr])+abs(r-A[tr-1]) > abs(l-A[tr-1])+abs(r-A[tr])) {
            res += abs(l-A[tr])+abs(r-A[tr-1]);
            l = A[tr]; r = A[tr-1];
        } else {
            res += abs(l-A[tr-1])+abs(r-A[tr]);
            l = A[tr-1]; r = A[tr];
        }
        tr -= 2;
        n -= 2;
        if(n==0) break;

        //左処理
        if(n-1==0) {
            res += max(abs(l-A[tl]), abs(r-A[tl]));
            break;
        }
        if(abs(l-A[tl])+abs(r-A[tl+1]) > abs(l-A[tl+1])+abs(r-A[tl])) {
            res += abs(l-A[tl])+abs(r-A[tl+1]);
            l = A[tl]; r = A[tl+1];
        } else {
            res += abs(l-A[tl+1])+abs(r-A[tl]);
            l = A[tl+1]; r = A[tl];
        }
        tl += 2;
        n -= 2;
        if(n==0) break;
    }
    return res;
}

signed main() {
    int N;
    cin >> N;
    vi A(N);
    rep(i, N) cin >> A[i];
    int n = N;

    SORT(A);
    int res = f(A, n);
    GSORT(A);
    res = max(res, f(A, n));

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>

using namespace std;

const int maxn=10000;
const int inf=(1<<20);

int n;
vector<pair<int,int> > adj[maxn];

void Dijkstra(){
    priority_queue<pair<int,int> > PQ;
 //   int color[maxn];
    bool vis[maxn];
    int d[maxn];
    for(int i=0;i<n;i++){
        d[i]=inf;
     //   color[i]=white;
        vis[i]=false;
    }

    d[0]=0;
    PQ.push(make_pair(0,0));
 //   color[0]=gray;
  //  vis[0]=1;

    while(!PQ.empty()){
        pair<int,int> f=PQ.top();PQ.pop();
        int u=f.second;

      //  color[u]=black;
        vis[u]=true;

        if(d[u]<f.first*(-1))   continue;

        for(int j=0;j<adj[u].size();j++){
            int v=adj[u][j].first;
            if(vis[v]==true) continue;
            if(d[v]>d[u]+adj[u][j].second){
                d[v]=d[u]+adj[u][j].second;
    // priority_queue priority_queue 默认优先较大值， 因此要乘以-1。
                PQ.push(make_pair(d[v]*(-1),v));
              //  vis[v]=true;这句不能加
              //  color[v]=gray;
            }
        }
    }

    for(int i=0;i<n;i++){
        printf("%d %d\n",i,(d[i]==inf?-1:d[i]));
    }
}

int main(){
    int k,u,v,c;

    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d%d",&u,&k);
        for(int j=0;j<k;j++){
            scanf("%d%d",&v,&c);
            adj[u].push_back(make_pair(v,c));
        }
    }

    Dijkstra();

    return 0;
}


Measured memory_bytes: 8140
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: String = read();
    let c = a.as_str().chars().rev().next().unwrap() as i32 - 48;

    match c {
        0 | 1 | 6 | 8 => print!("pon"),
        2 | 4 | 5 | 7 | 9 => print!("hon"),
        3 => print!("bon"),
        _ =>{}
    }
}


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

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    while (b<=a && k>0) {
        k--;
        b*=2;
    }
    while (c<=b && k>0) {
        k--;
        c*=2;
    }
    if (b>a && c>b) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 3668
#pragma GCC optimize("Ofast,fast-math,unroll-loops")

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef string str;

#define IOS ios::sync_with_stdio(0); cin.tie(0);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()

int v[10020];

int main() {
    IOS;
	
	int n,k;
	cin >> n >> k;
	
	
	
	for(int i = 1; i <= n; i++){
		cin >> v[i];
	}
	sort(v+1,v+n+1);
	ll s = 0;
	for(int i = 1; i <= k; i++){
		s += v[i];
	}
	cout << s;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h> 
using namespace std;
int main()
{
	char s[10000];
	int i,a,b,len;
	scanf("%d %d",&a,&b);
	scanf("%s",s);
	for(i=0;i<a;i++)
	{
		if(s[i]<'0'||s[i]>'9')
		{
			printf("No");
			return 0;
		}
	}
	if(s[a]!='-')
	{
		printf("No");
		return 0;
	}
	for(i=a+1;i<a+b+1;i++)
	{
		if(s[i]<'0'||s[i]>'9')
		{
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<set>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		string str;
		set<string> ss;
		cin >> str;
		for (int j = 0; j < str.length() - 1; j++)
		{
			string s1 = str.substr(0, j + 1);
			string s2 = str.substr(j + 1, str.length());
			string sr1 = s1;
			string sr2 = s2;
			reverse(sr1.begin(), sr1.end());
			reverse(sr2.begin(), sr2.end());
			ss.insert(s1 + s2);
			ss.insert(s2 + s1);
			ss.insert(sr1 + s2);
			ss.insert(s2 + sr1);
			ss.insert(s1 + sr2);
			ss.insert(sr2 + s1);
			ss.insert(sr1 + sr2);
			ss.insert(sr2 + sr1);
		}
		cout << ss.size() << endl;
	}
}


Measured memory_bytes: 3232
#include <stdio.h>

int main(void)
{
	int n, i, c;

	scanf("%d", &n);

	for (i = 1; i <= n; i++) {
		if (i % 3 == 0) printf(" %d", i);
		else {
			c = i;

			while (c) {
				if (c % 10 == 3) {
					printf(" %d", i);
					break;
				}
				c /= 10;
			}
		}
	}

	printf("\n");

	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  scanf("%d%d",&a,&b);
  int x[3];
  x[0]=a+b,x[1]=a-b,x[2]=a*b;
  sort(x,x+3);
  printf("%d",x[2]);
  return 0;
}

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

int main(){

      long n,Alice=0,Bob=0;
      cin>>n;
      int a[n];

      for(int i=0;i<n; i++){
        cin>>a[i];
      }

      sort(a,a+n);

      for(int i=0;i<n;i++){
        if(i%2 == 0){
          Bob+= a[i];
        }
        else{
          Alice+= a[i];
        }
      }

      cout<<abs(Bob-Alice)<<endl;

      return 0;
}


Measured memory_bytes: 3584
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可

const ll INF=1000000000000000000;

signed main(){
    int n,m;
    cin>>n>>m;
    V<pair<int,int>> p(m);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        p[i]=make_pair(b,a);
    }
    sort(all(p));
    int ans=0;
    int cnt;
    rep(i,m){
        if(i==0){
            ans++;
            cnt=p[i].ft-1;
        }else{
            if(p[i].sc<=cnt) continue;
            ans++;
            cnt=p[i].ft-1;
        }
    }
    cout<<ans<<endl;
}

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

typedef pair<int, int> pii;

int N;
int X[555], A[555 * 555];
vector<pii> P;

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

    for(int i = 1; i <= N; i++) {
        scanf("%d", &X[i]);
        P.push_back({ X[i], i });
    }
    sort(P.begin(), P.end());

    int sum = 0;
    for(int i = 0; i < N; i++) {
        sum += P[i].second - 1;
        if(P[i].first - 1 < sum) {
            printf("No");
            return 0;
        }
        sum++;
    }

    sum = 0;
    for(int i = N - 1; i >= 0; i--) {
        sum += N - P[i].second;
        if(N * N - P[i].first < sum) {
            printf("No");
            return 0;
        }
        sum++;
    }

    printf("Yes\n");

    for(int i = 1; i <= N; i++) {
        A[ X[i] ] = i;
    }
    int pos = 1;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < P[i].second - 1; j++) {
            while(A[pos]) pos++;
            A[pos] = P[i].second;
        }
    }
    pos = N * N;
    for(int i = N - 1; i >= 0; i--) {
        for(int j = 0; j < N - P[i].second; j++) {
            while(A[pos]) pos--;
            A[pos] = P[i].second;
        }
    }

    for(int i = 1; i <= N * N; i++) {
        printf("%d ", A[i]);
    }
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
typedef pair<int, int> pint;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vector<Int> a(n,0);
    rep(i,n) cin>>a[i];
    Int mod=1000000007;
    vector<Int> sa(n+1,0);
    sa[0]=0;
    for(int i=0; i<n; i++){
      sa[i+1]=sa[i]+a[i];
    }
    Int ans=0;
    for(int i=0; i<n; i++){
      Int tmp=(sa[n]-sa[i+1])%mod;
      ans+=a[i]*tmp;
      ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6368
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <sstream>
#include <stdio.h>
#include<cstdlib>
using namespace std;

int main(){

    string S,zenhan,kouhan;

    cin >> S;

    //100で割った商と余りでもよかった
    //'0'を引くとintになる
    //２桁の数を作るには10a+b

/*
    for(int i=0;i<4;i++){
        if(i<2){
            zenhan[i] = S[i];
            cout << zenhan[i];
        }
        else{
            kouhan[i-2] = S[i];
            cout << kouhan[i-2];
        }

    }
*/

    int zen = stoi(S.substr(0, 2));
    int kou = stoi(S.substr(2));



    //2*2の○×の４通りでできた

    if(1<=zen && zen<=12){
        if(1<=kou && kou<=12){
            cout << "AMBIGUOUS";
        }
        else{
            cout << "MMYY";
        }
    }
    else{
        if(1<=kou && kou<=12){
            cout << "YYMM";
        }
        else{
            cout << "NA";
        }
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
double dp[301][301][301];
int n;
double rec(int i, int j, int k)
{
    if(dp[i][j][k]) return dp[i][j][k];
    if(i == 0 && j == 0 && k == 0) return 0;
    double res = 0;
    if(i > 0) res += rec(i-1, j, k) * i;
    if(j > 0) res += rec(i+1, j-1, k) * j;
    if(k > 0) res += rec(i, j+1, k-1) * k;
    res += n;
    res /= i+j+k;
    return dp[i][j][k] = res;
}
int main()
{
    cin >> n;
    int one = 0;
    int two = 0;
    int three = 0;
    for(int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if(a == 1) one++;
        if(a == 2) two++;
        if(a == 3) three++;
    }
    memset(dp, 0, sizeof(dp));
    cout << fixed << setprecision(10) <<  rec(one, two, three) << endl;
}




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

int main(){
    int n,m;
    scanf(" %d %d",&n,&m);
    vector<vector<int>> see(m);
    for(int i = 0; i < m;++i){
        int k;
        scanf(" %d",&k);
        for(int j = 0; j < k;++j){
            int va;
            scanf(" %d",&va);
            --va;
            see[i].push_back(va);
        }
    }
    vector<int> p(m,0);
    for(int i = 0; i < m;++i)
        scanf(" %d",&p[i]);
    int ans = 0;
    for(int i = 0; i < (1<<n);++i){
        int temp = i;
        int j = 0;
        set<int> use;
        while(temp){
            if(temp&1)use.insert(j);
            temp >>=1;
            ++j;
        }
        bool add = 1;
        for(int j = 0; j < m && add;++j){
            int val = 0;
            for(auto va:see[j])
                if(use.count(va))
                    ++val;
            if(val%2 != p[j]) add = 0;
        }
        if(add) ++ans;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3748