akhauriyash/Code-Regression huggingface dataset:
import collections
N, M = list(map(int,input().split()))
loves = []
for i in range(N):
    love = list(map(int,input().split()))
    loves.append(love[1:])
lx = []
for l in loves:
    lx.extend(l)
c = collections.Counter(lx)
cnt = 0
for k, v in c.items():
    if v == len(loves):
        cnt += 1
print(cnt)

Measured memory_bytes: 3316
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

vector<int> G[55];

int to_num(char a){
	if('a' <= a && a <= 'z')
		return a-'a';
	return a-'A'+26;
}

const ll mod = 1e9+7;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	string s[2];
	cin >> N;
	cin >> s[0] >> s[1];
	ll res = 1;
	ll p = -1;
	REP(i, N){
		if(s[0][i] == s[1][i]){
			if(p == -1)
				res *= 3;
			else if(p == 0)
				res *= 2;
			else
				res *= 1;
			p = 0;
		}else{
			if(p == -1)
				res *= 6;
			else if(p == 0)
				res *= 2;
			else
				res *= 3;
			p = 1;
			i++;
		}
		res %= mod;
	}
	cout << res << endl;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a;
	cin>>a;
	if(a/1000==(a%1000-a%100)/100&&a/1000==(a%100-a%10)/10)cout<<"Yes"<<endl;
    else if((a%1000-a%100)/100==(a%100-a%10)/10&&(a%100-a%10)/10==a%10){
      cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
	return 0;
}


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

using namespace std;

