akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template<typename T = int> vector<T> create(size_t n){ return vector<T>(n); }
template<typename T, typename... Args> auto create(size_t n, Args... args){ return vector<decltype(create<T>(args...))>(n, create<T>(args...)); }
const int M = 100010;
int ways[1025][M];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> v(n + 1), w(n + 1);
	for(int i = 1; i <= n; i++) cin >> v[i] >> w[i];
	const int m = min(n, 1024);
	for(int i = 1; i <= m; i++){
		vector<int> at;
		{
			int j = i;
			while(j){
				at.push_back(j);
				j /= 2;
			}
		}
		int len = at.size();
		for(int j = 0; j < 1<<len; j++){
			int wei = 0, val = 0;
			for(int k = 0; k < len; k++){
				if((j>>k)&1){
					wei += w[at[k]];
					val += v[at[k]];
				}
			}
			if(wei < M){
				ways[i][wei] = max(ways[i][wei], val);
			}
		}
		for(int j = 1; j < M; j++) ways[i][j] = max(ways[i][j], ways[i][j - 1]);
	}
	int q;
	cin >> q;
	while(q--){
		int V, l;
		cin >> V >> l;
		vector<int> at;
		int u = V;
		while(u > m){
			at.push_back(u);
			u /= 2;
		}
		int len = at.size();
		int ans = 0;
		for(int j = 0; j < 1<<len; j++){
			int wei = 0, val = 0;
			for(int k = 0; k < len; k++){
				if((j>>k)&1){
					wei += w[at[k]];
					val += v[at[k]];
				}
			}
			if(wei <= l){
				ans = max(ans, ways[u][l - wei] + val);
			}
		}
		cout << ans << '\n';
	}
	return 0;
}


Measured memory_bytes: 405460
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)2e5 + 9;
int p[MAXN], r[MAXN];
unordered_map<int, int> mp;
	// mp.reserve(MAXN);

void init() {
	for (int i = 0; i < MAXN; ++i) {
		p[i] = i;
		r[i] = 1;
	}
	// mp.reserve(MAXN);
	mp.clear();
}

int find(int u) {
	if(p[u] != u) 
		p[u] = find(p[u]);
	return p[u];
}

void unionFunc(int u, int v) {
	int pu = find(u);
	int pv = find(v);
	if(pu == pv)
		return ;
	if(r[pv] == r[pu]) {
		p[pv] = pu;
		++r[pu];
	} else if(r[pu] < r[pv]) {
		p[pu] = pv;
	} else
		p[pv] = pu;
	return ;	
}

int main() {
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
	#endif
	init();
	int N, M;
	cin >> N >> M;
	// cout << "N: " << N << " M: " << M << '\n';
	long long ans = 0;
	// unordered_map<int, int> pp;
	// pp.clear();
	for (int i = 0; i < M; ++i) {
		int A, B;
		cin >> A >> B;
		// int pa = find(A);
		// int pb = find(B);
		// A = min(A, B);
		// B = max(A, B);
		// if(pp.find(A) == pp.end()){
		unionFunc(A, B);
			// ++pp[A];
		// }
		// cout << "UNION\n";
	}
	mp.clear();
	for (int i = 0; i <= N; ++i) {
		++mp[(int)find(i)];
		// cout << "FIND\n";
	}

	for (auto it = mp.begin(); it != mp.end(); ++it) {
		// if(it->second == ans)
			// ans = max(ans, (long long)it->second) + 1;
		ans = max(ans, (long long)it->second);
		// cout << "MP\n";
	}

	cout << ans << '\n';
	return 0;
}

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


for i in range(n):
    ip = 0
    for j in range(m):
        ip = ip + A[i][j] * b[j]
    print(ip)


Measured memory_bytes: 6016
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int a,b,c,k;
	cin >> a>>b>>c>>k;
	int mn=max(a,max(b,c));
	for(int i=0;i<k;i++){
        mn*=2;
	}
	
    cout << mn+a+b+c-max(a,max(b,c)) << endl;

	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func f(a int64, b int64, c int64) int64 {
	switch true {
	case a <= b && b <= c: return c - a
	case c <= b && b <= a: return a - c
	case c <= a && a <= b: return b - c
	case b <= a && a <= c: return c - b
	case b <= c && c <= a: return a - b
	case a <= c && c <= b: return b - a
	}
	return -1
}

func g(a int64, b int64) (int64, int64) {
	if a % 2 == 0 || b % 2 == 0 {
		return a * b / 2, a * b / 2
	} else if a < b {
		return b / 2 * a, (b+1) / 2 * a
	} else {
		return a / 2 * b, (a+1) / 2 * b
	}
}

func main() {
	var h, w int64
	fmt.Scan(&h, &w)
	var res int64 = math.MaxInt64
	var i int64
	for i = 1; i < h; i++ {
		x, y := g(h-i, w)
		tmp := f(x, y, i*w)
		if tmp < res {
			res = tmp
		}
	}
	for i = 1; i < w; i++ {
		x, y := g(w-i, h)
		tmp := f(x, y, i*h)
		if tmp < res {
			res = tmp
		}
	}
	fmt.Println(res)
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int a;
	cin >> a;
	if (a % 2 == 1)cout << (a + 1) / 2 * (a / 2);
	else cout << a * a / 4 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  int N,M; cin>>N>>M;
  cout << (N==M?Liny:Linn);
}

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

