akhauriyash/Code-Regression huggingface dataset:
#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>

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

#define cauto const auto&
#else

#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 F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
	string s;
	while(getline(cin,s)){
		// cout<<s<<endl;
		stringstream ss;
		ss<<s;
		vint v;
		int t;
		vint dp(30,0);
		while(ss>>t){
			// cout<<t<<endl;
			if(t==0) return;
			v.PB(t);
		}
		dp[0]=1;
		rep(i,v.size()){
			vint tmp=dp;
			if(i) dp=vint(30,0);
			int tt=v[i];
			if(v[i]>=10) tt=10;
			// cout<<tt<<endl;
			// cout<<i<<endl;
			// rep(j,30){
				// cout<<j<<" "<<tmp[j]<<endl;
			// }
			for(int j=29;j>=tt;j--){
				if(tmp[j-tt]) dp[j]=1;
			}
			if(v[i]==1){
				tt=11;
				for(int j=29;j>=tt;j--){
					if(tmp[j-tt]) dp[j]=1;
				}
			}
			dp[0]=0;
		}
		dp[0]=1;
		for(int i=21;i>=0;i--){
			if(dp[i]){
				cout<<i<<endl;
				break;
			}
		}
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 1244
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(GCD(ab[0], ab[1]));
    }

    static long GCD(long a, long b)
    {
        while (true)
        {
            if (b == 0) return a;
            a %= b;
            if (a == 0) return b;
            b %= a;
        }
    }
}


Measured memory_bytes: 20412
# coding: utf-8
# Your code here!
S = input()
ans = 1
prev=S[0]
now = ""
temp=""
i = 1
if len(S) != 1:
    while(1):
        now=S[i]
        flg=False
        while(prev == now and i < len(S)-1):
            now += S[i+1]
            i+=1
        # print(i, prev, now)
        temp=prev
        prev = now
        i+=1
        ans+=1
        if i >= len(S):
            break
if temp == now:
    ans -= 1
print(ans)


Measured memory_bytes: 3500
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int h[] = new int[K];
    int landCt =0;
    int answer=0;
    for(int i=0;i<K;i++){
      h[i] = sc.nextInt();
    }
    int start = h[0];
    for(int i=0;i<101;i++){
      landCt=0;
      for(int j=0;j<K-1;j++){
        if((h[j]==0&&h[j+1]>0)||(j==0&&h[0]>0)){
          landCt=landCt+1;
        }
      }
      answer = answer + landCt;
      oneMinus(h);
    }

    if(K!=1){
       System.out.println(answer);
    }else{
      System.out.println(start);
    }
    
  }
  
  public static void oneMinus(int[] h){
    for(int i=0;i<h.length;i++){
      if(h[i]!=0){
        h[i]=h[i]-1;
      }
    }
  }
  
}

Measured memory_bytes: 23764
#include <iostream>

int main(){
  int N;
  std::cin >> N;
  N %= 10;
  if(N == 3)
    std::cout << "bon" << std::endl;
  else{
    if(N < 2 || N == 6 || N == 8)
      std::cout << "pon" << std::endl;
    else
      std::cout << "hon" << std::endl;
  }

  return 0;
}

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

/*
next_permutation(a.begin(),a.end())
引数にvector（またはarray）をいれると、
次の順列を上書きしてくれる。
次の順列がなくなるとfalseを返してくれるらしい
mpは最初要素数０で更新していくごとに要素数が
増えていくので、size()で辞書順で何番目なのか
取得することができる
*/

