akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
 map<string,char>t2;
 map<char,string>t1;
 t1['A']="00000";t1['R']="10001";
 t1['B']="00001";t1['S']="10010";
 t1['C']="00010";t1['T']="10011";
 t1['D']="00011";t1['U']="10100";
 t1['E']="00100";t1['V']="10101";
 t1['F']="00101";t1['W']="10110";
 t1['G']="00110";t1['X']="10111";
 t1['H']="00111";t1['Y']="11000";
 t1['I']="01000";t1['Z']="11001";
 t1['J']="01001";t1[' ']="11010";
 t1['K']="01010";t1['.']="11011";
 t1['L']="01011";t1[',']="11100";
 t1['M']="01100";t1['-']="11101";
 t1['N']="01101";t1['\'']="11110";
 t1['O']="01110";t1['?']="11111";
 t1['P']="01111";t1['Q']="10000";
 t2["101"]=' ';t2["100101"]='A';
 t2["000000"]='\'';t2["10011010"]='B';
 t2["000011"]=',';t2["0101"]='C';
 t2["10010001"]='-';t2["0001"]='D';
 t2["010001"]='.';t2["110"]='E';
 t2["000001"]='?';t2["01001"]='F';
 t2["10011011"]='G';t2["010000"]='H';
 t2["0111"]='I';t2["10011000"]='J';
 t2["0110"]='K';t2["00100"]='L';
 t2["10011001"]='M';t2["10011110"]='N';
 t2["00101"]='O';t2["111"]='P';
 t2["10011111"]='Q';t2["1000"]='R';
 t2["00110"]='S';t2["00111"]='T';
 t2["10011100"]='U';t2["10011101"]='V';
 t2["000010"]='W';t2["10010010"]='X';
 t2["10010011"]='Y';t2["10010000"]='Z';
 string s,t;
 while(getline(cin,s)){
  t="";
 for(int i=0;i<s.size();i++)
  t+=t1[s[i]];
 string q;
 for(int i=0;i<t.size();i++){
  q+=t[i];
  if(t2[q]){
    cout<<t2[q];
    q="";
  }
 }
 cout<<endl;
}
}

Measured memory_bytes: 3240
import Data.Array

main = do
  let f i = (i+3)*(i+2)*(i+1) `div` 6 - max (2*(i-9)*(i-8)*(i-7) `div` 3) 0 in
    let p = array (0,50) $ zip [i | i <- [0..50]] $ [ f i | i <- [0..18]++[17,16..0]] ++ replicate 15 0 in
      let g x = show $ p!(read x::Int) in
        putStr . unlines . map g . lines =<< getContents

Measured memory_bytes: 4076
N, D = map(int, input().split())
X = [list(map(int, input().split())) for i in range(N)]

count = 0

for i in range(N-1):
    for j in range(i+1, N):
        distance = 0
        for k in range(D):
            distance += (X[i][k] - X[j][k])**2
        if distance**(1/2)%1 == 0:
            count += 1

print(count)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define var auto
#define Max std::max
#define Min std::min

#ifdef _MSC_VER
#define getchar_unlocked getchar
#define putchar_unlocked putchar
#define fseek_unlocked fseek
#endif

inline uint32_t read()
{
	uint32_t x = 0;
	int k;
	while (true)
	{
		k = getchar_unlocked();
		if (k < '0') break;
		x = x * 10 + k - '0';
	}
	return x;
}

void writeline(uint32_t x) {
	int s = 0;
	char f[8];
	while (x) {
		f[s++] = x % 10;
		x /= 10;
	}
	while (s--)
		putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}