int main()
{
  char sidemap[5][4];
  char upmap[4][5];
  int x=0,y=0;
  for(int i=0;i<9;i++)
    {
      if(i%2==0)
	{
	  for(int j=0;j<4;j++)
	      cin>>sidemap[i/2][j];
	}
      else
	{
	  for(int j=0;j<5;j++)
	    cin>>upmap[i/2][j];
	}
    }
  /*
  for(int i=0;i<5;i++,cout<<endl)
    for(int j=0;j<4;j++)
      {
	cout<<sidemap[i][j];
      }

  for(int i=0;i<4;i++,cout<<endl)
    for(int j=0;j<5;j++)
      {
	cout<<upmap[i][j];
      }
  */
  char move='R';
  do{
    //cout<<"now:"<<x<<","<<y;
    //    cout<<"X,y="<<x<<","<<y<<endl;
    //次の移動方向
    if(move=='L')
      {
	if(x<4&&upmap[x][y]=='1')
	  move='D';
	else if(y>0 && sidemap[x][y-1]=='1')
	  move='L';
	else if(x>0 && upmap[x-1][y]=='1')
	  move='U';
	else
	  move='R';
      }
    else if(move=='R')
      {
	if(x>0&&upmap[x-1][y]=='1')
	  move='U';
	else if(y<4 && sidemap[x][y]=='1')
	  move='R';
	else if(x<4&&y<5&&upmap[x][y]=='1')
	  move='D';
	else
	  move='L';
      }
    else if(move=='U')
      {
	if(y>0&&sidemap[x][y-1]=='1')
	  move='L';
	else if(x>0&&upmap[x-1][y]=='1')
	  move='U';
	else if(x<5&&y<4&&sidemap[x][y]=='1')
	  move='R';
	else
	  move='D';
      }
    else if(move=='D')
      {
	if(x<5&&y<4&&sidemap[x][y]=='1')
	  move='R';
	else if(x<4&&upmap[x][y]=='1')
	  move='D';
	else if(y>0&&sidemap[x][y-1]=='1')
	  move='L';
	else 
	  move='U';
      }
    //次の移動方向
    if(move=='L')
      {
	y--;
      }
    else if(move=='R')
      {
	y++;
      }
    else if(move=='U')
      {
	x--;
      }
    else if(move=='D')
      {
	x++;
      }
      
      cout<<move;
      ///      cout<<endl;
  }while(x!=0||y!=0);
  cout<<endl;
}

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

int main() {
	int N, a, b, c;
	cin >> N;
	vector<ll> A(N), B = A;
	for (int i = 0;i < N;i++) {
		cin >> A[i];
	}
	for (int i = 0;i < N;i++) {
		cin >> B[i];
	}

	queue<int> Q;
	for (int i = 0;i < N;i++) {
		a = i - 1; if (a == -1)a = N - 1;
		b = i;
		c = i + 1; if (c == N)c = 0;

		if (B[b] - A[b] >= B[a] + B[c])Q.push(b);
	}

	ll ans = 0;

	while (!Q.empty()) {
		b = Q.front();
		a = b - 1; if (a == -1)a = N - 1;
		c = b + 1; if (c == N)c = 0;
		Q.pop();

		if (B[b] - A[b] >= B[a] + B[c]) {
			ans += (B[b] - A[b]) / (B[a] + B[c]);
			B[b] = (B[b] - A[b]) % (B[a] + B[c]) + A[b];
			Q.push(a);
			Q.push(c);
		}
	}
	for (int i = 0;i < N;i++) {
		if (A[i] != B[i])ans = -1;
	}
	cout << ans << endl;
}


Measured memory_bytes: 4224
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	list := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&list[i])
	}

	count := 0
	min := list[0]
	for i := 0; i < n; i++ {
		if min >= list[i] {
			min = list[i]
			count++
		}
	}
	fmt.Println(count)
}


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

int main(){
  int INF=-10000;

  int d;
  int i,j,k;
  cin>>d;
  vector<int> ans(d);
  for(k=0;k<d;k++){
    string a,b;
    cin>>a>>b;

    vector<vector<int>> dp(a.size()+1,vector<int>(b.size()+1,0));
    dp.at(0).at(0)=0;
    for(i=0;i<a.size();i++){
      // cout<<"i "<<i<<endl;
      for(j=0;j<b.size();j++){
        // cout<<"j "<<j<<endl;
        if(a.at(i)==b.at(j)){
          dp.at(i+1).at(j+1)=dp.at(i).at(j)+1;
        } else{
          dp.at(i+1).at(j+1)=max(dp.at(i).at(j+1),dp.at(i+1).at(j));
        }
      }
    }

    ans.at(k)=dp.at(a.size()).at(b.size());
}

for(k=0;k<d;k++)
cout<<ans.at(k)<<endl;

}



Measured memory_bytes: 6888
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
#ifdef DAIJOBU
#include "/home/v-o_o-v/deb.h"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif 