int main(){
    int n;
    cin >> n;
    vector<int> p(n),q(n);
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> q[i];
    vector<int> a(n);
    rep(i,n) a[i] = i+1;
    map<vector<int>,int> mp;
    do {
        mp[a] = mp.size();
    } while (next_permutation(a.begin(),a.end()));
    int ans = abs(mp[p]-mp[q]);
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 5248
#include <iostream>
#include <stdlib.h>
#include <stdio.h>      /* printf */
#include <math.h>       /* pow */
#include <vector>
#include <stack>
#include <algorithm>
#include <string>

int linearSearch(std::vector<int>& list, std::vector<int>& seq) {
   int found = 0;
   for (int i=0; i<seq.size();i++) {
       int j=0;
       while (j<list.size()) {
            if (list[j]==seq[i]) {
                j=list.size();
                found++;
            } else {
                j++;
            }
        }
   }
   return found;
}

int main(void){
    int value;
    std::vector<int> list;
    int n;
    std::cin >> n;
    for(int i=0; i<n; i++) {
        std::cin >> value;
        list.push_back(value);
    } 
    std::vector<int> seq;
    int q;
    std::cin >> q;
    for(int j=0; j<q; j++) {
        std::cin >> value;
        seq.push_back(value);
    }
    std::cout << linearSearch(list,seq) << std::endl;
    return 0;
}

Measured memory_bytes: 1320
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

h,w = iim()
n = ii()
A = iil()
ans = []
l = []
for i,item in enumerate(A):
    l += [i+1]*A[i]

for i in range(h):
    p = l[i*w:(i+1)*w]
    if i%2 == 1:
        ans.append(p[::-1])
    else:
        ans.append(p)

for i in ans:
    print(*i)


Measured memory_bytes: 3956
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  double x, h;
  while (cin >> x >> h, x) {
    cout << prec(8) << x * x + x * hypot(h, x / 2) * 2 << endl;
  }
}

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

const int MOD = 1000000007;

int main()
{
  std::size_t n, k;
  std::cin >> n >> k;
  
  std::size_t result = 0;
  for (std::size_t i=k; i<=n+1; ++i) {
    result = (result + i * (n - i + 1) + 1) % MOD;
  }
  std::cout << result << std::endl;
}



Measured memory_bytes: 3192
import java.util.Scanner;

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

    long M = 1_000_000_007;
    int N = scanner.nextInt();
    int K = scanner.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++) a[i] = scanner.nextInt();

    long[][] dp = new long[N][K + 1];
    for (int i = 0; i <= a[0]; i++) dp[0][i] = 1;
    for (int i = 1; i < N; i++) {
      long sum = 0;
      for (int j = 0; j <= K; j++) {
        sum += dp[i - 1][j];
        if (sum > M) sum -= M;
        if (j > a[i]) sum -= dp[i - 1][j - a[i] - 1];
        if (sum < 0) sum += M;
        dp[i][j] = sum;
      }
    }
    System.out.println(dp[N - 1][K]);
  }
}


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

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

template<typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	long long K;
	scanf("%lld",&K);
	long long A;
	scanf("%lld",&A);
	long long B;
	scanf("%lld",&B);

	auto ans = B / K * K;
	cout << (ans >= A && ans <= B ? "OK" : "NG") << endl;

	return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define mpi         map<pair<ll int,ll int>,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vii         vector<pair<ll int, ll int>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
