akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG

int main() {
int N,M;
cin >>N>>M;
double S = 0.0;
vector<int> vec(N);
rep(i,N){
  cin>>vec[i];
  S += vec[i];
}
S /= 4*M;
sort(vec.begin(),vec.end());
reverse(vec.begin(), vec.end());
int count = 0;
rep(i,N){
  if(vec[i]<S){
    break;
  }
  else{
    count++;
  }

}

if(count>=M){
cout<<"Yes"<<endl;
}
else{
  cout<<"No"<<endl;
}

}


Measured memory_bytes: 256
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>
 
// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std
 
Jehian Norman Saviero;
 
// MACROS TYPE
typedef long l;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;
 
// MACROS FOR PRINT
#define nl printf("\n")
 
// MACROS FOR ATTRIBUTE
#define fi first
#define se second
 
// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))
 
// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scd(x) scanf("%lf", &x)
#define scld(x) scanf("%Lf", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

#define valid(P) (0 <= (P).fi && (P).fi < H && 0 <= (P).se && (P).se < W)

bool eq(pi A, pi B) {
	return A.fi == B.fi && A.se == B.se;
}

int dirX[] = {1, 0, -1, 0};
int dirY[] = {0, 1, 0, -1};

string M[20];
bool visit[20][20];
int val[20][20];
int H, W;

int eval(pi P, pi Q) {
	RESET(visit);
	RESET(val);
	queue< pair<pi, int> > q;
	q.push({P, 0});
	while (!q.empty()) {
		pi curr;
		int cost;
		tie(curr, cost) = q.front();
		q.pop();
		if (!visit[curr.fi][curr.se]) {
			visit[curr.fi][curr.se] = 1;
			val[curr.fi][curr.se] = cost;
			for (int i = 0; i < 4; ++i) {
				pi nx = {curr.fi + dirX[i], curr.se + dirY[i]};
				if (valid(nx) && !visit[nx.fi][nx.se] && M[nx.fi][nx.se] == '.') {
					q.push({nx, cost+1});
				}
			}
		}
	}
	return val[Q.fi][Q.se];
}