int main(){
  const int x = 600;
  int d,area=0,height=0,width;
  vector<int> data;
  while(cin >> width){
    data.push_back(width);
  }

  for(int j=0; j<data.size(); j++){
    width = data[j];
    area=0;
    d = x/width;

    for(int i=0; i<d; i++){
      height = (width*i)*(width*i);
      area+=height*width;
    }
    cout << area << endl;
  }
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  int cnt_Odd = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (a % 2 == 1) cnt_Odd++;
  }
  if (cnt_Odd % 2 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def main():
    N = in_n()
    yaku = make_divisors(N)
    keta = lambda s: len(str(s))

    ans = 11
    for t in yaku:
        ans = min(ans, max(keta(t), keta(N // t)))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9232
#include<iostream>
#include<cstdio>
using namespace std;
 
char s[3];
 
int main() {
	cin >> s;
	for(int i=0;i<3;++i)
		if (s[i] == '7') {
			printf("Yes");
			return 0;
		}
	printf("No");
	return 0;
}

Measured memory_bytes: 3764
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
    string w;
    vector<int> t(26);
    cin >> w;
    for (int i = 0; i < w.size(); ++i) ++t.at(w.at(i) - 'a');
    for (int i = 0; i < 26; ++i) if (t.at(i) % 2) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
r,c = map(int,input().split())
grid = []
temp = []
limit = r*c
total = 0
count = 0
for i in range(r):
    next = list(input())
    for j in range(c):
        if next[j]=='#':
            temp.append([i,j])
            total+=1
    grid.append(next)
while(total<limit):
    nextround = []
    while(len(temp)>0):
        x,y = temp.pop()
        # print('X:',x,'Y:',y)
        if x-1>-1:
            if grid[x-1][y] == '.':
                grid[x - 1][y] = '#'
                total +=1
                nextround.append([x-1,y])
        if x+1<r:

            if grid[x+1][y] == '.':
                grid[x + 1][y] = '#'
                total +=1
                nextround.append([x+1, y])
        if y-1>-1:
            if grid[x][y-1] == '.':
                grid[x][y-1] = '#'
                total +=1
                nextround.append([x,y-1])
        if y+1<c:
            if grid[x][y+1] == '.':
                grid[x][y+1] = '#'
                total +=1
                nextround.append([x,y+1])
    temp = nextround
    count+=1
print(count)

Measured memory_bytes: 171364
import java.util.Scanner;
import java.util.regex.Pattern;

public class Main {

    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        String s = sc.next();
        boolean result = false;

        int indexC = s.indexOf("C");

        if ("A".equals(s.substring(0, 1)) && indexC >= 2 && indexC <= s.length() - 2 && !onemoretime(s, 'C')) {
            s = s.replace("A", "");
            s = s.replace("C", "");
            String pattern = "^[a-z]+$";
            Pattern p = Pattern.compile(pattern);
            if (p.matcher(s).find()) {
                result = true;
            }
        }
        System.out.println(result ? "AC" : "WA");

    }

    static boolean onemoretime(String str, char target) {
        return str.length() - str.replace(target + "", "").length() > 1;
    }
}


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

using namespace std;

int main() {
	int N; cin >> N;
	for (int i = 0; i < N; ++i) {
		int x, y, b, p; cin >> x >> y >> b >> p;
		int ans = x * b + y * p;
		ans = min(ans, (x * max(5, b) + y * max(2, p)) / 10 * 8);
		cout << ans << endl;
	}
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main()
{
	int H,W,i,j;
	while(cin>>H>>W)
	{
		if(H==0&&W==0)
			break;
		else
		{
			for (i = 1; i <=H ; i++)
			{
					if(i%2==1)
					{
						for(j=1;j<=W;j++)
						{
							if(j%2==1)
								cout<<"#";
							else
								cout<<".";
						}
						cout<<"\n";
					}
					else
					{
						for(j=1;j<=W;j++)
						{
							if(j%2==1)
								cout<<".";
							else
								cout<<"#";
						}
						cout<<"\n";
					}
			}
		}
		cout<<"\n";
	}
	
	return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <vector>
using namespace std;
int n, m;
vector<int> G[100010];

int dp[100010];
int rec(int v) {
    if (dp[v] != -1) return dp[v];
    int res = 0;
    for (int i = 0; i < G[v].size(); i++) {
        res = max(res, rec(G[v][i]) + 1);
    }
    return dp[v] = res;
}

int main() {
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int x, y; cin >> x >> y;
        x--, y--;
        G[x].push_back(y);
    }

    fill(dp, dp + n, -1);

    int ans = 0;
    for (int i = 0; i < n; i++) ans = max(ans, rec(i));
    cout << ans << endl;
}

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

int main() {
    string S;
    cin >> S;
    
    string answer = "Yes";
    for(int i = 0; i < S.length(); i++){

        if( i % 2 == 1) {
            if(S[i] == 'R') {
                answer = "No";
                break;
            }
        } else {
            if(S[i] == 'L') {
                answer = "No";
                break;
            }
        }

    }

    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define INF 2e9
typedef long long ll;
typedef pair<int, int> P;

ll gcd(ll x, ll y)
{
  return y ? gcd(y, x % y) : x;
}
ll lcm(ll x, ll y)
{
  return x * y / gcd(x, y);
}
bool is_prime(int x)
{
  for (int i = 2; i * i <= x; i++)
  {
    if (x % i == 0)
      return 0;
  }
  return true;
}
vector<bool> prime_table(int n)
{
  vector<bool> prime(n + 1, 1);
  prime[0] = 0;
  prime[1] = 0;
  for (int i = 2; i * i <= n; i++)
  {
    if (!prime[i])
      continue;
    for (int j = i * i; j <= n; j++)
      prime[j] = 0;
  }
  return prime;
}
map<int, int> prime_factor(int n)
{
  map<int, int> res;
  for (int i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1)
    res[n]++;
  return res;
}
ll modpow(ll a, ll n, ll mod)
{
  ll res = 1;
  while (n > 0)
  {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
ll modinv(ll a, ll mod)
{
  return modpow(a, mod - 2, mod);
}

int main()
{
  int n;
  cin>>n;
  vector<int> p(n);
  REP(i,n) cin>>p[i];

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

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


Measured memory_bytes: 640
def main():
    #n = int(input())
    a,v = map( int, input().split())
    b,w = map( int, input().split())
    t = int(input())
    if v<=w:
        print("NO")
    elif abs(a-b)>t*(v-w):
        print("NO")
    else:
        print("YES")
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9184
#include <stdio.h>

int main(void)
{
char num[1001];
int i = 0;
int sum = 0;
int k;

while(1){

scanf("%s", num);

if(num[0] == '0')
break;

while(num[i] != '\0'){

k = num[i] - '0';
sum = sum + k;

i++;

}

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

sum = 0;
i = 0;

}

return 0;

}




Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  int a, b, x;
  cin >> a >> b >> x;
  bool ok = a + b >= x && a <= x ? true : false;
  print(ok ? "YES" : "NO");
  return 0;
}

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

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

Measured memory_bytes: 3624
import sys
sys.setrecursionlimit(10**6)
from collections import deque
n,m=map(int,input().split())
edges=[[] for i in range(n)]
for i in range(m):
    u,v=map(int,input().split())
    edges[u-1].append(v-1)
s,t=map(int,input().split())
inf=100000000000
score=[[inf]*3 for i in range(n)]
now=deque()
now.append(s-1)
score[s-1][0]=0
def bfs(dep,l):
    global n,m,edges,s,t,score,inf,now
    f=False
    for i in range(l):
        ne=now.popleft()
        for j in edges[ne]:
            if score[j][dep%3]==inf:
                score[j][dep%3]=dep
                now.append(j)
    l_ne=len(now)
    if l_ne:bfs(dep+1,l_ne)
bfs(1,1)
if score[t-1][0]!=inf:
    print(score[t-1][0]//3)
else:
    print(-1)

Measured memory_bytes: 295408
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
struct team {
	int solve;
	int time;
	int id;

};

int main() {
	while (1) {
		int N, T, P, R; cin >> N >> T >> P >> R;
		vector<vector<int>>wrongs(T, vector < int>(P));
		vector<vector<int>>scores(T, vector <int>(P,0));
		if (!N)break;
		for (int i = 0; i < R; ++i) {
			int m, t, p, j; cin >> m >> t >> p >> j;
			t--; p--;
			if (j) {
				wrongs[t][p]++;
			}
			else {
				if (!scores[t][p]) {
					scores[t][p] += 1+wrongs[t][p] * 20 + m;
				}
			}
		}
		vector<team>ts;
		for (int i = 0; i < T; ++i) {
			team t = team{ 0,0,i+1 };
			for (int j = 0; j < P; ++j) {
				if (scores[i][j]) {
					t.solve++;
					t.time += scores[i][j];

				}
			}
			ts.emplace_back(t);
		}
		sort(ts.begin(), ts.end(), [](const team&l, const team&r) {
			return l.solve == r.solve ? l.time == r.time ? l.id>r.id:l.time<r.time : l.solve>r.solve;
			; });
		cout << ts[0].id;
		for (int i = 1; i < ts.size(); ++i) {
			if (ts[i].solve == ts[i - 1].solve&&ts[i].time == ts[i - 1].time)cout << '=';
			else cout << ",";
			cout << ts[i].id;
		}
		cout << endl;
	}
	return 0;
}

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

int main(){
	int n, l;
	bool ans = 1;
	string a, b;
	map <string, bool> fl;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> b;
		if(fl.find(b) != fl.end()) ans = 0;
		if(i > 0){
			l = a.length() - 1;
			if(a[l] != b[0]) ans = 0;
		}
		a = b;
		fl[b] = 1;
	}
	cout << (ans ? "Yes" : "No") << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    string S;
    cin >> S;

    if(S=="RRR") cout << 3 << endl;
    else if(S=="SRR" || S=="RRS") cout << 2 << endl;
    else if(S=="SSS") cout << 0 << endl;
    else cout << 1 << endl;
}

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

using namespace std;

bool CanDefeat(const vector<int> &hp, int big_attack,
               int small_attack, int moves)
{
    auto attack_diff = big_attack - small_attack;
    auto needed = 0;

    for (const auto &elem : hp) {
        auto wanted = (elem - 1LL * small_attack * moves);
        wanted = (wanted + attack_diff - 1) / attack_diff;

        needed += max<long long int>(wanted, 0);
        if (needed > moves) {
            return false;
        }
    }
    return needed <= moves;
}

int Solve(const vector<int> &hp, int big_attack, int small_attack)
{
    auto moves = 0;
    auto power = (1 << 30);

    while (power > 0) {
        auto new_moves = moves + power;
        power >>= 1;

        if (!CanDefeat(hp, big_attack, small_attack, new_moves)) {
            moves = new_moves;
        }
    }
    return moves + 1;
}

int main()
{
    int monsters;
    cin >> monsters;

    int big_attack, small_attack;
    cin >> big_attack >> small_attack;

    vector<int> hp(monsters);
    for (auto &elem : hp) {
        cin >> elem;
    }

    auto res = Solve(hp, big_attack, small_attack);
    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 768
using System;
using System.Collections.Generic;
using System.Linq;

public static partial class Program
{
    public static void Main()
    {
        var n = CRL().SpTInts().ToList();
        if (n.All(x => x == n[0]))
        {
            CWL("Yes");
        }
        else
        {
            CWL("No");
        }
    }
}

public static partial class Program
{
    //テンプレここから
    private static int ToInt(this string str) => int.Parse(str);
    private static long ToLong(this string str) => long.Parse(str);
    private static int[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    private static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
    public static int[] SpTInts(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static long[] SpTLongs(this string str, char opr = ' ') => str.Split(opr).ToLong();
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static int Diff(int a, int b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static int Sign(this int i) => Math.Sign(i);
    public static bool IsEven(this int i) => i % 2 == 0;
    public static int[] dx = new int[] { 0, -1, 0, 1 };
    public static int[] dy = new int[] { -1, 0, 1, 0 };
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static int ToInt(this char c) => c.ToString().ToInt();
    public static long ToLong(this char c) => c.ToString().ToLong();
    //テンプレここまで
}


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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define vc vector<char>
#define mii map<int,int>
#define ii pair<int,int>
#define fi first
#define sc second
#define all(x) (x).begin(),(x).end()
#define get_bit(x, k) ((x >> k) & 1)
// ---------------------------------

void MAIN() {
  string s, t;
  cin >> s >> t;
  map<char, char> m, r;
  for (int i = 0; i < s.size(); i++) {
    if (m.count(s[i]) && m[s[i]] != t[i]) {
      cout << "No" << '\n';
      return;
    }
    m[s[i]] = t[i];
    if (r.count(t[i]) && r[t[i]] != s[i]) {
      cout << "No" << '\n';
      return;
    }
    r[t[i]] = s[i];
  }
  cout << "Yes" << '\n';
}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3824
import sys
# sys.stdin = open('input.txt')

import itertools

def add_lists(a, b):
    result = [0 for i in range(len(a))]
    for i in range(len(a)):
        result[i] = a[i] + b[i]
    return result

n, m, x = map(int, input().split())
c = []
a = [[0] for i in range(n)]
for i in range(n):
    cj, *aj = input().split()
    c.append(int(cj))
    aj = list(map(int, aj))
    a[i] = aj

INF = float('inf')
ans = INF

for flags in itertools.product([0,1], repeat=n):
    tot = [0 for i in range(m)]
    now = 0
    for i in range(len(flags)):
        if flags[i] == 1:
            tot = add_lists(tot, a[i])
            now += c[i]
    flag = True
    for i in tot:
        if i < x:
            flag = False
    if flag:
        ans = min(ans, now)

if ans == INF:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9280
#include <stdio.h>

int main(void)
{
	int i, n, a[100];
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (i = n; i > 1; i--) {
		printf("%d ", a[i-1]);
	}
	printf("%d\n", a[0]);
	
	return 0;
}

Measured memory_bytes: 596
# https://atcoder.jp/contests/abc051/tasks/abc051_c
# 同じ座標を複数回通らないようにということなので、始点と終点の上下左右をすべて使うなかで最短経路を提示すれば良い。
# 一番単純なのは時計回りに動くと決め打ちで文字を出力することかな

sx, sy, tx, ty = map(int, input().split())

dx = tx - sx
dy = ty - sy
U, D, L, R = 'UDLR'

ans = U * dy + R * dx + D * dy + L * dx  # 一周目
ans += L + U * (1 + dy) + R * (1 + dx) + D + R + \
    D * (1 + dy) + L * (1 + dx) + U  # うち間違えに注意
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int INF = pow(10, 7);

int main(){
  int n;cin>>n;
  int pre=-1;
  bool fixed=false;
  bool ans=true;
  for(int i=0;i<n;i++){
  	int h;cin>>h;
    if(fixed){
      if(h<pre){
      	ans=false;break;
      }else if(h>pre){
      	fixed=false;
      }
    }else{
      if(h==pre-1){
      	fixed=true;
      }else if(h<pre-1){
      	ans=false;break;
      }
    }
    pre=h;
  }
  cout<<(ans?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
left = []
right = []
for i in range(M):
    l,r = map(int,input().split())
    left.append(l)
    right.append(r)
if max(left)>min(right):
    print(0)
else:
    print(min(right)-max(left)+1)

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

using namespace std;
using ll = long long;
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    priority_queue<ll> que;
    REP(i, n) que.push(a[i]);
    REP(i, m) {
        ll t = que.top(); que.pop();
        t /= 2;
        que.push(t);
    }

    ll ret = 0;
    while(que.size()) {
        ret += que.top();
        que.pop();
    }
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end() 
#define allr(v) v.rbegin(),v.rend() 
//#define endl '\n'  
typedef  long long ll; 
typedef  unsigned long long ull; 
typedef vector< ll > edge; 
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <ll, vector<ll>, greater<ll> > min_heap;
 ll mod=1e9+7;
const ll inf=1e15+10;
const ll N=3e6;

struct matrix
{
	vector<vector<ll> > mat;
	void resize(ll a,ll b, ll initial)
	{
		mat.resize(a,vector<ll> (b,initial));
	}
	void identity()// first resize with initial = 0
	{
		for(ll i=0;i<(ll)mat.size();i++) mat[i][i]=1;
	}
	ll get_rows()
	{
		return mat.size();
	}	
	ll get_cols()
	{
		return mat[0].size();
	}
	matrix operator + ( matrix & b)  const
	{
		matrix temp;
		ll ro,co;
		ro=b.get_rows();
		co=b.get_cols();
		temp.resize(ro,co,0);
		for(ll i=0;i<ro;i++)  
		{
			for(ll j=0;j<co;j++)
			{
				//temp.mat[i][j]=mat[i][j]+b.mat[i][j];
				temp.mat[i][j]=(mat[i][j]%mod)+(b.mat[i][j]%mod);
				temp.mat[i][j]%=mod;
			}
		}	
		return temp;
	}
	matrix operator * ( matrix & b)  const
	{
		matrix temp;
		ll ro,co;
		ro=mat.size();
		co=b.get_cols();
		ll mi=b.get_rows();
		temp.resize(ro,co,0);
		for(ll i=0;i<ro;i++)  
		{
			for(ll j=0;j<co;j++)
			{
				for(ll k=0;k<mi;k++)
				{
					//temp.mat[i][j]+=mat[i][k]*b.mat[k][j];
					temp.mat[i][j]+=((mat[i][k]%mod) * (b.mat[k][j]%mod));
					temp.mat[i][j]%=mod;
				}
			}
		}	
		return temp;
	}	
	void print()
	{
		for(auto &i:mat)
		{
			for(auto &j:i) cout<<j<<" ";
			cout<<endl;	
		}	

	}


};

matrix power(matrix a,ll b)
{
	matrix ans;
	ans.resize(a.get_rows(),a.get_cols(),0);
	ans.identity();
	while(b)
	{
		if(b & (ll)1)
		{
			ans=ans*a;
		}
		a=a*a;
		b>>=1;
	}
	return ans;
}
int main()
{
	boost;
	ll l,a,b,m;
	cin>>l>>a>>b>>m;
	mod=m;
	ll lo,hi;
	matrix ans;
	ans.resize(1,3,0);
	ans.mat[0][0]=a%mod;
	ans.mat[0][1]=(a+b)%mod;
	ans.mat[0][2]=1;
	ll term =1,d=10;
	while(term<l)
	{
		lo=max((ll)0,((d/10-1)-a)/b);
		hi=min(l-1,max((d-1-a)/b,(ll)0));
		term+=hi-lo;
		ll now=hi-lo;
		matrix temp;
		temp.resize(3,3,0);
		temp.mat[0][0]=d%mod;
		temp.mat[1][0]=1;
		temp.mat[1][1]=1;
		temp.mat[2][1]=b%mod;
		temp.mat[2][2]=1;
		temp=power(temp,now);
		ans=ans*temp;
		d*=10;
		//check(term);check(hi);check(lo);
	}
	cout<<ans.mat[0][0];
  	return 0;
}  

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(dead_code)]
use std::io::prelude::*;
use std::cmp::{max, min};
use std::collections::BinaryHeap;

const MOD: i64 = 1e9 as i64 + 7; 

fn main(){
    let a: usize = read();
    let b: usize = read();
    let mut cnt = 1;
    let mut ans = 0;
    while cnt < b {
        cnt += a - 1;
        ans += 1;
    }
    println!("{}", ans);
}

fn read<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
H,W = map(int,input().split())
C = []
A = []
for i in range(10) :
    C.append(list(map(int,input().split())))
for i in range(H) :
    A.append(list(map(int,input().split())))
for i in range(10) :
    for j in range(10) :
        for k in range(10) :
            C[j][k] = min(C[j][k], C[j][i]+C[i][k])
ans = 0
for row in A :
    for a in row :
        if a == -1 or a == 1 :
            continue
        else :
            ans += C[a][1]
print(ans)


Measured memory_bytes: 3316
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
typedef pair< int , int > Pi;

int main()
{
  int m, n;
  Pi target[200], star[1000];

  while(scanf("%d", &m), m){
    for(int i = 0; i < m; i++){
      scanf("%d %d", &target[i].first, &target[i].second);
    }
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
      scanf("%d %d", &star[i].first, &star[i].second);
    }

    sort( target, target + m);
    sort( star, star + n);

    int shiftx = 0;
    int shifty = 0;

    for(int i = 0; i < n; i++){
      shiftx = star[i].first - target[0].first;
      shifty = star[i].second - target[0].second;

      bool flag = true;
      for(int j = 1; j < m; j++){      
        if(!binary_search( star, star + n, Pi( target[j].first + shiftx, target[j].second + shifty))){
          flag = false;
          break;
        }
      }
      if(flag) break;
    }

    printf("%d %d\n", shiftx, shifty);
  }
  return(0);

}

Measured memory_bytes: 1036
#include <bits/stdc++.h>
//#include "atcoder/all"
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
const ll mod = 1e9 + 7;
int main() {
  ll n, m;
  cin >> n >> m;

  if (!(n == 1 || m == 1))
    cout << n * m - (n * 2 + m * 2) + 4 << endl;
  else if (n == 1 && m == 1)
    cout << 1 << endl;
  else
    cout << max(m, n) - 2 << endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
int main()
{
    int a,b,c,k,t1=0;
    cin>>a>>b>>c>>k;
    while(b<=a)
    {
        b*=2;
        t1++;
    }
    while(c<=b)
    {
        c*=2;
        t1++;
    }
    
   if(t1<=k) cout<<"Yes\n";
   else cout<<"No\n";


}

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

 
int main() {
    int n,m;
    cin>>n>>m;
    priority_queue<int> A;
    rep(i,n){
        int a;
        cin>>a;
        A.push(a);
    }
    rep(i,m){
        int p=A.top();
        A.pop();
        A.push(p/2);
    }
    ll ans=0;
    rep(i,n){
        ans+=A.top();
        A.pop();
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 892
n, k = map(int, input().split())
MOD = 10 ** 9 + 7

a = [0] *(k+1)

for x in range(1, k + 1):
    a[x] = pow(k // x, n, MOD)

for x in range(k, 0, -1):
    for i in range(2, k // x + 1):
        a[x] -= a[x * i]

answer = sum([i * x for i,x in enumerate(a)])

print(answer % MOD)

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


int main() {
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> C(N);
  vector<vector<int>> A(N, vector<int> (M, 0));
  for (int i = 0; i < N; i++) {
    cin >> C[i];
    for (int j = 0; j < M; j++) {
      cin >> A[i][j];
    }
  }
  int min_cost = -1;
  for (int i = 0; i < (1 << N); i++) {
    int cost = 0, buy = i;
    vector<int> level(M, 0);
    for (int j = 0; j < N; j++) {
      if ((buy & (1 << j))) {
        for (int k = 0; k < M; k++) {
          level[k] += A[j][k];
        }
        cost += C[j];
      }
    }
    bool valid = true;
    for (int j = 0; j < M; j++) {
      if (level[j] < X) {
        valid = false;
        break;
      }
    }
    if (valid) {
      min_cost = min_cost == -1 ? cost : min(min_cost, cost);
    }
  }
  cout << min_cost << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,v.size())
#define all(v) (v).begin(),(v).end()
#define bit(n) (1ll<<(n))
#define clamp(n,mi,ma) max(min(n,ma),mi)
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b) cout<<((n)?a:b)<<endl
#define YES(n) cho(n,"YES","NO")
#define Yes(n) cho(n,"Yes","No")
#define Poss(n) cho(n,"Possible","Impossible")
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(a>b){a=b;return 1;}return 0;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>ostream&operator<(ostream&o,const T&t){return o<<t;}
template<class T>istream&operator>(istream&i,T&t){return i>>t;}
#ifndef LOCAL
struct ostdmy{
template<class T>ostdmy&operator<<(const T&t){return*this;}
template<class T>ostdmy&operator<(const T&t){return*this;}};ostdmy cer_;
#define cerr cer_
#endif
inline int dist(P a,P b){
    return abs(a.F-b.F)+abs(a.S-b.S);
}
int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int h,w;
    cin>h>w;
    vector<string> a(h);
    queue<P> q;
    vvi l(h,vi(w,INF));
    cin>a;
    REP(y,h){
        REP(x,w){
            if(a[y][x]=='#'){
                l[y][x]=0;
                q.push({y,x});
            }
        }
    }
    while(!q.empty()){
        int x,y;
        x=q.front().S;
        y=q.front().F;
        q.pop();
        if(y>0   )
            if(chmin(l[y-1][x], l[y][x]+1)) q.push({y-1,x});
        if(x>0   )
            if(chmin(l[y][x-1], l[y][x]+1)) q.push({y,x-1});
        if(y<h-1 )
            if(chmin(l[y+1][x], l[y][x]+1)) q.push({y+1,x});
        if(x<w-1 )
            if(chmin(l[y][x+1], l[y][x]+1)) q.push({y,x+1});
    }
    /*REP(y,h){
        cerr<<l[y]<<endl;
    }cerr<<endl;//*/
    int ma=0;
    REP(y,h){
        REP(x,w){
            chmax(ma,l[y][x]);
        }
    }
    cout<ma<endl;
    return 0;
}


Measured memory_bytes: 13456
//  Author : Amit Kumar 
//  Date   : Saturday 11 July 2020 05:39:49 PM IST

#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define int int64_t

signed main(void){
#ifdef HELL_JUDGE
    freopen("input","r",stdin);
    freopen("output","w",stdout);
    freopen("error","w",stderr);
#endif 
    ios::sync_with_stdio(false); // FLUSH THE STREAM IF USING puts / printf / scanf/
    cin.tie(nullptr);            // DISABLE FOR INTERACTIVE PROBLEMS
    cout.tie(nullptr);           //
#ifdef HELL_JUDGE
    auto INITIAL_TIME = high_resolution_clock::now();
#endif 
    int n; cin >> n; 
    int counter{};
    for(int i=1;i<=n;++i){
        int x; cin>>x; 
        counter += (i&1 && x&1);
    }
    cout << counter << endl;
#ifdef HELL_JUDGE
    auto FINAL_TIME = high_resolution_clock::now();
    cout << "Time : "
         << duration_cast<milliseconds>(FINAL_TIME-INITIAL_TIME).count() 
         << " ms" << '\n'; 
#endif 
    return 0;
}


Measured memory_bytes: 3648
// https://atcoder.jp/contests/dwacon5th-prelims/tasks/dwacon5th_prelims_a
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize,
        a: [i32; n],
    };

    let sum = a.iter().fold(0, |sum, x| sum + x);
    let best = a.iter().map(|&ai| (sum-ai*(n as i32)).abs()).zip(0..).min().unwrap();
    println!("{}", best.1);
}


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

#define int long long
#define rep(i,n) for(int i=0; i<(n); i++)
#define lep(j,n) for(int j=0; j<(n); j++)
#define reps(i,n) for(int i=1; i<=(n); i++)
#define leps(j,n) for(int j=1; j<=(n); j++)

using namespace std;
bool a[1000];
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    stack<int> st;

    int l;
    cin>>l;

    for(int i=1; i<=l; i++){

        int n;
        cin>>n;

        if(n>0){
            if(a[n]==0){
                st.push(n);
                a[n]++;
            }else{
                cout<<i<<'\n';
                return(0);
            }
        }else{
            if(st.empty()){
                cout<<i<<'\n';
                return(0);
            }else{
                if(st.top()==-n){
                    st.pop();
                    a[-n]=false;
                }else{
                    cout<<i<<'\n';
                    return(0);
                }
            }
        }
    }
    cout<<"OK\n";
}


Measured memory_bytes: 3180
#include <cstdio>

using namespace std;

int rec(int x, int acc, int n, int s) {
  if (x == 10) {
    return n == 0 && acc == s;
  }

  int ret = 0;
  ret += rec(x+1, acc, n, s);
  if (n > 0)
    ret += rec(x+1, acc+x, n-1, s);
  
  return ret;
}

int solve(int n, int s) {
  return rec(0, 0, n, s);
}

int main(int argc, char *argv[])
{
  int n, s;
  while (~scanf(" %d %d", &n, &s)) {
    if (n == 0 && s == 0)
      break;
    int ret = solve(n, s);
    printf("%d\n", ret);
  }
  
  return 0;
}

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

int main() {
  string s;
  cin >> s;
  int n = s.length();
  bool RL[n];
  int ans[n];
  for ( int i = 0; i < n; i++ ) {
    RL[i] = false;
    ans[i] = 0;
  }

  bool R = true;
  for ( int i = 1; i < n; i++ ) {
    if ( s[i] == 'R' ) { R = true; }
    if ( s[i] == 'L' ) {
      if ( R ) { RL[i] = RL[i-1] = true; }
      R = false;
    }
  }
  R = true;
  int Lpos;
  int num = 0;;
  for ( int i = 0; i < n; i++ ) {
    if ( R ) {
      num++;
      if ( RL[i] ) {
        if ( num%2 == 0 ) {
          ans[i] += num/2;
          ans[i+1] += num/2;
        } else {
          ans[i] += num/2 + 1;
          ans[i+1] += num/2;
        }
        num = 0;
        R = false;
        Lpos = i+1;
      }
    } else {
      num++;
      if ( i == n-1 || s[i+1] == 'R' ) {
        if ( num%2 == 0 ) {
          ans[Lpos] += num/2;
          ans[Lpos-1] += num/2;
        } else {
          ans[Lpos] += num/2 + 1;
          ans[Lpos-1] += num/2;
        }
        num = 0;
        R = true;
      }
    }
  }

  for ( int i = 0; i < n-1; i++ ) { cout << ans[i] << ' '; }
  cout << ans[n-1] << endl;

  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
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();}
template<class T> inline T sqr(T x) {return x*x;}
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef pair<int, int> PII;
#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 SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

    int n,s;
    cin >> n>>s;
    
    if(n%s==0){
        cout<<n/s<<endl;
    }else{
        cout<<n/s+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
using namespace std;
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
int dx[4]={0,0,-1,1},dy[4]={1,-1,0,0};


int main(int argc, char const *argv[]) {
  ll a,b,c,cnt=0;
  std::cin >> a >> b >> c;
  if(a==b && b==c && a!=1) std::cout << "-1" << '\n';
  else{
    while(a%2==0 && b%2==0 && c%2==0){
      ll s=a,t=b,u=c;
      a=t/2+u/2;
      b=s/2+u/2;
      c=s/2+t/2;
      cnt++;
    }
    std::cout << cnt << '\n';

  }
  return 0;
}


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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  ll count=0; 
  for(int i=0;i<n;i++) {
    cin >> a[i];
    if(a[i]<0) {
      count++;
    }
  }
  sort(a.begin(),a.end());
  ll ans=0;
  if(count%2!=0) {
    if(count<n&&abs(a[count-1])>abs(a[count])) {
      count++;
    }
    else {
      count--;
    }
  }
  for(ll i=0;i<n;i++) {
    if(count) {
      a[i]*=-1;
      count--;
    }
    ans+=a[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){
    char w[200];
    char W[200];
    int N;
    int n;
    
    while(1){
        scanf("%s",w);
        if(w[0]=='-')
            break;
        
        scanf("%d",&N);//処理回数

        for(int i=0;i<N;i++){
            //回数読み取り
            scanf("%d",&n);
            //シャッフル
            int f=0;
            for(int g=0;w[n+g]!='\0';g++,f++){
                W[f]=w[n+g];
            }
            for(int g=0;g<n;g++,f++){
                W[f]=w[g];
            }
            W[f]='\0';
            //元に戻す
            for(int g=0;W[g]!='\0';g++){
                w[g]=W[g];   
            }
        }
        printf("%s\n",w);
    }
}


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

#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

template <int MOD>
struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator-() const noexcept { return val ? MOD - val : 0; }
    constexpr Fp operator+(const Fp& r) const noexcept {
        return Fp(*this) += r;
    }
    constexpr Fp operator-(const Fp& r) const noexcept {
        return Fp(*this) -= r;
    }
    constexpr Fp operator*(const Fp& r) const noexcept {
        return Fp(*this) *= r;
    }
    constexpr Fp operator/(const Fp& r) const noexcept {
        return Fp(*this) /= r;
    }
    constexpr Fp& operator+=(const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator-=(const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator*=(const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator/=(const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator==(const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator!=(const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator<<(ostream& os,
                                         const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD>& a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

const int MOD = 1000000007;
using mint = Fp<MOD>;

int main() {
    int X, Y;
    cin >> X >> Y;

    if (X > 2 * Y || Y > 2 * X) {
        cout << 0 << endl;
        return 0;
    }

    if ((X + Y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }

    int a = (X + Y) / 3 + X - Y;
    a /= 2;
    int b = a - (X - Y);

    mint output = 1;
    if (a > b) {
        int tmp = a;
        a = b;
        b = tmp;
    }
    for (int i = a + b; i > b; i--) {
        output *= i;
    }
    for (int i = 1; i <= a; i++) {
        output /= i;
    }

    cout << output << endl;

    return 0;
}


Measured memory_bytes: 3632
//ssenseeeeeeeeeeeeeeeeeeeeeeeeeeeee
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef unsigned long long ull;
#define MX 1000000000
#define endl '\n'
#define startt ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fr first
#define sc second
#define MOD 1000000007

int main()
{
    int n;
    cin >> n;
    if(n >= 30)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}


Measured memory_bytes: 3620
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
	
	public static void main(String[] args) {
		String[] tmp = new String[]{"0","1","2","3","5","7","8","9"};
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			Long n = stdIn.nextLong();
			if(n == 0) break;
			String p = Long.toOctalString(n);
			for(int i = 0; i < p.length(); i++) {
				int tmpA = Integer.parseInt(String.valueOf(p.charAt(i)));
				System.out.print(tmp[tmpA]);
			}
			System.out.println();
		}
	}
	

}

Measured memory_bytes: 60520
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc=new Scanner(System.in);
    int h=sc.nextInt();
    int a=sc.nextInt();
    int ans=h/a;
    if(h%a!=0){++ans;}
   	System.out.println(ans);
  }
}


Measured memory_bytes: 21588
#include <iostream>

using namespace std;

int main()
{
  int S;
  int h;
  int m;
  int s;
  
  cin >> S;
  if(S>=0 && S<=86400)
    {
    h=S/3600;
    m=(S%3600)/60;
    s=(S%3600)%60;
    
    cout << h << ":" << m << ":" << s << "\n";
    }
} 

Measured memory_bytes: 1168
#include<iostream>
using namespace std;
#define mod 1000000007
#define N 200127
#define U 8001
inline int M(int x){return (x>=mod)?(x-mod):x;}
inline int M1(int x){return (x<0)?(x+mod):x;}
inline int ksm(int p,int k)
{
	int res=1;
	while(k)
	{
		if(k&1)res=1ll*res*p%mod;
		p=1ll*p*p%mod;k>>=1;
	}return res;
}
int n,a[N],b[N],s[N],fac[U],inv[U],f[4001][4001];
//令f[i][j]表示点集偏移i,j的答案,组合数前缀和转移 
//如果在凸包上,为1,否则为左下角矩形和 
inline int C(int n,int m)
{return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;}
int main(){
	scanf("%d",&n);int i,j,ans=0;
	for(i=1;i<=n;i++)scanf("%d%d",&a[i],&b[i]),s[i]=a[i]+b[i];
	fac[0]=1;for(i=1;i<U;i++)fac[i]=1ll*fac[i-1]*i%mod;
	inv[U-1]=ksm(fac[U-1],mod-2);
	for(i=U-2;i>=0;i--)inv[i]=1ll*inv[i+1]*(i+1)%mod;
	for(i=1;i<=n;i++)++f[2000-a[i]][2000-b[i]];
	for(i=0;i<=4000;i++)
	for(j=0;j<=4000;j++)
	f[i][j]=M(f[i][j]+M((i?f[i-1][j]:0)+(j?f[i][j-1]:0)));
	for(i=1;i<=n;i++)ans=M1(M(ans+f[2000+a[i]][2000+b[i]])-C(s[i]*2,a[i]*2));
	printf("%d",1ll*ans*ksm(2,mod-2)%mod);return 0;
}

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

namespace Volume0019
{
    class Program
    {
        static void Main(string[] args)
        {
            long num = long.Parse(Console.ReadLine());
            long factorinal = Calclation.Factorial(num);
            Console.WriteLine(factorinal);
        }
    }
    class Calclation
    {
        internal static long Factorial(long num)
        {
            long factorinal = 1;
            for (int i = 1; i <= num; ++i)
            {
                factorinal *= i;
            }
            return factorinal;
        }
    }
}



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

#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using pii = pair<int , int>;
using pll = pair<long long , long long>;

//プロトタイプ宣言
void faster(void);
template <class T>
T gcd(T , T);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);



int main(){
  faster();
  int k,n;
  cin >> n >> k;
  vi p(n);
  rep(i,n) cin >> p[i];
  vector<double> dp(n+1,0);
  rep(i,n){
    dp[i+1] += dp[i];
    dp[i+1] += (double)(1+p[i])/2.00000000;
  }
  double ans=0.0;
  for(int i=0;i+k<=n;i++){
    ans = max(ans , dp[i+k]-dp[i]);
  }
  cout << setprecision(10) << ans << endl;
}



























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//ユークリッドの互除法
template <class T>
T gcd(T a, T b) {
  return (b ? gcd(b, a%b) : a);
} 

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//べき乗計算
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
string str;
int main()
{
    cin >> str;
    for (int i = 0;i <= 3;i++)
    {
        cout << str[i];
    }
    cout << " ";
    for (int i = 4;i <= 11;i++)
    {
        cout << str[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256