using namespace std;

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#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)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef long long lint;
typedef double ld;

const int maxn = 1e5 + 100;
int dp[maxn][3];
int a[maxn], b[maxn], c[maxn];
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;
    forn(i, n)cin >> a[i] >> b[i] >> c[i];
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for(int i = 1; i < n; i++){
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
    }
    cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]});
    return 0;
}
// Write Here


Measured memory_bytes: 5948
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef long long LL;
typedef pair<int , int > P;
const int maxn=3005;
const LL INF=1e13+5;
LL DP[maxn][maxn][4];
int rc[maxn][maxn];
int main()
{
    memset(DP, 0, sizeof DP);
    memset(rc, 0, sizeof rc);
    LL R , C , K;
    cin >> R >> C >> K;
    while(K--)
    {
        int a, b, c;
        cin >> a >> b >> c;
        rc[a][b]=c;
    }
    for(int i=R;i>=1;i--)
    for(int k=C;k>=1;k--)
    {
       // cout << DP[i][k+1][1] << ' '<< DP[i][k+1][2] << ' '<< DP[i][k+1][3] << endl;
        //cout << DP[i+1][k][1] << ' '<< DP[i+1][k][2] << ' '<< DP[i+1][k][3] << endl;
        //cout << endl;
        for(int n=1;n<=3;n++)
        {
            if(!rc[i][k])
            DP[i][k][n]=max(DP[i+1][k][n], DP[i][k+1][n]);
            else
            {
                 LL max1=0;
                 if(n==1)
                for(int x=1;x<=3;x++) max1=max(max1, DP[i+1][k][x]+rc[i][k]);
                if(n!=1&&DP[i][k+1][n-1]==0)
                {
                    DP[i][k][n]=0;
                    continue;
                }
                max1=max(DP[i][k+1][n], max(DP[i][k+1][n-1]+rc[i][k], max1));
                DP[i][k][n]=max1;
            }
        }

    }
    LL ans=-4;
    for(int i=1;i<=3;i++)
        ans=max(ans, DP[1][1][i]);
    cout << ans;
    return 0;
}



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

 int  main() {
     
     int n,h;
     cin>>n>>h;
     if(n>=10){
         cout<<h<<endl;
     }else if(n<10){
         int d=100*(10-n);
         cout<<h+d<<endl;
     }
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

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

    int a, b;
    char op;

    cin >> a >> op >> b;

    if (op == '+') {
        a += b;
    } else {
        a -= b;
    }

    cout << a << endl;

    return 0;
}


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

int main() {
  int X;
  cin >> X;
  
  if(X >=1800) cout << 1 << endl;
  else if(X >=1600) cout << 2 << endl;
  else if(X >=1400) cout << 3 << endl;
  else if(X >=1200) cout << 4 << endl;
  else if(X >=1000) cout << 5 << endl;
  else if(X >=800) cout << 6 << endl;
  else if(X >=600) cout << 7 << endl;
  else cout << 8 << endl;
}

Measured memory_bytes: 3632
import heapq
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 9)
INF = 10e18
MAX_V = 50
MAX_S = MAX_V*50+5

n, m, s = map(int, input().split())
g = [[] for _ in range(n)]
for i in range(m):
    u,v,a,b = map(int, input().split())
    g[u-1].append((v-1,a,b))
    g[v-1].append((u-1,a,b))
cd = [list(map(int, input().split())) for _ in range(n)]

# print(g)
# print(cd)
dp = [[INF]*(MAX_S+5) for _ in range(MAX_V)]   # 頂点vに銀貨xを持っている時の時間
s = min(s, MAX_S)
q = []

def push(v,s,x):
    if s<0: return
    if dp[v][s]<=x: return
    dp[v][s] = x
    heapq.heappush(q, (x,s,v))

push(0, s, 0)
while q:
    x,s,v = heapq.heappop(q)
    if dp[v][s] != x: continue
    ns = min(s+cd[v][0], MAX_S)
    push(v, ns, x+cd[v][1])
    for to, a, b in g[v]:
        push(to, s-a, x+b)

# print(dp)
for i in range(1,n):
    print(min(dp[i][:MAX_S+5]))
    # print(dp[i][:50])


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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            int ans = 0;
            for (double i = 0; i < 50000; i++) {
                int zeikomi = (int)(i * 1.08);
                if (zeikomi == N) {
                    ans = (int)i;
                    break;
                }
            }

            if (ans == 0) {
                Console.WriteLine(":(");
            } else {
                Console.WriteLine(ans);
            }

        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define dd double
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ll long long
#define ull unsigned long long
#define ld long double
#define mx 200005
#define mod 1000000007
#define fr first
#define cti(a) (a-48)
#define itc(a) char(a+48)
#define se second
#define End cout<<"\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define memo(Array,val) memset(Array, val, sizeof Array)
#define PI acos(-1)
bool check(ll n, ll pos){ return (n&(1<<pos)); }
bool Set(ll n, ll pos) {  return (n | (1<<pos)); }
ld LOG(ld b, ld e){ return log(b)/log(e); }

int tc=1;