//#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
#define N  1000000007 
#define MAXN   200005
int main()
{
ios_base::sync_with_stdio(false);
 cin.tie(0);
 cout.tie(0);
ll int n,h,w;
cin>>n>>h>>w;
cout<<(n-h+1)*(n-w+1);
}


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

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    sort(h.begin(),h.end(),greater<int>());
    int ans=1e9;

    rep(i,n-k+1){
        ans = min(ans,h[i] - h[i+k-1]);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define INF 2<<29

int main(){
  int r,d,x;
  cin>>r>>d>>x;

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



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define     ll              long long
#define     MAX             100000
#define     FI              freopen("input.txt","r",stdin)
#define     FO              freopen("output.txt","w",stdout)
#define     fast            ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define     sc(a)           scanf("%d",&a)
#define     sc2(a,b)        scanf("%d %d",&a,&b)


int main()
{
    int n;
    cin>>n;
    int arr[n+1];
    memset(arr,0,sizeof arr);
    for(int i=0;i<n-1;i++)
    {
        int x;
        cin>>x;
        arr[x]++;
    }
    for(int i=1;i<=n;i++)
        cout<<arr[i]<<"\n";
    return 0;
}


Measured memory_bytes: 4412
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

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

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

int cal(int n) {
    string s = to_string(n);
    int res = 0;
    for (int i = 0;i < s.size();i++) res += s[i] - '0';
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    int v = N;
    for (int i = 1;i < N;i++) {
        v = min(v, cal(i) + cal(N - i));
    }
    cout << v << endl;
    return 0;
}

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

int main(){

    int n,m;
    cin >> n >> m;

    vector<int> x(m);

    rep(i,m) cin >> x[i];

    if(m<=n||m==1){
        cout << 0 << endl;
        return 0;
    }

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

    int su=x.back()-x[0]+1;

    vector<int> d(m-1);

    rep(i,m-1){
        d[i]=x[i+1]-x[i]-1;
    }
    sort(d.begin(),d.end());

    rep(i,n-1){
        su-=d.back();
        d.pop_back();
    }

    cout << su-n << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <climits>
#include <cstring>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

using namespace std;

const int N_MAX = 1000000;

int pque[1000000001];
int ele_counter = 0;


void insert(int data){
  pque[ele_counter] = data;
  int cur_ix = ele_counter;
  int parent_ix = (cur_ix - 1)/2;
  while(parent_ix >= 0 && pque[parent_ix] < pque[cur_ix]){
    swap(pque[parent_ix], pque[cur_ix]);
    cur_ix = parent_ix;
    parent_ix = (cur_ix - 1)/2;
  }
}


void heapify_topdown(int cur_ix){
  int left_ix = 2*cur_ix + 1;
  int right_ix = 2*cur_ix + 2;
  // minus 1 because element is popped but counter not decreased
  if(left_ix <= ele_counter-2 && right_ix <= ele_counter-2){
    // swap whichever bigger
    if(pque[left_ix] <= pque[right_ix] && pque[cur_ix] < pque[right_ix]){
      swap(pque[right_ix], pque[cur_ix]);
      heapify_topdown(right_ix);
    }
    else if(pque[left_ix] > pque[right_ix] && pque[cur_ix] < pque[left_ix]){
      swap(pque[left_ix], pque[cur_ix]);
      heapify_topdown(left_ix);
    }
    // else: do nothing
  }
  else if(left_ix == ele_counter-2){
    // compare with left
    if(pque[cur_ix] < pque[left_ix]) swap(pque[cur_ix], pque[left_ix]);
  }
  // else: do nothing
}

int extract(){
  //  if(ele_counter <= 0) return;
  int extracted = pque[0];
  pque[0] = pque[ele_counter - 1];
  int cur_ix = 0;
  // swap with whichever bigger
  heapify_topdown(cur_ix);
  
  return extracted;
}

int main(){
  string order;
  vector<int> ans;
  while(cin >> order){
    int data;
    if(order == "end") break;
    if(order == "insert"){
      cin >> data;
      insert(data);

      ele_counter++;

    }
    else{
      ans.push_back(extract());
      ele_counter--;

    }
  }
  rep(i, 0, ans.size()) cout << ans[i] << endl;
  return 0;
}



Measured memory_bytes: 8820
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ABC148A
    {
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var A = NN;
            var B = NN;
            var list = new List<long>(new long[] { 1, 2, 3 });
            list.Remove(A);
            list.Remove(B);
            Console.WriteLine(list.First());
        }
        static class Console_
        {
            static Queue<string> param = new Queue<string>();
            public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static public void Main(string[] args) { if (args.Length == 0) { Console.SetOut(new Printer(Console.OpenStandardOutput())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); }
        static long NN => long.Parse(Console_.NextString());
        static double ND => double.Parse(Console_.NextString());
        static string NS => Console_.NextString();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift);
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
    }
}
namespace Library {
}


Measured memory_bytes: 15072
n,k=map(int,input().split())
l=list(map(int,input().split()))
d={}
for i in range(0,len(l)):
    d[i+1]=l[i]
ans=1
s=set()
seq=[]
e=0
for i in range(0,k):
    ans=d[ans]
    if ans in s:
        seq.append(ans)
        break
    else:
        s.add(ans)
    seq.append(ans)
else:
    print(ans)
    e=1
if e==0:
    b = seq.index(seq[-1])
    rep = seq[b:-1]
    sl = len(seq) - seq.index(seq[-1]) - 1
    k = k - b - 1
    ans = seq[b]
    x = k % sl
    # print(x,sl)
    print(rep[x])










Measured memory_bytes: 48448
n = int(input())
lst = list(map(int, input().split()))
ans = 0
a,b = 0,0
lst2=[0]
d = {0:1}
for i in range(n):
    s = lst2[-1]+lst[i]
    lst2.append(s)
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1

temp = set()

for i in d:
    l = d[i]
    if l > 1 and i not in temp:
        temp.add(i)
        ans += l*(l-1)//2
print(ans)


"""
6
1 3 -4 2 2 -2


7
1 -1 1 -1 1 -1 1

5
1 -2 3 -4 5


0 0 0 0 0
"""

Measured memory_bytes: 38644
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#define INF 1000000;

using namespace std;

int main() {
    int n, x, a[110], min_weight=INF;

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

    if (x==0) cout << n << endl;

    else{
        int count = n;
        count += (x / min_weight);
        cout << count << endl;
        }
}

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


int main(void) {
  int N;
  cin >> N;
  int A[N];
  REP(i,N) cin >> A[i];

  int rv[100000] = {};
  REP(i,N) rv[A[i]]++;

  sort(rv, rv+100000, greater<int>());
  int j = 1;
  int others = 0;
  while(rv[j]>1) {
    others += rv[j] - 1;
    j++;
  }
  if (others == 0 && rv[1] == 0) {
    cout << 1 << '\n';
    return 0;
  }
  int all = others + rv[0] - 1;
  int del_time = max(rv[0]-1, all/2+all%2);
  cout << N - del_time * 2 << '\n';
}


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

int main()
{
    string s;
    cin >> s;
    long long ans = 0, cnt = 0;
    for (int i = s.size() - 1; i >= 0; i--)
    {
        if (s[i] == 'B')
            ans += cnt;
        cnt += s[i] == 'W';
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
import sys
import math
n = int(input())
T,A = 1,1
for i in range(n):
    t,a = map(int,input().split())
    coef = max((T+t-1)//t,(A+a-1)//a)
    T,A = coef * t, coef * a 
print(T+A)     

    


Measured memory_bytes: 3060
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

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

    public static void main(String[] args) {
        int a = nextInt();
        int b = nextInt();

        int Answer = -1;

        if (a > 9 || b > 9) {
        	println(Answer);
        } else {
        	println(a * b);
        }
    }

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

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }
}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;

#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)

int main(){
    int n;
    cin >> n;
    int p[n], ans = 0;
    Fp(i, 0, n) cin >> p[i];
    Fp(i, 1, n - 1){
        if(p[i - 1] < p[i]){
            if(p[i] < p[i + 1]) ans++;
        }else if(p[i] > p[i + 1]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	string s; cin >> s;
	if( n%2 != 0 ){
		cout << "No" << endl;
		return 0;
	}
	for( int i = 0; i < n/2; ++i ){
			if( s[i] != s[i+n/2] ){
				cout << "No" << endl;
				return 0;
			}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    String s= "APPROVED";
    for(int i= 0; i < n; i++){
      a[i] = sc.nextInt();
      if(a[i] % 2==0 && (a[i] % 3!= 0 && a[i] % 5 != 0)) s = "DENIED";
    }
    System.out.println(s);
  }
}


Measured memory_bytes: 23252
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll k,t;
cin >> k >> t;
vector<ll> cakes(t);
rep(i,t)
cin >> cakes[i];
sort(cakes.begin(),cakes.end());
ll sum = 0;
rep(i,t - 1)
sum += cakes[i];
cakes[t - 1]--;
cout << max(0LL,cakes[t - 1] - sum) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
template<class T> inline void chmin(T &a, T b){if(a>=b)a=b;}
template<class T> inline void chmax(T &a, T b){if(a<=b)a=b;}
typedef long long ll;
const int INF = 1e9;

int N,Ma,Mb;
int A[50],B[50],C[50];
// dp[i][j][k] : i番目まで使った時、maがj,mbがkの場合の最小値
int dp[50][500][500];

int main()
{
    cin >> N >> Ma >> Mb;
    REP(i,N) cin >> A[i] >> B[i] >> C[i];

    // 初期化
    REP(i,41) REP(a,401) REP(b,401) dp[i][a][b] = INF;
    //
    
    // 初期値　：　何も使ってないときはコスト０
    dp[0][0][0] = 0;
    // 可能なa,bを全て調査
    REP(i,N){
        REP(a,401){
            REP(b,401){
                // 使わない
                chmin(dp[i+1][a][b],dp[i][a][b]);
                // 使う
                chmin(dp[i+1][a+A[i]][b+B[i]],dp[i][a][b] + C[i]);
            }
        }
    }
    // a, bは1から(dp[n][0][0]には何も使わない時の値0が入ってる)
    int ans = INF;
    for(int a = 1; a < 401; ++a){
        for(int b = 1; b < 401; ++b){
            // a : b = Ma : Mb -> bMa == aMb
            if(b*Ma == a*Mb){
                chmin(ans,dp[N][a][b]);
            }
        }
    }
    if(ans==INF) cout << -1 << endl;
    else    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 40960
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

using P = pair<int,int>;

int m = 1000000+1;
int main(void){
    // Your code here!
    int n; cin >> n;
    vector<int> a(n);
    ll ans = 0;
    rep(i,n) {
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    vector<int> b(m,0);
    rep(i,n) {
        int cur = a[i];
        if (b[cur] != 0) {
            b[cur] = 2;
            continue;
        } 
        for (int j = cur; j <=m;j += cur) {
            b[j]++;
        }
    }
    for(auto x:a) {
        if(b[x] == 1) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 7960
#include <bits/stdc++.h>
using namespace std;
#define fl(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
#define mx 200005
#define inf 2e9
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int main()
{
    string s,t;
    cin>>s>>t;
    int n = s.length() , m = t.length();
    int dp[n+1][m+1];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
            dp[i][j] = 0;
    }
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            if(i==0 || j==0)
                dp[i][j] = 0;
            else if( s[i-1] == t[j-1] )
                dp[i][j] = 1+dp[i-1][j-1];
            else
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
    }/*
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
            cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/
    int index = dp[n][m];
    char lcs[index+1];
   lcs[index] = '\0'; // Set the terminating character

   // Start from the right-most-bottom-most corner and
   // one by one store characters in lcs[]
   int i = n, j = m;
   while (i > 0 && j > 0)
   {
      // If current character in X[] and Y are same, then
      // current character is part of LCS
      if (s[i-1] == t[j-1])
      {
          lcs[index-1] = s[i-1]; // Put current character in result
          i--; j--; index--;     // reduce values of i, j and index
      }

      // If not same, then find the larger of two and
      // go in the direction of larger value
      else if (dp[i-1][j] > dp[i][j-1])
         i--;
      else
         j--;
   }
   cout<<lcs<<endl;
   /*
    int i=n,j=m;
    string str;
    while(i>0 && j>0)
    {
        if(s[i-1]==t[j-1])
        {
            str+=s[i-1];
        }
        else
        {
            if(dp[i-1][j]>dp[i][j-1])
            {
               i--;
            }
            else
            {
                j--;
            }
        }
    }
    for(int i=0;i<str.length();i++)
        cout<<str[i];*/
}


Measured memory_bytes: 35456
($n, $d) = split(/ /, <>);

$s = $d + 1;
$e = $s + $d;
$last = $n - $d;

$cnt = 1;
while($s < $last){
	$s = $e + $d + 1;
	$e = $s + $d;
	$cnt++;
}

print "$cnt\n";


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

int main()
{
  int n;
  std::cin >> n;
  std::vector<int> a(n + 1);
  for(int i = 1; i <= n; i++){
    std::cin >> a[i];
    a[i] += a[i - 1];
  }
  int max = 1000000000;
  for(int i = 0; i <= n; i++){
    max = std::min(max, std::abs((a[n] - a[i]) - a[i]));
  }
  std::cout << max << std::endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int x = sc.nextInt();
			Integer l[] = new Integer[n];
			for (int i = 0; i < n; i++) {
				l[i] = sc.nextInt();
			}
			
			int count = 1;
			int d = 0;
			for (int i = 0; i < n; i++) {
				d = d + l[i];
				if (d > x) {
					break;
				}
				count ++;
			}
			System.out.println(count);
		}
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define END return 0
typedef int64_t ll;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a % b) : abs(a);}
template<typename T> T lcm(T a, T b) {return a / gcd(a, b) * b;}
template<typename T> bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) {fill((T*)array, (T*)(array+N), val);}

int main() {
    string s;
    cin >> s;
    rep(i, s.size()) cout << 'x';
    cout << endl;
}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(ll i=0;i<(n);i++)


using namespace std;


int main() {
    ll x, y;
    cin >> x >> y;

    ll cnt = 0;
    while(x <= y){
        x *= 2;
        cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    vector<int> cnt(m, 0); //m個の要素、0で初期化
    rep(i, n) {
        int k;
        scanf("%d", &k);
        rep(j, k) {
            int a;
            scanf("%d", &a);
            cnt[a - 1]++; //iについてそれを好きだと答えた人数をカウントしてく
        }
    }
    int ans = 0;
    rep(i, m) {
        if(cnt[i] == n) { //人数とカウント数が一緒だったら
            ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    const int mx = 200000;
    int n;
    cin >> n;
    vector<int> x(n), y(n), u(n);
    map<char, int> mp;
    mp['U'] = 0;
    mp['L'] = 1;
    mp['D'] = 2;
    mp['R'] = 3;
    rep(i, n) {
        char c;
        cin >> x[i] >> y[i] >> c;
        u[i] = mp[c];
    }

    auto rotate = [&]() {
                      rep(i, n) {
                          int tmp = x[i];
                          x[i] = mx - y[i];
                          y[i] = tmp;
                          u[i] = (u[i] + 1) % 4;
                      }
                  };
    using P = pair<int, int>;
    const int inf = 1001001001;
    int ans = inf;
    rep(_, 4) {
        auto xs = make_vec<P>(mx+1, 0);
        rep(i, n) if (u[i] == 0 || u[i] == 2) xs[x[i]].emplace_back(y[i], u[i]);
        rep(i, mx+1) {
            sort(xs[i].begin(), xs[i].end());
            rep(j, xs[i].size() - 1) {
                if (xs[i][j].second == 0 && xs[i][j+1].second == 2) chmin(ans, (xs[i][j+1].first - xs[i][j].first) * 5);
            }
        }

        auto sums = make_vec<P>(2*mx+1, 0);
        rep(i, n) if (u[i] == 0 || u[i] == 3) sums[x[i]+y[i]].emplace_back(x[i]-y[i], u[i]);
        rep(i, 2*mx+1) {
            sort(sums[i].begin(), sums[i].end());
            rep(j, sums[i].size() - 1) {
                if (sums[i][j].second == 3 && sums[i][j+1].second == 0) chmin(ans, (sums[i][j+1].first - sums[i][j].first) * 5);
            }
        }
        rotate();
    }
    if (ans == inf) cout << "SAFE" << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 32184
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i, n)for(int i=0; i<n; i++)

int main(){
  int N;
  cin >> N;
  int A[N+2];
  for(int i=2; i<=N; i++)
    cin >> A[i];

  int count[N+1] = {0};
  for(int i=2; i<=N; i++)
    count[A[i] ]++;

  rep(i, N)
    cout << count[i+1] << endl;


  return 0;
}


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

const int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  vector<int> hs(n);
  rep(i, n) {
    cin >> hs.at(i);
  }

  vector<int> dps(n);
  dps.at(0) = 0;
  dps.at(1) = abs(hs.at(1) - hs.at(0));
  rep(i, n) {
    if (i == 0 || i == 1) {
      continue;
    }
    dps.at(i) = min(abs(hs.at(i) - hs.at(i - 1)) + dps.at(i - 1), abs(hs.at(i) - hs.at(i - 2)) + dps.at(i - 2));
  }

  cout << dps.at(n-1) << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n,v,p;
ll m,a[100010];

void solve(){
    cin >> n >> m >> v >> p;
    rep(i,n){
        cin >> a[i];
    }
    sort(a,a+n,greater<ll>());
    //rep(i,n) cout << a[i] << " ";
    //cout << "" << endl;
    int ok=0,ng=n;
    while(ng-ok>=2){
        //cout << ok << " " << ng << endl;
        int mid =(ok+ng)/2;
        if (mid<=p-1) {
            ok=mid;
            continue;
        }
        ll s=v-p-n+mid+1;
        if (s<=0){
            if (a[p-1]<=a[mid]+m) ok=mid;
            else ng=mid;
        } 
        else{
            if (a[p-1]>a[mid]+m) {
                ng=mid;
                continue;
            }
            ll S=0;
            Rep(l,p-1,mid){
                S+=min(m,a[mid]+m-a[l]);
            }
            //cout << S << "," << s*m << endl;
            if (S>=s*m) ok=mid;
            else ng=mid;
        }
    }
    cout << ok+1 << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 1024
from scipy.sparse.csgraph import floyd_warshall
H, W = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(H)]
# 有向グラフと考えらる
C = floyd_warshall(C)
ans = 0
for i in range(H):
    for j in range(W):
        if A[i][j] != -1:
            ans += C[A[i][j]][1]  # 頂点1に到達するためのコスト
print(int(ans))


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

int main() {
  string s;
  cin >> s;
  long int t = 1;
  long int out = 0;
  long int sho = 0;
  long int dai = 0;
  if(s.size() == 1){
    cout << 1;
  }else{
  for(int i = 0; i < s.size() - 1; i++){
    if(s.at(i) == s.at(i+1)){
      t++;
    }else{
      if(s.at(i) == '<'){
        sho = t;
        t = 1;
      }else{
        dai = t;
        t = 1;
        if(sho == 0){
          out += (dai*(dai+1))/2;
        }else if(sho < dai){
          out += ((sho-1)*sho)/2 + (dai*(dai+1))/2;
        }else{
          out += ((sho+1)*sho)/2 + (dai*(dai-1))/2;
        }
      }
    }
    if(i == s.size() - 2){
      if(s.at(i + 1) == '<'){
        out += ((t+1)*t)/2;
      }else{
        dai = t;
        if(sho < dai){
          out += ((sho-1)*sho)/2 + (dai*(dai+1))/2;
        }else{
          out += ((sho+1)*sho)/2 + (dai*(dai-1))/2;
        }
      }
    }
  }
  cout << out;
  }
}


Measured memory_bytes: 900
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <time.h>
#include <string>
#include <stack>
#include <set>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
#define MP make_pair
#define PB push_back
typedef long long LL;
typedef pair<int, int> Pii;
const int inf = 0x3f3f3f3f;
const LL INF = (1uLL << 63) - 1;
const LL mod = 1000000007;
const int N = 150 + 5;
const double Pi = acos(-1.0);
const int maxn = 1e5 + 5;
vector<Pii>G;
int a[maxn];
int main() {
#ifdef local
    freopen("in", "r", stdin);
    //  freopen("w","w",stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,x;
    cin>>n;
    for(int i = 0; i < n ; i++){
        cin>>x;
        a[x]++;
    }
    for(int i = 0 ; i < maxn ; i++){
        if(a[i]){
            G.PB(MP(i,a[i]));
        }
    }
    int k = 0;
    int o = 0;
    for(int i = 0; i < G.size(); i++){
      //  cout<<G[i].first<<" "<<G[i].second<<endl;
        if(G[i].second % 2 == 0){
            o++;
        }
    }
    if(o%2==0){
        cout<<G.size()<<endl;
    }
    else cout<<G.size() - 1<<endl;
}


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

int main() {
  string O, E;
  cin >> O >> E;
  string ans;
  for (int i = 0; i < O.size(); i++) {
    cout << O[i];
    if (i < E.size()) {
      cout << E[i];
    }
  }
}


Measured memory_bytes: 256
S = input()
goal = "keyence"
if S.startswith(goal) or S.endswith(goal):
    print("YES")
else:
    for i in range(len(S)-1):
        if S.startswith(goal[:len(S)-i]) and S.endswith(goal[len(S)-i:]):
            print("YES")
            exit(0)
    print("NO")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yes(){
    cout << "Yes" << endl;
}

void no (){
    cout << "No" << endl;
}

ll cel (ll a, ll b){
    if (a % b == 0) return a / b;
    else return a / b + 1;
}

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

vector<int> dx = {0,1,0,-1};
vector<int> dy = {1,0,-1,0};

int main() {
    int n; cin >> n;
    bool t = false;
    rep(i,100) rep(j,100){
        if (4*i + 7*j == n){
            t = true;
        }
    }
    if (t) yes();
    else no();
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


int n,l;


main(){
  cin>>n>>l;

  if(l>=0){
    int sum=0;
    rep(i,n-1){
      sum+=l+i+1;
    }
    cout<<sum<<endl;
  }else if(n+l>0){
    int sum=0;
    rep(i,n){
      sum+=l+i;
    }
    cout<<sum<<endl;
  }else{
    int sum=0;
    rep(i,n-1){
      sum+=l+i;
    }
    cout<<sum<<endl;
  }

}


Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
int main()
{
	string a, b, c;
	cin >> a >> b >> c;
	printf("A%cC\n", b[0]);
	//cout << max(a*b,c*d) << endl;
	//printf((a+b==c||b+c==a||c+a==b) ? "Yes\n" :"No\n");
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

bool judge(ll x, ll D){
	ll waru;
	if(D==0) waru=1;
	if(D==1) waru=100;
	if(D==2) waru=10000;
	return (x%waru==0)&&(x%(100*waru)!=0);
}

int main(){
	ll D, N;
	cin>>D>>N;

	ll x=1;
	while(1){
		if(judge(x, D)) N--;
		if(N==0){
			cout << x << endl;
			return 0;
		}
		x++;
	}
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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

vector<int> color[100100];
vector<pair<int,int>> G[100100];
int N,a,b,maxi=0,start=0;
int ans[100100];

void dfs(int now,int col){
    int ansco=1;
    for(pair<int,int> p:G[now]){
        if(ans[p.second]==-1){
            if(ansco==col)ansco++;
            ans[p.second]=ansco;
            color[now].push_back(ansco);
            color[p.first].push_back(ansco);
            dfs(p.first,ansco);
            ansco++;
        }
    }
}

int main(){
    cin>>N;
    rep(i,N-1){
        cin>>a>>b;
        a--;
        b--;
        G[a].push_back({b,i});
        G[b].push_back({a,i});
    }
    rep(i,N){
        int tmp = G[i].size();
        maxi=max(maxi,tmp);
        start=i;
    }
    rep(i,N)ans[i]=-1;
    out(maxi);
    dfs(start,-1);
    rep(i,N-1){
        out(ans[i]);
    }



    

}


Measured memory_bytes: 12544
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;cin>>H>>W;
  vector<vector<char>> S(H,vector<char>(W,false));
  for(int i=0; i<H; i++){
    string s;
    cin>>s;
    for(int j=0; j<W; j++){
      S[i][j]=s[j];
    } 
  }
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(S[i][j]!='#'){
        int c=0;
        if(j+1<W)if(S[i][j+1]=='#')c++;
        if(i+1<H&&j+1<W)if(S[i+1][j+1]=='#')c++;
        if(i+1<H)if(S[i+1][j]=='#')c++;
        if(i+1<H&&j-1>=0)if(S[i+1][j-1]=='#')c++;
        if(j-1>=0)if(S[i][j-1]=='#')c++;
        if(i-1>=0&&j+1<W)if(S[i-1][j+1]=='#')c++;
        if(i-1>=0)if(S[i-1][j]=='#')c++;
        if(i-1>=0&&j-1>=0)if(S[i-1][j-1]=='#')c++;
        S[i][j]='0'+c;
      }
    } 
  }
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cout<<S[i][j];
    }
    cout<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
#define ll long long

int main() {
	int n, v[50], c[50], ans, hoge;
	ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	for (int i = 0; i < n; i++) {
		hoge = v[i] - c[i];
		if (hoge > 0)ans += hoge;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384