akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = (LL)INF * INF;

const int mod = 1000 * 1000 * 1000 + 7;
const int MAX = 1007;

int a[MAX], b[MAX];

int mult(int a, int b)
{
	return (LL)a * b % mod;
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	int n, m;
	cin >> n >> m;
	FOR(i, 0, n)
		cin >> a[i];
	FOR(i, 0, m)
		cin >> b[i];
	sort(a, a + n);
	reverse(a, a + n);
	FOR(i, 0, n - 1)
	{
		if(a[i] == a[i + 1])
		{
			cout << 0;
			return 0;
		}
	}
	sort(b, b + m);
	reverse(b, b + m);
	FOR(i, 0, m - 1)
	{
		if(b[i] == b[i + 1])
		{
			cout << 0;
			return 0;
		}
	}
	int ptr1 = 0, ptr2 = 0;
	int cnt = 0;
	int cc = 0, cr = 0;
	int ans = 1;
	RFOR(i, n * m + 1, 1)
	{
		if(a[ptr1 + 1] == i)
			ptr1++;
		if(b[ptr2 + 1] == i)
			ptr2++;
		if(a[ptr1] == i && b[ptr2] == i)
		{
			cnt += cr + cc;
			cr++;
			cc++;
		}
		else if(a[ptr1] == i)
		{
			ans = mult(ans, cc);
			cnt += cc - 1;
			cr++;
		}
		else if(b[ptr2] == i)
		{
			ans = mult(ans, cr);
			cnt += cr - 1;
			cc++;
		}
		else
		{
			ans = mult(ans, cnt--);
		}
	}
	cout << ans;
	return 0;
}

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

struct Res{
    int P,ID;
    char S[10];
};

int compare_char(const void* left, const void* right) {
    char *left_char = ((Res *)left) -> S;
    char *right_char = ((Res *)right) -> S;

    if(strcmp( left_char, right_char )==0){
        return ((Res *)right) -> P - ((Res *)left) -> P;
    }

    return strcmp( left_char, right_char );
}

int main(){
    int N,i;
    cin >> N;
    Res res[N];
    for(i=0;i<N;i++){
        cin >> res[i].S >> res[i].P;
        res[i].ID = i;
    }
    qsort(res,N,sizeof(Res),compare_char);
    for(i=0;i<N;i++){
        cout << res[i].ID + 1 << endl;
    }
    return 0;
}

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

const int maxn(5e5 + 5);

struct Edge {  int u, v, w;  };
inline int operator <(const Edge &a, const Edge &b) {  return a.w < b.w;  }

int fa[maxn], n, q, f[maxn], cnt;
Edge edge[maxn];
ll ans;

inline int Find(int x) {  return (fa[x] ^ x) ? fa[x] = Find(fa[x]) : x;  }

inline void Init() {
	int i, a, b, c, mn = -1;
	memset(f, 63, sizeof(f));
	scanf("%d%d", &n, &q);
	for (i = 1; i <= n; ++i) fa[i] = i;
	for (i = 1; i <= q; ++i) {
		scanf("%d%d%d", &a, &b, &c);
		edge[++cnt] = (Edge){a + 1, b + 1, c};
		f[(a + 1) % n] = min(f[(a + 1) % n], c + 1);
		f[(b + 1) % n] = min(f[(b + 1) % n], c + 2);
	}
	for (i = 0; i < n; ++i) if (mn == -1 || f[i] < f[mn]) mn = i;
	for (i = (mn + 1) % n; i ^ mn; i = (i + 1) % n) f[i] = min(f[i], f[(i - 1 + n) % n] + 2);
	for (i = 0; i < n; ++i) {
		a = i + 1, b = (i + n - 1) % n + 1;
		edge[++cnt] = (Edge){a, b, f[i]};
	}
}

inline void Kruskal() {
	int i, fx, fy;
	sort(edge + 1, edge + cnt + 1);
	for (i = 1; i <= cnt; ++i)
		if ((fx = Find(edge[i].u)) ^ (fy = Find(edge[i].v))) ans += edge[i].w, fa[fx] = fy;
	printf("%lld\n", ans);
}

int main() {
	Init(), Kruskal();
	return 0;
}

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

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;
typedef vector<pi> vpi;
typedef vector<string> vsi;
typedef map<ll, ll> mape;
#define rep(i, a, b) for(ll i=(ll)a;i<=(ll)b;i++)
#define per(i, a, b) for(ll i=(ll)a;i>=(ll)b;i--)
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
//#define N 2100
#define MAX 1234567890
#define f first
#define s second
#define pb push_back
#define mkp make_pair
#define MOD 1000000007