void solve(int kk)
{
   ll a,b,c;
   cin >> a >> b >> c;

   cout << c << " " << a << " " << b << "\n";

}

int main()
{
   fast;
   int kk=0;
//   cin >> tc;
   while(++kk<=tc) solve(kk);

   return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  map<int, int> m;
  int a, b, c; cin >> a >> b >> c;
  m[a]++; m[b]++; m[c]++;
  if(m[5] == 2 && m[7] == 1){
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
  system("pause");
}

Measured memory_bytes: 504
N,Y=gets.chomp.split.map(&:to_i)
0.upto(N) do |i|
  0.upto(N-i) do |j|
    if Y == 10000 * i + 5000 * j + 1000 * (N-i-j)
      printf("%d %d %d\n",i,j,N-i-j)
      exit
    end
  end
end
puts "-1 -1 -1"

Measured memory_bytes: 3836
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define SUM 1000000007

long calcFib(int n)
{
  if(n == 0) return (long long)1;
  else if(n == 1) return (long long)1;

  long long a2, a1 = 1, a0 = 1;
  for(int i = 1; i < n; i++)
  {
    a2 = (a1 + a0) % SUM;
    a0 = a1;
    a1 = a2;
  }
  return a2;
}

int main(void)
{
  int *a;
  int n, m;
  scanf("%d %d", &n, &m);
  a = (int*)malloc((n - 1) * sizeof(int));
  for(int i = 1; i <= m; i++)
  {
    scanf("%d", a + i);
  }

  long long all = 1;
  a[0] = -1;
  for(int i = 1; i <= m; i++)
  {
    all = (all * calcFib(a[i] - a[i - 1] - 2)) % SUM;
  }
  all = (all * calcFib(n - a[m] - 1)) % SUM;

  printf("%ld\n", all);

  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
int a[maxn],vis[maxn];
int ans,pos;
vector<int> ve;
void dfs(int u)
{
	ans++;
	vis[u]=ans;
	ve.push_back(u);
	if(!vis[a[u]]) 
		dfs(a[u]);
	else
	{
		pos=vis[a[u]];
		ve.push_back(a[u]);
		return;
	}
}
int main()
{
	int n;
	long long k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	dfs(1);
	if(k<ve.size())
		cout<<ve[k]<<"\n";
	else
	{
		k-=ve.size();
		int len=ve.size()-pos;
		cout<<ve[pos+k%len]<<'\n';
	}
	return 0;
}

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

#define SIZE 1000000

char bracs[SIZE]; //??¬??§???????????????????????????????????????????????????
int count; //bracs[]???????????????

void flush(char* str){ int i; for(i=0;i<SIZE;i++){ str[i]='\0'; } } //??????????????????????????\
void init(){ count = 0; flush(bracs); } //?????????????????????
void push(char c){ bracs[count++] = c; } //???????????????push

//??¬??§?????????????????¢??°???7-1????§£???????????????????????????????????¨??????????????????
int rmbrac(char* str){
	int i;
	int l = strlen(str); //??\?????????????????????
	char s1[SIZE]; //???????????°
	char s2[SIZE]; //???????????°
	//i+1??????????????????????????????????????§??°?????????
	for(i = 0; str[i+1] != '\0'; i++){
		//??????????±?????????????????????£?????´????????????????????????
		if(str[i]=='('&&str[i+1]==')') 			break;
		else if(str[i]=='{'&&str[i+1]=='}')		break;
		else if(str[i]=='['&&str[i+1]==']')		break;
		else continue;
	}
	if(str[i+1]=='\0') return -1; //??£??????????????¢?????£?????´???
	strncpy(s1, str, i); //??????????±????????????????????????´???????????????s1?????????
	s1[i] = '\0';
	strncpy(s2, (str+i)+2, l-(i+2)); //????????´???????????????s2?????????
	s2[l-(i+2)] = '\0';
	strcat(s1, s2); //s1+s2
	strcpy(str, s1);
	return 1; //??£?????????
}

void solve(){
    //?????????????????????0??????????????§??°?????????
	while(strlen(bracs)!=0){
		if(rmbrac(bracs)==-1){
			//rmbrac???????????????-1?????¨???????????£?????\?????§???????????¨??????????????§?????????????????????????????§????????????
			printf("no\n");
			return;
		}
	}
	//???????????°???????????¨???????????¨???strlen(buf)==0????????¨?????£?????¨???????????¨
	printf("yes\n");
}

int main(){
    int i,l;
    char tmp;
    char buf[SIZE]; //??\????????????
    for(;;){
        flush(buf);
        for(i=0;;){
            if((tmp=getchar())=='\n') continue; //?????????????????????
            if(tmp=='.'){
                if(i==0) return 0; //??\?????????????????????????????¨????????????
                else break; //????????§???????????¨????????\????????????
            }
            buf[i++] = tmp;
        }
        buf[i+1] = '\0'; //????°??????????????????????
        init(); //?????????????????????
        l=strlen(buf); //????????????????¨????
        for(i=0;i<l;i++)//??????????????°???????????¬??§????????????????????\????????????
            if(buf[i] == '(' || buf[i] == ')' || buf[i] == '[' || buf[i] == ']') push(buf[i]);
        solve();
    }
    return 0;
}

Measured memory_bytes: 2468
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
/*lcm(gcd(N1, M), gcd(N2, M), ..., gcd(Nk, M)) = gcd(lcm(N1, ..., Nk), M)
gcd(lcm(N1, M), lcm(N2, M), ..., lcm(Nk, M)) = lcm(gcd(N1, ..., Nk), M).

If gcd(N1, N2) = 1, then
gcd(N1·N2, M) = gcd(N1, M)·gcd(N2, M)
lcm(N1·N2, M) = lcm(N1, M)·lcm(N2, M)/M.

lcm(M, N, P) · gcd(M, N) · gcd(N, P) · gcd(P, M) = NMP · gcd(N, M, P).
*/
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
    ll x;
    cin>>x;
    ll u=x/11;
    ll j=x%11;
    //cout<<2*u<<"\n";//
    if(j==0)
    {
        cout<<2*u;
    }
    else
    {
        if(j<=6)
        cout<<2*u + 1;
        else cout<<2*(u+1);
    }
    
  }  
  return 0;
}
/* Look for:
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* special cases (n=1?)
* 1LL<<i and not 1<<i
* overflow (int vs ll?)
* array bounds
* if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
*/

