akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container;

void main()
{
    auto nv = readln.split.to!(long[]);
    auto N = nv[0];
    auto V = nv[1];
    auto aa = readln.split.to!(long[]);
    auto bb = readln.split.to!(long[]);
    auto cc = readln.split.to!(long[]);
    auto dd = readln.split.to!(long[]);
    long[long] ab, cd;
    foreach (a; aa) foreach (b; bb) ab[a+b] += 1; 
    foreach (c; cc) foreach (d; dd) cd[c+d] += 1;
    long r;
    foreach (x, n; ab) if (V-x in cd) r += n * cd[V-x];
    writeln(r);
}


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

int main(){
    int n, m;
    cin >> n >> m;

    vector<int> r(n+1);
    for(int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        r[x]++;
        r[y]++;
    }
    for(int i = 1; i <= n; i++){
        cout << r[i] << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5;
const ll mod = 1e9 + 7;
ll fact[maxn];
ll inv[maxn];
ll fp(ll b, ll x) {
	ll ans = 1;
	while (x) {
		if (x & 1) {
			ans = ans * b%mod;
		}
		b = b * b%mod;
		x >>= 1;
	}
	return ans;
}
ll Inv(ll x) {
	return fp(x, mod - 2);
}
void init() {
	fact[0] = 1;
	for (int i = 1; i < maxn ; i++) {
		fact[i] = fact[i - 1] * i %mod;
	}
	inv[maxn - 1] = fp(fact[maxn - 1], mod - 2);
	for (int i = maxn - 2; i >= 0; i--) {
		inv[i] = inv[i + 1] * (i + 1) % mod;
	}
}
ll C(ll n, ll m) {
	ll ans = 1;
	for (ll i = 0; i < m; i++) {
		ans = ans * (n - i) % mod;
	}
	ans = ans * inv[m] % mod;
	return ans;
}
int main() {
	init();
	ll n, a, b;
	cin >> n >> a >> b;
	ll ans = fp(2, n) - 1 - C(n, a) - C(n, b);
	while (ans < 0) {
		ans += mod;
	}
	ans %= mod;
	cout << ans << endl;
}


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

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

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;

#define INF INT_MAX
#define MOD 1000000007
#define all(x) x.begin(), x.end()

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

    ll N, A, B; cin >> N >> A >> B;
    ll k = N / (A + B);

    ll ans = A*k; N -= (A + B)*k;
    ans += min(A, N);
    cout << ans << endl;

    return 0;
}

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

#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for (size_t i = 0; i < (size_t) (n); i++)

using namespace std;
using ll = long long;

int main(void) {
  ll n, k;
  cin >> n >> k;
  auto as = vector<int>(n);
  REP(i, n) cin >> as[i];

  ll slow = 1;
  ll fast = 1;
  ll count = 0;
  auto ans = vector<int>();
  do {
    ans.push_back(slow);
    slow = as[slow - 1];
    fast = as[as[fast - 1] -1];
    count++;
  } while (slow != fast);

  auto ans2 = vector<int>();
  REP(i, count) {
    ans2.push_back(slow);
    slow = as[slow - 1];
  }

  if (k < count) {
    cout << ans[k] << endl;
  } else {
    cout << ans2[k % count] << endl;
  }
}


Measured memory_bytes: 6356
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
ll num[100010] = { 0 };

//ABC
int main() {
	ll n, a;
	cin >> n;
	for (ll i = 0;i < n;i++) {
		cin >> a;
		num[a]++;
	}
	if (n % 2 == 1) {
		if (n == 1) {
			if (num[0] == 0)cout << 1 << endl;
			else cout << 1 << endl;
		}
		else {
			for (ll i = 0;i < n;i++) {
				if (num[i] != 0) {
					if ((i == 0) && (num[i] != 1)) {
						cout << 0 << endl;
						return 0;
					}
					else {
						if ((i != 0) && (num[i] != 2)) {
							cout << 0 << endl;
							return 0;
						}
					}
				}
			}
			ll N = n / 2;
			ll ans = 2;
			for (ll i = 1;i < N;i++) {
				ans = (ans * 2) % (1000000007);
			}
			cout << ans << endl;
			return 0;
		}
	}
	else {
		for (ll i = 0;i < n;i++) {
			if (num[i] != 0) {
				if (i==0&&num[0] >= 1) {
					cout << 0 << endl;
					return 0;
				}
				else {
					if (i!=0&&num[i] != 2) {
						cout << 0 << endl;
						return 0;
					}
				}
			}
		}
		ll N = n / 2;
		ll ans = 2;
		for (ll i = 1;i < N;i++) {
			ans = (ans * 2) % (1000000007);
		}
		cout << ans << endl;
		return 0;
	}
	/*string a, b, c;
	cin >> a >> b >> c;
	if (b == "+") {
		ll num1 = stoi(a);
		ll num2 = stoi(c);
		cout << num1 + num2 << endl;
	}
	else {
		ll num1 = stoi(a);
		ll num2 = stoi(c);
		cout << num1 - num2 << endl;
	}*/
	/*int n, m, time = 0, a, b;
	cin >> n;
	vector<int>t(n);
	for (int i = 0;i < n;i++) {
		cin >> t[i];
		time += t[i];
	}
	cin >> m;
	vector<int>ans(m);
	for (int i = 0;i < m;i++) {
		cin >> a >> b;
		ans[i] = time - t[a - 1] + b;
	}
	for (int i = 0;i < m;i++)cout << ans[i] << endl;*/
	/*ll n, sum1 = 0, sum2 = 0;
	cin >> n;
	vector<int>a(n);
	for (ll i = 0;i < n;i++) {
		cin >> a[i];
		sum2 += a[i];
	}
	ll ans = 10000000000;
	for (ll i = 0;i < n-1;i++) {
		sum1 += a[i];
		sum2 -= a[i];
		ans = min(ans, abs(sum1 - sum2));
	}
	cout << ans << endl;*/
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
using namespace std;
typedef long long LL;
const LL N = 1e9 + 7;

LL n,ans = 1,s;
string a;
string b;
 
int main(){
	cin >> n; cin >> a; cin >> b;
	if(a[0] == b[0]){ ans = 3; s = 1; }
	if(a[0] != b[0]){ ans = 6; s = 2; }
	for(LL i = s;i < n;){
		if(a[i] == b[i] && a[i - 1] == b[i - 1]) ans *= 2;
		if(a[i] == b[i] && a[i - 1] != b[i - 1]) ans *= 1;
		if(a[i] != b[i] && a[i - 1] == b[i - 1]) ans *= 2;
		if(a[i] != b[i] && a[i - 1] != b[i - 1]) ans *= 3;
		if(a[i] != b[i]) i += 2;
		else i ++;
		ans %= N;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
h, w = (int(v) for v in input().split())
a = [input() for _ in range(h)]

my = [True for _ in range(h)]
mx = [True for _ in range(w)]

for y in range(h):
    for x in range(w):
        if a[y][x] != '.':
            break
    else:
        my[y] = False

for x in range(w):
    for y in range(h):
        if a[y][x] != '.':
            break
    else:
        mx[x] = False

s = ''
for y in range(h):
    for x in range(w):
        if my[y] and mx[x]:
            s += a[y][x]
    if my[y]:
        s += '\n'
print(s, end='')

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

void bfs(vector<vector<ll>> &friends,vector<bool> &checked,queue<ll> &q,ll &k){
  ll i;
  for(i=0;i<friends.at(k).size();i++){
    if(!checked.at(friends.at(k).at(i))){
      q.push(friends.at(k).at(i));
    }
  }
}

int main(void){
  ll n,m,k;
  cin >> n >> m >> k;
  ll a,b;
  vector<vector<ll>> friends(n,vector<ll>(0));
  ll i;
  for(i=0;i<m;i++){
    cin >> a >> b;
    a--;
    b--;
    friends.at(a).push_back(b);
    friends.at(b).push_back(a);
  }
  
  vector<ll> group(n);
  vector<bool> checked(n,false);
  queue<ll> q;
  for(i=0;i<n;i++){
    if(!checked.at(i)){
      q.push(i);
      while(!q.empty()){
        group.at(q.front())=i;
        bfs(friends,checked,q,q.front());
        checked.at(q.front())=true;
        q.pop();
      }
    }
  }
  
  vector<ll> count(n,0),member(n,0);
  for(i=0;i<n;i++){
    count.at(group.at(i))++;
  }
  for(i=0;i<n;i++){
    member.at(i)=count.at(group.at(i))-1-friends.at(i).size();
  }
  
  ll c,d;
  for(i=0;i<k;i++){
    cin >> c >> d;
    c--;
    d--;
    if(group.at(c)==group.at(d)){
      member.at(c)--;
      member.at(d)--;
    }
  }
  
  cout << member.at(0);
  for(i=1;i<n;i++){
    cout << " " << member.at(i);
  }
}


Measured memory_bytes: 12584
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <set>

using namespace std;
using ll = long long;
const int MOD = 1000000007;
const ll INF = 1LL << 60;

// LRUD
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
// const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
// const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

vector<vector<int> > vvi;
vector<vector<vector<int> > > vvvi;

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

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


int main(int argc, char**argv){
    ll r, d, x;
    cin >> r >> d >> x;

    ll now = x;
    for (ll i = 0; i < 10; i++){
        now = r * now - d;
        cout << now << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
  int n, i, j, total = 0, maxv, minv = 0;
  int *ip, *R;

  scanf("%d", &n);

  
  R = (int *)malloc(n * sizeof(int));

  for(i = 0; i < n; i++) scanf("%d", &R[i]);

  //for(i = 0; i < n; i++) printf("\nR[%d] = %d\n\n", i, R[i]);
  maxv = R[1] - R[0];
  minv = R[0];

  for(j = 1; j <= n - 1; j++){
    if(R[j] - minv > maxv) maxv = R[j] - minv;
    
    if(R[j] < minv) minv = R[j];
    
    //printf("maxv = %d\n", maxv);
    // printf("minv = %d\n\n", minv);

}
  //printf("minv = %d\n\n", minv);
  printf("%d\n", maxv);

 
  free(R);

  return 0;
}

Measured memory_bytes: 1152
#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
#define repi(i,a,b) for(lint i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) tsort(v); reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_1
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif

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; }

lint f(lint a){
    switch(a){
    case 2:{
        return 0;
    }
    case 1:case 3:case 5:case 7:case 8:case 10:case 12:{
        return 1;
    }
    default:{
        return 2;
    }
    }
}

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

    lint a,b;cin>>a>>b;
    Yes(f(a)==f(b));
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <fstream>
#include <iomanip>
#include <complex>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <queue>

#define IO ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef long double ld;
const ll INF = 1e18;
const int N = 1e3 + 5, inf = 1e9, mod = 998244353;
using namespace std;

int main()
{
    IO
    int n, k, a, cnt = 0;
    vector <int> vec, ans;
    map <int, int> mp;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
    {
        cin >> a;
        if(!mp[a])
            vec.push_back(a);
        mp[a]++;
    }
    for(auto i : vec)
        ans.push_back(mp[i]);
    sort(ans.rbegin(), ans.rend());
    for(int i = k; i < ans.size(); i++)
        cnt += ans[i];
    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 14904
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,ans=0;
string s;

int main()
{
	cin>>n>>s;
	int i=0;
	while(i<n)
	{
		int j=i;
		while(j<n&&s[i]==s[j]) j++;
		ans++;
		i=j;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
S = input()
ans = 0

# 値を入れられる場所がlen(S)-1箇所
for i in range(pow(2, len(S)-1)):
    bit = bin(i)[2:].zfill(len(S)-1)
    ind = 0
    res = 0
    for j in range(len(bit)):
        if bit[j] == "1":
            res += int(S[ind:j+1])
            ind = j+1
    res += int(S[ind:])
    ans += res

print(ans)


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

/*
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
*/

using namespace std;

class Dice
{
  public:
    int s[10];

    void roll(char dir)
    {
        int tmp[10];
        memcpy(tmp, s, sizeof(int) * 10);
        switch (dir)

        {
        case 'N':
            s[1] = tmp[2];
            s[2] = tmp[6];
            s[6] = tmp[5];
            s[5] = tmp[1];
            break;
        case 'E':
            s[1] = tmp[4];
            s[4] = tmp[6];
            s[6] = tmp[3];
            s[3] = tmp[1];
            break;
        case 'W':
            s[1] = tmp[3];
            s[3] = tmp[6];
            s[6] = tmp[4];
            s[4] = tmp[1];
            break;
        case 'S':
            s[1] = tmp[5];
            s[5] = tmp[6];
            s[6] = tmp[2];
            s[2] = tmp[1];
            break;
        case 'R':
            s[2] = tmp[3];
            s[3] = tmp[5];
            s[5] = tmp[4];
            s[4] = tmp[2];
            break;
        }
        return;
    }
    void roll(int x)
    {
        switch (x)
        {
        case 1:
            break;
        case 2:
            roll('N');
            break;
        case 3:
            roll('W');
            break;
        case 4:
            roll('E');
            break;
        case 5:
            roll('S');
            break;
        case 6:
            roll('N');
            roll('N');
            break;
        }
        return;
    }
    void print(){
        cout << "   " << s[1] << "    " << endl
             << " " << s[4] << " " << s[2] << " " << s[3] << " " << s[5] << endl
             << "   " << s[6] << "    " << endl
             << endl;
    }
};

bool comp(Dice d1, Dice d2)
{
    for (int i = 1; i <= 6; i++)
        if (d1.s[i] != d2.s[i])
            return false;
    return true;
}

int main()
{
    bool ans = false;

    Dice d1, d2;
    for (int i = 1; i <= 6; i++)
        cin >> d1.s[i];
    for (int i = 1; i <= 6; i++)
        cin >> d2.s[i];

    Dice tmp = d1;

    for (int i = 1; i <= 6; i++)
    {
        d1 = tmp;
        d1.roll(i);
        for (int i = 0; i < 4; i++)
        {
            d1.roll('R');
            //d1.print();
            if (comp(d1, d2)){
                ans = true;
                //cout << "/|_____d1 == d2" << endl
                //     << endl;
            }
        }
    }

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


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

using namespace std;

int main(){
  int x; cin >> x;
  if(x % 2 == 0) cout << x/2 -1 << endl;
  else cout << x/2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int A, B, ans;
    scanf("%d %d", &A, &B);
    ans = A - 2*B;
    if(ans < 0){
        printf("0\n");
    }else{
        printf("%d\n",ans);
    }
    
    return 0;
}


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

int main() {

    int n;

    cin >> n;

    int p[n];

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

    int ans = 0;

    for(int i=0;i<n-1;i++){
        if(p[i] == i+1){
            swap(p[i],p[i+1]);
            ans++;
        }
    }

    if(p[n-1] == n){
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(){
  int n,a,b=0;
  scanf("%d",&n);
  for(int i=1;i<=n;i++){
    scanf("%d",&a);
    if(a!=i){
      b++;
    }
  }
  if(b>2){
    printf("NO");
  }
  else{
    printf("YES");
  }
}

Measured memory_bytes: 128
//
//  main.c
//  program3-2
//
//  Created by 木元颯人 on 2019/02/21.
//  Copyright © 2019 木元颯人. All rights reserved.
//

#include <stdio.h>

int main(void){
    int a,b,n;
    scanf("%d",&n);
    scanf("%d",&a);
    scanf("%d",&b);
    if(a*n<b){
        printf("%d",a*n);
    }else{
        printf("%d",b);
    }
}


Measured memory_bytes: 128
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<cctype>
#include<cstdlib>
#include<cstring>
#include<utility>
#include<algorithm>
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define For(i,x,y) for(int i=((int)x);i<=((int)y);i++)
#define Dep(i,y,x) for(int i=((int)y);i>=((int)x);i--)
#define Rep(i,x) for (int y,i=head[x];i;i=E[i].nxt)
using namespace std;
 
typedef long long ll;
typedef unsigned int uint;
typedef pair<int,int> pii;
 
int rd() {
    char c=getchar(); int t=0,f=1;
    while (!isdigit(c)) f=(c=='-')?-1:1,c=getchar();
    while (isdigit(c)) t=t*10+c-48,c=getchar(); return t*f;
}
void wt(int x) {
    if (x<0) putchar('-'),wt(-x);
    else { if (x>9) wt(x/10); putchar(x%10+48); }
}

const int N=2e5+5;

char s[N];
int n,j,t,up,fail[N];
ll l,r,ans[26],len[101],pre[N][26],sum[101][26];

void solve(ll p,ll f) {
	for (int i=up;i>=0;i--) if (p>=len[i]) {
		p-=len[i];
		For (j,0,25) ans[j]+=f*sum[i][j];
	}
	For (j,0,25) ans[j]+=f*pre[p][j];
}

int main() {
	scanf("%s",s+1);
	scanf("%lld%lld",&l,&r);
	
	n=strlen(s+1)/2,j=0;
	For (i,2,n) {
		while (j && s[j+1]!=s[i]) j=fail[j];
		if (s[j+1]==s[i]) j++; fail[i]=j;
	}
	t=n-fail[n];
	For (i,1,n) For (j,0,25)
		pre[i][j]=pre[i-1][j]+(s[i]=='a'+j);
	
	len[0]=n;
	len[1]=n+t;
	For (j,0,25) {
		sum[0][j]=pre[n][j];
		sum[1][j]=pre[n][j]+pre[t][j];
	}
	for (up=2;len[up-2]+len[up-1]<=1e18;up++) {
		len[up]=len[up-2]+len[up-1];
		For (j,0,25) sum[up][j]=sum[up-2][j]+sum[up-1][j];
	}
	up--;
	
	solve(l-1,-1);
	solve(r,1);
	
	For (j,0,25) printf("%lld ",ans[j]); puts("");
	return 0;
}

Measured memory_bytes: 22912
// by syu
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var in = NewScanner(os.Stdin, 0)

func main() {
	n := in.Int()
	if n == 0 {
		Rln(n)
	}
	var a ByteSlice
	for n != 0 {
		r := Abs(n) % 2
		a = append(a, byte(r)+'0')
		n = (n - r) / -2
	}
	Pf("%s\n", ReverseBytes(a))
}

type Scanner struct {
	*bufio.Scanner
}

func NewScanner(r io.Reader, max int) *Scanner {
	s := bufio.NewScanner(r)
	s.Split(scanWords)
	if max <= 0 {
		max = 1048576
	}
	s.Buffer([]byte{}, max)
	return &Scanner{s}
}
func (s *Scanner) Int() int {
	s.Scan()
	i, e := strconv.ParseInt(s.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return int(i)
}
func isSpace(b byte) bool {
	return b == ' ' || b == '\n' || b == '\r' || b == '\t'
}
func scanWords(data []byte, atEOF bool) (advance int, token []byte, err error) {
	start := 0
	for start < len(data) && isSpace(data[start]) {
		start++
	}
	for i := start; i < len(data); i++ {
		if isSpace(data[i]) {
			return i + 1, data[start:i], nil
		}
	}
	if atEOF && len(data) > start {
		return len(data), data[start:], nil
	}
	return start, nil, nil
}
func Abs(n int) int {
	y := n >> 63
	return (n ^ y) - y
}
func Pf(f string, s ...interface{}) {
	fmt.Printf(f, s...)
}
func Rln(s ...interface{}) {
	fmt.Println(s...)
	os.Exit(0)
}

type ByteSlice []byte
type IntSlice []byte

func ReverseBytes(a []byte) []byte {
	r := make([]byte, len(a))
	for i, j := 0, len(a)-1; i <= j; i, j = i+1, j-1 {
		r[i], r[j] = a[j], a[i]
	}
	return r
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)


def solve():
    N, M = LI()
    a_list = LI()

    # 最小を取り出すのでマイナスにする
    a_list = [-1*a for a in a_list]

    import heapq
    heapq.heapify(a_list)

    for i in range(M):
        mn = heapq.heappop(a_list)
        mn = -1*(-1*mn // 2)
        heapq.heappush(a_list, mn)

    print(-1*sum(list(a_list)))


solve()

Measured memory_bytes: 14168
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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;
}

int main() {
    ll n,k;
    cin>>n>>k;
    vector<ll>a(n);
    vector<ll>f(n);
    for(int i=0;i<n;i++){
        cin>>a.at(i);
    }
    for(int i=0;i<n;i++){
        cin>>f.at(i);
    }

    sort(a.begin(),a.end());//昇順
    sort(f.begin(),f.end(),greater<ll>());//降順

    //二分探索で求める。
    vector<ll>b(n);
    ll MAX=-1;
    for(int i=0;i<n;i++){
        b.at(i)=a.at(i)*f.at(i);
        MAX=max(MAX,b.at(i));
    }
    ll left=-1;
    ll right=MAX;
    while(right-left>1){
        ll m = left+(right-left)/2;
        ll cnt=0;
        for(int i=0;i<n;i++){
            if(b.at(i)>m){
                cnt+=a.at(i)-m/f.at(i);//間違ってるかも
                // cout<<"m="<<m<<" cnt="<<cnt<<endl;
            }
        }
        if(cnt>k){
            left=m;
        }
        else{
            right=m;
        }
    }
    cout<<right<<endl;










    return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>
#include <string.h>


int del(int *s,int len){
	int check=0;
	for(int i=0;i<len-1;i++){
		if(s[i]!=s[i+1]){
			for(int f=i;f<len-2;f++){
				s[f]=s[f+2];
			}
			check=1;
			break;
		}
	}
	return check;
}

int main(){
	char n[100000];
	int S[100000];
	int length;
	int i;
	int cnt;
	
	gets(n);
	
	length=strlen(n);
	
	for(i=0;i<length;i++){
		S[i]=n[i]-'0';
	}
	
	cnt=0;
	while(del(S,length)==1){
		cnt++;
		length-=2;
	}
	
	printf("%d",cnt*2);
	
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n,t,x,y;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>t>>x>>y;
        if(!(x+y<=t&&(t-x-y)%2==0)){
            cout<<"No\n";
            return 0;
        }
    }
    cout<<"Yes\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    
    int a[N];
    for(int i=0; i<N; i++){
        cin >> a[i];
    }

    // 平均値を求める
    float ave;
    float sum = 0;
    for(int i=0; i<N; i++){
        sum += a[i];
    }
    ave = sum/N;
    
    // 距離を求める
    float b[N];
    for(int i=0; i<N; i++){
        b[i] = fabs(a[i]-ave);
    }
    
    //距離が最小のiを探査する
    int A = 0;
    float diff = b[0];
    for(int i=1; i<N; i++){
        if(b[i]<diff){
            diff = b[i];
            A = i;
        }
    }
    cout << A << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll h, w;
    char s[1100][1100];
    ll dx[4] = {1, -1, 0, 0}, dy[4] = {0, 0, 1, -1};
    ll d[1100][1100];

    cin >> h >> w;
    deque<pair<ll, ll>> dq;
    memset(d, -1, sizeof(d));
    rep(i, 0, h) rep(j, 0, w) {
        cin >> s[i][j];
        if(s[i][j] == '#') {
            dq.emplace_back(i, j);
            d[i][j] = 0;
        }
    }

    while(!dq.empty()) {
        auto p = dq.front();
        dq.pop_front();
        rep(i, 0, 4) {
            ll nx = p.first + dx[i], ny = p.second + dy[i];
            if (0 <= nx && nx < h && 0 <= ny && ny < w && d[nx][ny] == -1 && s[nx][ny] == '.') {
                d[nx][ny] = d[p.first][p.second] + 1;
                dq.emplace_back(nx, ny);
            }
        }
    }

    ll ans = 0;
    rep(i, 0, h) rep(j, 0, w) chmax(ans, d[i][j]);
    cout << ans << endl;
}


Measured memory_bytes: 27188
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  int r,d,x;
  cin >> r >> d >>x;
  for(int i=0;i<10;i++){
    x = r*x-d;
    cout<< x <<endl;
  }
}


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

template <int mod = (int)(1e9 + 7)>
struct ModInt {
  int x;
  constexpr ModInt() : x(0) {}
  constexpr ModInt(int64_t y)
      : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  constexpr ModInt &operator+=(const ModInt &p) noexcept {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt &p) noexcept {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt &p) noexcept {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  constexpr ModInt &operator/=(const ModInt &p) noexcept {
    *this *= p.inverse();
    return *this;
  }
  constexpr ModInt operator-() const { return ModInt(-x); }
  constexpr ModInt operator+(const ModInt &p) const noexcept {
    return ModInt(*this) += p;
  }
  constexpr ModInt operator-(const ModInt &p) const noexcept {
    return ModInt(*this) -= p;
  }
  constexpr ModInt operator*(const ModInt &p) const noexcept {
    return ModInt(*this) *= p;
  }
  constexpr ModInt operator/(const ModInt &p) const noexcept {
    return ModInt(*this) /= p;
  }
  constexpr bool operator==(const ModInt &p) const noexcept { return x == p.x; }
  constexpr bool operator!=(const ModInt &p) const noexcept { return x != p.x; }
  constexpr ModInt inverse() const noexcept {
    int a = x, b = mod, u = 1, v = 0, t = 0;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  constexpr ModInt pow(int64_t n) const {
    ModInt res(1), mul(x);
    while (n) {
      if (n & 1) res *= mul;
      mul *= mul;
      n >>= 1;
    }
    return res;
  }
  friend constexpr ostream &operator<<(ostream &os, const ModInt &p) noexcept {
    return os << p.x;
  }
  friend constexpr istream &operator>>(istream &is, ModInt &a) noexcept {
    int64_t t = 0;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  constexpr int get_mod() { return mod; }
};

long long n, m;
vector<vector<vector<ModInt<>>>> dp;

ModInt<> solve();

int main() {
  cin >> n >> m;
  cout << solve() << endl;
  return 0;
}

ModInt<> solve() {
  ModInt<> res = 0;
  dp.assign(2, vector(n + 1, vector<ModInt<>>(2, 0)));
  for (int i = 0; i <= n; ++i) dp[0][i][0] = 1;
  for (int i = 0; i < m; ++i) {
    dp[i + 1 & 1].assign(n + 1, vector<ModInt<>>(2, 0));
    for (int j = 0; j <= n; ++j)
      for (int k = 0; k < 2; ++k) {
        // fi: red
        if (j != 0) {
          int num = k || (j == n);
          // se : red
          dp[i + 1 & 1][j - 1][num] += dp[i & 1][j][k];
          // se : blue
          dp[i + 1 & 1][j][num] += dp[i & 1][j][k];
        }
        // fi : blue
        if (j != n) {
          int num = k || (j == 0);
          // se : red
          dp[i + 1 & 1][j][num] += dp[i & 1][j][k];
          // se : blue
          dp[i + 1 & 1][j + 1][num] += dp[i & 1][j][k];
        }
      }
  }
  for (int i = 0; i <= n; ++i) res += dp[m & 1][i][1];
  return res;
}

Measured memory_bytes: 4020
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)
typedef pair<int, int> P;

int main() {
    int l;
    cin >> l;
    double ans = 0;
    ans = (l/3.0*l/3.0*l/3.0);
    printf("%.10lf\n", l*l*l/27.0); 
    //printf("%.10lf\n", double(ans));
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <random>
#include <deque>
#include <bitset>
#include <string>
#include <queue>
#include <complex>

//#define int long long

#define mp(a, b) make_pair(a, b)
#define all(v) (v).begin(), (v).end()

#define endl '\n'

using namespace std;
typedef long long ll;
typedef long double ld;

mt19937 mrand(random_device{}());

double PI = acos((double)-1);
const double eps = 1e-8;
const ll inf0 = 1023 * 1024 * 1024;
const ll inf = inf0 * inf0;
const ll mod = 1e9 + 7;
//const ll mod2 = 998244353;

void solve();
void scan();

signed main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	cout << fixed; cout.precision(15);
	solve();
	return 0;
}

const int N = 1e5 + 7;

vector<pair<int, int>> g[N];
int ans[N];
int t = 0;

void dfs(int v, int c = -1, int last = -1) {
	t = max(t, (int)g[v].size());
	int tmp = 0;
	for (auto u : g[v]) {
		if (u.first == last) continue;
		if (tmp == c) tmp++;
		ans[u.second] = tmp;
		dfs(u.first, tmp, v);
		tmp++;
	}
}

void solve() {
	int n; cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int a, b; cin >> a >> b; a--; b--;
		g[a].push_back({ b, i }); g[b].push_back({ a, i });
	}
	dfs(0);
	cout << t << endl;
	for (int i = 0; i < (n - 1); i++) cout << ans[i] + 1 << endl;
}


Measured memory_bytes: 9344
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
	int N;
	cin>>N;
	map<string,int> myMap;
	map<string,int>::iterator mit;
	int i;
	string word;
	char ch;
	for (i=0;i<N;i++){
		if (word.size()>0){
			ch=word[word.size()-1];
		}
		cin>>word;
		if (myMap.size()==0){
			myMap[word]=1;
		}else{
			if (word[0]!=ch){
				cout<<"No"<<endl;
				return 0;
			}
			mit=myMap.find(word);
			if (mit!=myMap.end()){
				cout<<"No"<<endl;
				return 0;
			}
			myMap[word]=1;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
using namespace std;
typedef long long ll;


int main(int argc, char *args[]) {
	int K;
	cin >> K;
	if (K % 2 == 0) {
		cout << K / 2 * K / 2 << endl;
	}
	else {
		cout << K / 2 * (K / 2 + 1) << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
  string S;
  cin >> S;

  if (S.size() == 3) reverse(S.begin(), S.end());
  cout << S << endl;
	return 0;
}



Measured memory_bytes: 764
// tested on node version 0.10.36
var fs = require("fs");
function digit_count(c) {
    return String(c).length;
}
var input = fs.readFileSync('/dev/stdin').toString();
var lines = input.split("\n");
for(var i = 0; i < lines.length; i++) {
    var parts = lines[i].split(" ");
    var a = parseInt(parts.shift());
    var b = parseInt(parts.shift());
    if(!isNaN(a + b)) {
        console.log(digit_count(a + b));
    }
}

Measured memory_bytes: 16108
#include<stdio.h>

int main()
{
    int a,b,c,t;
    scanf("%d %d %d",&a,&b,&c);
    if(a > b){
        t = a;
        a = b;
        b = t;
    }
    if(a > c){
        t = a;
        a = c;
        c = t;
    }
    if(b > c){
        t = b;
        b = c;
        c = t;
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#define SENTINEL 1000000000;
using namespace std;

struct CardData {
	string suit;
	int    value;
};
CardData Q[100001],M[100001],L[50001],R[50001];

int partition(CardData A[],int n,int min,int max) {
	int r = A[max].value;
	int i = min - 1;

	for (int j = min; j <max; j++) {
		if (A[j].value <= r) {
			swap(A[j], A[++i]);
		}
	}

	swap(A[max], A[i + 1]);

	return i+1;
}

void quickSort(CardData A[],int n, int min, int max) {
	int q;
	if (min < max) {
		int q = partition(A, n, min, max);
				quickSort(A, n, min, q - 1);
				quickSort(A, n, q + 1, max);
	}
}

void merge(CardData A[], int n,int left ,int mid ,int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	for (int t = 0; t < n1; t++)L[t] = A[left+t];
	for (int t = 0; t < n2; t++)R[t] = A[mid +t];
	L[n1].value = R[n2].value = SENTINEL;

	int l = 0, r = 0;
	for (int t = left; t < right; t++) {
		if (L[l].value > R[r].value) {
			A[t] = R[r];
			r++;
		}
		else {
			A[t] = L[l];
			l++;
		}
	}

}

void mergeSort(CardData A[], int n,int left, int right) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(A, n, left, mid);
		mergeSort(A, n, mid, right);
		merge    (A, n, left, mid, right);
	}
}

void print(CardData A[],int n){
	for (int t = 0; t < n; t++) {
		cout << A[t].suit << " " << A[t].value << "\n";
	}
}

int main() {
	int n, cont = 0;
	cin >> n;
	for (int t = 0; t < n; t++) { 
		cin >> Q[t].suit >> Q[t].value; 
		M[t].suit  = Q[t].suit;
		M[t].value = Q[t].value;
	}

	quickSort(Q, n, 0, n - 1);
	mergeSort(M, n, 0, n);

	for (int t = 0; t < n; t++) {
		if (Q[t].suit != M[t].suit)cont++;
	}
	if (cont > 0) {
		cout << "Not stable" << "\n";
	}
	else if(cont==0) {
		cout << "Stable" << "\n";
	}

	print(Q, n);

	return 0;
}


Measured memory_bytes: 12388
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

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

	int ans = INF;
	for (int i = 0; i+k-1 < n; i++) {
		int tmp = abs(a[i] - a[i + k - 1]);
		ans = min(ans, tmp);
	}

	cout << ans << endl;


	return 0;
}

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

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	vector<string> ans(h, string(w, '0'));
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if((i < b) == (j < a)){
				ans[i][j] = '1';
			}
		}
	}
	for(int i = 0; i < h; i++){
		cout << ans[i] << '\n';
	}
}

Measured memory_bytes: 2304
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        while( scan.hasNextInt() ){
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = a+b;
        int i = 1;
        while(c / 10 > 0){
           c = c / 10;
                 i++;
        }   System.out.println(i);
            
            
        

    }
   }
}   




Measured memory_bytes: 26660
#include <iostream>
using namespace std;
int main()
{
	int A,B ;
	cin>>A>>B ;
	if (A==1) {
		A=14 ;
	}
	if (B==1) {
		B=14 ;
	}
	if (A<=14 && B<=14 && A!=0 && B!=0)

	{
		if(A>B || A==1) {
			cout<<"Alice" ;
		}
		else if (B>A || B==1) { 
			cout<<"Bob" ;
		}
		else {
			cout<<"Draw" ;
		}

	}
     
	return 0;

}

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

#define rep(i, n)  for (int i = 0; i < (int) (n); i++)
#define Rrep(i, n) for (int i = ((int) n - 1); i >= 0; i--)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
#define INF 2e15
#define MOD 10e9 + 7

typedef vector <int> vint;
typedef long long    ll;

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    string s;
    cin >> s;

    if (s == "SUN") {
        cout << "7" << endl;
    }
    else if (s == "MON") {
        cout << "6" << endl;
    }
    else if (s == "TUE") {
        cout << "5" << endl;
    }
    else if (s == "WED") {
        cout << "4" << endl;
    }
    else if (s == "THU") {
        cout << "3" << endl;
    }
    else if (s == "FRI") {
        cout << "2" << endl;
    }
    else if (s == "SAT") {
        cout << "1" << endl;
    }

    return 0;
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	deque<char> s;
	string tmp;
	cin>>tmp;
	REP(i,0,tmp.size())
	{
		s.push_back(tmp.at(i));
	}

	lli q;
	cin>>q;
	bool state=false;

	REP(i,0,q){

		lli now;
		cin>>now;
		if(now==1){
			if(state)state=false;
			else state = true;
		}
		else{
			lli f;
			cin>>f;
			char c;
			cin>>c;
			if(f==1){
				if(!state)s.push_front(c);
				else  s.push_back(c);
			}
			else{
				if(!state)s.push_back(c);
				else s.push_front(c);
			}
		}
	}
	if(!state){
		while(s.size()){

			char top = s.front();
			cout<<top;
			s.pop_front();
		}
	}
	else{
		while(s.size()){
			char top = s.back();
			cout<<top;
			s.pop_back();
		}
	}

	return 0;
}

Measured memory_bytes: 1024
I=lambda:list(map(int,input().split()));n,m=I();p=I();l=[i for i in range(n+1)]
def u(x):
 if l[x]!=x:l[x]=u(l[x])
 return l[x]
for _ in[0]*m:x,y=I();l[u(x)]=u(y)
print(sum(u(i)==u(j)for i,j in enumerate(p,1)))

Measured memory_bytes: 14008
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    A, B, N = LI()

    def f(x):
        return int(A*x/B)-A*int(x/B)

    print(f(min(B-1, N)))

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 9220
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
  int n,k,i,j,d,a,c=0;
  int m[100]={};

  scanf("%d %d",&n,&k);
  for(i=0;i<k;i++)
  {
    scanf("%d",&d);
    for(j=0;j<d;j++)
    {
      scanf("%d",&a);
      m[a-1]=1;
    }
  }

  for(i=0;i<n;i++)
  {
    if(m[i]==0) c++;
  }

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

  return 0;
}

Measured memory_bytes: 1728
(N, M, X), *T = [[*map(int, line.split())] for line in open(0)]

ans = 12345678
for bit in range(1, 2**N):
    t = [T[i] for i in range(N) if bit & (1 << i)]
    c, *a = map(sum, zip(*t))
    if all(e >= X for e in a):
        ans = min(ans, c)

print(-1 if ans == 12345678 else ans)


Measured memory_bytes: 9204
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	ll N, A, B;
	cin >> N >> A >> B;
	if ((B - A) % 2 == 0) {
		cout << (B - A) / 2 << endl;
	}
	else {
		cout << min(A - 1, N - B) + (B - A + 1) / 2 << endl;
	}
}

Measured memory_bytes: 256
s=input()
t=input()
#print(s,t)

if len(s) < len(t):
    print('UNRESTORABLE') 
elif len(s) == len(t):
  cnt=0
  for i in range(len(s)):
    if s[i] == t[i]:
      cnt+=1
    elif s[i] == '?':
      cnt+=1
  if len(t)==cnt:
    print(t)
  else:
    print('UNRESTORABLE') 
else:
  flag1=0
  for j in range(len(s)-len(t),-1,-1):
    cnt=0
    for i in range(len(t)):
      if s[i+j]==t[i]:
        cnt+=1
      elif s[i+j]=='?':
        cnt+=1
    if cnt==len(t):
      flag1=1
      if j==0:
        s=t+s[len(t):]
      if 0 < j < len(s)-len(t)+1:
        s=s[0:j]+t+s[j+len(t):]
      if j == len(s)-len(t)+1:
        s=s[0:j]+t      
      s=s.replace('?','a')
      print(s)
    
  if flag1==0:
    print('UNRESTORABLE') 



Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
  int i, n;
  string str;
  string str2 = "Hoshino";
  string::iterator iter;

  cin >> n;

  for(i=0; i<=n; ++i){
    getline(cin, str);

    iter = str.begin();
    while(1){
      iter = search(iter, str.end(), str2.begin(), str2.end());
      if(iter == str.end()) break;

      iter += 6;
      *iter = 'a';
    }
    if(i != 0)
      cout << str << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

char buf[129];
int filter[128];
int POW[20],table[19],next_table[19];
int calc[19][7] = {{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},{11,12,5,6,7,0,1},
		{12,8,6,7,3,1,2},{13,9,12,8,4,7,3},{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},{15,16,10,11,12,5,6},{16,13,11,12,8,6,7},{17,14,16,13,9,12,8},
		{0,0,0,0,0,0,0},{0,0,0,0,0,0,0},{18,17,15,16,13,11,12},{0,0,0,0,0,0,0},{0,0,0,0,0,0,0}};



int getState(int loc){
	int sum = 0;
	for(int i = 0; i < 7; i++){
		sum += table[calc[loc][i]]*POW[i];
	}
	return sum;
}

void func(){

	for(int i = 0; i < 128; i++){
		filter[i] = buf[i] - '0';
	}

	int state,first_data,second_data;

	bool FLG = true;

	for(int i = 0; i < POW[19]; i++){

		for(int k = 0; k < 19; k++){
			if(i & (1 << k)){
				table[k] = 0;
			}else{
				table[k] = 1;
			}
		}

		state = getState(12);
		next_table[12] = filter[state];
		first_data = filter[state];

		state = getState(6);
		next_table[6] = filter[state];

		state = getState(7);
		next_table[7] = filter[state];

		state = getState(8);
		next_table[8] = filter[state];

		state = getState(11);
		next_table[11] = filter[state];

		state = getState(13);
		next_table[13] = filter[state];

		state = getState(16);
		next_table[16] = filter[state];

		state = 0;
		for(int a = 0; a < 7; a++){
			state += next_table[calc[12][a]]*POW[a];
		}
		second_data = filter[state];

		if(first_data != second_data){
			FLG = false;
			break;
		}
	}

	if(FLG){
		printf("yes\n");
	}else{
		printf("no\n");
	}


}

int main(){

	for(int i = 0; i < 20; i++){
		POW[i] = pow(2,i);
	}

	while(true){
		scanf("%s",buf);
		if(buf[0] == '#')break;

		func();
	}
	return 0;
}

Measured memory_bytes: 2636
#include<cstdio>
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>

using namespace std;

const int CMax = 32;

int n, A[CMax];
string S;
long long ats;

int main(){
    cin >> S;
    n = (int)S.length();
    ats = ((long long)n * (long long)(n-1)) / 2 + 1;
    for (int i = 0; i < n; i++) {
        A[(int)S[i] - 'a']++;
    }
    for (int i = 0; i < 28; i++){
        ats -= ((long long)(A[i]) * (long long)(A[i]-1)) / 2;
    }
    cout << ats << endl;
}


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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#define int ll
//#define endl '\n'

int32_t main()
{
    IOS
    int a,b;
    cin>>a>>b;
    if ((a+b)&1) cout<<"IMPOSSIBLE"<<endl;
    else cout<<(a+b)/2<<endl;
}



Measured memory_bytes: 256
n = int(input())
s = [list(map(int, input().split())) for i in range(n)]  # 数値の二次元配列入力

for i in range(n):
    if i < n-2:
        if s[i][0] == s[i][1] and s[i+1][0] == s[i+1][1] and s[i+2][0] == s[i+2][1]:
            print('Yes')
            exit()
print('No')


Measured memory_bytes: 62552
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder119B
{
    class Program
    {
        static void Main(string[] args)
        {
            // 整数の入力
            int N = int.Parse(Console.ReadLine());
            float[] x = new float[N];
            string[] u = new string[N];
            // スペース区切りの整数の入力
            float ans = 0f;
            for(var i = 0; i < N; i++)
            {
            string[] input = Console.ReadLine().Split(' ');
            x[i] = float.Parse(input[0]);
            u[i] = input[1];
                if (u[i] == "JPY")
                {
                    ans += x[i];
                }
                else
                {
                    ans += x[i] * 380000f;
                }
            }
            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 13140