int main()
{
    fastio;

    ll n;
    string s;
    cin >> n >> s;
    ll len = s.size(), integer;
    ll dec = (s[len-2] - '0') * 10 + (s[len-1] - '0');
    if(len == 4) integer = (s[0] - '0') ;
    else integer = 10;
    ll temp = (n * dec) / 100;
    n *= integer;
    cout << n + temp << endl;

    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    int n, k; cin>>n>>k;
    k--;
    string s; cin>>s;
    s[k] = s[k] - 'A' + 'a';
    cout << s << endl;
}

Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=((int)(x) - 1 * 100);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
using namespace std;
ll n;
int main() {
	ll m;
	cin >> n >> m;
	ll t;
	if (m >= (n * 2)) {
		t = n;
	}
	else {
		t = m / 2;
	}
	ll ans = t;
	ans += (m-t*2) / 4;
	cout << ans << endl;
	return 0;
}

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

int main (int argc, char **argv) {
  int a, b;
  cin >> a >> b;

  string result;
  if (a > b) {
    result = "a > b" ;
  } else if (a < b) {
    result = "a < b";
  } else {
    result = "a == b";
  }
  cout << result << endl;
}

Measured memory_bytes: 1192
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>

using namespace std;

int main(){

  int h;
  cin >> h;

  while(h!=0){
    int a[h][5];
    for(int i=0;i<h;i++){
      for(int j=0;j<5;j++)cin >> a[i][j];
    }

    int score=0;

    int c=1;
    while(c!=0){
      c=0;
      //b・・・各列に対しての落差
      int b[5]={};
      for(int i=0;i<h;i++){
        //その行はすべて消える
        if(a[i][0]==a[i][1] && a[i][1]==a[i][2] && a[i][2]==a[i][3] && a[i][3]==a[i][4] && a[i][0]!=0){
          c+=5*a[i][1];
          for(int j=0;j<5;j++){
            b[i]++;
            a[i][j]=0;
          }
        }
        //左から4つ消える
        else if(a[i][0]==a[i][1] && a[i][1]==a[i][2] && a[i][2]==a[i][3] && a[i][0]!=0){
          c+=4*a[i][1];
          for(int j=0;j<4;j++){
            b[j]++;
            a[i][j]=0;
          }
        }
        //右から4つ消える
        else if(a[i][3]==a[i][4] && a[i][1]==a[i][2] && a[i][2]==a[i][3] && a[i][1]!=0){
          c+=4*a[i][1];
          for(int j=1;j<5;j++){
            b[j]++;
            a[i][j]=0;
          }
        }
        //左から3つ消える
        else if(a[i][0]==a[i][1] && a[i][1]==a[i][2] && a[i][2]!=0){
          c+=3*a[i][2];
          for(int j=0;j<3;j++){
            b[j]++;
            a[i][j]=0;
          }
        }
        //真ん中の3つ消える
        else if(a[i][3]==a[i][2] && a[i][1]==a[i][2] && a[i][2]!=0){
          c+=3*a[i][2];
          for(int j=1;j<4;j++){
            b[j]++;
            a[i][j]=0;
          }
        }
        //右から3つ消える
        else if(a[i][4]==a[i][3] && a[i][3]==a[i][2] && a[i][2]!=0){
          c+=3*a[i][2];
          for(int j=2;j<5;j++){
            b[j]++;
            a[i][j]=0;
          }
        }
      }

      score += c;
      for(int i=0;i<5;i++){
        int z=0;
        for(int j=h-1;j>=0;j--){
          if(a[j][i]==0)z++;
          else if(z!=0){
            a[j+z][i]=a[j][i];
            a[j][i]=0;
          }
        }
      }

    }

    cout << score << endl;

    cin >> h;
  }


}