int main()
{
	int h = read(), w = read();
	vector<int> rowMax(w, 0);
	vector<int> columnAccum(w, 0);
	int max = 0;
	for (size_t i = 0; i < h; i++)
	{
		int currentChain = 0;
		for (size_t j = 0; j < w; j++)
		{
			if (getchar_unlocked() == '#') 
			{
				max = Max(max, columnAccum[j] + rowMax[j]);
				if (currentChain)
					for (size_t k = j - currentChain; k < j; k++)
						rowMax[k] = Max(rowMax[k], currentChain);
				currentChain = 0;
				rowMax[j] = 0;
				columnAccum[j] = 0;
			}
			else
			{
				currentChain++;
				columnAccum[j]++;
			}
		}
		if (currentChain)
			for (size_t j = w - currentChain; j < w; j++)
				rowMax[j] = Max(rowMax[j], currentChain);
		getchar_unlocked();
	}
	for (size_t i = 0; i < w; i++)
		max = Max(max, columnAccum[i] + rowMax[i]);
	writeline(max - 1);
	return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
nx = []
ny = []
mx = []
my = []

for i in range(n):
    a,b = map(int,input().split())
    nx.append(a)
    ny.append(b)
    
for i in range(m):
    c,d = map(int,input().split())
    mx.append(c)
    my.append(d)
    
for i in range(n):
    man = []
    for j in range(m):
        k = abs(nx[i]-mx[j])+abs(ny[i]-my[j])
        man.append(k)
    print(man.index(min(man))+1)

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

/* snippet: useful macros and functions */
#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<class T> T rng(const T &a, const T &b){ return a < b ? b - a : a - b; }
template<class T> void th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

/* snippet: modint library */
template<class T, int MOD>
class Modint{
	T val;
public:
	Modint(T val = 0) : val(val) {}
	operator T(){ return val; }
	Modint &operator+=(const Modint &a){ val += a.val; if(val >= MOD) val -= MOD; return *this; }
	Modint &operator-=(const Modint &a){ val -= a.val; if(val < 0) val += MOD; return *this; }
	Modint &operator*=(const Modint &a){ val = val * a.val % MOD; return *this; }
	void inverse(){T x[2]={MOD,val},a[2]={0,1};int i;for(i=0;x[!i];i^=1){a[i]-=x[i]/x[!i]*a[!i];x[i]=x[i]%x[!i];}if(!i)a[i]+= MOD;val=a[i];}
	Modint &operator/=(Modint a){ a.inverse(); return *this *= a; }
	friend Modint modpow(Modint a, int n){ Modint ret(1); while(n){ if(n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
	friend Modint operator+(Modint a, const Modint &b){ return a += b; }
	friend Modint operator-(Modint a, const Modint &b){ return a -= b; }
	friend Modint operator*(Modint a, const Modint &b){ return a *= b; }
	friend Modint operator/(Modint a, const Modint &b){ return a /= b; }
	friend std::ostream &operator<<(std::ostream &os, const Modint &a){ return os << a.val; }
};

/* snippet: using declarations */
using Int = int;
using namespace std;
using Mint = Modint<long long, 1000000007>;

char ch[100];

int k;

int cnt;

void fnc(char *p, char n, int i){
	if(i == 0){
		*p = n;
		if(++cnt== k){
			puts(ch);
		}
	}else{
		*p = n;
		++p;
		if(n != '0') fnc(p, n - 1, i - 1);
		fnc(p, n, i - 1);
		if(n != '9') fnc(p, n + 1, i - 1);
	}
}

int main(){
	cin >> k;
	for(int i = 0; i < 10; ++i){
		for(int j = '1'; j <= '9'; ++j){
			fnc(ch, j, i);
		}
	}
}



Measured memory_bytes: 256
k, n = [int(x) for x in input().strip().split()]
a = [int(x) for x in input().strip().split()]

diff = []
res = abs(a[0]-a[1])
ld = abs(k-a[-1])+abs(a[0]-0)
for i in range(1,n):
    res = max(res,abs(a[i-1]-a[i]))

res = max(res, ld)
res = k-res
print(res)





Measured memory_bytes: 26444
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;

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

	int N; cin >> N;
	string S, T; cin >> S >> T;
	string ans;
	for (int i = 0; i < N; i++) {
		ans.push_back(S[i]);
		ans.push_back(T[i]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
using namespace std;

int inf = 2147483647;
int64_t inf64 = 9223372036854775807;
int mod = 1e+7;

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

  int n;
  cin >> n;
  vector<int> diff(n);
  rep(i,n) cin >> diff[i];
  sort(diff.begin(), diff.end());

  cout << diff[n/2] - diff[n/2-1] << endl;

  return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;

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; }
template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}
template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<v.size(); i++) {
		if (i)ost << ", ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}
template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}


int main()
{
	double n,k,ans;
	cin >> n >> k;
	ans = log(n)/log(k);
	cout << (int)ans + 1 << endl;

	return 0;
}

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

#define fs first
#define se second
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define pb emplace_back

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

int main() {
	string s;
	string t[4] = {"dream", "dreamer", "erase", "eraser"};

	cin >> s;
	int l = s.size();
	while (l) {
		bool po = true;
		rep(i, 4) {
			bool f = true;
			for (int j = 0; j < t[i].size(); ++j) {
				if (t[i][j] != s[l - t[i].size() + j]) f = false;
			}

			if (f) {
				l -= t[i].size();
				po = false;
				break;
			}
		}
		if (po) {
			puts("NO");
			return(0);
		}
	}

	puts("YES");
}


Measured memory_bytes: 512
import java.util.*;

public class Main{
  static int max = 0;
  static Scanner sc = new Scanner(System.in);
  static int N = sc.nextInt();
  static int M = sc.nextInt();
  static int Q = sc.nextInt();
  static int[][] req = new int[4][Q];
    static int[] a = new int[Q];
    static int[] b = new int[Q];
    static int[] c = new int[Q];
    static int[] d = new int[Q];
  
    public static void main(String[] args){
      for(int i = 0 ; i < Q ; i++){
        a[i] = sc.nextInt() - 1;
        b[i] = sc.nextInt() - 1;
        c[i] = sc.nextInt();
        d[i] = sc.nextInt();     
      }
      List<Integer> list = new ArrayList<>();      
      dfs(list);
      System.out.println(max);
	}
  static void dfs(List<Integer> list){
    if(list.size() == N){
      int sum = 0;
      for(int j = 0 ; j < Q ; j++){
      if (list.get(b[j]) - list.get(a[j]) == c[j])
                    sum += d[j];
      }
        if(max < sum)
          max = sum;
        return;
    }
    for(int i = 0 ; i < 10 ; i++){
    if(list.size() == 0 || i >= list.get(list.size() - 1) && i <= M - 1){
      list.add(i);
      dfs(list);
      list.remove(list.size() - 1);
    }
    }
  }
}
  

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

int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int X, Y;
		cin >> X >> Y;
		int a[X + 1][Y + 1];
		a[0][0] = 1;
		bool b[X + 1][Y + 1]; //y方向
		bool c[X + 1][Y + 1]; //x方向
		for (int i = 0; i < X + 1; i++) {
			for (int j = 0; j < Y + 1; j++) {
				b[i][j] = false;
				c[i][j] = false;
			}
		}
		int M;
		cin >> M;
		for (int i = 0; i < M; i++) {
			int x1, x2, y1, y2;
			cin >> x1 >> y1 >> x2 >> y2;
			if (x1 == x2) {
				if (y1 < y2) {
					b[x1][y1] = true;
				} else {
					b[x1][y2] = true;
				}
			} else {
				if (x1 < x2) {
					c[x1][y1] = true;
				} else {
					c[x2][y1] = true;
				}
			}
		}
		for (int i = 0; i < X + 1; i++) {
			for (int j = 0; j < Y + 1; j++) {
				if (i == 0 && j == 0) {
					continue;
				}
				int left = 0;
				int up = 0;
				if (i != 0) {
					if (!c[i - 1][j]) {
						left = a[i - 1][j];
					}
				}
				if (j != 0) {
					if (!b[i][j - 1]) {
						up = a[i][j - 1];
					}
				}
				a[i][j] = left + up;
				//cout << a[i][j] << endl;
			}
		}
		if (a[X][Y] != 0) {
			cout << a[X][Y] << endl;
		} else {
			cout << "Miserable Hokusai!" << endl;
		}
	}
}



Measured memory_bytes: 2992
N, K = map(int, input().split())
v = list(map(int, input().split()))

max_pick = min(K, N)
ans = 0

# 左右から取る量を決め打ち

for left in range(max_pick + 1):
    for right in range(max_pick - left + 1):
        t = v[:left] + v[N - right:]
        m = sorted(filter(lambda x: x < 0, t))[:K - left - right]
        ans = max(ans, sum(t) - sum(m))
print(ans)


Measured memory_bytes: 3064
n,m=map(int,input().split())
ans=[0]*m
for i in range(n):
  l=list(map(int,input().split()))
  x=l[1:]
  for j in range(l[0]):
    y=x[j]-1
    ans[y]+=1
count=0
for i in range(m):
  if ans[i]==n:
    count+=1
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <assert.h>
#include <cstdio>

// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

inline bool chmin(ll &a, ll b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

inline bool chmax(ll &a, ll b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

//桁数取得
template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}
//整数乗
ll llpow(ll a, ll n)
{
    if (n == 0)
    {
        return 1;
    }
    else
    {
        ll rep = a;
        for (ll i = 1; i < n; i++)
        {
            rep *= a;
        }
        return rep;
    }
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

template <typename T>
T amarinasi(T a, T b)
{
    if (a % b == 0)
    {
        return a / b;
    }
    else if (a % b > 0)
    {
        return a / b + 1;
    }
    else
    {
        return a / b - 1;
    }
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------
const double pi = 3.14159265358979323846264;

int main()
{
    ll n;
    ll c;
    cin >> n >> c;
    vector<vector<ll>> vec(35, vector<ll>(100100, 0));
    for (ll i = 0; i < n; i++)
    {
        ll s, t, c_in;
        cin >> s >> t >> c_in;
        vec[c_in][s]++;
        vec[c_in][t + 1]--;
    }
    for (ll i = 1; i <= c; i++)
    {
        for (ll j = 0; j < 100010; j++)
        {
            vec[i][j + 1] += vec[i][j];
        }
    }
    ll ans = 0;
    for (ll j = 0; j < 100010; j++)
    {
        ll cnt = 0;
        for (ll i = 1; i <= c; i++)
        {
            if (vec[i][j])
            {
                cnt++;
            }
        }
        chmax(ans, cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 31500
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class APair {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int k, ans;
        cin >> k;

        if(k%2==0){
            ans = (k/2)*(k/2);
        }else{
            ans = ((k/2)+1)*(k/2);
        }
        cout << ans << endl;
    }
};


int main() {
	APair solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

using namespace std;
typedef long long ll;

#define INF (long long)(10e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

int main(void)
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max(0, min(b, d) - max(a, c)) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 500
#define INFTY 100000000
int main(){
  int n, i, j, e, sum,u,v,minv;
  int M[MAX][MAX],d[MAX],p[MAX],vis[MAX];

 scanf("%d", &n);
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      scanf("%d", &e);
      M[i][j] = (e==-1)?INFTY:e;
    }
  }

  for ( i = 0; i < n; i++ ) {
    d[i] = INFTY;
    p[i] = -1;
    vis[i] = 0;
  }

  d[0] = 0;

  while(1){
    minv = INFTY;
    u = -1;
    for ( i = 0; i < n; i++ ){
      if ( minv > d[i] && !vis[i] ){
 u = i;
 minv = d[i];
      }
    }
    if ( u == -1 ) break;
    vis[u] = 1;
    for ( v = 0; v < n; v++ ){
      if ( !vis[v] && M[u][v] != INFTY ){
 if ( d[v] > M[u][v] ){
   d[v] =  M[u][v];
   p[v] = u;
 }
      }
    }
  }

  sum = 0;

 for ( i = 0; i < n; i++ ){
    if ( p[i] != -1 ) sum += M[i][p[i]];
  }

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

  return 0;
}


Measured memory_bytes: 1968
using System;
using System.Linq;

class C
{
	static void Main()
	{
		var h = Console.ReadLine().Split().Select(int.Parse).ToArray();
		var scs = new int[h[1]].Select(_ => Console.ReadLine()).ToArray();
		Console.WriteLine(Enumerable.Range(0, 1000).Select(i => $"{i}").FirstOrDefault(x => x.Length == h[0] && scs.All(sc => x[sc[0] - '1'] == sc[2])) ?? "-1");
	}
}


Measured memory_bytes: 28556
/**
 *    author        : Saurav Paul 
 *    created       : August 29, 2020 6:15 PM
 *    Problem Name  : C - Sum of product of pairs
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc177/tasks/abc177_c
 *    @genarated by : ai-virtual-assistant
**/

#include<bits/stdc++.h>
using namespace std;

using ll = long long int ;
ll BigMod(ll num , ll power, ll mod){
	
	if(power == 0 ){
		return 1 ;
	}
	ll x = 1 ;
	if(power&1){
		x = num ;
	}
	ll y = BigMod(num,power/2,mod) ;
	y = ( y%mod * y%mod )%mod ;
	return (y%mod * x%mod)%mod ;
	
}
ll BigModInverse(ll num , ll mod ){

	return BigMod(num,mod-2,mod) ;
}
class TC{

    ll N ;
    vector<ll> v ;
    ll mod = 1e9 + 7 ;

    void add(ll &x , ll y){
        x = (x%mod + y%mod) %mod ;
    }
    
    public :
    void solve(){
        cin >> N ;

        ll sum2 = 0 ;
        ll square_sum = 0 ;
        for(int i = 0 ; i < N ; i++){
            ll x;
            cin >> x;
            add(sum2 , x) ;
            x *= x;
            add(square_sum, x) ;
            v.push_back(x) ;
        }

        sum2 *= sum2 ;
        ll new_got = (sum2%mod - square_sum%mod + mod)% mod ;
        new_got = (new_got * BigModInverse(2,mod))%mod ;
        cout << new_got << endl ;

    }
};

int main(){
    ios_base::sync_with_stdio(false);

    int testcases = 1;
    for(int i = 1 ; i <= testcases ; i ++){
        TC tc;
        tc.solve() ;
    }

    return 0 ;
}


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

vector <int> v;

int main(){
	int n,k;//n人,k操作次数 
	ios::sync_with_stdio(0);
	cin>>n>>k;
	string s;
	cin>>s;
	int ans=0;
	for(int i=1;i<s.length();i++){
		if(s[i]==s[i-1]) ans++;//数原本有多少个人开心 
		//printf("1");
	}
	ans=min(2*k+ans,n-1); //2*1+9，9 
	cout<<ans<<"\n";
	return 0;
}
/*
10 1
LLLLLRRRRR
LLLLLRRRRR
*/






Measured memory_bytes: 764
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll mod=1e9+7;

int main()
{
    ll n;
    cin >> n;
    vector<ll> b(3);
    vector<ll> a(n);
    ll ans=0;
    rep(i,n){
        cin >> a[i];
        ll cnt=0;
        rep(j,3){
            if(a[i]==b[j]){
                cnt++;
            }
        }
        rep(j,3){
            if(a[i]==b[j]){
                b[j]++;
                break;
            }
        }
        if(i==0){
            ans=cnt;
        }
        else{
            ans*=cnt;
            ans%=mod;
        }
    }
    cout << ans << endl;
    return 0;
} 


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

int main(){
  int d;
  long long n;
  cin>>d >>n;
  if(n == 100) n++;
  if(d == 0){
    cout<<n<<endl;
  }else if(d == 1){
    cout<<100*n<<endl;
  }else{
    cout<<10000*n<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int x,n;cin>>x>>n;
  vector<int> p(n);
  for(int i=0; i<n; ++i) cin>>p[i];
  vector<bool> q(102,true);
  for(int i=0; i<n; ++i) q[p[i]]=false;
  vector<int> r;
  for(int i=0; i<102; ++i) if(q[i]==true) r.push_back(i);
  auto s=lower_bound(r.begin(),r.end(),x);
  auto t=upper_bound(r.begin(),r.end(),x);
  if(s<t) cout<<*s<<endl;
  else if(*t-x<x-*(t-1)) cout<<*t<<endl; else cout<<*(t-1)<<endl;
  return 0;
}


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

int main() {
	int n, k; cin >> n >> k;
	vector<int> l(n);
	for (int i = 0; i < n; i++) cin >> l[i];
	sort(l.begin(), l.end(), greater<int>());
	int ans = 0;
	for (int i = 0; i < k; i++) {
		ans += l[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122


int main() {
    int a, b, k;
    cin >> a >> b >> k;
    vector<int> v;
    rep(i, 1, max(a, b) + 1) {
        if (a % i == 0 && b % i == 0) {
            v.push_back(i);
        }
    }

    sort(all(v));
    reverse(all(v));
    cout << v[k - 1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
#define MAX 1000000
#define MOD 1000000007
#define INF 100000000000000

int main(){
  ll N,A,B;
  cin>>N>>A>>B;
  vector<ll> h(N);
  for(int i=0;i<N;i++){
    cin>>h.at(i);
  }
  ll left=0,right=1000000000;
  while(left+1<right){
    ll x=(left+right)/2;
    ll sum=0;
    for(int i=0;i<N;i++){
      ll y=h.at(i)-B*x;
      if(y>0){
        sum+=(y-1)/(A-B)+1;
      }
    }
    if(sum<=x){
      right=x;
    }else{
      left=x;
    }
  }
  cout<<right<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e8;
int N, M;

struct edge {
    int to; // 次の頂点.
    int d;  // 距離.
    bool operator < (const edge &E) const { return d > E.d; }
};

int dist[101][101];    // 頂点(i, j) の 最短距離 を 保存.
vector<edge> graph[1001];

// https://ja.wikipedia.org/wiki/ダイクストラ法
// グラフを最良優先探索する.
// ※bfsの動作確認用.
// @param s: 今回探索する頂点番号.
// @return: 特に無し.
void dijkstra(int s) {
    
    // 1. 初期化.
    priority_queue<edge> pq;
    
    // 2. 始点設定.
    dist[s][s] = 0;
    pq.push({s, 0});

    // 3. キュー pq が 空になるまで, 探索.
    while(!pq.empty()){
        // 4. 探索を継続するために, 頂点を取得.
        int u = pq.top().to;
        int d = pq.top().d;
        pq.pop();
        
        // 5. より小さい距離が設定済みなら, Skip.
        if(dist[s][u] < d) continue;

        // 6. 各隣接する頂点について, 距離を確認し, 最短経路を更新.
        for(int i = 0; i < graph[u].size(); ++i){
            int nu = graph[u][i].to;
            int nd = d + graph[u][i].d;
            // 最短経路更新.
            if(dist[s][nu] > nd) dist[s][nu] = nd, pq.push({nu, nd});
        }
    }
}

int main() {

    // 1. 入力情報取得.
    scanf("%d %d", &N, &M);
    map<pair<int, int>, int> m; // 二頂点間の距離を保存.
    for(int i = 0; i < M; i++){
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        a--, b--;
        if(a > b) swap(a, b);
        graph[a].push_back({b, c});
        graph[b].push_back({a, c});
        m[{a, b}] = c;
    }
    
    // 2. 各二頂点間の最短経路を求める(ダイクストラ法).
    int ans = 0;
    for(int i = 0; i < 101; i++) for(int j = 0; j < 101; j++) dist[i][j] = INF;
    for(int i = 0; i < N - 1; i++){
        dijkstra(i);
        for(int j = i + 1; j < N; j++){
            // 始めに保存した二頂点間の距離が, 最短経路探索後の二頂点間の距離と異なっているのであれば, 
            // この辺は, 最短経路に含まれてないと判定.
            if(m[{i, j}] > 0 && m[{i, j}] != dist[i][j]) ans++;
            // printf("m[{%d, %d}]=%d dist[%d][%d]=%d\n", i, j, m[{i, j}], i, j, dist[i][j]);
        }
    }
    
    // 3. 出力 ～ 後処理.
    printf("%d\n", ans);
    return 0;
    
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define e1 first
#define e2 second
#define int int_fast32_t
#define uint uint_fast64_t
#define ll int_fast64_t
#define ull uint_fast64_t
#define int16 int_fast16_t
#define uint16 uint_fast16_t
#define int32 int_fast32_t
#define uint32 uint_fast32_t
#define int64 int_fast64_t
#define uint64 uint_fast64_t
#define ld long double
#define float long double
#define size(x) (int)x.size()
#define satori int testCases; cin>>testCases; while(testCases--)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define all(r) begin(r),end(r)
#define rall(r) rbegin(r),rend(r)
#define time chrono::high_resolution_clock().now().time_since_epoch().count()
#define elapsed(__begin,__end) (__end-__begin)/CLOCKS_PER_SEC
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
float pi=3.14159265358979323846;

int32_t main()
{
	fastio;
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	while(a>=b)
		b*=2,k--;
	while(b>=c)
		c*=2,k--;
	if(k>=0)
		cout<<"Yes";
	else
		cout<<"No";
}

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

class Program
{
    static void Main(string[] args)
    {
        var inputs1 = Console.ReadLine().Split(' ');
        var inputs2 = Console.ReadLine().Split(' ');

        var n = int.Parse(inputs1[0]);
        var k = int.Parse(inputs1[1]);
        var hs = inputs2.Select(i => int.Parse(i)).ToList();

        List<int> dp = new List<int>();
        dp.Add(0);
        for(int i = 1; i < n; i++)
        {
            var tmp = new List<int>();
            for(int j = 1; j <= k; j++)
            {
                if (i - j < 0) break;
                tmp.Add(dp[i - j] + Math.Abs(hs[i - j] - hs[i]));
            }
            dp.Add(tmp.Min());
        }

        Console.Write(dp.Last());


    }
}


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

#define ll long long
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0)
#define f first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pii pair<int, int>
#define all(x) x.begin(), x.end()

const int N = 3e3 + 144, mod = 1e9 + 7, inf = 1e9 + 7;
int dp[N][N];

ll bp(ll x, ll y){
    if(y == 0)
        return 1;
    if(y & 1)
        return (x * bp(x, y - 1));
    ll z = bp(x, y / 2);
    return (z * z) % mod;
}

int main(){
    boost;
    string st, sp;
    cin >> st >> sp;
    st = '!' + st;
    sp = '!' + sp;
    for(int i = 1; i < st.size(); i++){
        for(int j = 1; j < sp.size(); j++){
            if(st[i] == sp[j]){
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    int i = st.size() - 1, j = sp.size() - 1;
    string ans = "";
    while(dp[i][j] != 0){
        if(dp[i][j] == dp[i - 1][j]){
            i--;
        }else if(dp[i][j] == dp[i][j - 1]){
            j--;
        }else{
            ans += st[i];
            i--;
            j--;
        }
    }
    reverse(all(ans));
    cout << ans;
    return 0;
}



Measured memory_bytes: 37120
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;

int top, S[1000];

void push(int x) {
    S[++top] = x;
}

int pop() {
    return S[top--];
}

int main(){
    int a, b;
    top = 0;
    char s[100];

    while(scanf("%s", s) != EOF){
        if (s[0] == '+'){
            b = pop();
            a = pop();
            push(a + b);

        } else if ( s[0] == '-' ){
            b = pop();
            a = pop();
            push(a - b);

        } else if ( s[0] == '*' ){
            b = pop();
            a = pop();
            push(a * b);

        } else {
            push(atoi(s));
        }
    }
    printf("%d\n", pop());

    return 0;
}


Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000000+7;

int main(){
  ll N,K;cin>>N>>K;
  vector<ll>A(N);
  for(int i=0;i<N;i++) cin>>A.at(i);
  ll res=0;
  
  ll m=0; ll s=0;
  
  for(int i=0;i<N;i++){
    
    for(int j=0;j<N;j++){
      
      if(A.at(i)>A.at(j)){
        s++;
        if(i<j)
          m++;
      }
      s%=mod;
      m%=mod;
    }
  }
  
  cout<< (m*K%mod + K*(K-1)/2%mod*s%mod)%mod <<endl;
  //cout<<m<<endl<<s<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';

int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;


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

    int t=1,te=0;
    // cin>>t;
    while(t--){
        ll x,n,k,s=0ll;
        cin>>x>>n;

        for(ll i=1;i<=n;++i){
            cin>>k;
            s+=k;
        }

        if(s>=x){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }


        //printf("Case %d: ",++te);
    }
    return 0;
}

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vector<ll> A(N);
  vector<ll> B(N);
  
  for(int i = 0; i < N; i++){
    cin >> A[i] >> B[i];
  }
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  ll high,low;
  if(N%2 == 0){
    
    high = B[N/2]+B[-1+N/2];
    low =  A[N/2]+A[-1+N/2];
  }
  else{
    high = B[N/2];
    low =  A[N/2];
  }
  cout << high - low + 1 << endl;
  
}


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

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

    vector<int> vecPoint(n);
    for(int i=0; i<n; i++)
        cin >> vecPoint.at(i);
    
    int res = 0;
    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            res += vecPoint[i] * vecPoint[j];
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
 int main()
 {
 	
 	int i,j,k,n;
 	cin>>n>>k;
 	int ara[n],arr[k];
	 if(n==k)
	 {
	 	for(i=0;i<n;i++)
	 	cout<<n;
	 	return 0;
	 }
	 else if(n<k)
	 {
	 	for(i=0;i<k;i++)
	  cout<<n; 
	  return 0;
	  } 
	  else 
	  {
	  	for(i=0;i<n;i++)
	  	cout<<k;
	  	return 0;
		  }	
 	return 0;
 }

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	N := nextInt64()
	c := int64(0)

	for i := int64(1); i <= N; i++ {
		if i%5 != 0 && i%3 != 0 {
			c += i
		}
	}

	fmt.Println(c)
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 1788
using System;
using System.Linq;
using System.Collections.Generic;
public class Hello{
    public static void Main(){
        var r = double.Parse(Console.ReadLine());
        
        var c = Math.Round(r * 2 * Math.PI,6,MidpointRounding.AwayFromZero);
        var s = Math.Round(Math.Pow(r,2) * Math.PI,6,MidpointRounding.AwayFromZero);
        Console.WriteLine($"{s} {c}");
    }
}



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

int get_length(long long n)
{
    int counter = 0;
    while (n != 0) {
        counter++;
        n /= 10;
    }
    return counter;
}

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

    int answer = get_length(n);
    long long A, B;
    for (A = 1; A <= sqrt(n); ++A) {
        if (n % A != 0) continue;
        B = n / A;

        int cur = max(get_length(A), get_length(B));
        if (answer > cur) answer = cur;
    }
    cout << answer << endl;
    return 0;
}


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

#define rep(x, y) for (int i = (x); i < (y); i++)

typedef long long ll;

using namespace std;

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

    bool found = false;
    rep(1, 4) {
        if (a * b * i % 2 != 0) {
            found = true;
            break;
        }
    }

    cout << (found ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int sdkys(int a,int b){
    if(b==0) return a;
    return sdkys(b,a%b);
}
int sskbs(int a,int b){
    return a*b/sdkys(a,b);
}
int n,m,cnt=0,aa[220000],ans=0,ab[220000];
pair<int,int> pp[220000];
string s,sa[220000];
char ca[220000];
queue<int> que;
signed main(){
    cin>>n;
    rep(i,n){
        cin>>aa[i];
        cnt+=aa[i]-1;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 10460
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int A, B;

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

  cin >> A >> B;

  cout << max(0, A-(2*B)) << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n';
#define ll long long
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back

int main() {

   // IOS;
   /*ll n;
    cin>>n;
    string s;
   while(n>0){
     int x=(n%26);
     cout<<(char)(x+97);
     n/=2;
   }
   */
    int n;
    cin>>n;
    int a[n];
    int d=0;
    rep(i,0,n){cin>>a[i];
        d=d^a[i];
    }
    rep(i,0,n){
        int c=a[i]^d;
        cout<<c<<" ";
    }

    return 0;
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> ruiseki(n+1, 0);
    rep(i,n){
        ruiseki[i+1] = ruiseki[i] + a[i];
    }
    map<ll, ll> mp;
    for(i = 0;i <= n;++i){
        ++mp[ruiseki[i]];
    }
    ll ans = 0;
    for(auto x:mp){
        ll num = x.second;
        ans += num*(num-1)/2;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 18772
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	
	int ans = 0;
	for(int i = a; i <= b; i++)
	{
		vector<int> a;
		int tmp = i;
		while(tmp != 0)
		{
			a.push_back(tmp % 10);
			tmp /= 10;
		}
		
		bool flag = true;
		for(int j = 0; j < a.size() / 2; j++)
		{
			if(a[j] != a[a.size() - 1 - j])
			{
				flag = false;
				break;
			}
		}
		
		if(flag == true)
		{
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <climits>
#include <iostream>
#include <map>
#include <queue>

using namespace std;

const int MAX_N = 100000;

int N, T;
int A[MAX_N];
map<int, int, greater<int>> mp;

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

    cin >> N >> T;

    int minc = INT_MAX;

    for (int i = 0; i < N; i++) {
        cin >> A[i];
        minc = min(minc, A[i]);
        int bft = A[i] - minc;
        if (mp.count(bft)) {
            mp[bft]++;
        } else {
            mp.insert(make_pair(bft, 1));
        }
    }

    cout << mp.begin()->second << "\n";

    return 0;
}

Measured memory_bytes: 8684
#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 N;
  cin >> N;
  vector<int> W(N);
  rep(i, N) cin >> W[i];

  int ans = 1 << 30;
  int A, B;
  for (int T = 1; T < N; T++) {
    A = 0;
    B = 0;
    rep(i, T) A += W[i];
    rep(i, N - T) B += W[T + i];
    ans = min(ans, abs(A - B));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main(void) {
  int n, k, q, input;
  cin >> n >> k >> q;
  vector<int> a(n, k - q);
  rep(i, q) {
    cin >> input;
    a[input - 1]++;
  }
  rep(i, n) {
    if (a[i] > 0)
      cout << "Yes" << '\n';
    else
      cout << "No" << '\n';
  }
  return 0;
}

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

using namespace std;
 
 int main()
 {
  int d,s,t;
  cin>>d>>t>>s;
  int g=s*t;
  if(d<=g)
  cout<<"Yes"<<endl;
  
  else
  cout<<"No"<<endl;
  
     return 0;
 }

Measured memory_bytes: 3572
#include<stdio.h>
int main(){
int A,B,C,i;
scanf("%d%d%d",&A,&B,&C);
for(i=0;i<B;i++){
  if(A*(i+1) % B==C){
  printf("YES\n");
  break;
  }
if(i==B-1) printf("NO\n");
}
return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n;
  ll a[252521], b[252521];
  cin>>n;
  REP(i, n){
    cin>>a[i]>>b[i];
  }
  // vi ord(n);
  // iota(ALL(ord), 0);
  // sort(ALL(ord), [&a, &b](int x, int y){
  //   if(a[x]==a[y]) return b[x]<b[y];
  //   return a[x]<a[y];
  // });
  sort(a, a+n);
  sort(b, b+n);
  if(n&1){
    cout<<b[n/2]-a[n/2]+1<<'\n';
  }
  else{
    ll mi=(a[n/2]+a[n/2-1]);
    ll ma=(b[n/2]+b[n/2-1]);
    cout<<ma-mi+1<<'\n';
  }
  return 0;
}


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

typedef long long int ll;

ll a[100010], b[100010];

int main() {

	int n;

	cin >> n;
	for (int i = 0; i <= n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ll kill = min(a[i], b[i]);
		ans += kill;
		if (a[i] >= b[i]) {
			a[i] -= b[i];
			b[i] = 0;
		}
		else {
			b[i] -= a[i];
			kill = min(a[i + 1], b[i]);
			ans += kill;
			a[i + 1] = max(0LL, a[i + 1] - b[i]);
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdlib>
using namespace std;

int main(){

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



}


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

using namespace std;

int main()
{
    while (true) {
        int w, h;
        cin >> w >> h;
        if (w == 0 && h == 0) {
            return 0;
        }
        vector<vector<int>> v(h, vector<int>(w, -1));
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                cin >> v[i][j];
            }
        }
        constexpr int MIN_ID = 10;
        function<int(int, int, int)> f = [&v, &f, w, h, MIN_ID](int i, int j,
                                                                int id) {
            // ?????¢????¶???????
            if (i == -1 || j == -1 || i == h || j == w) {
                return 0;
            }
            // ?????§?????¶????±?????????????
            else if (MIN_ID <= v[i][j] && v[i][j] <= id) {
                return 0;
            }
            // ???
            else if (v[i][j] == 0) {
                return 0;
            }
            else {
                v[i][j] = id;
                int r = 1;
                r += f(i - 1, j - 1, id);
                r += f(i - 1, j, id);
                r += f(i - 1, j + 1, id);
                r += f(i, j - 1, id);
                r += f(i, j + 1, id);
                r += f(i + 1, j - 1, id);
                r += f(i + 1, j, id);
                r += f(i + 1, j + 1, id);
                return r;
            }
        };
        int islandId = MIN_ID;
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                auto r = f(i, j, islandId);
                if (r > 0) {
                    islandId += 1;
                }
            }
        }

        cout << (islandId - MIN_ID) << endl;
    }
}

Measured memory_bytes: 3552
import itertools


h, w, k = map(int, input().split())

if w == 1:
    print(1)
    exit()

mod = 10**9 + 7
path = [[i, i+1] for i in range(w-1)]
DP = [[0]*(h+1) for _ in range(w)]
DP[0][0] = 1

for height in range(h):
    for pos in range(w):
        down_unable = {pos}
        left_unable = {pos-1, pos}
        right_unable = {pos, pos+1}

        down_count = 1
        left_count = 1
        right_count = 1
        for pick in range(1, 1 + w//2):
            all_pattern = list(itertools.combinations(path, pick))

            for pattern in all_pattern:
                check = set()
                possible = True
                for a, b in pattern:
                    if check & {a, b}:
                        possible = False
                        break
                    check |= {a, b}
                if not possible:
                    continue
                if not check & down_unable:
                    down_count += 1
                if not check & left_unable:
                    left_count += 1
                if not check & right_unable:
                    right_count += 1

        if pos == 0:
            DP[pos][height+1] += DP[pos][height] * down_count % mod
            DP[pos+1][height+1] += DP[pos][height] * right_count % mod

        elif pos == w-1:
            DP[pos][height+1] += DP[pos][height] * down_count % mod
            DP[pos-1][height+1] += DP[pos][height] * left_count % mod
        else:
            DP[pos][height+1] += DP[pos][height] * down_count % mod
            DP[pos+1][height+1] += DP[pos][height] * right_count % mod
            DP[pos-1][height+1] += DP[pos][height] * left_count % mod

print(DP[k-1][h] % mod)


Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#include <chrono>
#include <random>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

struct Edge {
	int u, v, c;
	void read() {
		std::cin >> u >> v >> c;
		u--;v--;
	}
};

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n, m, p;
	std::cin >> n >> m >> p;
	std::vector<Edge> edges(m);
	for(int i = 0; i < m; i++) {
		edges[i].read();
		edges[i].c = p - edges[i].c;
	}
	const long long INF = 1e18;
	std::vector<long long> dist(n, INF);
	dist[0] = 0;
	for(int i = 0; i < n; i++) {
		for(auto e : edges) {
			dist[e.v] = std::min(dist[e.v], dist[e.u] + e.c);
		}
	}
	long long ans = dist[n-1];
	for(int i = 0; i < n; i++) {
		for(auto e : edges) {
			dist[e.v] = std::min(dist[e.v], dist[e.u] + e.c);
		}
	}
	if(ans == dist[n-1]) {
		ans = std::max(-ans, 0LL);
	} else {
		ans = -1;
	}
	std::cout << ans << '\n';
	
}

Measured memory_bytes: 384