akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int m; //???????????£??????????????????
		StringBuffer cards;; 
		String shuCards = "";

		while(true){
	        cards = new StringBuffer(br.readLine());
			if(cards.toString().equals("-")){break;}
			m = Integer.parseInt(br.readLine());
			int cnt = 0; //???????????£??????????????????
			while(cnt++ != m){
				int h = Integer.parseInt(br.readLine()); //?????????h???????????????????????????????????£???????????????
				shuCards = cards.substring(h, cards.length());
				shuCards += cards.substring(0, h);
				cards.delete(0, cards.length());
				cards.append(shuCards);
			}
			System.out.println(shuCards);
		}
    }
 
}

Measured memory_bytes: 24340
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using uint = unsigned int;
using ll = long long;
 
int main() {
	int N;
	cin >> N;
	
	vector<pair<ll, ll>> XL(N, pair<ll, ll>());
	
	for(uint i=0; i<N; i++) {
		ll X, L;
		cin >> X >> L;
		XL[i] = make_pair(X - L, X + L);
	}
	
	sort(XL.begin(), XL.end());
	
	ll bais = XL[0].first;
	for(uint i=0; i<N; i++) { // 0 origin
		XL[i].first -= bais;
		XL[i].second -= bais;
	}
	
	ll front = 0;
	uint findx = 0;
	vector<uint> ans(N + 1);
	
	for(uint i=0; i<N; i++) {
		ll le = XL[i].first;
		ll re = XL[i].second;
		
		//cout << front << " ";
		if(front <= le) {
			ans[i+1] = ans[findx] + 1;
			front = re;
			findx = i + 1;
		} else if(re <= front) {
			ans[i+1] = ans[findx];
			front = re;
			findx = i + 1;
		} else {
			ans[i+1] = ans[findx];
		}
		
		//cout << le << " " << re << " " << ans[i+1] << " " << front << endl;
	}
	
	cout << ans[N];
	
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int n;
    cin >> n;
    vector<int> a(n), sorted(n);
    in_arr(int, a, n);
    copy(a.begin(), a.end(), sorted.begin());
    sort(sorted.begin(), sorted.end());
    int mid = sorted[(sorted.size() + 1) / 2 - 1];
    repi(i, a){
        if(*i < mid && a.size() % 2 == 1){
            cout << mid << endl;
        }else if(a.size() % 2 == 1){
            cout << sorted[sorted.size() / 2 - 1] << endl;
        }else if(*i <= mid){
            cout << sorted[sorted.size() / 2] << endl;
        }else{
            cout << mid << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3712
from heapq import heappush, heappop, heapify

n, m = list(map(int, input().split()))
q = list(map(lambda x: -int(x), input().split()))
heapify(q)

for _ in range(m):
    highest = -heappop(q)
    heappush(q, -(highest // 2))

cost = -sum(q)

print(cost)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define s(x, n) memset(x, n, sizeof(x));
#define pb(x) push_back(x)
#define NIL -1
#define MAXN 11

void solve()
{
    ll h, w;
    cin >> h >> w;
    string s[h];
    for (ll i = 0; i < h; i++)
        cin >> s[i];
    ll dp[h][w];
    s(dp, 0);
    dp[0][0] = 1;
    for (ll i = 0; i < h; i++)
    {
        for (ll j = 0; j < w; j++)
        {
            if (s[i][j] == '#')
                dp[i][j] = 0;
            else
            {
                if (i - 1 >= 0)
                {
                    dp[i][j] += (dp[i - 1][j] % mod);
                    dp[i][j] %= mod;
                }
                if (j - 1 >= 0)
                {
                    dp[i][j] += (dp[i][j - 1] % mod);
                    dp[i][j] %= mod;
                }
            }
        }
    }
    cout << dp[h - 1][w - 1] << "\n";
}
int main()
{
#ifdef WIN32
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

#ifndef WIN32
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#endif
    int t;
    t = 1;
    /// cin >> t;
    for (int I = 1; I <= t; I++)
    {
        solve();
    }
    return 0;
}

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

using namespace std;

int main()
{

    int n,m,i,j;

    cin>>n;

    int a[n+1],p[n+1]={0};

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

    for(i=1;i<=n;i++)
    {
        cout<<p[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 5200
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int Q;
	priority_queue<int> lpq;
	priority_queue<int, vector<int>, greater<int>> rpq;
	int sl = 0, sr = 0;
	int m = INF;
	int B = 0;
	int q, a, b;

	cin >> Q;
	rep(i, 0, Q)
	{
		cin >> q;
		if (q == 1)
		{
			cin >> a >> b;
			B += b;
			if (m == INF)
			{
				m = a;
			}
			else
			{
				if (a <= m)
				{
					lpq.push(a);
					sl += m - a;
				}
				else
				{
					rpq.push(a);
					sr += a - m;
				}

				if (SZ(lpq)+1 < SZ(rpq))
				{
					int t = rpq.top();
					lpq.push(m);
					sl += (t - m)*SZ(lpq);
					sr -= (t - m)*SZ(rpq);
					m = t;
					rpq.pop();
				}

				if (SZ(lpq) > SZ(rpq))
				{
					int t = lpq.top();
					rpq.push(m);
					sr += (m - t)*SZ(rpq);
					sl -= (m - t)*SZ(lpq);
					m = t;
					lpq.pop();
				}
			}
		}
		else
		{
			cout << m << " " << sl + sr + B << endl;
		}
	}

	return 0;
}



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

using namespace std;

int main()
{
    int n;
    cin>>n;
    int d[n][2];
    string ans="No\n";
    
    for(int i=0;i<n;i++) for(int j=0;j<2;j++) cin>>d[i][j];
    
    for(int i=0;i+2<n;i++){
        if(d[i][0]==d[i][1] && d[i+1][0]==d[i+1][1] && d[i+2][0]==d[i+2][1]) ans="Yes\n";
    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort(v.rbegin(), v.rend())
typedef pair<int, int> pii;

ll exp(ll taban, ll us) {
    ll carpan = taban % mod;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
    }
    return res;
} 
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
} 
ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}
ll fonk(ll n){
	return n*(n+1)/2;
}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
	ll n, k; cin>>n>>k;
	ll ans = 0;
	for(ll i = k; i <= n+1; i++){
		ans = (ans + i*(2*n-i+1)/2 - i*(i-1)/2 + 1) % mod;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
    ll N, K;
    cin >> N >> K;
    ll po[K + 1] = {};
    for(ll i = 1; i <= N; i++) po[i % K]++;
    ll ans = 0;
    for(ll i = 0; i <= K; i++) if(i * 2 % K == 0) ans += po[i] * po[i] * po[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

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

		Integer K = Integer.parseInt(scanner.next());
		Integer A = Integer.parseInt(scanner.next());
		Integer B = Integer.parseInt(scanner.next());

		int a = A / K;
		int num = A % K;
		if (num == 0) {
			if (a * K <= B) {
				System.out.println("OK");
			} else {
				System.out.println("NG");
			}
		} else {
			if ((a+1) * K <= B) {
				System.out.println("OK");;
			} else {
				System.out.println("NG");
			}
		}
	}

}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  bool res = true;
  rep(i, s.size()) {
    if(s[i] != t[i]) {
      res = false;
      break;
    }
  }
  if(res) puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 3592
import java.util.Scanner;
 
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    long h = sc.nextLong();
    long w = sc.nextLong();
    if(h==1||w==1){
      System.out.print(1);
    } else {
      System.out.print(h*w/2+h*w%2);
    }
  }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;

long long C[4005][4005];
long long p2[2005];

int main() {
  int k, n;
  cin >> k >> n;
  C[0][0] = 1;
  for (int i = 1; i <= k + n; i++) {
    C[i][0] = 1;
    C[i][i] = 1;
    for (int j = 1; j < i; j++) {
      C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
    }
  }
  long long p = 1;
  for (int i = 0; i <= k; i++) {
    p2[i] = p;
    p *= 2;
    p %= mod;
  }
  for (int i = 2; i <= 2 * k; i++) {
    long long ans = 0;
    if (i % 2 == 0) {
      int x = min(i / 2 - 1, k - i / 2);
      int y = k - 1 - x * 2;
      for (int xi = 0; xi <= x; xi++) {
        if (xi > n) continue;
        long long cnt = C[x][xi] * p2[xi] % mod * C[y + n - 1][n - xi] % mod;
        cnt += C[x][xi] * p2[xi] % mod * C[y + n - 2][n - xi - 1] % mod;
        ans += cnt;
        ans %= mod;
      }
    } else {
      int x = min(i / 2, k - i / 2);
      int y = k - x * 2;
      for (int xi = 0; xi <= x; xi++) {
        if (xi > n) continue;
        long long cnt = C[x][xi] * p2[xi] % mod * C[y + n - 1][n - xi] % mod;
        ans += cnt;
        ans %= mod;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 123776
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {
    int N;
    cin >> N;
    vector<ll> a(N);
    REP(i, N) cin >> a[i];
    sort(a.begin(), a.end(), greater<ll>());
    ll ans = a[0];
    int j = 2;
    rep(i,1, N){
        if (j == N) break;
        ans += a[i];
        j++;
        if (j == N) break;
        ans += a[i];
        j++;

    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 4432
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    long long N,P;
    int count=0;
    int ans=1;
    cin >> P >> N;
    if(P==1){
        cout << N;
        return 0;
    }
    for(long long i=2;i<sqrt(N)+3;i++){
        while(N%i==0){
            N/=i;
            count++;
        }
        ans*=(int)(pow(i,(int)(count/P)));
        count=0;
    }
    cout << ans;
    return 0;
}


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

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s; int ans = 0;
	cin >> s;	
	for (int i = 0; i < s.size(); i++)
		if (s[i] == 'o') ans++;
	cout << ans * 100 + 700 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
double Pi = 3.1415926535897932384626;
 
vector<ll> G[550010];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
ll mod = 1000000007;
/*
2000000011 is prime
2000000033 is prime
*/

ll rui(ll number1,ll number2){

    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

/*
ll fact[800005],rfact[800005];

void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[800000] = rui(fact[800000],mod - 2);
    for(ll i=800000; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,q,r,l;
ll k,ans;
ll x[500005],y[500005],z[500005];

char s[500005];


int main(){
    cin >> n >> m;
    for(int i=0;i<n;i++){
        cin >> x[i];
    }
    for(int i=0;i<n;i++){
        pql.push(x[i]);
    }
    while(m--){
        ll now = pql.top();
        pql.pop();
        now /= 2;
        pql.push(now);
    }
    while(!pql.empty()){
        ll now = pql.top();
        pql.pop();
        ans += now;
    }
    p(ans);
    return 0;
    
}


















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

using ll =  long long;
using pint =  pair<int,int>;

#define INF 99999999
#define rep(i,n) for(int (i)=0,temp=(int)(n);(i)<temp;++(i)) 
#define repi(i,start,end) for(int (i)=(start),temp=(int)(end);i<(end);++(i))
#define rfor(v,x) for(const auto& (x) : (v)) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort((v), (v)+(n))
#define vsort(v) sort((v).begin(), (v).end())
#define vfsort(v,lambda) sort(all((v)),(lambda))
#define vint vector<int>
#define vvint vector<vector<int>> //vvint v(n,vint(n))のように宣言できる
#define vin(v) rep(i,(v).size()) {cin >> (v)[i];}
//最終奥義
//#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//lambda式 -> [&](int x, int y){return x<y;}
//vector内の重複を削除-> v.erase(unique(all(v)),v.end());

signed main(void){
  int a,b;cin >> a >> b;
  if(a<=0||a>=10||b<=0||b>=10)cout << -1 << endl;
  else cout << a*b << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
string S[100]; int n, l;
int main() {
	cin >> n >> l;
	for (int i = 0; i < n; i++)cin >> S[i];
	sort(S, S + n);
	for (int i = 0; i < n; i++)cout << S[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,first,last) for(int i=first;i<=last;++i)
#define DOW(i,first,last) for(int i=first;i>=last;--i)
using namespace std;
const int MAXN=2e5+5;
const long long MOD=1e9+7;
int n,m,k;
int T;
void YES()
{
	printf("YES\n");
}
void NO()
{
	printf("NO\n");
}
void read(int &a)
{
	scanf("%d",&a);
}
void work()
{

}
int main()
{
	scanf("%d%d",&n,&k);
	long long answer=0;
	REP(i,k,n+1)
	{
		answer+=1ll*(2*n-i+1)*i/2-1ll*(i-1)*i/2+1;
		answer%=MOD;
	}
	printf("%lld",answer);
	return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(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)

template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

using namespace std;

int main(int argc, char** argv) 
{
#ifdef HOME
	if(IsDebuggerPresent())
	{
		freopen("../in.txt", "rb", stdin);
		freopen("../out.txt", "wb", stdout);
	}
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
	int N;
	cin >> N;
	vector<double> p(N);
	for (auto& pv : p)
	{
		cin >> pv;
	}
	vector<double> dp(N + 1), dp2(N + 1);
	dp[0] = 1;
	forn(i, N)
	{
		fill(all(dp2), 0);
		forn(j, N)
		{
			dp2[j+1] += p[i]*dp[j];
			dp2[j] += (1-p[i]) * dp[j];
		}
		dp.swap(dp2);
	}
	double res = 0;
	fore(i, N / 2 + 1, N)
		res += dp[i];
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stdlib.h>
#include <iomanip>

using namespace std;

#define ll long long
#define vi vector<int>
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pi 3.14159265359


ll gcd(ll a, ll b)
{
	ll c;
	while (a != 0) {
		c = a; a = b % a;  b = c;
	}
	return b;
}

int main() {
	ll A[3];
	REP(i, 3) {
		cin >> A[i];
	}
	sort(A, A + 3);
	cout << A[2] * 10 + A[1] + A[0];


	return 0;



}

Measured memory_bytes: 256
def main():
    n=int(input())
    s=input()
    
    ans=s.count('.')
    t=ans
    for i in range(n):
        if s[i]=='.':
            t-=1
        else:
            t+=1           
        ans=min(ans,t)
    print(ans)
    
if __name__=='__main__':
    main()

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

using namespace std;
using ll = long long;
using ld = long double;
using Vec = vector<int>;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}


int main(){

 string s;
 cin>>s;
 int n=s.size();
 int ct=0;
 ll sum=0;
 for(int i=0;i<n;i++){

     if(s[i]=='W'){
         sum+=(i-ct);
         ct++;
     }
 }
 
cout<<sum<<endl;



}

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

int main() {
    int n,m,a[100]={}, i;
    float sum=0;
    cin >> n>>m;
    for(i=0; i<n; i++) {
        cin>>a[i];
        sum += a[i];
    }
    sort(a, a+100);
    sum = (1.0*sum)/(4.0*m);
    for(i=99; i>99-m; i--) {
        if(a[i]>=sum)
            continue;
        else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

int main() {
  string s, t;
  cin >> s >> t;
  int cnt = 0;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] != t[i]) {
      s[i] = t[i];
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3824
n,m,c=list(map(int,input().split()))
b=list(map(int,input().split()))
a=[]
for i in range(n):
    a1=list(map(int,input().split()))
    a.append(a1)

sum=0
for i in range(n):
    t=0
    for j in range(m):
       t+=a[i][j]*b[j]
    t+=c
    if t>0:
        sum+=1
print(sum)

Measured memory_bytes: 3316
N, K = map(int, input().split())

bit0_count = [0] * 64
bit1_count = [0] * 64

for A in map(int, input().split()):
    for i in range(64):
        if A & (1 << i):
            bit1_count[i] += 1
        else:
            bit0_count[i] += 1

ans = 0
less = -1
equal = 0
for i in range(63, -1, -1):
    if K & (1 << i):
        if less == -1:
            less = bit1_count[i] * (1 << i)
        else:
            less += max(bit0_count[i], bit1_count[i]) * (1 << i)
    
        if bit0_count[i] > bit1_count[i]:
            equal += bit0_count[i] * (1 << i)
        else:
            equal += bit1_count[i] * (1 << i)
            less = max(less, equal)
    else:
        equal += bit1_count[i] * (1 << i)
        if less != -1:
            less += max(bit0_count[i], bit1_count[i]) * (1 << i)
    
print(max(less, equal))

Measured memory_bytes: 81864
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		boolean easy = true;
		for(int i=0; i<s.length; i++)
			if(s[i]==(i%2==0 ? 'L' : 'R'))
				easy = false;
		
		System.out.println(easy ? "Yes" : "No");
		sc.close();
	}
}


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

ll k, a, b, ans;

int main() {
    cin >> k >> a >> b;
    k++;
    if (k < a + 2 || a + 2 >= b) {
        ans = k;
    } else {
        // first
        k -= a + 2;
        ll diff = b - a;
        ans = b;
        // second ~
        ll multi = k / 2;
        ans += diff * multi;
        if (k % 2 == 1) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;
//clang++ -std=c++11 -stdlib=libc++ 
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int main() {
  int a,b; cin>>a>>b;
  cout << lcm(a,b) << endl;
  return 0;
}

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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(int i= (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    ll N; cin >> N;
    map<string, ll> m;
    ll ans = 0;
    REP(i, N) {
        string s; cin >> s;
        sort(s.begin(), s.end());
        ans += m[s];
        m[s]++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 11400
#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;
#define Khela ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
#define PII pair<ll ,ll>
 
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};
 
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int max=1e9+100;
const ll  MAX=1e18+500;
const int sz=1e5+100;
const ll mod=1e9+7;
int mark[sz];
ll dp[sz][14];
ll n;
string str;
ll cholo(ll id,ll sum)
{
    if(id>=n){
        if(sum%13==5) return 1;
        else return 0;
    }
 
    ll &ret=dp[id][sum];
    if(~ret) return ret;
    ll tot=0;
    if(str[id] != '?') ret=cholo(id+1,(sum*10+(str[id]-'0'))%13);
    else{
        for(ll i=0;i<=9;i++) tot=(tot+cholo(id+1,(sum*10+i)%13))%mod;
        ret=tot;
    }
 
    return ret;
    
    
}
int main()
{
    Khela
    ll a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,mx;
    char ch;
    double d;
    //string str1;
    bool bl,bl1;
    int t,cs=1;
    while(cin>>str)
    {
        memset(dp,-1,sizeof dp);
        n=str.length();
        ll ans=cholo(0,0);
        cout<<ans<<endl;
      
        
    }
 
 
 
 
 
}

Measured memory_bytes: 17744
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

vector<pii> data[100010];
int N, M;

string zerofill(string s)
{
	reverse(all(s));
	while (s.length() < 6) s += '0';
	reverse(all(s));
	return s;
}

signed main()
{
	cin >> N >> M;
	vector<string> ans(M);

	rep(i, M) {
		int p, y;
		cin >> p >> y;
		data[p].push_back(pii(y, i));
	}

	rep1(p, N) {
		sort(all(data[p]));
		int idx = 1;
		for (pii &d : data[p]) {
			ans[d.second] = zerofill(to_string(p)) + zerofill(to_string(idx));
			idx++;
		}
	}

	rep(i, M) {
		cout << ans[i] << endl;
	}
}



Measured memory_bytes: 13952
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CTraveling solver = new CTraveling();
        solver.solve(1, in, out);
        out.close();
    }

    static class CTraveling {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long[] t = new long[n + 1];
            long[] x = new long[n + 1];
            long[] y = new long[n + 1];
            for (int i = 1; i <= n; i++) {
                t[i] = in.nextInt();
                x[i] = in.nextInt();
                y[i] = in.nextInt();
            }

            boolean answer = true;
            for (int i = 1; i <= n; i++) {
                long distance = Math.abs(x[i] - x[i - 1]) + Math.abs(y[i] - y[i - 1]);
                long time = t[i] - t[i - 1];
                answer &= (distance <= time && Math.abs(distance - time) % 2 == 0);
            }

            out.println(answer ? "Yes" : "No");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 45188
#include <iostream>
#include <vector>
#include <numeric>
#include <tuple>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <unordered_map>
#include <type_traits>
#include <map>

using namespace std;
using str = string;

#define rep(a,l,r) for(int a=(l);a<(r);a++)
#define get cin>>
#define put cout<<

int gcd_euclid(int u, int v) {
  int r;
  while (0 != v) {
    r = u % v; u = v; v = r; /* swap */
  }
  return u;
}

// 最大公約数算出
int calc_gcd(const vector<int> vec){
	int gcd = *min_element(vec.begin(), vec.end());
	for (const int ele: vec){
		gcd = gcd_euclid(gcd,ele);
	}
	return gcd;
}

// 最小公倍数
int calc_lcm(const vector<int> vec) {
	int tmp = 1;
	for (const int ele: vec){
		tmp *= ele;
	}
	int gcd = calc_gcd(vec);
	return tmp/gcd;
}



void run() {
    int n; get n;

    vector<int> x{111,222,333,444,555,666,777,888,999};

    for(auto a: x){
    	if (n <= a) {
    		put a;
    		return;
    	}
    }
}

int main() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);run();return 0;}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 9e18
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


int main(void) {
	int N;
	cin >> N;
	vi t(N), v(N);
	rep(i, N) {
		cin >> t[i];
	}
	rep(i, N) {
		cin >> v[i];
	}
	double ans = 0;
	double s = 0, d = 0;
	double pre = 0;
	rep(i, N) {
		int a = pre;
		int b = (i == N - 1 ? 0 : min({ a + t[i], v[i], v[i + 1] }));
		int time = 0;
		repr(j, i + 1, N) {
			time += t[j];
			b = min(b, time + min(v[j], (j == N - 1 ? 0 : v[j + 1])));
		}
		pre = b;
		double x = (b - a + t[i]) / 2.0;
		s += t[i] * (a + x) - x*x / 2 - (t[i] - x)*(t[i] - x) / 2;
		d += (a + x > v[i] ? (a + x - v[i])*(a + x - v[i]) : 0);
		//cout << a << " " << b << " " << x << " " << s << " " << d << endl;
	}

	cout << fixed << setprecision(15) << s - d << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# n,m = map(int,sys.stdin.readline().split())
# a = list(map(int,sys.stdin.readline().split()))
# a = [sys.stdin.readline() for _ in range(n)]
# s = sys.stdin.readline().rstrip()
# n = int(sys.stdin.readline())
import sys,bisect
sys.setrecursionlimit(15000)

S,W = map(int,sys.stdin.readline().split())

if S<=W:
  print("unsafe")
  exit()
print("safe")


Measured memory_bytes: 9156
import math


def cal():
    string = input()
    a, b, h, m = string.split(" ")
    a = int(a)
    b = int(b)
    h = int(h)
    m = int(m)
    minuteAngel = (float(m) * 360) / 60
    hourAngel = (float(h) % 12) * 30 + (float(m) * 30) / 60
    angel = abs(hourAngel - minuteAngel)
    angel=angel/180
    cosine = math.cos(math.pi*angel)
    ans = math.sqrt(a*a + b*b - 2*a*b*cosine)
    print(format(ans, '.20f'))
    # print(angle1)
    # print(angle2)
    # print(angle)
    # print(cosine)

cal()

Measured memory_bytes: 9460
n = int(input())
t,a = map(int, input().split())
H = [int(x) for x in input().split()]
ans, ans_abs = -1, float('inf')
H=[(i+1,t-h*0.006) for i,h in enumerate(H)]

for i,h in H:
  if ans_abs > abs(a-h):
    ans =i
    ans_abs = abs(a-h)
print(ans)

Measured memory_bytes: 3188
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func main() {
	n := oneInt()

	//fmt.Println(n)
	//fmt.Println(int64(math.Sqrt(float64(n))))
	var ans int64

	var i int64
	for i = 1; i < int64(math.Sqrt(float64(n))+1); i++ {
		if n%i == 0 {
			if i > 1 && n/(i-1) == n%(i-1) {
				ans += (i - 1)
			}
			if i != n/i && n/((n/i)-1) == n%((n/i)-1) {
				ans += (n / i) - 1
			}
		}
	}
	fmt.Println(ans)
}

func oneInt() int64 {
	var a int64
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func scanNums(n int) (nums []int) {
	str := readLine()
	s := strings.Split(str, " ")
	for i := 0; i < n; i++ {
		num, _ := strconv.Atoi(s[i])
		nums = append(nums, num)
	}
	return nums
}

func scanStrings() []string {
	str := readLine()
	s := strings.Split(str, " ")

	return s
}

func abs(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}

func cumSum(nums []int) []int {
	sums := []int{0}

	for i := 0; i < len(nums); i++ {
		sums = append(sums, sums[i]+nums[i])
	}
	return sums
}


Measured memory_bytes: 640
package main

import (
	"fmt"
)

func main() {
	var a1, a2, a3 int
	fmt.Scanf("%d %d %d", &a1, &a2, &a3)
	if a1+a2+a3 >= 22 {
		fmt.Println("bust")
	} else {
		fmt.Println("win")
	}
}


Measured memory_bytes: 512
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, K int
	fmt.Scan(&N, &K)
	ln := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&ln[i])
	}
	sort.Sort(sort.Reverse(sort.IntSlice(ln)))
	var sum int
	for i := 0; i < K; i++ {
		sum += ln[i]
	}
	fmt.Println(sum)
}


Measured memory_bytes: 512
function Main(input) {
    input = input.split("\n");
    const [n, ...arr] = input;
    const d = arr.map(v => v.split(" ").map(v => parseInt(v, 10)));
    
    let zorome = 0;
    for(let i = 0; i < n; i++) {
        if(d[i][0] === d[i][1]) {
            zorome++;
            if(zorome === 3) break;
        } else {
            zorome = 0;
        }
    }

    if(zorome === 3) {
        console.log("Yes");
    } else {
        console.log("No");
    }
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29580
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    vector<int> NUM(N);   
    int cnt = 0;
    int cur = 0;
    while(1) {
        int pos = S.find("AC", cur);
        if (pos == string::npos) {
            for (int i = cur; i < S.size(); i++) NUM[i] = cnt;
            break;
        }
        for (int i = cur; i <= pos; i++) NUM.at(i) = cnt;
        NUM[pos + 1] = ++cnt;
        cur = pos + 2;
    }

    rep(i,Q) {
        int l, r;
        cin >> l >> r;
        cout << NUM[r - 1] - NUM[l - 1] << endl;
    }
}

Measured memory_bytes: 1408
#include"iostream"
#include<stdlib.h>
#include<stdio.h>
#include<time.h>
#include<list>
#include<map>
#include<string>
#include<algorithm> 
#include <queue> 
#include <sstream>
#include <fstream>
#include<cmath>
#define INF 100000000000
#define LL long long
using namespace std;
map<LL, LL> m;
long long N, M, K,Q, ans, A[100001], B[100001], ss[100001],a[100000], b[100000];

string s;

LL gcd(LL x, LL y) {
	if (x < y) {
		LL c = x;
		x = y;
		y = c;
	}
	if (y == 0)return x;
	if (x%y == 0) {
		return y;
	}
	else {
		return gcd(y, x%y);
	}
}
int main() {
	cin >> N;
	A[0] = 0;
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= N; i++) {
		A[i+1] = gcd(A[i], a[i]);
	}
	B[N+1] = 0;
	for (int i = N; i > 0; i--) {
		B[i] = gcd(B[i + 1], a[i]);
	}
	ans = -1;
	for (int i = 1; i <= N; i++) {
		ans = max(ans, gcd(A[i], B[i+1]));
	}

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

Measured memory_bytes: 2560
abcd = list(input())
operator = ['+','-']
for i in operator:
    for p in operator:
        for o in operator:
            seven = eval(abcd[0]+i+abcd[1]+p+abcd[2]+o+abcd[3])
            if seven == 7:
                ans = abcd[0]+i+abcd[1]+p+abcd[2]+o+abcd[3]+'='+str(seven)
print(ans)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	readb(a, b);
	if (a*b == 15) cout << '*';
	else if (a + b == 15) cout << '+';
	else cout << 'x';
}

















Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
int main(int argc, char *argv[]) {
	int f[100][15],p[100][15],temp[100];
	int i,j,k,n,r,t;
	cin >> n;
	for(i=0;i<n;i++)
		for(j=0;j<10;j++)
			cin >> f[i][j];
	for(i=0;i<n;i++)
		for(j=0;j<=10;j++)
			cin >> p[i][j];
	r=-2147483647;
	for(i=1;i<(1<<10);i++){
		memset(temp,0,sizeof(temp));
		for(j=0;j<n;j++)
			for(k=0;k<10;k++)
				if((f[j][k])&&((i>>k)&1))
					temp[j]++;
		t=0;
		for(j=0;j<n;j++)
			t+=p[j][temp[j]];
		r=max(r,t);
	}
	cout << r;
	return 0;
}

Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import           Data.Primitive.MutVar
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM

main :: IO ()
main = do
    [v, e] <- map read.words <$> getLine
    edges <- U.unfoldrN e (readInt2.B.dropWhile isSpace) <$> B.getContents
    putStr.unlines.map show . solve . fromEdges v $ toUndirectedEdges edges

solve :: Graph -> [Vertex]
solve gr = U.toList $ articulations gr

type Vertex = Int
type Edge = (Vertex, Vertex)
type Graph = V.Vector (U.Vector Vertex)

toUndirectedEdges :: U.Vector Edge -> U.Vector Edge
toUndirectedEdges edges = edges U.++ U.map swap edges

fromEdges :: Int -> U.Vector Edge -> Graph
fromEdges numV edges = V.map U.fromList
    . V.unsafeAccumulate (flip (:)) (V.replicate numV [])
    $ U.convert edges

nothing :: Int
nothing = -1

articulations :: Graph -> U.Vector Vertex
articulations gr = runST $ do
    let numV = V.length gr
    low <- UM.replicate numV nothing
    num <- UM.replicate numV nothing
    parent <- UM.replicate numV nothing
    isArticulation <- UM.replicate numV False
    numOfVisited <- newMutVar 0 :: ST s (MutVar s Int)

    let root = 0

    fix `flip` root `flip` nothing $ \dfs !v !p -> do
        !nv <- readMutVar numOfVisited
        modifyMutVar' numOfVisited (+1)
        UM.unsafeWrite num v nv
        UM.unsafeWrite parent v p
        UM.unsafeWrite low v nv

        U.forM_ (V.unsafeIndex gr v) $ \child -> do
            isVisited <- (/= nothing) <$> UM.unsafeRead num child
            if not isVisited
            then do
                dfs child v
                lc <- UM.unsafeRead low child
                unsafeModify low v (min lc)
                when (nv <= lc) $
                    UM.unsafeWrite isArticulation v True
            else
                when (child /= p) $ do
                    nc <- UM.unsafeRead num child
                    unsafeModify low v (min nc)

    ps <- U.unsafeFreeze parent
    let deg = U.length $ U.filter (== root) ps
    UM.unsafeWrite isArticulation root $ deg >= 2

    U.findIndices id <$> U.unsafeFreeze isArticulation


-------------------------------------------------------------------------------

readInt2 :: B.ByteString -> Maybe ((Int,Int), B.ByteString)
readInt2 bs = Just ((x,y),bsy)
  where
    Just (x, bsx) = B.readInt bs
    Just (y, bsy) = B.readInt $ B.unsafeTail bsx

unsafeModify :: (PrimMonad m, GM.MVector mv a)
             => mv (PrimState m) a -> Int -> (a -> a) -> m ()
unsafeModify v i f = GM.unsafeRead v i >>= GM.unsafeWrite v i . f
{-# INLINE unsafeModify #-}

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

public class Main {
    public static void main(String args[]) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String st[] =  in.readLine().split(" ");
        Arrays.sort(st,Collections.reverseOrder());
        System.out.println(Integer.parseInt(st[0]+st[1])+Integer.parseInt(st[2])); 
    }
}

Measured memory_bytes: 21204
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int x, n;
	cin >> x >> n;
	int* p = new int[n];
	rep(i, n) cin >> p[i];
	map<int, int> flag;
	rep(i, n) {
		flag[p[i]] += 1;
	}

	rep(i, 200) {
		if (flag[x - i] == 0) {
			cout << x - i << "\n";
			break;
		}
		else if (flag[x + i] == 0) {
			cout << x + i << "\n";
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 3616
# Import
from collections import deque

# I/O
def read(): return input()
def read_int(): return int(input())
def read_array(type=int): return list(map(type, input().split()))
def read_tupple(type=None):
    tmp = input().split()
    if type is None: return map(int, tmp)
    assert len(tmp) == len(type)
    return [type[i](tmp[i]) for i in range(len(tmp))]

# Implementation
class PrimeNumber:
    def __init__(self, N):
        self.N = N
        self.compute()

    def compute(self):
        self.isP, self.P = [True] * (self.N + 1), []
        for i in range(2, self.N+1):
            if self.isP[i]:
                self.P.append(i)
                for j in range(2*i, self.N+1, i):
                    self.isP[j] = False

N = read_int()

pn = PrimeNumber(1000006)
ans = 0
for p in pn.P:
    cnt = 0
    while N % p == 0:
        N /= p
        cnt += 1
    dec = 1
    while cnt >= dec:
        cnt -= dec
        dec += 1
        ans += 1
if N > 1:
    ans += 1
print(ans)

Measured memory_bytes: 81032
N,x = map(int,input().split())
AAA = map(int,input().split())
AA = list(AAA)
AA.sort()
total = 0
count =0
for i in AA:
  total += i
if total == x:
  ans = N
elif total < x:
  ans = N-1
else:
  for i in AA:
    if x >= i:
      x -= i
      count +=1
  ans = count
print(ans)

Measured memory_bytes: 8968