Measured memory_bytes: 3004
#include <iostream>
using namespace std;
int main(){
    string s, t; cin >> s >> t;
    bool a = 1;
    for(int i = 0; i < s.size(); ++i) {
        if(s.at(i) != t.at(i)) a = 0;
    }
    if(a) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3628
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< std::vector<T> > vv)
{
  for (auto& vec : vv){ os << vec; }
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

// GCD, LCM
ll gcd(ll a, ll b) {
  while (b != 0) { a %= b; std::swap(a, b); }
  return a;
}
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

// FAIL
void fail(){ print(-1); std::exit(0); }
//void fail(){ print("No"); std::exit(0); }

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

  ll N;
  std::cin >> N;

  std::string S;
  std::cin >> S;

  ll cnt = 1LL;
  char pre = S[0];
  for (ll i = 1; i < N; ++i) {
    if (pre != S[i]) pre = S[i], cnt++;
  }

  print(cnt);

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	ll X, Y;
	cin >> X >> Y;
	ll ans = 0;
	if (X == 1 && Y == 1)cout << 400000+300000*2 << "\n";
	else {
		if (X <= 3)ans += (4 - X) * 100000;
		if (Y <= 3)ans += (4 - Y) * 100000;
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
Ps = [int(input())for _ in range(n)]
p_to_i = {p: i for i, p in enumerate(Ps)}

cnt = x = 1
for p in range(1, n):
    if p_to_i[p] < p_to_i[p+1]:
        x += 1
        if cnt < x:
            cnt = x
    else:
        x = 1
print(n-cnt)


Measured memory_bytes: 37884
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    string S;
    cin >> S;
    array<bool, 26> exists;
    exists.fill(false);
    for(const char c : S)
    {
        exists[c - 'a'] = true;
    }
    rep(i, 0, 26)
    {
        if (!exists[i])
        {
            cout << static_cast<char>('a' + i) << endl;
            return;
        }
    }
    cout << "None" << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    vector<int> x;

    cin >> n;

    x.resize(n);

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

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

    int ans = 1 << 30;
    for(int p = x.front(); p <= x.back(); ++p)
    {
        int cost = 0;
        for(const auto& xi : x)
        {
            cost += (xi - p) * (xi - p);
        }

        ans = min(ans, cost);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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

bool done[100010];
int
main(void){  
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int ans = 0;
  string s;
  int n_one = 0, n_zero = 0;
  cin >> s;

  REP(i, s.size()){
    if(s[i] == '1') n_one++;
    else n_zero++;
  }
  ans = min(n_one, n_zero);
  cout << ans*2 << endl;
  
  return 0;
}



Measured memory_bytes: 512
from operator import itemgetter
n,m=map(int,input().split())
l=[]
id_list=[]
for i in range(m):
  obj = list(map(int, input().split()))
  obj.append(i+1)
  l.append(obj)
l=sorted(l, key=itemgetter(0,1))
idx=0
for j in range(m):
  id_obj=[]
  if j == 0:
    idx=1
  else:

    if l[j][0] == l[j-1][0]:
      idx+=1
    else:
      idx =1
  id_obj.append(l[j][2])
  id_obj.append(str(l[j][0]).zfill(6)+str(idx).zfill(6))
  id_list.append(id_obj)
id_list = sorted(id_list)
for k in range(m):
  print(id_list[k][1])

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



int main(){
    int n, m;
	cin >> n >> m;
	int a[m];
	for(int i=0; i<m; i++)
		cin >> a[i];
	if(n>=m)
		cout << 0 << endl;
	else{
		sort(a, a+m);
		vector<int> res;
		for(int i=1; i<m; i++)
			res.push_back(a[i]-a[i-1]);
		sort(res.begin(), res.end());
		int ans = 0;
		for(int i=0; i<m-n; i++)
			ans += res[i];
		cout << ans << endl;
	}
}

Measured memory_bytes: 4172
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <queue>
#include <vector>

#define testin freopen("1.txt","r",stdin);
#define testout freopen("out.txt","w",stdout);

using namespace std;

int main(){
    int a,b,c;
    cin>>a>>b;
    c=a+b;
    if(c%2) cout<<"IMPOSSIBLE\n";
    else cout<<c/2<<endl;
    return 0;
}


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

namespace ConsoleApp1
{
    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            B();
        }

        static void B()
        {
            var N = ReadInt();
            var V = ReadSplitInt();
            var C = ReadSplitInt();
            var list = new List<List<int>>();
            for (int i = 0; i < N; i++)
            {
                if (V[i] >= C[i])
                    list.Add(new List<int> { V[i], C[i] });
            }

            var ans = 0;
            foreach (var l in list)
            {
                ans += l[0] - l[1];
            }
            Console.WriteLine(ans);
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static IList<string> ReadSplit() => Read().Split().ToList();
        static IList<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>

using namespace std;

int n = 0;

int main() {
    scanf("%d", &n);
    bool okay = true;
    int lx = 0, ly = 0, lt = 0;
    for (int i = 1; i <= n; i++) {
        int x, y, t;
        scanf("%d%d%d", &t, &x, &y);
        if (abs(x-lx)+abs(y-ly) > t-lt || (t-lt-abs(x-lx)-abs(y-ly))%2 == 1) {
            okay = false;
        }
    }
    if (okay) {
        printf("Yes\n");
    } else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

#define REP(i,m,n) for(int i=(m); i<(n); i++)
#define RREP(i,n,m) for(int i=(n);i>=(m); i--)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << endl
// #define int long long 

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = ((1<<30)-1);
const ll linf = (1LL<<60);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct mint 
{
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    int a[n];
    REP(i,0,n) cin >> a[i];
    int ans = 0;
    double sum = 0;
    REP(i,0,n) sum += a[i];
    sum = sum/(4*m);
    REP(i,0,n)
    {
        if(a[i] >= sum) ans++;
    }
    if(ans >= m) cout << "Yes";
    else cout << "No";
}




Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        if (N%K == 0){
            System.out.println(0);
        }
        else{
            System.out.println(1);
        }
    }
}


Measured memory_bytes: 22484
#include <iostream>
#include <cstring>
#include <utility>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;


int N, W;
vector<int> w;
vector<int> v;


long long memo[101][100001];


long long get_max_value(int i, int maxW) {
    if (i == N) {
        return 0;
    } else {
        long long a = v[i] + get_max_value(i+1, maxW - w[i]);
        long long b = get_max_value(i+1, maxW);

        if (w[i] > maxW) {
            return b;
        } else {
            return max(a, b);
        }
    }
}



long long get_max_value_using_memo_cache(int i, int maxW) {
    if (memo[i][maxW] != -1) {
        return memo[i][maxW];
    }

    if (i == N) {
        return 0;
    } else {
        long long ans;
        long long b = get_max_value_using_memo_cache(i+1, maxW);

        if (w[i] > maxW) {
            ans = b;
        } else {
            long long a = v[i] + get_max_value_using_memo_cache(i+1, maxW - w[i]);
            ans = max(a, b);
        }

        memo[i][maxW] = ans;
        return ans;
    }
}



int main() {
    cin >> N >> W;
    w.resize(N);
    v.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
    }

    // recursive
    // long long ans = get_max_value(0, W);


    // memo
    // memset(memo, -1, sizeof(memo));
    // long long ans = get_max_value_using_memo_cache(0, W);
   
    // DP
    //vector<long long> (W)
    //vector<long long> W(N, -1);
    //vector<T> dp(N, T(W));
    vector<vector<long long>> dp(N+1, vector<long long> (W+1));

    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= W; j++) {
            if (w[i-1] <= j) { // i-1が入りうるとき
                long long a = v[i-1] + dp[i-1][j-w[i-1]];
                dp[i][j] = max(a, dp[i-1][j]);
            } else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    long long ans = dp[N][W];

    cout << ans;
    return 0;
}




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

#define int long long

vector<int> tree[200010];
int imos[200010];
int cnt[200010];

void solve(int idx, int par, int c){
    c += imos[idx];
    cnt[idx] = c;

    for(auto e : tree[idx]){
        if(e != par) solve(e, idx, c);
    }
    return;

}

signed main(){
    int n, q;
    cin >> n >> q;

    for(int i = 0;i < n-1;i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }

    for(int i = 0;i < q;i++){
        int p, x;
        cin >> p >> x;
        imos[--p] += x;
    }

    solve(0, -1, 0);

    cout << cnt[0];
    for(int i = 1;i < n;i++){
        cout << " " << cnt[i]; 
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 25600
#include<stdio.h>
int n,A[2000];
int solve(int,int);
int main(){
  int q,mi[2000],i,rig,lef=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);}
scanf("%d",&q);
rig=n;
    for(i=0;i<q;i++){
    scanf("%d",&mi[i]);}
  for(i=0;i<q;i++){
    if(solve(0,mi[i])==1) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}
int solve(i,m){
  int rec;
  if(m==0) return 1;
  if(i>n) return 0;
  rec=(solve(i+1,m)||solve(i+1,m-A[i]) );
  return rec;
}



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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main()
{
    int r, D, x[20];
    cin >> r >> D >> x[0];
    for(int i = 1; i < 11; ++i) {
        x[i] = r * x[i-1] - D;
        printf("%lld\n", x[i]);
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vb=vector<bool>;
ll n,q,m,k,l,ans;
string s;
vll a,b;
map<ll, vll> bits;

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    
    cin >> n >> m;
    a.resize(m);
    ll homework = 0;
    rep(i,m) {
        cin >> a[i];
        homework += a[i];
    }
    ans = (homework > n)?-1:n-homework;
    cout << ans << endl;
    return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    for (auto& e : x) cin >> e;
    sort(x.begin(), x.end());
    vector<int> d(m-1);
    for (int i=0; i<m-1; i++) d[i] = x[i+1] - x[i];
    sort(d.begin(), d.end());
    cout << (n >= m ? 0 : accumulate(d.begin(), d.begin() + m-n, 0)) << endl;
}

Measured memory_bytes: 1024
#include<iostream>

using namespace std;

double in[123][2234],out[123][2234];

int main(){
  for(int N,M,K;cin>>N>>M>>K,N|M|K;){
    int O=M-1;
    double canal[2234]={};
    double rtime[2234]={},ltime[2234]={};
    for(int i=0;i<N;i++){
      int X,L,F,D,UD;
      cin>>X>>L>>F>>D>>UD;
      rtime[X+O]=UD?L*1./D:L*1./F;
      ltime[X+O]=UD?L*1./F:L*1./D;
      if(UD){
	canal[X+O]=ltime[X+O];
      }
    }
    int V[123];
    for(int i=0;i<M;i++){
      cin>>V[i];
    }
    for(int i=0;i<M;i++){
      double t=0;
      for(int j=O-i;j<2200;j++){
	in[i][j]=t;
	out[i][j]=max(t,canal[j])+rtime[j];
	canal[j]=out[i][j]+ltime[j];
	t=max(out[i][j]+1./V[i],!i?0:in[i-1][j+2]);
      }
    }
    cout<<fixed<<in[M-1][K+O]<<endl;
  }
}
      
	

Measured memory_bytes: 5076
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n, k; cin >> n >> k;
    int ans = inf;
    for (int i = 0; i <= n; i++) {
        int j = n-i;
        ans = min(ans,(int)pow(2,i)+k*(n-i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  ll N;
  cin>>N;

  vector<pair<ll,ll>> primes;
  ll val=N;
  for(ll i=2;i*i<=val;i++){
    if(val%i==0){
      ll num=0;
      while(val%i==0){
        val/=i;
        num++;
      }
      primes.push_back(mkp(i,num));
    }
  }
  if(val!=1) primes.push_back(mkp(val,1));

  ll ans=0;
  for(auto e:primes){
    ll val=e.first;
    ll num=e.second;
    for(ll i=1;;i++){
      if(num<i) break;
      num-=i;
      ans++;
    }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3660
use proconio::input;
// use num::*;

fn main() {
    input! {
      x: i128,
      y: i128,
    };
    let turt = (y - 2 * x) / (4 - 2);
    let ans = if (turt * 4) <= y && (y % 2) == 0 && turt >= 0 {
        "Yes"
    } else {
        "No"
    };
    println!("{}", ans);
}


Measured memory_bytes: 2140
#include <cstdio>
#include <cstring>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>

using namespace std;

#define BTCRATE 380000.0

int main(){
	
	int N, M, C;
	vector<int> B;
	vector<vector<int>> A;
	int tmp;
	int sum;
	int ans = 0;
	
	scanf("%d", &N);
	scanf("%d", &M);
	scanf("%d", &C);
	
	for(int i=0; i<M; i++){
		scanf("%d", &tmp);
		B.push_back(tmp);
	}
	
	for(int i=0; i<N; i++){
		A.push_back(vector<int>());
		for(int j=0; j<M; j++){
			scanf("%d", &tmp);
			A[i].push_back(tmp);
		}
	}
	
	/* test print 
	printf("----test----\n");
	for(int i=0; i<A.size(); i++){
		for(int j=0; j<A[i].size(); j++){
			printf("%d ", A[i][j]);
		}
		printf("\n");
	}
	 test print */
	
	for(int i=0; i<N; i++){
		sum = 0;
		for(int j=0; j<M; j++){
			sum += B[j] * A[i][j];
		}
		sum += C;
		if(sum > 0) ans++;
	}
	
	printf("%d\n", ans);
	
	return 0;
	
}


Measured memory_bytes: 256
K, N = map(int,input().split())
lis = list(map(int,input().split()))
l = []

for i in range(N-1):
    l.append(lis[i+1]-lis[i])

l.append(lis[0] + (K-lis[-1]))
l.remove(max(l))
print(sum(l))

Measured memory_bytes: 26060
#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 x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> p(a), q(b), r(c);
  rep(i,a) cin >> p[i];
  rep(i,b) cin >> q[i];
  rep(i,c) cin >> r[i];

  sort(p.rbegin(), p.rend());
  sort(q.rbegin(), q.rend());

  vector<int> d;

  rep(i,x) d.push_back(p[i]);
  rep(i,y) d.push_back(q[i]);
  rep(i,c) d.push_back(r[i]);
  sort(d.rbegin(), d.rend());
  ll ans = 0;
  rep(i,x+y) ans += d[i];

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

int main() {
  int N;
  cin >> N;
  
  vector<pair<pair<int, int>, int>> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p[i].first.first >> p[i].first.second;
    p[i].second = i;
  }
  
  sort(p.begin(), p.end());
  
  dsu uf(N);
  
  int min_y = p[0].first.second;
  int idx = p[0].second;
  for (int i = 1; i < N; i++) {
    if (p[i].first.second < min_y) {
      min_y = p[i].first.second;
      idx = p[i].second;
    } else {
      uf.merge(p[i].second, idx);
    }
  }
  
  sort(p.rbegin(), p.rend());
  
  int max_y = p[0].first.second;
  idx = p[0].second;
  for (int i = 1; i < N; i++) {
    if (p[i].first.second > max_y) {
      max_y = p[i].first.second;
      idx = p[i].second;
    } else {
      uf.merge(p[i].second, idx);
    }
  }
  
  for (int i = 0; i < N; i++) {
    swap(p[i].first.first, p[i].first.second);
  }
  
  sort(p.begin(), p.end());
  
  min_y = p[0].first.second;
  idx = p[0].second;
  for (int i = 1; i < N; i++) {
    if (p[i].first.second < min_y) {
      min_y = p[i].first.second;
      idx = p[i].second;
    } else {
      uf.merge(p[i].second, idx);
    }
  }
  
  sort(p.rbegin(), p.rend());
  
  max_y = p[0].first.second;
  idx = p[0].second;
  for (int i = 1; i < N; i++) {
    if (p[i].first.second > max_y) {
      max_y = p[i].first.second;
      idx = p[i].second;
    } else {
      uf.merge(p[i].second, idx);
    }
  }
  
  for (int i = 0; i < N; i++) {
    cout << uf.size(i) << endl;
  }
  
  return 0;
}

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

using namespace std;

int main()
{
	int M1, D1, M2, D2;
	cin >> M1 >> D1 >> M2 >> D2;

	if (M1 + 1 == M2 && D2 == 1) {
		cout << 1 << endl;
	}
	else {
		cout << 0 << endl;
	}


}


Measured memory_bytes: 3616
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line[] = br.readLine().split(" ");
        int n = Integer.parseInt(line[0]);
        int k = Integer.parseInt(line[1]);
        line = br.readLine().split(" ");
        int a[] = new int[n];
        for(int i = 0; i < n; i++)  a[i] = Integer.parseInt(line[i]);
        int r = 1000000000, l = 0;
        while(r-l > 1){
            int mid = (l+r)/2;
            long x = 0;
            for(int i = 0; i < n; i++){
                x += (a[i]+mid-1)/mid-1;
            }
            if(x <= k)  r = mid;
            else        l = mid;
        }
        System.out.println(r);
    }
}


Measured memory_bytes: 62664
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextLong()
    println(problem144c(n))
}

fun problem144c(n: Long): Long {
    val nR = Math.sqrt(n.toDouble()).toLong()
    var min = Long.MAX_VALUE to Long.MAX_VALUE
    for (i in 1..nR) {
        val j = n / i
        if (i * j == n) {
            min = i to j
        }
    }
    return min.first + min.second - 2
}

Measured memory_bytes: 31264
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n; cin >> n;
  int mcnt=0;
  ll sum=0;
  vector<ll> a(n);
  rep(i,n){
    cin >> a[i];
    if(a[i]<0){
      mcnt++;
      a[i]=-a[i];
    }
    sum+=a[i];
  }
  sort(all(a));
  if(mcnt%2==0){
    cout << sum << endl;
  }
  else{
    cout << sum-2*a[0] << endl;
  }
  
}

Measured memory_bytes: 1024
N = int(input())
C = []
S = []
F = []
for i in range(N-1) :
    c,s,f = map(int,input().split())
    C.append(c)
    S.append(s)
    F.append(f)
for j in range(N) :
    if j != N-1 :
        answer = 0
        for k in range(j,N-1) :
            if answer < S[k] :
                answer = S[k]
            if answer % F[k] != 0 :
                answer = (answer // F[k] + 1) * F[k]
            answer += C[k]
        print(answer)
    else :
        print(0)


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

int main(int argc, char const* argv[]) {
    int a, b, c;
    std::cin >> a >> b >> c;
    if (a + b == c || a + c == b || b + c == a) {
        std::cout << "Yes" << '\n';
    } else {
        std::cout << "No" << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
int main()
{
    ft
    ll t,i,j,n,s=LLONG_MAX,l,r;
    cin>>n>>t;
    for(i=0;i<n;i++)
    {
        cin>>l>>r;
        if(r<=t)
        {
            s=min(s,l);
        }
    }
    if(s==LLONG_MAX)
    {
        cout<<"TLE\n";
        return 0;
    }
    cout<<s<<"\n";
    return 0;
}

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


int main() {
  ll n,m;cin >> n >> m;
  priority_queue<ll> q;
  rep(i,n){
    ll num;cin >> num;
    q.push(num);
  }

  rep(i,m){
    if( q.top() == 0 ) break;
    ll num = q.top();
    q.pop();
    q.push(num/2);
  }

  ll ans = 0;
  while( !q.empty() ){
    ans += q.top();
    q.pop();
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4264
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main(void) {
    vector<int> vec(5);
    cin >> vec[0] >> vec[1] >> vec[2] >> vec[3] >> vec[4];
    sort(vec.begin(), vec.end(), greater<int>());
    for(int r = 0; r < 5; r++) {
        cout << vec[r];
        if(r == 4) cout << endl;
        else       cout << " ";
    }
    return(0);
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		vector<UL> ans; ans.assign(26, 0);
		vector<UL> prev; prev.assign(26, (UL)-1);
		string S; cin >> S;
		rep(i, S.size()) {
			UL p = S[i] - 'a';
			if (prev[p] == (UL)-1) {
				ans[p] = max(ans[p], i);
			}
			else {
				ans[p] = max(ans[p], (UL)(i - prev[p] - 1));
			}
			prev[p] = i;
		}
		UL ans2 = 10000000;
		rep(i, 26) {
			if (prev[i] == (UL)-1) continue;
			ans[i] = max(ans[i], (UL)(S.size() - 1 - prev[i]));
			ans2 = min(ans2, ans[i]);
		}
		cout << ans2 << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

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

int main() {
  ll n,m;cin >> n >> m;
  vector<vector<ll>> lt(m);
  rep(i,m){
    ll k;cin >> k;
    rep(j,k){
      ll num;cin >> num;
      --num;
      lt.at(i).push_back(num);
    }
  }
  // オンになっているスイッチの個数を2で割った余り
  vector<ll> p(m);
  rep(i,m) cin >> p.at(i);

  ll ans = 0;

  vector<ll> sw(n,0);

  for(ll bit=0;bit<(1<<n);++bit){
    rep(i,n){
      if( (bit>>i) & 1 ) sw.at(i) = 1;
      else sw.at(i) = 0;
    }
    bool ok = true;
    rep(i,m){
      ll cnt = 0;
      rep(j,lt.at(i).size()){
        if( sw.at(lt.at(i).at(j)) == 1 ) ++cnt;
      }
      if( cnt%2 != p.at(i) ){
        ok = false;
        break;
      }
    }
    if( ok ) ++ans;
  }

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

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n,a[21],ans=0;
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=1;i<n-1;i++)
		if(min(a[i-1],min(a[i],a[i+1]))!=a[i]&&max(a[i-1],max(a[i],a[i+1]))!=a[i])
			ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric> 
#include <math.h>

#define REP(i, n) for (int i = 0; i < n; i++)
#define INF 999999999
using namespace std;

int main()
{
    int a[3],k;
    cin >> a[0] >> a[1] >> a[2];
    cin >> k;
    sort(a, a+ 3);
    REP(i, k) {
        a[2] = 2*a[2];
    }
    int ans = a[0] + a[1] + a[2];
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;

int main(){
    int N,M;
    cin>>N>>M;
    vector<int> A(M);
    for(int i=0; i<M; i++) cin>>A[i];

    for(int i=0; i<M; i++){
        N -= A[i];
    }

    cout<<((N < 0) ? -1 : N)<<endl;

    return 0;
}

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

int highest(int a) {
	while (a >= 10) {
		a /= 10;
	}
	return a;
}

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

	vector<vector<int>> c(10, vector<int>(10, 0));
	for (int i = 1; i <= n; i++) {
		int top = highest(i), bottom = i % 10;
		c.at(top).at(bottom)++;
	}
	int ans = 0;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			ans += c.at(i).at(j)*c.at(j).at(i);
		}
	} 
	cout << ans << endl;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define contains(v, t) (find(v.begin(), v.end(), t) != v.end())
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, n) { cin >> v[i]; }

  int ans = 0;
  for (;;) {
    rep(i, n) {
      if (v[i] % 2 == 1) {
        cout << ans;
        return 0;
      }
      v[i] /= 2;
    }
    ans++;
  }
}

Measured memory_bytes: 256
#include "algorithm"
#include "iostream"
#include "cmath"
#include "string"
#include "map"
using namespace std;

const char dir[4]={'N','E','S','W'};
int x[20],y[20];
int nx,ny,cnt;

void find(char d,int I,int N){
int a=-1;
  for(int i=0;i<4;++i){
    if(dir[i]==d)a=i;
  }
  for(int i=0;i<I;++i){
    if(a==0)ny+=1;
    if(a==1)nx+=1;
    if(a==2)ny-=1;
    if(a==3)nx-=1;
    for(int j=0;j<N;++j){
      if(x[j]==nx && y[j]==ny){
        ++cnt;
        x[j]=-1;
        y[j]=-1;
        break;
      }
    }
  }
}

int main(){
  while(true){
    int N,M,I;
    cnt=0;
    nx=10;
    ny=10;

    char d;
    cin >> N;
    if(!N)break;
    for(int i=0;i<N;++i){
      cin >> x[i] >> y[i];
    }
    cin >>M;
    while(M--){
      cin >> d >> I;
      find(d,I,N);
    }
    if(cnt==N)cout << "Yes" <<endl;
    else cout << "No" <<endl;
  }
  return 0;
}

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

llong cast(string s){
    llong sum = 0;
    string t = "";
    for(int i = 0; i < s.length(); i++){
        if(s[i] == '+'){
            sum += stoi(t);
            t = "";
        }else{
            t += s[i];
        }
    }
    sum += stol(t);
    return sum;
}

llong f(string s, llong n, llong i){
    if(n == 1) return cast(s);
    return f(s,n-1,i+1) + f(s.insert(s.length()-i-1,"+"),n-1,i+2);
}

int main(){
    string s; cin >> s;
    cout << f(s,s.length(),0) << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000)

X = 10**9+7
N,M = list(map(int,input().split()))
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n;

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])%X

    return result%X


ans = 1
for val,dupes in factorize(M):
    ans *= cmb(N+dupes-1,N-1)
    ans = ans % X
print(ans%X)


Measured memory_bytes: 38512
N,K = map(int,input().split(" "))
h = []
for i in range(N):
    h.append(int(input()))
h.sort()
ans = 10**9
for i in range(N-K+1):
    h1 = h[i]
    h2 = h[i+K-1]
    ans = min(ans,h2-h1)
print(ans)


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

const int Mod = 1000000007;
class mll {
public:
	long long x;
	mll(long long x = 0) : x((x% Mod + Mod) % Mod) {};
	void operator *= (const mll& a) {
		(x *= a.x) %= Mod;
	}
};
int main() {
	int N;
	cin >> N;
	string S;
	cin >> S >> S;
	mll ans = 1;
	int state = 0;
	for (int i = 0; i < N; i++) {
		if (i == N - 1) {
			if (state == 0) ans *= 3;
			if (state == 1) ans *= 2;
			break;
		}
		else {
			if (S[i] == S[i + 1]) {
				if (state == 0) ans *= 6;
				if (state == 1) ans *= 2;
				if (state == 2) ans *= 3;
				state = 2;
				i++;
			}
			else {
				if (state == 0) ans *= 3;
				if (state == 1) ans *= 2;
				state = 1;
			}
		}
	}
	cout << ans.x << endl;
}


Measured memory_bytes: 256
from collections import Counter
n,k=map(int,input().split())
a=list(map(int,input().split()))
tmp=min(a)
count_min=Counter(a)[tmp]
kazu=n-count_min
if kazu%(k-1)==0:
    print(kazu//(k-1))
else:
    print(kazu//(k-1)+1)

Measured memory_bytes: 19936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N, M; cin >> N >> M;
    vector<pair<int, int>> A(M);

    for(int i=0; i<M; i++){
        int a, b; cin >> a >> b;
        A[i] = {b, a};              //逆にしてる
    }

    sort(A.begin(), A.end());
    
    int ans = 0, bridge = -1;
    for(int i=0; i<M; i++){
        if(bridge + 1 <= A[i].second){
            ans++;
            bridge = A[i].first-1;
        }
    }

    cout << ans << endl;
}

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

using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> v(n, 0);
	vector<bool> dp(k + 1, false);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}

	for (int i = 0; i <= k; i++) {
		for (int x : v) {
			if (i >= x && dp[i - x] == false) {
				dp[i] = true;
			}
		}
	}

	if (dp[k]) {
		cout << "First";
	} else {
		cout << "Second";
	}
	return 0;
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int a,b,t; cin >> a >> b >> t;

  int time = t/a;
  int ans = b*time;

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


Measured memory_bytes: 3600
N,A,B=[int(s) for s in input().split()]
kotae=0
for i in range(1,N+1):
  x=i
  count = 0
  while x>0:
    count += x % 10
    x = x // 10
  if A<=count and count<=B:
    kotae += i
print(kotae)

Measured memory_bytes: 3060
#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(){
	ll a, b; cin >> a >> b;
	set<ll> ap;
	set<ll> bp;
	for( ll k = 2; k * k <= a; ++k ){
		if( a%k == 0 ){
			ap.insert(k);
			while( a%k == 0 ) a /= k;
		}
	}
	if( a != 1 ) ap.insert(a);
	for( ll k = 2; k * k <= b; ++k ){
		if( b%k == 0 ){
			bp.insert(k);
			while( b%k == 0 ) b /= k;
		}
	}
	if( b != 1 ) bp.insert(b);
	ll ans = 0;
	for( auto p : ap ){
		// cout << "check: " << p << endl;
		if( bp.count(p) ) ++ans;
	}
	cout << ans + 1 << endl;
}


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

int n;
int num[102];
long long int memo[22][200];
int ans;

long long int solve( int now,int cnt){
  //if(cnt == n-1 )cout<<now<<endl;
  if(now < 0 || now > 20)return 0;
  if(memo[now][cnt] != -1)return memo[now][cnt];
  if(cnt == n-1 && ans == now)return 1;
  if(cnt == n-1 && ans != now)return 0;
  return memo[now][cnt] = solve(now + num[cnt] ,cnt + 1) + solve(now - num[cnt],cnt + 1);
}
int main(){
  cin>>n;
  memset(memo,-1,sizeof(memo));
  for(int i = 0;i < n;i++){
    cin >> num[i];
  }
  ans = num[n-1];
  cout << solve(num[0],1) << endl;
}

Measured memory_bytes: 1204