int main() {
	sci(H), sci(W);
	for (int i = 0; i < H; ++i) {
		cin >> M[i];
	}
	int ans = 0;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (M[i][j] == '#') continue;
			for (int x = 0; x < H; ++x) {
				for (int y = 0; y < W; ++y) {
					if (M[x][y] == '#') continue;
					ans = max(ans, eval({i,j}, {x,y}));
				}
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

int main() {
    int a, b, s, l;
    cin >> a >> b;
    s = a * b;
    l = 2 * (a + b);
    cout << s << " " << l << endl;
    return 0;
}


Measured memory_bytes: 3096
#include<iostream>
#include<iomanip>
#include<vector>
#include<numeric>
#include<algorithm>
#define int long long
const int inf=1145141919;
using namespace std;
template<class T>void chmax(T &x,const T &y){
	x=max(x,y);
}
template<class T>void chmin(T &x,const T &y){
	x=min(x,y);
}
int N,M;
int p[101][101][301];
signed main(){
	int i,j,k;
	cin>>N>>M;
	pair<int,int> q[100];
	for(i=0;i<N;i++)
		cin>>q[i].first>>q[i].second;
	int u=q[0].first;
	for(i=0;i<N;i++)
		q[i].first-=u;
	for(i=0;i<101;i++)
		for(j=0;j<101;j++)
			for(k=0;k<301;k++)
				p[i][j][k]=-1;
	p[0][0][0]=0;
	for(i=0;i<N;i++)
		for(j=0;j<100;j++)
			for(k=0;k<300;k++)
				if(p[i][j][k]!=-1){
					chmax(p[i+1][j][k],p[i][j][k]);
					chmax(p[i+1][j+1][k+q[i].first],p[i][j][k]+q[i].second);
				}
	int ans=0;
	for(i=0;i<=N&&u*i<=M;i++)
		for(j=0;j<=300&&u*i+j<=M;j++)
			chmax(ans,p[N][i][j]);
	cout<<ans<<endl;
}

Measured memory_bytes: 24192
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// まずは全探索，次にDP
// 偶奇，逆から，ソート，出現回数，出現位置，DP
// 余事象，包除
// データ構造
// 問題の特徴量
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
int main() {
cin.tie(0);
ios::sync_with_stdio(false);

int n;cin >> n;
VI a(n); 
rep(i, 0, n) cin >> a[i];
int ma = *max_element(ALL(a));
int d = INF, se = ma;
rep(i, 0, n){
    if (d > abs(ma / 2 - a[i]) && se != a[i]) {
        d = abs(ma / 2 - a[i]);
        se = a[i];
    }
}

cout << ma << ' ' << se << "\n";
}

// 境界，出力文字列 チェック



Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>

#ifndef ONLINE_JUDGE
	#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define FOR(i, A, N) for(int (i) = (A); (i) < (N); (i)++)
#define REP(i, N) for(int (i) = 0; (i) < (N); (i)++)

using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

int n,m,d;
#define eps 0.0000000001l

int main() {
	scanf("%d%d%d", &n, &m, &d);
	REP(i, n) {
		REP(j, m) {
//		int nr = i+j, nc = j-i;
			int nr = (i+j), nc = (j-i);
			int remr = nr%(2*d), remc = (nc+2*d*500)%(2*d);
			int col = 0;
			if(remr < d && remc >= d)
				col = 1;
			else if(remr < d && remc < d) {
				col = 2;
			} else if(remr >= d && remc >= d) {
				col = 3;
			}
			printf("%c", "RGBY"[col]);
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
// #include <ctgmath>
#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;


int main() {
  double a, b, x;
  scanf("%lf %lf %lf", &a, &b, &x);

  double r = 0;
  if (x <= (a * a * b) / 2) {
    r = M_PI / 2 - atan(2 * x / (a*b*b));
  } else {
    r = atan(2 * (a*a*b - x) / (a*a*a));
  }

  cout << to_string(r * 180 / M_PI) << endl;
  
  return 0;
}


Measured memory_bytes: 256
/*
*                                 Name : chaitanya
*
*                         Institute : ANITS,Visakhapatnam
*   "Don't regret anything you do, because in the end it makes you who you are."
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#include<sstream>
#define infy  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
const ll m = 1000000007;
#pragma GCC optimization ("O3")
using namespace std;

bool prime(int n)
{
  for (int i = 2; i < min(500000,n); ++i)
  {
    if(n%2 == 0)
    {
      return 0;
  }
}
return 1;
}
vector<string> vec_splitter(string s) {
  s += ',';
  vector<string> res;
  while(!s.empty()) {
    res.push_back(s.substr(0, s.find(',')));
    s = s.substr(s.find(',') + 1);
}
return res;
}
void debug_out(
    vector<string> __attribute__ ((unused)) args,
    __attribute__ ((unused)) int idx,
    __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
  if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
  stringstream ss; ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifndef ONLINE_JUDGE
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

// 2+3+5+7+11+13
//   consecutivePrimes = (41) is also a prime

const int  N = 1000 * 10000 + 4;
vector <bool> isPrime(N,true);
vector <int> odd;
void  oddnum()
{
    for (int i = 1; i < N; i+=2 )
    {
        odd.pb(i);
    }
}
bool pall (int n)
{
    string s = to_string(n),r = "";
    r = string(s.rbegin(),s.rend());
    if (s == r)
        return true;
    else
        return false;

}
int main()
{

	// int x = -1, y = 10000;
	// double z = 0.2;
	// string s2 = "beginner1010";
	// long long b = 1LL << 60;B
	// // debug(x, y, z, s, b);
	// double aux = 1010.0;
	// string code = "code";

	// debug(code + "forces",-aux / 10 * 2.3);
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	//ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int x, n, ansr = 1000, ansl = 1000;
    cin >> x >> n;
    vector<int> v(110);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        v[a]++;
    }
    int i = 0;
    while(true) {
        if (v[x - i] == 0) {
            ansl = x - i;
            break;
        }
        if (v[x + i] == 0) {
            ansr = x + i;
            break;
        }
        i++;
    }
    cout << min(ansl, ansr);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,n,t,p=0,m=1;
    cin>>n;
    for(i=1;i<10;i++){
        if(n%i==0)
             p=n/i;m=1;
        if(p<=9){
            cout<<"Yes"<<endl; p=0;
         return 0;
        }
    }
    cout<<"No"<<endl;

}


Measured memory_bytes: 256
#if defined(LOCAL)
#define PROBLEM_NAME "a"
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) (debug(x, #x))
#define I(x, ...) (x)
#define C(x...) CHECK(x)
#else
#define L(x, ...) (x)
#define I(x, ...) (x)
#define C(x, ...) ;
#endif
#include <algorithm>
#include <vector>
#include <string>
#include <iomanip>
#include <iostream>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <limits>
#include <numeric>

using namespace std;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ii = pair<int,int>; using lu = unsigned long long; using l = long long;
using vs = vector<string>; using vii = vector<ii>;
using vl = vector<l>; using vvl = vector<vl>; using vvvl = vector<vvl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; static constexpr double PI = 3.1415926;
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)
#define VVL(x, a, b, i) vvl x(a, vl(b, l(i)));
#define VVVL(x, a, b, c, i) vvvl x(a, vvl(b, vl(c, l(i))));

const l MOD = e9 + 7; // end of template

void solve(istream& in, ostream& out) {
  l n, k; in >> n >> k;
  vl left, right;
  F(i, 0, n) {
    l x; in >> x;
    if (x < 0) {
      left.emplace_back(x);
    } else {
      right.emplace_back(x);
    }
  }
  reverse(all(left));
  l best = INF;
  F(i, 0, left.size() + 1) {
    l a = 0;
    if (i) a = -left[i - 1];
    l j = k - i;
    if (j < 0) break;
    if (j > right.size()) continue;
    l b = 0;
    if (j) b = right[j - 1];
    best = min({best, a * 2 + b, 2 * b + a});
  }
  out << best << lf;
}

int main(int argc, char** argv) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  // TODO: infer binary name from args instead of problem name
  F(i, 0, argc) cerr << "arg " << i << ' ' << argv[i] << endl;
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


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

long digit(long n, long k)
{
	long cnt = 1;
	while (n >= k)
	{
		n /= k;
		cnt++;
	}
	return cnt;
}

int  main()
{
	int n; cin >> n;
	vector<int> a(n);
	rep(i, n)
	{
		cin >> a[i];
	}
	int ans = 0;
	rep(i, n)
	{
		if (a[i] % 2 == 0)
		{
			if (a[i] % 3 == 0 || a[i] % 5 == 0)
			{
				ans++;
			}
			else
			{
				cout << "DENIED\n"; return 0;
			}
		}
	}
	cout << "APPROVED\n";
	return (0);
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

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

  int n, a, b;
  cin >> n >> a >> b;
  if(abs(b-a)%2){
    cout<<"Borys"<<endl;
  }
  else cout<<"Alice"<<endl;
  /*
  int i;
  for (i = 0; abs(a - b) > 1; i++) {
    if (i & 1)
      b--;
    else
      a++;
    dump(a,b);
  }
  while (a!=1 and b!=n) {
    if(i&1){
      if(a==b-1)b++;
      else b--;
    }
    else{
      if(a==b-1)a--;
      else a++;
    }
    i++;
    dump(a,b);
  }
  cout<<(a==1?"Borys":"Alice")<<endl;
  */
  /*
  if (n & 1) {
    int m = (n + 1) / 2;
    if (abs(a - 1) >= abs(b - n)) {
      cout << "Alice" << endl;
    } else
      cout << "Borys" << endl;
  } else {
    int m1 = n / 2;
    int m2 = n / 2 + 1;
    if (abs(a - 1) > abs(b - n)) {
      cout << "Alice" << endl;
    }
    else {
      cout << "Borys" << endl;
    }

  }
  */

  return 0;
}


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

int main() {
  int N, M; cin >> N >> M;
  bool A[N][N], B[M][M];
  for (int i = 0; i < N; i++) {
    string s; cin >> s;
    for (int j = 0; j < N; j++) A[i][j] = (s[j] == '.');
  }
  for (int i = 0; i < M; i++) {
    string s; cin >> s;
    for (int j = 0; j < M; j++) B[i][j] = (s[j] == '.');
  }
  bool matches = false;
  for (int i = 0; i < N-M+1; i++) {
    for (int j = 0; j < N-M+1; j++) {
      bool matches_in = true;
      for (int k = 0; k < M; k++) {
        for (int l = 0; l < M; l++) {
          matches_in = matches_in && (A[i+k][j+l] == B[k][l]);
        }
      }
      matches = matches || matches_in;
    }
  }
  cout << (matches ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3576
from collections import deque
n=int(input())
A=[]
B=[0]*(n-1)
G=[[] for i in range(n)]
GG=[[0]*2 for i in range(n-1)]
for i in range(n-1):
  a,b=map(int,input().split())
  GG[i]=[a,b]
  G[a-1].append(b-1)
  G[b-1].append(a-1)
  A.append(a*10**6+b)
D=dict(zip(A,B))
ans=0
for i in range(n):
  if len(G[i])>ans:
    ans=len(G[i])
    a=i
print(ans)
VC=[10**6]*n #各頂点と親を結ぶ辺の色を記憶
#aを根とする木をDFS
E=[0]*n
E[a]=1
F=deque([a])
while len(F)>0:
  s=F[0]
  F.popleft()
  c=1
  for i in range(len(G[s])):
    if E[G[s][i]]==0:
      F.append(G[s][i])
      E[G[s][i]]=1
      if c==VC[s]:
        c=c+1
      VC[G[s][i]]=c
      t=s
      D[min(s+1,G[s][i]+1)*10**6+max(s+1,G[s][i]+1)]=VC[G[s][i]]
      c=c+1
for i in range(n-1):
  print(D[GG[i][0]*10**6+GG[i][1]])

Measured memory_bytes: 53048
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect# lower_bound etc
#import numpy as np
#from copy import deepcopy
#from collections import deque

def run():
    N = int(input())
    if N % 2:
        print(0)
    else:
        ans = 0
        div = 10
        while True:
            val = N // div
            ans += val
            if not val:break
            div *= 5
        print(ans)

if __name__ == "__main__":
    run()

Measured memory_bytes: 9116
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)




int main() {
    double x1, y1, x2, y2, x3, y3;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    double a = sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
    double b = sqrt((x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2));
    double c = sqrt((x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1));
    double s = (a + b + c) / 2.0;
    double S = sqrt(s * (s - a) * (s - b) * (s - c));
    double r = (2.0 * S) / (a + b + c);
    double t = max({a, b, c});
    printf("%.11lf\n", 1.0 / (2.0 * ((1.0 / t) + (1.0 / (2.0 * r)))));
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 998244353
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;

int modpow(int a, int p) {
	if (p == 0) return 1;
	if (p % 2 == 0) {

		int halfP = p / 2;
		int half = modpow(a, halfP);

		return half * half % mod;
	}
	else {

		return a * modpow(a, p - 1) % mod;
	}
}
ll comb(ll N_, ll C_) {
	const int NUM_ = 3000001;
	static ll fact[3000002], factr[3000002], inv[3000002];
	if (fact[0] == 0) {
		inv[1] = fact[0] = factr[0] = 1;
		for (int i = 2; i <= NUM_; ++i) inv[i] = inv[mod % i] * (mod - mod / i) % mod;
		for (int i = 1; i <= NUM_; ++i) fact[i] = fact[i - 1] * i%mod, factr[i] = factr[i - 1] * inv[i] % mod;
	}
	if (C_<0 || C_>N_) return 0;
	return factr[C_] * fact[N_] % mod*factr[N_ - C_] % mod;
}

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

	int N, M, K; cin >> N >> M >> K;
	int ans = 0;

	eFOR(i, 0, K) {
		int tmp = M * modpow(M - 1, N - i - 1) % mod;
		tmp *= comb(N - 1, i);
		tmp %= mod;
		ans += tmp;
		ans %= mod;
	}

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



Measured memory_bytes: 73968
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<bitset>

using namespace std;
typedef long long ll;

ll calc(ll x) {
   if (x % 8 == 1 || x % 8 == 5) x = 1;
   else if (x % 8 == 3 || x % 8 == 7) x = 0;
   else if (x % 8 == 0) {
      x -= x % 8;
   }
   else if (x % 8 == 2) {
      x -= x % 8;
      x += 3;
   } else if (x % 8 == 4) {
      x -= x % 8;
      x += 4;
   } else {
      x -= x % 8;
      x += 7;
   }
   return x;
}

int main() {
   ll A, B;
   cin >> A >> B;
   if (A != 0) A = calc(A - 1);
   B = calc(B);
   ll ans = A^B;
   cout << ans << endl; 
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
template<class T> inline bool chmax(T& a, T b){
    if(a<b){
        a = b;
        return true;
    }
    else return false;
}
template<class T> inline bool chmin(T& a, T b){
    if(a>b){
        a = b;
        return true;
    }
    else return false;
}
const long long INF = 1LL<<60;

string s, t;

int dp[3100][3100] = {0};

int main(){
    cin >> s >> t;
    for(int i=0; i<s.size(); ++i){
        for(int j=0; j<t.size(); ++j){
            if(s[i]==t[j]) chmax(dp[i+1][j+1], dp[i][j]+ 1);
            chmax(dp[i+1][j+1], dp[i+1][j]);
            chmax(dp[i+1][j+1], dp[i][j+1]);
        }
    }
    string res = "";
    int i = (int)s.size(), j = (int)t.size();
    while(i>0 && j>0){
        if(dp[i][j] == dp[i-1][j]){
            --i;
        }
        else if(dp[i][j] == dp[i][j-1]){
            --j;
        }
        else{
            res = s[i-1] + res;
            --i, --j;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 37120
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1e9 + 7;

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

vector<vector<ll>> g;


int main() {
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    ll n, a, b, c, d;
    string s;
    cin >> n >> a >> b >> c >> d;
    a--;
    b--;
    c--;
    d--;
    cin >> s;
    
    vector<bool> dp1(s.size());
    vector<bool> dp2(s.size());
    dp1[a] = 1;
    dp2[b] = 1;
    
    for (int i = b + 1; i <= d; ++i)
    {
        if (s[i] == '.')
        {
            if (i - 2 >= 0)
            {
                dp2[i] = max(dp2[i], dp2[i - 2]);
            }
            if (i - 1 >= 0)
            {
                dp2[i] = max(dp2[i], dp2[i - 1]);
            }
        }
    }
    bool f = 0;
    for (int i = a + 1; i <= c; ++i)
    {
        if (s[i] == '.')
        {
            if (i - 2 >= 0)
            {
                dp1[i] = max(dp1[i], dp1[i - 2]);
            }
            if (i - 1 >= 0)
            {
                dp1[i] = max(dp1[i], dp1[i - 1]);
            }
            if (d < c)
            {
                if (i > b && i - 2 >= 0 && i <= d + 1)
                {
                    if (dp1[i] && dp1[i - 1] && dp1[i - 2])
                    {
                        f = 1;
                    }
                }
            }
            else
            {
                f = 1;
            }
        }
    }
    
    if (dp1[c] && dp2[d] && f)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 592
import sys
input = sys.stdin.readline

def main():
    N,K = map(int,input().split())
    S = input()[:-1]

    score = 0
    for i in range(N-1):
        if S[i] == S[i+1]:
            score += 1

    print(min(score+2*K,N-1))

if __name__ == "__main__":
    main()

Measured memory_bytes: 39380
#include <iostream>
#define ll long long
using namespace std;

int main(){
    ll n, s;
    cin >> n;
    s = (n+1)*n/2;
    for(ll i = 1;i<=n;i++){
        if(i % 3 == 0 || i % 5 == 0)
            s -= i;
    }
    cout << s;
}


Measured memory_bytes: 3644
use std::io::Read;
use std::collections::HashSet;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let m: usize = iterator.next().unwrap().parse().unwrap();

    let mut from_first: HashSet<usize> = HashSet::new();
    let mut to_last: HashSet<usize> = HashSet::new();
    for _ in 0..m {
        let a: usize = iterator.next().unwrap().parse().unwrap();
        let b: usize = iterator.next().unwrap().parse().unwrap();
        if a == 1 {
            from_first.insert(b);
        }
        if b == n {
            to_last.insert(a);
        }
    }

    if from_first.intersection(&to_last).count() >= 1 {
        return String::from("POSSIBLE")
    }

    return String::from("IMPOSSIBLE");
}


Measured memory_bytes: 15196
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;

#define rep(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define Rep(i, a, b) for (int (i) = (a) - 1; (i) < (b); (i)++)
#define REP(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a) memset(a, 0, sizeof(a))
#define Sort(a, len, cmp) sort(a + 1, a + len + 1, cmp)
#define ass(a, sum) memset(a, sum, sizeof(a))

#define ls ((rt) << 1)
#define rs ((rt) << 1 | 1)
#define lowbit(x) (x & -x)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'
#define ENDL cout << endl
#define SZ(x) ((int)x.size())

typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> vi ;
typedef pair <int, int> pii ;
typedef pair <ll, ll> pll ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
typedef map <ll, ll> mll ;

const int N = 100010 ;
const double eps = 1e-8 ;
const int iinf = INT_MAX ;
const ll linf = 2e18 ;
const double dinf = 1e30 ;
const int MOD = 1000000007 ;

inline int read(){
    int X = 0, w = 0 ;
	char ch = 0 ;
    while (!isdigit(ch)) { w |= ch == '-' ; ch = getchar() ; }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar() ;
    return w ? - X : X ;
}

void write(int x){
     if (x < 0) putchar('-'), x = - x ;
     if (x > 9) write(x / 10) ;
     putchar(x % 10 + '0') ;
}

void print(int x) {
	cout << x << endl ;
	exit(0) ;
}

void PRINT(string x) {
	cout << x << endl ;
	exit(0) ;
}

void douout(double x){
	 printf("%lf\n", x + 0.0000000001) ;
}

string s ;
int ans = iinf ;

signed main(){
	cin >> s ;
	for (int i = 2; i < s.size(); i++) {
		int tmp = (s[i - 2] - '0') * 100 + (s[i - 1] - '0') * 10 + (s[i] - '0') ;
		ans = min(ans, abs(tmp - 753)) ;
	}
	printf("%d\n", ans) ;
}

/*
写代码时请注意：
	1.是否要开Long Long？数组边界处理好了么？
	2.实数精度有没有处理？
	3.特殊情况处理好了么？
	4.做一些总比不做好。
思考提醒：
	1.最大值和最小值问题可不可以用二分答案？
	2.有没有贪心策略？否则能不能dp？
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	int p=0,w=0,g=0,y=0,sum=0;
	cin>>n;
	char s[100];
	for(int i=1;i<=n;i++)
	{
		cin>>s[i];
		if(s[i]=='P'&&p==0)
		{
			p++;
		}
		if(s[i]=='W'&&w==0)
		{
			w++;
		}
		if(s[i]=='G'&&g==0)
		{
			g++;
		}
		if(s[i]=='Y'&&y==0)
		{
			y++;
		}
	}
	sum=p+w+g+y;
	if(sum==1)
	cout<<"One";
	if(sum==2)
	cout<<"Two";
	if(sum==3)
	cout<<"Three";
	if(sum==4)
	cout<<"Four";
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(i, n) printf("%d%c", a[i], i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(i, n) REP(j, m) printf("%d%c", a[i][j], j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 12;
const int M_MAX = 1000;
const int S_MAX = 1 << N_MAX;
const int INF = 1000000000;

int N, M;
int a[M_MAX];
int f[M_MAX];

int S;
int dp[M_MAX + 1][S_MAX];

void solve() {
  // DUMP(a, M);
  // DUMP(f, M);
  fill(dp[0], dp[1], INF);
  dp[0][0] = 0;
  S = 1 << N;
  REP(i, M) {
    REP(s, S) dp[i + 1][s] = dp[i][s];
    REP(s, S) {
      int s2 = s | f[i];
      dp[i + 1][s2] = min(dp[i + 1][s2], dp[i][s] + a[i]);
    // printf("i:%d, s:%d, f:%d, dp[%d][%d]:%d\n", i, s, f[i], i + 1, s2, dp[i + 1][s2]);
    }
  }

  // DUMP2D(dp, M + 1, S);

  int ans = dp[M][S - 1];
  if (ans >= INF) ans = -1;
  printf("%d\n", ans);
}

void input() {
  scanf("%d%d", &N, &M);
  REP(i, M) {
    int b;
    scanf("%d%d", a + i, &b);
    f[i] = 0;
    REP(j, b) {
      int c;
      scanf("%d", &c);
      f[i] |= 1 << (c - 1);
    }
  }
}

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


Measured memory_bytes: 16128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

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

    unordered_map<string,int>mp;
    int n,ans = 0;
    cin>>n;
    rep(i,n){
        string s;
        cin>>s;
        if(++mp[s] == 1)ans++;
    }
    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 17680
#include<bits/stdc++.h>
using namespace std;
const int ZDN=1e2+8;
long long sz[ZDN][2+2]; 
int main(){
	long long n;
	cin>>n;
	
	for (int i=1; i<=n; i++){
		for (int j=1; j<=2; j++){
			cin>>sz[i][j];
		}
	}
	for (int i=1; i<=n-2; i++){
		if (sz[i][1]==sz[i][2] && 
		sz[i+1][1]==sz[i+1][2] && 
		sz[i+2][1]==sz[i+2][2]){
			cout<<"Yes\n";
			return 0;
		}
	}
	cout<<"No\n";
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
using LL = long long;
using ULL = unsigned long long;


void solve() {
	int n; cin >> n;
	int d[100000] = {};
	int dn[100000] = {};
	rep(i, n) {
		cin >> d[i];
		dn[d[i]]++;
	}

	if (d[0] != 0) { cout << 0 << endl; return; }
	if (dn[0] != 1) { cout << 0 << endl; return; }

	ULL ans = 1;
	const ULL M = 998244353;
	for (int i = 1; i < n; i++) {
		ans = ans * dn[d[i] - 1] % M;
	}
	cout << ans << endl;
}

int main() {

	solve();

	return 0;
}


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

int main (){
int N;
  int ans = 0;
cin >> N;
  int cnt = 0;
 if(N < 105){
 ans = 0;
 }else{
  for(int j = 1;j <= N;j++){
    cnt = 0;
 for(int i = 0; 2 * i + 1 <= j;i++){
 	if(j%(2 * i + 1 )==0){
    	cnt++;
    }
 }
    if(cnt == 8){
    	ans++;
    }
  }
 
 }
 cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input())
T = [int(input()) for _ in range(N)]

print(lcm_list(T))


Measured memory_bytes: 5048
from collections import Counter
from itertools import combinations_with_replacement
N = int(input())
L = [i for i in range(1, 100)]
C = Counter()
for i in range(1, N+1):
    C[i] = 0

for c in combinations_with_replacement(L, 3):
    x = c[0]
    y = c[1]
    z = c[2]
    tmp = x**2+y**2+z**2+x*y+y*z+z*x
    if tmp <= N:
        if len(set(c)) == 2:
            C[tmp] += 3
        elif len(set(c)) == 3:
            C[tmp] += 6
        else:
            C[tmp] += 1

for i in range(1, N+1):
    print(C[i])


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

using namespace std;

int n, k, q, x;
int a[100010], cnt[100010];

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

    cin >> n >> k >> q;
    for(int i = 0; i < n; i++) a[i] = k;
    for(int i = 0; i < q; i++){
        cin >> x; cnt[x - 1]++;
    }
    for(int i = 0; i < n; i++){
        a[i] -= (q - cnt[i]);
        if(a[i] <= 0) cout << "No\n";
        else cout << "Yes\n";
    }
}

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

int main() {
  int a,b,c;
  string s,t;
  cin>>a;
  cin>>s>>t;
  
  for(int i=0;i<s.size();i++){
  	cout<<s.at(i);
    cout<<t.at(i);
    
  }
    
  cout<<endl;
  
  return 0;
}
  

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

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; }
using ll = long long;
using pint = pair<int, int>; 
using pll  = pair<ll, ll>;
using vint = vector<int>; 
using vll  = vector<ll>;
using vstr = vector<string>;

//　定数, 変数 *********************************************
const ll MOD=1e9+7;
const ll INF=1ll<<60;

int N;
// *********************************************************
int main(){

    // 入力スタンダード
    cin >> N;
    vector<int> ai;
    for(int i=0; i<N; i++){
        int tmp;
        cin >> tmp;
        ai.emplace_back(tmp);
    }
    sort(ai.begin(), ai.end());
    reverse(ai.begin(), ai.end());
    
    int A=0;
    int B=0;
    for(int i=0; i<N; i++){
        if(i%2==0){
            A += ai[i];
        }else{
            B += ai[i];
        }
    }
    
    cout << A - B<< endl;




    return 0;
}

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

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

void solve(void){
  string s, t; cin >> s >> t;

  vector<int> start(26, -1);
  vector<int> goal(26, -1);

  rep((int)s.size(), i){
    int a = s[i] - 'a';
    int b = t[i] - 'a';

    if (start[a] != -1 || goal[b] != -1) {
      if (start[a] != b || goal[b] != a) {
        cout << "No" << endl;
        return;
      }
    }

    start[a] = b, goal[b] = a;
  }
  cout << "Yes" << endl;
  return;
}

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


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

#define INF 1000000001

int main() {
	int n, x, k;
	long long ans;

	scanf("%d", &n);
	x = INF;
	ans = k = 0;
	while (n--) {
		int a;

		scanf("%d", &a);
		if (a < 0)
			k++;
		a = abs(a);
		ans += a;
		if (x > a)
			x = a;
	}
	printf("%lld\n", k % 2 == 0 ? ans : ans - x * 2);
	return 0;
}


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



int main()
{
    int a,b=0;
    cin>>a;
    if(a>=105)
        b++;
    if (a >= 135)
        b++;
    if(a>=189)
        b++;
    if (a >= 165)
        b++;
    if(a>=195)
        b++;
    cout << b << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<list>
#include<queue>
#include<set>
#include<string>
#include <vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;

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

	int l = S.length();
	bool f = false;
	REP(i,l ){
		if (S == T){
			f = true;
			break;
		}
		T = T.back() + T;
		T.pop_back();
	}
	if (f){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 256
use std::collections::BTreeMap;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: u32 = read();
    let mut dic: BTreeMap<String, u32> = BTreeMap::new();
    for _ in 0..n {
        let s: String = read();
        let ins_val = match dic.get(&s) {
            Some(v) => v + 1,
            None => 1,
        };
        dic.insert(s, ins_val);
    }

    let mut max_val: u32 = 0;
    for v in dic.values() {
        max_val = if max_val > *v { max_val } else { *v };
    }

    let max_val = max_val;
    for (k, v) in &dic {
        if *v == max_val {
            println!("{}", k);
        }
    }
}


Measured memory_bytes: 20348
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}
int main() {
    ll n, m; cin >> n >> m;
    priority_queue<ll> q;
    REP(i, n) {
        ll tmp;
        cin >> tmp;
        q.push(tmp);
    }
    REP(i, m) {
        ll tmp = q.top(); q.pop();
        tmp /= 2;
        q.push(tmp);
    }
    ll res = 0;
    REP(i, n) {
        ll tmp = q.top(); q.pop();
        res += tmp;
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;

typedef long long int ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
ll mod = 1e9+7;
ll powr(ll b, ll x) {
	if(x == 0) return 1;
	return (b*powr(b, x-1))%mod;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    vi cc = vi(27, 0);
    ll sol = 0;
    
    for(int i=0; i < n; i++) {
		ll cs = 1;
		for(char c = 'a'; c <= 'z'; c++) {
			int j = int(c-'a');
			if(c == s[i]) {
				
			}
			else {
				cs *= (cc[j]+1);
				cs %= mod;
			}
		}
		sol += cs;
		sol %= mod;
		cc[s[i]-'a']++;
	}
	cout << sol << endl;

}


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

int main() {
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    if(a+b < k){
        cout << a - (k - a - b) << endl;
        return 0;
    }else if(a > k){
        cout << k << endl;
    }else{
        cout << a << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
import math
import sys
from itertools import accumulate
from functools import reduce
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

sys.setrecursionlimit(10000)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())
    = [list(list(sys.stdin.readline().rstrip())) for i in range(h)] #文字列を分解して二次元配列入力

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
"""

if __name__ == "__main__":
    h,w = map(int, sys.stdin.readline().split())
    s =["."+input()+"." for i in range(h)]
    s =["."*(w+2)]+s+["."*(w+2)]
    flag=0
    for i in range(h):
        for j in range(w): #２重for文で行列を一つずつ確認
            if s[i][j] == "#":
                if s[i-1][j] =="." and s[i+1][j] =="." and s[i][j-1] =="."  and s[i][j+1] ==".":#上下左右塗れなかった時
                    flag = 1
                    print("No")
                    exit()
    print("Yes" if flag==0 else "No")

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, Y;
  cin >> N >> Y;           //お札の枚数N    お年玉金額Y
  int a = -1; int b = -1; int c = -1;                   //一万円の枚数、五千円の枚数、千円の枚数
  int found = false;                                              //組み合わせ検知の真偽
 
  if(N < 1 || N > 2000 || Y > 20000000 || Y < 1000)                          //実現しえない金額
    ;                                                             //というかYの上限近くだったら羨ましすぎる
  else{
    /*重積分の如き処理を行う*/
    for(int i = 0; i <= N; i++){
      for(int j = 0; j <= N - i; j++){
         if(10000 * i + 5000 * j + 1000 * (N-i-j) == Y){
            a = i;
            b = j;
            c = N-i-j;
            found = true;
            break;
          }
      }                       //jブロック
      if(found)
        break;
    }                        //iブロック
  }
    
  cout << a << " " << b << " " << c << endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;

int is_login[1005][1300];

int main() {
  int n, m;
  while (cin >> n >> m) {
    if (n == 0 && m == 0) { break; }
    // is_login[x][y] := pc xに時刻yにloginしている生徒
    rep(i, 1003) {
      rep(j, 1280) {
        is_login[i][j] = 0;
      }
    }
    int r; cin >> r;
    rep(i, r) {
      int time, pc_id, student_id, s;
      cin >> time >> pc_id >> student_id >> s;
      if (s) {
        is_login[pc_id][time] = student_id;
      } else {
        is_login[pc_id][time] = -student_id;
      }
    }
    rep(x, 1003) {
      for (int i = 1; i <= 1280; i++) {
        is_login[x][i] += is_login[x][i-1];
      }
    }
    int q; cin >> q;
    while (q--) {
      int ts, te, m;
      int ans = 0;
      cin >> ts >> te >> m;
      /*
      for (int t = 750; t <= 900; t++) {
        cout << t << ": " << is_login[1][t] << " ";
        cout << t << ": " << is_login[2][t] << " ";
        cout << t << ": " << is_login[3][t] << " ";
        cout << t << ": " << is_login[4][t] << " ";
        cout << endl;
      } 
      */
      for (int t = ts; t < te; t++) {
        bool f = false;
        rep(x, 1003) {
          if ( is_login[x][t] == m ) {
            f = true;
            break;
          }
        }
        if (f) { ans++; }
      }
      cout << ans << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 8100
#include <cstdio>
static const int MAXN = 2004;
static const int MAXQ = 200004;

int n, m, q;
int s[MAXN][MAXN] = {{ 0 }};
int r1, c1, r2, c2;

int sum_deg[MAXN][MAXN] = {{ 0 }};
int sum_hor[MAXN][MAXN] = {{ 0 }}, sum_ver[MAXN][MAXN] = {{ 0 }};

int main()
{
    scanf("%d%d%d", &n, &m, &q); getchar();
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) s[i][j] = getchar() - '0';
        getchar();
    }

    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j) if (s[i][j] == 1) {
            sum_deg[i][j] = 2 - (s[i - 1][j] + s[i + 1][j] + s[i][j - 1] + s[i][j + 1]);
            if (i < n) sum_hor[i][j] = s[i + 1][j];
            if (j < m) sum_ver[i][j] = s[i][j + 1];
        }

    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            sum_deg[i][j] += (sum_deg[i - 1][j] + sum_deg[i][j - 1] - sum_deg[i - 1][j - 1]);
    for (int i = 1; i < n; ++i)
        for (int j = 1; j <= m; ++j) sum_hor[i][j] += sum_hor[i][j - 1];
    for (int i = 1; i < m; ++i)
        for (int j = 1; j <= n; ++j) sum_ver[j][i] += sum_ver[j - 1][i];

    /*for (int i = 1; i < n; ++i)
        for (int j = 1; j <= m; ++j) printf("%d%c", sum_hor[i][j], j == m ? '\n' : ' ');
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j < m; ++j) printf("%d%c", sum_ver[i][j], j == m - 1 ? '\n' : ' ');
    for (int i = 0; i <= n; ++i)
        for (int j = 0; j <= m; ++j) printf("%d%c", sum_deg[i][j], j == m ? '\n' : ' ');*/

    for (int i = 0; i < q; ++i) {
        scanf("%d%d%d%d", &r1, &c1, &r2, &c2);
        int count = sum_deg[r2][c2] - sum_deg[r1 - 1][c2] - sum_deg[r2][c1 - 1] + sum_deg[r1 - 1][c1 - 1];
        //puts("----");
        //printf("%d\n", count);
        count += (sum_hor[r2][c2] - sum_hor[r2][c1 - 1]);
        //printf("%d\n", count);
        count += (sum_hor[r1 - 1][c2] - sum_hor[r1 - 1][c1 - 1]);
        //printf("%d\n", count);
        count += (sum_ver[r2][c2] - sum_ver[r1 - 1][c2]);
        //printf("%d\n", count);
        count += (sum_ver[r2][c1 - 1] - sum_ver[r1 - 1][c1 - 1]);
        //printf("%d\n", count);
        printf("%d\n", count / 2);
    }

    return 0;
}


Measured memory_bytes: 64512
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

bool check(int a, int b) {
	return a > b;

}

int main() {
	llint a, b;
	cin >> a >> b;
	llint ans = 0;
	if (b - a < 10) {
		for (llint i = a;i <= b;i++) {
			ans ^= i;
		}
		cout << ans << endl;
		return 0;
	}
	if (a % 4 != 0) {
		for (llint i = a;i < a / 4 * 4 + 4;i++) {
			ans ^= i;
		}
	}
	if (b % 4 != 3) {
		for (llint i = b;b / 4 * 4 <= i;i--) {
			ans ^= i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256