Measured memory_bytes: 256
s=str(input())
k=int(input())

res=''

if len(s)>=k:
	for i in range(k):
		if s[i]!='1':
			res=s[i]			
			break
		if i==k-1:
			res='1'
else:
	for i in range(len(s)):
		if s[i]!='1':
			res=s[i]
			break

print(res)

Measured memory_bytes: 3060
import numpy as np

N = int(input())
p_lst = list(map(int, input().split()))

p_arr = np.array(p_lst) - 1

a_arr = [N*i + 1 for i in range(N)]
b_arr = [0]*N
for i in range(N):
    b_arr[p_arr[i]] = N*(N - p_arr[i]) + i + 1

a_output = ""
b_output = ""
for i in range(N):
    a_output += str(a_arr[i])
    b_output += str(b_arr[i])
    if i == N-1:
        continue
    else:
        a_output += " "
        b_output += " "

print(a_output)
print(b_output)


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

x = []
y = []

for i in range(n):
    a, b = [int(i) for i in input().split()]
    x.append(a+b)
    y.append(a-b)

x.sort()
y.sort()

print(max(abs(x[0]-x[n-1]),abs(y[0]-y[n-1])))

Measured memory_bytes: 104904
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const double pi=acos(-1);





int main() 
{
  ll N; cin>>N;
  vector<ll> f(N+1,0);
  for(int i=1;i<=N;i++)
  {
    for(int j=i;j<=N;j+=i)
    {
      f.at(j)++;
    }
  }
  ll ans=0;
  rep(i,N+1)
  {
    ans+=f.at(i)*i;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 81404
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

int ans=-50;

int main(){
	int m=inf;
	for(int i=0;i<3;i++){
		int t;
		cin>>t;
		m=min(m,t);
	}
	ans+=m;
	m=inf;
	for(int i=0;i<2;i++){
		int t;
		cin>>t;
		m=min(m,t);
	}
	ans+=m;
	cout<<ans<<endl;
}

Measured memory_bytes: 3012
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0092
"""
import sys


def find_square2(data):
    max_size = 0
    dp = [[0]*len(data[0]) for _ in range(len(data))] # dp??¨???2?¬??????????
    # '.'????????????1??????'*'????????????0????????????
    for y, row in enumerate(data):
        for x, c in enumerate(row):
            if c == '.':
                dp[y][x] = 1
                max_size = 1

    # ????±?????????????????????????????????£????????????????????£?????¢????¢??????§??????????????§????????????
    # (?????¨???(curr_row)??¨???????????????(prev_row)????????¢????????????????????§?????????????????????)
    prev_row = dp[0]
    for curr_row in dp[1:]:
        for x, t in enumerate(curr_row[1:], start=1):
            if t == 1:
                curr_row[x] = min(prev_row[x-1], prev_row[x], curr_row[x-1]) + 1
                if curr_row[x] > max_size:
                    max_size = curr_row[x]
        prev_row = curr_row
    return max_size


def main(args):
    while True:
        n = int(input())
        if n == 0:
            break
        data = [input() for _ in range(n)]
        result = find_square2(data)
        print(result)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 34240
import java.io.*;
import java.util.Scanner;

public class Main{
	static int digit(int a, int b){
		int x = a + b;
		int d = 0;
		while( x > 0 ){
			d++;
			x /= 10;
		}
		return d;
	}

	public static void main(String[] args) throws IOException {
		Scanner stdIn = null;
		
		final int NUM = 1000;
		int[][] p = new int[NUM][2];
		
		try{
			stdIn = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
	
			int i = 0;
	
			while( stdIn.hasNext() ){
				if( stdIn.hasNextInt() ){
					p[i][0] = stdIn.nextInt();
					p[i][1] = stdIn.nextInt();
				} else {
					stdIn.next();
				}
				i++;
			}
		
			for(int j = 0; j < i; j++){
				System.out.println(digit(p[j][0],p[j][1]));
			}
		} finally {
			if( stdIn != null ){
				stdIn.close();
			}
		}
	}
}

Measured memory_bytes: 12000
(function(stdin) {
  // Define Function

  // Declare Variable
  const inputs  = stdin.toString().trim().split('\n');
  const cols = inputs[0].split(' ').map(Number);

  // Main Procedure
  const result = (function(a, b, c) {

    const sort = [a, b, c].sort().join(' ');
    return sort;

  }(cols[0], cols[1], cols[2]));

  // Display
  console.log(result);

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

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

int main() {
    int n, b[101], ans[101], m = 1;
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> b[i];
        ans[i-1] = 0;
    }
    for(int i=n;i>0;i--){
        for(int j=i;j>0;j--){
            if(b[j] == j){
                ans[i] = j;
                for(int k=j;k<n;k++){
                    b[k] = b[k+1];
                }
                break;
            }
        }
        if(ans[i] == 0){
            cout << -1 << endl;
            return 0;
        }
    }
    for(int i=1;i<=n;i++){
        cout << ans[i] << endl;
    }
	return 0;
}

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

bool isprime(int number){
	
	for(int i=2;i<(number+1)/2;i++){
		if(number % i == 0){
		//	cout<<"number:"<<number<<"is not prime"<<endl;
			return 0;
		}
	}
	//cout<<"number:"<<number<<"is prime"<<endl;
	return 1;
}
int main(){
	int n;
	//用来存每个质因子的个数 
	map<int,int> factors;
	cin >> n;
	int numbers[n+1];
	for(int i=2;i<=n;i++){
		//用来存从2到n； 
		numbers[i] = i;
	}
	 
	for(int i=2;i<=n;i++){
		if(!isprime(i)){
			//不是质数跳过 
			continue;
		}
		for(int j=2;j<=n;j++){
			//如果当前这个数能够被质数整除，那么就整除，并且当前质因数的数量+1 
			//并且如果整除的结果还能被整除，那就就继续整除 
			while(numbers[j] % i ==0){
				numbers[j] /= i;
				if(factors[i]){
					factors[i]++;
				}else{
					factors[i]=1;
				}
				
			}	
		
		}
	}
	//for(int i=2;i<=n;i++){
	//	cout<<i<<":"<<factors[i]<<endl;
	//}
	map<int, int>::iterator  iter = factors.begin();
	long long result = 1;
	for(iter = factors.begin();iter != factors.end();iter++){
    	//如果一个数的质因数，2有3个，3有2个，5有1个，那么他的所有因数的数量就是
		//(3+1) * (2+1) * (1+1)  
		
        result *= (iter->second+1);
       	result = result % 1000000007;
        //cout<<iter->first<<":"<<iter->second<<"result:"<<result<<endl;
    }
    cout<<result;
	
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
ll inf = llmax / 2;

int main() {
    int N, Z, W;
    cin >> N >> Z >> W;
    int a[N];
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    int diffa = abs(a[N - 1] - W);
    int diffb = (N > 1) ? abs(a[N - 2] - a[N - 1]) : 0;
    cout << max(diffa, diffb) << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int N;
bool stop = false;
void dfs(string s1, string s2, bool f) {
    if (s1.size() == N) return;
    if (stop) return;
    string res;
    bool f2 = false;
    rep(i, 2) rep(j, 2) {
        if (stop) return;
        char c1 = i == 0 ? '.' : '#';
        char c2 = j == 0 ? '.' : '#';
        string t1, t2;
        if (f) {
            t1 = s1 + c1;
            t2 = s2 + c2;
        } else {
            t1 = c1 + s1;
            t2 = c2 + s2;
        }
        printf("%s\n%s\n", t1.c_str(), t2.c_str());
        fflush(stdout);
        cin >> res;
        if (res == "end") {
            stop = true;
            break;
        }
        if (res == "T") {
            dfs(t1, t2, f);
            f2 = true;
        }
        if (stop) return;
    }
    if (!f2) dfs(s1, s2, !f);
}
int main() {
    cin >> N;
    dfs("", "", 1);
    return 0;
}


Measured memory_bytes: 724
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())


map<LL, int> prime_factor(long long l){
    map<LL, int> res;
    for(long long i=2; i*i<=l; i++){
        while(l%i == 0){
            res[i]++;
            l /= i;
        }
    }
    if(l!=1) res[l] = 1;
    return res;
}

const int MOD = 1000000007;
long long modPow(long long x, long long y){
    long long r=1, a=x%MOD;
    while(y > 0){
        if((y&1) == 1) r = (r*a) % MOD;
        a = (a*a) % MOD;
        y /= 2;
    }
    return r;
}

long long modInverse(long long x){
    return modPow(x, MOD-2);
}

long long modDivision(long long p, long long q){
    return (p*modInverse(q)) % MOD;
}

long long modC(long long n, int k){
    if(k > n) return 0;
    long long p=1, q=1;
    for(int i=1; i<=k; i++){
        q = (q*i) % MOD;
        p = (p*((n-i+1+MOD)%MOD))%MOD;
    }
    return modDivision(p, q);
}

void solve() {
  LL n, m;
  cin >> n>> m;
  map<LL, int> pf = prime_factor(m);
  LL res = 1;
  for (auto a : pf) {
    res = (res * modC(n-1+a.second, a.second)) % MOD;
  }
  cout << res << endl;
}

int main() {
	solve();
	return 0;
}


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}


void Main()
{
    int n;cin>>n;

    VPII mt(n);
    VPII ma(n);
    VI t(n);
    VI a(n);

    REP(i,n){
        cin>>t[i];
    }
    REP(i,n){
        cin>>a[i];
    }

    REP(i,n){
        if(i==0){
            mt[i].first=t[i];
            mt[i].second=t[i];
        }
        else if(t[i] > t[i-1]){
            mt[i].first=t[i];
            mt[i].second=t[i];
        }
        else{
            mt[i].first=t[i];
            mt[i].second=1;
        }
    }

    PER(i,n){
        if(i==n-1){
            ma[i].first=a[i];
            ma[i].second=a[i];
        }
        else if(a[i] > a[i+1]){
            ma[i].first=a[i];
            ma[i].second=a[i];
        }
        else{
            ma[i].first=a[i];
            ma[i].second=1;
        }
    }

    LL result = 1;

    REP(i,n){
        int high = min(mt[i].first,ma[i].first);
        int low = max(mt[i].second,ma[i].second);

        if(high < low){
            cout<<0<<endl;
            return;
        }
        
        result *= (high-low+1);
        result %= MOD;

    }

    cout<<result<<endl;

	return;
}

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

Measured memory_bytes: 2560
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	LL h, w;
	cin >> h >> w;
	LL ans;
	if(h == 1 || w == 1){ ans = 1; }
	else{ ans = (h / 2) * (w / 2) + ((h + 1) / 2) * ((w + 1) / 2); }
	cout << ans << endl;
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){
	throw;
}


Measured memory_bytes: 256
import heapq
N,M = map(int,input().split())
A = list(map(int,input().split()))
A = list(map(lambda x: x*(-1), A)) 

heapq.heapify(A) # リストを優先度付きキューへ

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

ans = -sum(A)
print(ans)

Measured memory_bytes: 14184
#[allow(unused_imports)]
use proconio::{fastout, input, marker::*};

#[fastout]
fn main() {
    input! {
        s: Chars,
        t: Chars,
    }
    let t = &t[0..s.len()].to_vec();

    if &s == t {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

int main(){
    string a;
    int sum=0, i=0;
    cin >> a;
    size_t size = a.length();
    for(i=0;i<size;i++){
        sum += (int)(a[i] - '0');
    }

    if(sum%9==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


    return 0;
}

Measured memory_bytes: 3652
antenna = []
bool = True

for i in range(5):
    a = int(input())
    antenna.append(a)
max_distance = int(input())

antenna.sort()
if abs(antenna[0] - antenna[-1]) > max_distance:
    bool = False
    
if bool:
    print("Yay!")
else:
    print(":(")

Measured memory_bytes: 3060
#include <stdio.h>

int main()
{
    char S[4+1];
    int i;
    char old;
    int is_good;

    scanf("%s", S);

    is_good = 1;
    for(i = 0; i < 3; i++) {
        if(S[i] == S[i+1]) {
            is_good = 0;
        }
    }

    if(is_good) {
        printf("Good\n");
    } else {
        printf("Bad\n");
    }

    return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python

def main():
    a, b, c, x, y = map(int, input().split())
    ab = c * 2

    i = min(x, y)
    if ab < a + b:
        pay = ab * i
    else:
        pay = a * i + b * i
    x -= i
    y -= i

    if x != 0:
        if ab < a:
            pay += ab * x
        else:
            pay += a * x
    elif y != 0:
        if ab < b:
            pay += ab * y
        else:
            pay += b * y

    print(pay)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
N, M = map(int, input().split())
A = [input().split() for i in range(M)]
problems = {}
rejected = [0]*(N+1)
reject_count = 0
for P, S in A:
    P = int(P)
    if not problems.get(P):
        if S != 'AC':
            rejected[P] += 1
        else:
            problems[P] = S
for i in range(N+1):
    if problems.get(i):
        reject_count += rejected[i]
print(len(problems), reject_count)

Measured memory_bytes: 45060
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int M = in.nextInt();
            int X = in.nextInt();
            int Y = in.nextInt();
            int[] x = new int[N];
            for (int i = 0; i < N; i++) {
                x[i] = in.nextInt();
            }
            int[] y = new int[M];
            for (int i = 0; i < M; i++) {
                y[i] = in.nextInt();
            }
            int minY = Y;
            for (int i = 0; i < M; i++) {
                minY = Math.min(minY, y[i]);
            }
            System.out.println(isWar(minY, X, x) ? "War" : "No War");
        }
    }

    private static boolean isWar(int minY, int X, int[] x) {
        if (X >= minY) {
            return true;
        }
        for (int i = 0; i < x.length; i++) {
            if (x[i] >= minY) {
                return true;
            }
        }
        return false;
    }
}


Measured memory_bytes: 21844
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005


ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=1000000000000;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}


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



int main(){
    int n,m;cin>>n>>m;
    vector<int>v[n+m];//0~n-1とn~n+m-1
    rep(i,0,n-1){
        int k;cin>>k;
        while(k--){
            int t;cin>>t;t--;
            v[i].push_back(n+t);
            v[n+t].push_back(i);
        }
    }
    bool check[n+m];rep(i,0,n+m-1)check[i]=false;
    check[0]=true;
    queue<int>q;
    q.push(0);
    while(!q.empty()){
        int t=q.front();q.pop();
        for(auto x:v[t]){
            if(!check[x]){
                check[x]=true;
                q.push(x);
            }
        }
    }
   // rep(i,0,n+m-1)cout<<check[i]<<" ";
    rep(i,0,n-1)if(!check[i]){cout<<"NO"<<endl;return 0;}
    cout<<"YES"<<endl;
    
    return 0;
}

Measured memory_bytes: 9080
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  string s;
  cin >> s;

  int n = s.length();

  int left = 0;
  int right = n-1;
  while (left < right) {
    if (s[left] == s[right]) {
      left++;
      right--;
    }
    else {
      cout << "No" << endl;
      return 0;
    }
  }
  left = 0;
  right = (n-1) / 2 - 1;
  while (left < right) {
    if (s[left] == s[right]) {
      left++;
      right--;
    }
    else {
      cout << "No" << endl;
      return 0;
    }
  }
  left = (n+1) / 2;
  right = n-1;
  while (left < right) {
    if (s[left] == s[right]) {
      left++;
      right--;
    }
    else {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  int rmax = n / r;
  int gmax = n / g;
  int ans = 0;
  for(int i = 0; i <= rmax; i++) {
    for(int j = 0; j <= gmax; j++) {
      int sum = r * i + g * j;
      if(n - sum >= 0 && (n - sum) % b == 0) {
        // cout << i << ' ' << j << endl;
        ans++;
      }
    }
  }
  cout << ans << endl;

  return 0;
}

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

bool a[200005];
bool b[200005];//0 羊 1 オオカミ
signed main() {
	int k; cin >> k;
	string c; cin >> c; c += c;
	for (int d = 0; d < c.length(); d++) {
		if (c[d] == 'x')a[d] = true;
	}
	for (int i = 0; i < 2; i++) {
		for(int j=0;j<2;j++){
			b[0] = i;
			b[1] = j;
		for (int d = 2; d <= k+5; d++) {
			int f = b[d - 2] + a[d - 1] + b[d - 1];
			f = f & 1;
			b[d] = f;
		}
		if (b[0] == b[k]&&b[1]==b[k+1]) {
			for (int i = 0; i < k; i++) {
				if (b[i])cout << 'W';
				else cout << 'S';
			}
			cout << endl;
			return 0;
		}
		}
	}
	puts("-1");
}

Measured memory_bytes: 936
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define p (int)(1e9 + 7)

int MOD(int a){
	return (a %= p) >= 0 ? a : a + p;
}

int power(int a, int N){
	if(N == 0) return 1;
	else if(N % 2 == 0) return power(MOD(a * a), N / 2);
	else return MOD(a * power(a, N - 1));
}

int inverse(int a){
	return power(a, p - 2);
}

int fact(int N){
	static vector<int> _fact(1, 1);
	for(int i = _fact.size(); i <= N; i++){
		_fact.push_back(MOD(i * _fact[i - 1]));
	}
	return _fact[N];
}
 
int fact_inv(int N){
	static vector<int> inv(2, 1), _fact_inv(2, 1);
	for(int i = inv.size(); i <= N; i++){
		inv.push_back(MOD(-(p / i) * inv[p % i]));
		_fact_inv.push_back(MOD(inv[i] * _fact_inv[i - 1]));
	}
	return _fact_inv[N];
}
 
int combination(int N, int k){
	if(k < 0 || N < k || N < 0) return 0;
	else return MOD(fact(N) * MOD(fact_inv(N - k) * fact_inv(k)));
}

signed main(){
	int N, K, i, j, k;
	scanf("%lld%lld", &N, &K);
	vector<int> a(K + 1);
	for(i = 1; i <= K; i++){
		scanf("%lld", &a[i]);
	}
	vector<vector<int>> dp(K + 1, vector<int>(N + 1, 0));
	dp[0][0] = 1;
	for(i = 1; i <= K; i++){
		for(j = 0; j <= N; j++){
//			printf("a[i] = %lld\n", a[i]);
			for(k = 0; k <= a[i] && k <= j; k++){
//				printf("k = %lld\n", k);
//				printf("%lld\n", combination(N - j + k, k));
//				printf("%lld\n", combination(N - k, a[i] - k));
				dp[i][j] = MOD(dp[i][j] + MOD(combination(N - j + k, k) * combination(N - k, a[i] - k)) * dp[i - 1][j - k]);
			}
//			printf("dp[%lld][%lld] = %lld\n", i, j, dp[i][j]);
		}
//		printf("\n");
	}
	printf("%lld\n", dp[K][N]);
	return 0;
}

Measured memory_bytes: 436