akhauriyash/Code-Regression huggingface dataset:
import sys,collections as cl,bisect as bs,random
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""

d = onem()

c = l()

s = []
for i in range(d):
	s.append(l())
	s[-1] = [[s[-1][i]-c[i],i+1] for i in range(26)]
	s[-1].sort(reverse = True)
	print(s[-1][random.randrange(1,5)-1][1])



	


Measured memory_bytes: 77944
n,k = map(int,input().split())
h_L = list(map(int,input().split()))


#dp = [float("inf")] * (20)
dp = [float("inf")] * (10**5 + 1)
dp[0] = 0

for i in range(n):
    for j in range(1,k+1):
        #print(j,i+j)
        # i=1,j=1
        if i - j < 0:
            continue
        dp[i] = min(dp[i],dp[i-j]+abs(h_L[i] - h_L[i-j]))
        #print(i,j)
        #print(dp)

print(dp[n-1])

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

int main() {

  string t;
  cin >> t;
  
  for(int i = 0;i < t.size();i++){
    if(t.at(i) == '?'){
      t.at(i) = 'D';
    }
  }
  
  cout << t;
  
}


Measured memory_bytes: 3724
import numpy as np
N, M = map(int, input().split())
al = list(map(int, input().split()))
sums = sum(al)
al.sort(reverse=True)
al = np.array(al)[:M]
al = np.sum(al>=(sums/(4*M)))
if al == M:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14032
'''A - Weather Prediction
https://atcoder.jp/contests/abc141/tasks/

>>> main('Sunny')
Cloudy
>>> main('Rainy')
Sunny'''


def main(s):
    if s == 'Sunny':
        print('Cloudy')
    if s == 'Cloudy':
        print('Rainy')
    if s == 'Rainy':
        print('Sunny')


if __name__ == "__main__":
    s = input()
    main(s)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
int gcd(int a,int b){if(a<b)swap(a,b);int c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  string s; cin >> s;
  vector<int> c;
  bool now = 0;
  int k = 0;
  rep(i, s.size()){
    if(now){
      if(s[i] == '0'){
        c.pb(k);
        k = 1;
        now = 0;
        // cout << i <<" "<< k << endl;
      }else k++;
    }else{
      if(s[i] == '1'){
        c.pb(k);
        k = 1;
        now = 1;
        // cout << i <<" "<< k << endl;
      }else k++;
    }
  }
  c.pb(k);
  if(!now) c.pb(0);

  // rep(i, c.size())
  // cout << c[i] << endl;
  int sum = 0;
  int c0 = 0;
  int c1 = 0;
  for(int i = 0; i < c.size(); i += 2){
    c[i] += c0;
    c0 = 0;
    if(c[i] < c[i + 1]){
      sum += c[i] * 2;
      c1 += c[i + 1] - c[i];
    }else{
      sum += c[i + 1] * 2;
      c0 += c[i] - c[i + 1];
    }
    // cout << c0 <<" "<< c1 <<" "<< sum << endl;
  }
  sum += 2 * min(c0, c1);
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define MAX 100005
#define bit(x) (1ll << x)

using namespace std;

int n;
int cnt[64];
long long a[MAX], ans;

inline long long Rd() {
	long long x = 0; char ch = getchar();
	while(!isdigit(ch)) ch = getchar();
	while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
	return x;
}

struct linear_base {
	long long u[60];
	inline void insert(long long val) {
		for(int i = 59; i >= 0; --i) {
			if(val & bit(i)) {
				if(u[i]) val ^= u[i];
				else {
					u[i] = val;
					return;
				}
			}
		}
	}
	inline long long query() {
		long long res = 0;
		for(int i = 59; i >= 0; --i)
			if((res ^ u[i]) > res) res ^= u[i];
		return res;
	}
}lsk;

int main() {
	n = Rd();
	for(int i = 1; i <= n; ++i) {
		a[i] = Rd();
		for(int j = 59; j >= 0; --j)
			if(a[i] & bit(j)) ++cnt[j];
	}
	
	for(int i = 59; i >= 0; --i) {
		if(cnt[i] & 1) {
			ans += bit(i);
			for(int j = 1; j <= n; ++j) {
				if(a[j] & bit(i)) {
					a[j] ^= bit(i);
				}
			}
		}
	}
	for(int i = 1; i <= n; ++i) lsk.insert(a[i]);

	cout << ans + 2ll * lsk.query() << endl;
	return 0;
}

Measured memory_bytes: 1024
a = []
b = []
n = gets.chomp.to_i
b = gets.chomp.split(" ").map(&:to_i)

bl = n-1

for i in 0...bl do
  if i ==0
    a[i]=a[i+1]=b[i]
  end

  if b[i]<a[i]
    a[i]=a[i+1]=b[i]
  else
    a[i+1]=b[i]
  end
end

puts a.inject(:+)


Measured memory_bytes: 1788
// ConsoleApplication1.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
#define show(ans) cout << ans << endl
const long MOD = 1000000007;

//long tonum(string x) {
//	if (x == "") {
//		return 0;
//	}
//	else {
//		return stoll(x);
//	}
//}
string tost(long x) {
	if (x == 0) {
		return "";
	}
	else return to_string(x);
}
bool check(string a, string b) {
	if (a.length() > b.length()) return true;
	else if (a.length() < b.length()) return false;
	else {
		if (a >= b) return true;
		else return false;
	}
}

int main() {
	long N;
	long M;
	long ans;
	cin >> N;
	cin >> M;
	vector<long> a(M + 1);
	vector<long> num = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
	vector<string> dp(10001, "");
	erep(i, M) {
		cin >> a[i];
	}
	erep(i, M) {
		//dp[num[a[i]]] = max(dp[num[a[i]]], tost(a[i]));
		dp[num[a[i]]] = (check(dp[num[a[i]]], tost(a[i]))) ? dp[num[a[i]]] : tost(a[i]);
	}
	rep(i, 10001) {
		erep(j, M) {
			if (i >= num[a[j]] && dp[i-num[a[j]]] != "") {
				string tmpmax = (check(dp[i - num[a[j]]] + tost(a[j]), tost(a[j]) + dp[i - num[a[j]]])) ? dp[i - num[a[j]]] + tost(a[j]) : tost(a[j]) + dp[i - num[a[j]]];
				dp[i] = (check(dp[i], tmpmax)) ? dp[i] : tmpmax;
				//long maxforward = tonum(dp[i - num[a[j]]] + tost(a[j]));
				//long maxback = tonum(tost(a[j]) + dp[i - num[a[j]]]);
				//long tmpmax = max(maxforward, maxback);
				//dp[i] = tost(max(tonum(dp[i]), tmpmax));
			}
		}
	}
	//rep(i, 102) {
	//	show(dp[i]);
	//}
	show(dp[N]);


	//string b = "12";
	// c = 
	//show(stoll(b)+3);
	return 0;

}
// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 33920
import math

n=int(input())

dic={}
for i in range(n):
    s=''.join(sorted(input()))
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1

ans=0
for n in dic.values():
    if n>1:
        ans += math.factorial(n) // (math.factorial(n-2) * math.factorial(2))


print(ans)


Measured memory_bytes: 17848
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG 
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, s, n) for (int i = s; i < n; i++)
#define all(v) v.begin(), v.end() // sort(all(array))
#define INF 1000000000
#define mod 1000000007
using namespace std;
using ll = long long;
using vi = vector<int>; //vi array(要素数, 初期値)
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>; //vvi table(行数, vi(列数, 初期値))
using vvc = vector<vc>;
using vvs = vector<vs>;
using vvb = vector<vb>;

int main() {
    int d, t, s; cin >> d >> t >> s;
    if (t * s >= d) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    int N, K;
    cin >> N >> K;

    int ans = K;
    rep(i, N-1) ans *= K - 1;

    cout << ans << endl;
}

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

int main() {
    vector<int> t(2);
    int k, ans;
    rep(i, 2) {
        int h, m;
        cin >> h >> m;
        t.at(i) = h * 60 + m;
    }
    cin >> k;
    ans = t.at(1) - t.at(0) - k;
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long 
#define ull unsigned long long 
#define f(i,x,n) for(ll int i=x;i<n;i++) 
#define re(j,x,n) for(ll int j=x;j>=n;j--)
#define f1(k,x,n) for(ll int k=x;k<=n;k++)
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define MAX 1000001
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll int n;
    cin>>n;
    string s,s1;
    cin>>s;
    f(i,1,n)
    {
      if(s[i]!=s[i-1])
      {
      	s1+=s[i-1];
      }
    }
    if(s1.size()!=0)
    cout<<s1.size()+1;
    else
    cout<<1;
}

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

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

int main() {
  int n;
  cin >> n;
  vector <int> v(n);
  int64_t ans = 0;
  rep(i, n) {
    cin >> v.at(i);
    ans += v.at(i);
  }
  int m;
  cin >> m;
  rep(i, m) {
    int p, x;
    cin >> p >> x;
    int tmp = ans;
    tmp -= v.at(p-1);
    tmp += x;
    cout << tmp << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, std::vector<long long> A, std::vector<long long> B){
  multimap<ll,ll> m;
  REP(B.size()){
    if(B[i]!=A[i]){
    m.insert(make_pair(B[i],i));
    }
  }
  REP(N){
    if(A[i]>B[i]){
      cout<<-1<<endl;
      return;
    }
  }
  ll ans=0;
  while(!m.empty()){
    ll tmp=m.rbegin()->second;
    m.erase(prev(m.end()));
    if(A[tmp]==B[tmp])continue;
    if(A[tmp]<B[tmp]){
      ll mx=B[(tmp+1)%N]+B[(tmp+N-1)%N];
      if(mx>B[tmp]){
        if(A[tmp]!=B[tmp]){
          cout<<-1<<endl;
          return;
        }
        continue;
      }
      if(A[tmp]>B[tmp]%mx){
        if((B[tmp]-A[tmp])%mx!=0){
          cout<<-1<<endl;
          return;
        }
        ans+=(B[tmp]-A[tmp])/mx;
        B[tmp]=A[tmp];
        continue;
      }
      ans+=B[tmp]/mx;
      B[tmp]%=mx;
      if(A[tmp]>B[tmp]){
        cout<<-1<<endl;
        return ;
      }
      if(A[tmp]!=B[tmp]){
        m.insert(make_pair(B[tmp],tmp));
      }
    }else{
      cout<<-1<<endl;
      return;
    }
  }
  cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&B[i]);
    }
    solve(N, std::move(A), std::move(B));
    return 0;
}


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

namespace AtCoder.Abc
{
    class QuestionE
    {
        public class XY : IEquatable<XY>
        {
            public int X;
            public int Y;

            public override bool Equals(object obj)
            {
                return this.Equals(obj as XY);
            }

            public bool Equals(XY p)
            {
                if (Object.ReferenceEquals(p, null)) {
                    return false;
                }

                if (Object.ReferenceEquals(this, p)) {
                    return true;
                }

                if (this.GetType() != p.GetType()) {
                    return false;
                }

                return (X == p.X) && (Y == p.Y);
            }
            public static bool operator ==(XY lhs, XY rhs)
            {
                // Check for null on left side.
                if (Object.ReferenceEquals(lhs, null)) {
                    if (Object.ReferenceEquals(rhs, null)) {
                        // null == null = true.
                        return true;
                    }

                    // Only the left side is null.
                    return false;
                }
                // Equals handles case of null on right side.
                return lhs.Equals(rhs);
            }

            public static bool operator !=(XY lhs, XY rhs)
            {
                return !(lhs == rhs);
            }

            public override int GetHashCode()
            {
                return X * 0x1000 + Y;
            }
        }

        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var dic = new Dictionary<XY, long>();

            dic.Add(new XY(), 0);

            // 整数の入力
            var n = long.Parse(Console.ReadLine());

            var xy = new XY[n];

            for(int i = 0; i < n; i++) {
                // 整数配列の入力
                var a = Console.ReadLine().Split(' ').Select(q => long.Parse(q)).ToArray();
                xy[i] = new XY { X = (int)a[0], Y = (int)a[1] };
            }

            foreach(var q in xy) {
                foreach (var w in xy) {
                    if(q.Equals(w)) {
                        continue;
                    }

                    var aa = q.X - w.X;
                    var bb = q.Y - w.Y;

                    var d = new XY { X = aa, Y = bb };

                    if (dic.ContainsKey(d)) {
                        dic[d]++;
                    } else {
                        dic[d] = 1;
                    }
                }
            }

            var max = dic.Max(x => x.Value);

            var result = n - max;

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13664
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

int main() {
    char A;
    cin >> A;
    cout << char(A + 1) << endl;
}


Measured memory_bytes: 3588
# E - Knapsack 2
from collections import defaultdict


def main():
    INF = 1 << 30
    N, W, *WV = map(int, open(0).read().split())
    dp = defaultdict(lambda: INF)  # dp[i] := minimum weight at value i
    dp[0] = 0
    for w, v in zip(*[iter(WV)] * 2):
        for cur_v, cur_w in tuple(dp.items()):
            if w + cur_w <= W:
                dp[v + cur_v] = min(dp[v + cur_v], w + cur_w)
    print(max(dp.keys()))


if __name__ == "__main__":
    main()


Measured memory_bytes: 69084
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7+1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define ll long long int
typedef vector<ll> vi;
typedef vector < pair<int, int > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
//ll n, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

ll fun(ll a,ll b,ll c)
{
	return max(max(a, b), max(b, c)) - min(min(a, b), min(b, c));
}

int main()
{
	int a, b;
	cin >> a >> b;
	string s[101];
	REP(i,a)
	{
		cin >> s[i];
	}
	REP(i,b+2)
	{
		cout << '#';
	}
	cout << endl;
	REP(i,a)
	{
		cout << '#' << s[i] << '#' << endl;;
	}
	REP(i, b + 2)
	{
		cout << '#';
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int abs(int x)
{
	return x > 0 ? x : -x;
}

int main(void)
{
	int n, i, sum = 0;
	int h[102];
	
	scanf("%d", &n);
	
	h[0] = h[n+1] = 0;
	for (i = 1; i <= n; i++)
		scanf("%d", &h[i]);
	
	for (i = 0; i <= n; i++)
		sum += abs(h[i]-h[i+1]);
	
	printf("%d", sum/2);
	
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>

using namespace std;

int x[50];
long long dp[2][51][2501];

int main() {
    int n, a, i, j, k;
    long long ans = 0;
    
    scanf("%d %d", &n, &a);
    
    for (i = 0; i < n; i++) scanf("%d", &x[i]);
    
    dp[0][0][0] = 1;
    
    for (i = 0; i < n; i++) {
        for (j = 0; j <= i; j++) {
            for (k = 0; k <= i * 50; k++) {
                if (dp[0][j][k] == 0) continue;
                
                dp[1][j][k] += dp[0][j][k];
                dp[1][j + 1][k + x[i]] += dp[0][j][k];
            }
        }
        
        for (j = 0; j <= i + 1; j++) {
            for (k = 0; k <= (i + 1) * 50; k++) {
                dp[0][j][k] = dp[1][j][k];
                dp[1][j][k] = 0;
            }
        }
    }
    
    for (i = 1; i <= n; i++) ans += dp[0][i][a * i];
    
    printf("%lld\n", ans);
    
    return 0;
}


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

const ll MAX = 1000000;
const ll MOD = 1000000007;

ll fac[MAX];

// テーブルを作る前処理
/*
void COMinit() {
    fac[0] = fac[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
    }
}
*/

ll pow_kai(ll a,ll n){//aのn乗を計算します。
  ll x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a%MOD;
    }
    a = a*a%MOD;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    ll tmp=1;
    for(ll i=n;i>=n-k+1;i--) tmp = (tmp*i)%MOD;

    return (tmp * pow_kai(fac[k],MOD-2)) % MOD;
}




int main()
{
    ll X,a,b;

    cin >> X;

    a=X/500;

    X=X%500;

    b=X/5;

    cout << a* 1000+b*5<<endl;

 
    return 0;

}

Measured memory_bytes: 256
/*
	Created by Faisal Ahmed
*/

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef long double ld;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	string a, b;
	
	cin >> a >> b;
	
	cout << b + a << endl;
	
	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() {
  string s;
  cin >> s;
  string ans = "No";
  rep(i,3){
    if(s[i]=='7')
      ans = "Yes";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a[20], b[20], c[20];
    int i, j;
    cin >> a >> b >> c;

    printf("%c%c%c\n", a[0]-32, b[0]-32, c[0]-32);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int N,K;
  cin>>N>>K;
  long long int arr[N];
  int i;
  long long int sum=0;
  for(i=0;i<N;i++)
 	cin>>arr[i];
  sort(arr,arr+N);
  for(i=0;i<(N-K);i++)
  {
     sum=sum+arr[i];
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 1920
use std::io;
use std::str::FromStr;
use std::f64::consts;

fn input_f64_tuple() -> (f64, f64, f64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<f64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1], vec[2])
}

fn main() {
    let (a, b, x) = input_f64_tuple();
    let s = x / a;
    if s >= a * b / 2f64 {
        let tangent = ((b - s / a) * 2f64) / a;
        println!("{}", tangent.atan() / consts::PI * 180f64);
    } else {
        let tangent = b / (s / b * 2f64);
        println!("{}", tangent.atan() / consts::PI * 180f64);
    }
}


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

typedef long long ll;

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

    ll x,ans;
    cin >> x;
    if(x<=6) ans = 1;
    else{
        ll uku = x / 11;
        if(uku==0) ans = 2;
        else{
            if(x%11==0) ans = 2 * uku;
            else if(x%11<=6) ans = 2 * uku + 1;
            else ans = 2 * uku + 2;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {

    vector<int> vec(3);
    rep(i, 3){
        cin >> vec.at(i);
    }
    sort(vec.begin(), vec.end());
    rep(i, 3){
        cout << vec.at(i);
        if(i < 2) cout << " ";
    }
    cout << endl;

}


Measured memory_bytes: 3132
def main():


   N,X = map(int,input().split())
   dList = [int(input()) for _ in range(N)]
   atLeast = len(dList)
   atMin = min(dList)
   atMinNum = (X-sum(dList))//atMin
   print(atMinNum + atLeast)




if __name__== "__main__":
    main() 



Measured memory_bytes: 2940
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val ss = in.readLine().split("\\s+")

    out.println(s"A${ss(1)(0)}C")

    out.flush()
  }
}


Measured memory_bytes: 25420
import sys
import numpy as np
from numba import njit

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

@njit('(i4[::1],i4,i8[::1])', cache=True)
def main(A, B, C):
    counts = np.zeros(1 << 18, np.int32)
    popcount = np.zeros(1 << B, np.int32)
    for i in range(B):
        popcount[1 << i:1 << i + 1] = popcount[:1 << i] + 1

    answer = 0
    for i in range(1 << B):
        k = popcount[i]
        t = 0
        for x in A & i:
            n = counts[x]
            counts[x] += 1
            t -= C[n]
            t += C[n + 1]
        for x in A & i:
            counts[x] = 0
        if k & 1:
            t = -t
        answer += t
    return answer
  
if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('main', '(i4[::1],i4,i8[::1])')(main)
    cc.compile()
    exit()
from my_module import main

N, K, S, T = map(int, readline().split())
A = np.array(readline().split(), np.int32)

def convert_problem(S, T, A):
    ng = np.zeros(len(A), np.bool)
    B = np.zeros_like(A)
    n = 0
    for i in range(18):
        s, t = (S >> i) & 1, (T >> i) & 1
        if (s, t) == (0, 0):
            ng |= ((A >> i) & 1) == 1
        elif (s, t) == (1, 1):
            ng |= ((A >> i) & 1) == 0
        elif (s, t) == (1, 0):
            print(0)
            exit()
        else:
            B += ((A >> i) & 1) << n
            n += 1
    return B[~ng], n

A, B = convert_problem(S, T, A)

C = np.zeros((100, 100), np.int64)
C[0, 0] = 1
for n in range(1, 100):
    C[n, :-1] += C[n - 1, :-1]
    C[n, 1:] += C[n - 1, :-1]
C = C[:, 1:K + 1].sum(axis=1)

print(main(A, B, C))

Measured memory_bytes: 110580
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;
 
#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
 
const ll MAX_N = 100000;
 
int main(void){
    ll a, b;//,c,d;
    string S;
    //cin >> S;
    cin >> a>>b;//>>c>>d;
    
    if ((a+b)%2==0) cout << (a+b)/2 <<endl;
    else cout << (a+b)/2 + 1<<endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 1000000007;

     signed main(){
    int h,w,a,b;
    cin>>h>>w>>a>>b;
    if(h%a==0&&w%b==0){
         cout<<"No"<<endl;
         return 0;
    }
    cout<<"Yes"<<endl;
    int ans[h+1][w+1];
    for(int i=0;i<h+1;i++)for(int j=0;j<w+1;j++){
         if(i>=a&&j>=b)ans[i][j]=ans[i][j-b]+ans[i-a][j]-ans[i-a][j-b]-1;
         else ans[i][j]=0;
    }
    int p=ans[h][w]-1;
    if(w%b)for(int j=w;j>=0;j-=b)ans[h][j]-=p;
    else for(int i=h;i>=0;i-=a)ans[i][w]-=p;
    for(int i=1;i<=h;i++){
         for(int j=1;j<=w;j++){
               
                    cout<<ans[i][j]+ans[i-1][j-1]-ans[i][j-1]-ans[i-1][j]<<' ';
              
         }
          cout<<endl;
    }
   
    




    }





      

        


Measured memory_bytes: 2816
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(b == 1) {
            System.out.println(0);
            return;
        }
        int count = a;
        int i = 1;
        for(; i<=20; i++) {
            if(b <= count) {
                break;
            }
            else {
                count += a - 1;
            }
        }
        System.out.println(i);
    }
}

Measured memory_bytes: 35704
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const MAX_LEN = 3010;
ll dp[MAX_LEN][MAX_LEN];

int main() {
  string s, t;
  cin >> s >> t;
  ll len_s = s.length();
  ll len_t = t.length();
  ll INF = 1LL << 60;
  for (int i = 0; i < len_s; i++) {
    for (int j = 0; j < len_t; j++) {
      dp[i][j] = -INF;
    }
  }
  for (int i = 0; i < len_s; i++) {
    for (int j = 0; j < len_t; j++) {
      if (i == 0 || j == 0) {
        dp[i][j] = (s[i] == t[j]) ? 1 : 0;
        if (i > 0) dp[i][j] = max(dp[i][j], dp[i - 1][j]);
        if (j > 0) dp[i][j] = max(dp[i][j], dp[i][j - 1]);
      } else {
        if (s[i] == t[j])
          dp[i][j] = dp[i - 1][j - 1] + 1;
        else
          dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
      }
    }
  }
  int len = dp[len_s - 1][len_t - 1];
  ll index_s = len_s - 1;
  ll index_t = len_t - 1;
  string ans(len, 'x');
  while (len > 0) {
    // cout << len << "," << index_s << "," << index_t << endl;
    if (s[index_s] == t[index_t]) {
      ans[len - 1] = s[index_s];
      index_s--;
      index_t--;
      len--;
    } else if (index_s > 0 &&
               dp[index_s][index_t] == dp[index_s - 1][index_t]) {
      index_s--;
    } else if (index_t > 0 &&
               dp[index_s][index_t] == dp[index_s][index_t - 1]) {
      index_t--;
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

vector<vector<ll>> dynamic_programing(ll n, ll t, vector<P> menu) {
    vector<vector<ll>> dp(n + 1, vector<ll>(t + 1, -1));
    dp[0][0] = 0;

    auto get = [&](ll i, ll j) {
        return dp[i][j];
    };

    auto set = [&](ll i, ll j, ll v) {
        if (i > n) return;
        if (j > t) return;
        ll value = get(i, j);
        dp[i][j] = max(value, v);
    };

    for (ll i = 0; i < n; i++) {
        P p = menu[i];
        for (ll j = 0; j <= t; j++) {
            ll prev = get(i, j);
            if (prev == -1) continue;
            set(i + 1, j + p.first, prev + p.second);
            set(i + 1, j, prev);
        }
    }
    for (ll i = 0; i <= n; i++) {
        assert(dp[i][0] == 0);
        for (ll j = 1; j <= t; j++) {
            dp[i][j] = max(dp[i][j], dp[i][j - 1]);
        }
    }
    return dp;
}

int main() {
    ll n, t;
    cin >> n >> t;

    vector<P> menu(n);
    rep(i, n) cin >> menu[i].first >> menu[i].second;

    vector<vector<ll>> dp1 = dynamic_programing(n, t - 1, menu);
    reverse(menu.begin(), menu.end());
    vector<vector<ll>> dp2 = dynamic_programing(n, t - 1, menu);
    reverse(menu.begin(), menu.end());

    ll ans = 0;
    for (ll i = 0; i < n; i++) {
        assert(i < dp1.size());
        ll i2 = n - i - 1;
        assert(i2 < dp2.size());
        assert(i + i2 == n - 1);
        // i を最後にとっておいた場合の
        for (ll bj = 0; bj <= t - 1; bj++) {
            ll aj = t - bj - 1;
            assert(bj < dp1[i].size());
            assert(aj < dp2[i].size());
            assert(aj + bj == t - 1);
            ll bh = dp1[i][bj];
            ll ah = dp2[i2][aj];
            assert(bh >= 0);
            assert(ah >= 0);
            ll lh = menu[i].second;
            ll now = bh + ah + lh;
            cmax(ans, now);
        }
    }

    cout << ans << endl;

}

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

int main(){
  int n,l,k=0;
  cin >> n >> l;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    a.at(i)=l+i;
    k+=a.at(i);
  }
  
  int x;
  if(a.at(0)>=0)
    x=a.at(0);
  else if(a.at(n-1)<=0)
    x=a.at(n-1);
  else
    x=0;
  
  cout << k-x << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
#include <set>
#include <string>
#include <bitset>
#include <fstream>
#include <stack>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

ll mod = 1000000007;
const ll INF = 100000000000010000;
//const ull B = 998244353;
//ll kai[3010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }

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

void chmin(ll& x, ll y) {
	x = min(x, y);
}

void chmax(ll& x, ll y) {
	x = max(x, y);
}

ll pow_long(ll x, ll y) {
	ll res = 1;
	while (y > 0) {
		if (y % 2 == 1) res *= x;
		x *= x;
		y /= 2;
	}
	return res;
}

void test() {
	cout << "888888888888888888888888" << endl;
}

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll k) {
	x %= mod;
	ll res = 1;
	while (k > 0) {
		if (k % 2) {
			res *= x; res %= mod;
		}
		x *= x; x %= mod;
		k /= 2;
	}
	return res;
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

//コンビネーション
const int MAXcomb = 1000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAXcomb; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
ll comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * finv[k] % mod * finv[n - k] % mod;
}

vector <ll> par; // 各元の親を表す配列
vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

void init_u(ll sz_) {
	par.resize(sz_);
	siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
	for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
}

string S;
ll a, b;

void solve() {
	cin >> S;
	rep(i, 3) {
		if (S[i] == 'A') a++;
	}
	if (a == 0 || a == 3) cout << "No" << endl;
	else cout << "Yes" << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll T = 1;
	//cin >> T;
	rep(i, T) solve();
}


Measured memory_bytes: 256
import sys
import math
n,m = map(int,input().split())
max = max(n,m)
min = min(n,m)
total = n+m
f_n = math.factorial(n)
f_m = math.factorial(m)
if max - min >= 2:
	print(0)
	sys.exit()
if total%2 == 0:
	ans = f_n*f_m*2
else:
	ans = f_n*f_m
if ans > 10**9+7:
	print(ans%(10**9+7))
else:
	print(ans)

Measured memory_bytes: 10964
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
int N, M, k;
int a[1500], A[1500000], b[1500], B[1500000];
int s;
int main()
{
	while(cin >> N >> M && N*M!=0)
	{
		for(int i=1; i<=1500000; i++)
		{
			A[i]=0;
			B[i]=0;
		}
		a[0]=0;
		b[0]=0;
		s=0;
		for(int i=1; i<=N; i++)
		{
			cin >> k;
			a[i]=a[i-1]+k;
			for(int j=0; j<i; j++)
			{
				A[a[i]-a[j]]+=1;
			}
		}
		for(int i=1; i<=M; i++)
		{
			cin >> k;
			b[i]=b[i-1]+k;
			for(int j=0; j<i; j++)
			{
				B[b[i]-b[j]]+=1;
			}
		}
		for(int i=1; i<=1500000; i++)
		{
			s+=A[i]*B[i];
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 12888
#include <iostream>
using namespace std;
typedef long long ll;
ll N,M;

int main(){
	cin >> N >> M;
	if(2*N>=M){
		cout << M/2 << endl;
	}else{
		ll t = N;
		M -= 2*N;
		cout << t + M/4 << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include<math.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; }

int main()
{
    int H, W, K;
    cin >> H >> W >> K;
    vector<string>masu(H);
    for (int i=0; i<H; i++) {
        cin >> masu[i];
    }

    int64_t count = 0;
    for (int h=0; h<(1<<H); h++) {
        for (int w=0; w<(1<<W); w++) {
            int black = 0;
            for (int i=0; i<H; i++) {
                for (int j=0; j<W; j++) {
                    if ((h >> i & 1) == 0 && (w >> j & 1) == 0) {
                        if (masu[i][j] == '#') black += 1;
                    }
                }
            }

            if (black == K) count += 1;
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;

// to container
template <class C>
void input(C &c)
{
    for_each(c.begin(), c.end(), [](auto &i) { cin >> i; });
}

// to number, string
template <class T>
T input()
{
    T data;
    cin >> data;
    return data;
}

int main()
{
    ll N = input<ll>();
    auto compare = [](pll a, pll b) {
        return a.second >= b.second;
    };

    priority_queue<pll, vector<pll>, decltype(compare)> q(compare);
    for (ll i = 0; i < N; i++)
    {
        ll a = input<ll>(), b = input<ll>();
        q.push(pll(a, b));
    }

    ll t = 0;
    while (!q.empty())
    {
        pll task = q.top();
        t += task.first;
        q.pop();
        if (t > task.second)
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 6256
#include<iostream> 
#include<string>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<sstream>
using namespace std;
 
#define sf scanf
#define pf printf
#define pfn printf("\n");
#define pfk printf(" ");
#define pf0 printf("0");
#define pf1 printf("1");
#define ll long long
#define sfd(n) scanf("%d",&n);
#define sfdd(n,m) scanf("%d%d",&n,&m);
#define sfld(n) scanf("%lld",&n);
#define sfldd(n,m) scanf("%lld%lld",&n,&m);
#define sflf(n) scanf("%lf",&n);
#define sflff(n,m) scanf("%lf%lf",&n,&m);
#define sfc(n) scanf("%c",n);
#define sfcc(n,m) scanf("%c%c",n,m);
#define sfs(n) scanf("%s",n);
#define sfss(n,m) scanf("%s%s",n,m);
#define pfd(n) printf("%d",n);
#define pfld(n) printf("%lld",n);
#define pflf(n) printf("%lf",n);
#define pfc(n) printf("%c",n);
#define pfs(n) printf("%s",n);
 
#define csh(a,n) memset(a,n,sizeof(a));
int arr[210000];
int brr[210000][2];
queue<int>qu[210000];
bool crr[210000];
map<pair<int,int>,int>mp;
pair<int,int>pa;
void fff(int a,int c){
	int n=qu[a].size();
	int count=1;
	for(int i=0;i<n;i++){
		int p=qu[a].front();
		qu[a].pop();
		if(!crr[p]){
			crr[p]=1;
			if(c==count){
				count++;
			}
			pa.first=a;
			pa.second=p;
			mp[pa]=count;
			pa.first=p;
			pa.second=a;
			mp[pa]=count;
			fff(p,count);
			count++;
		}
	}
}
int main(){
	int n;
	cin>>n;
	for(int i=1;i<n;i++){
		sfdd(brr[i][0],brr[i][1])
		arr[brr[i][0]]++;
		arr[brr[i][1]]++;
		qu[brr[i][0]].push(brr[i][1]);
		qu[brr[i][1]].push(brr[i][0]);
	}
	int max=0;
	int maxi;
	for(int i=0;i<=n;i++){
		if(arr[i]>max){
			max=arr[i];
			maxi=i;
		}
	}
	cout<<max<<endl;
	crr[maxi]=1;
	fff(maxi,0);
	for(int i=1;i<n;i++){
		pa.first=brr[i][0];
		pa.second=brr[i][1];
		pfd(mp[pa])
		pfn
	}
}

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

#define mod 1000000007

// F_mod 上でのべき乗, 蟻本p115
ll modPow(ll x, ll n) {
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

// Fermat の小定理を用いた F_mod 上での逆元計算x^(mod-2)
ll Inverse(ll x){
    return modPow(x, mod - 2);
}

// iの階乗 = fact[i], main内の階乗計算をする必要がある
#define MAX_FACT 100001
ll fact[MAX_FACT];

int main() {
    int N;
    cin >> N;
    vector<ll>A(N+1);
    for (int i = 1; i <= N; ++i) {
        cin >> A[i];
    }

    // 階乗計算
    fact[0]=1;
    for(int i = 1; i < MAX_FACT; ++i) {
        fact[i] = fact[i-1] * i % mod;
    }
    
    // 1/i の累積和
    vector<ll>cuSum(N+1, 0);
    for (int i = 1; i <= N; ++i) {
        cuSum[i] = (cuSum[i-1] + Inverse(i)) % mod;
    }

    ll ans = 0;
    for (int i = 1; i <= N; ++i) {
        ans += A[i] * (cuSum[i] + cuSum[N-i+1] + mod - 1);
        ans %= mod;
    }
    ans = ans * fact[N] % mod;
    cout << ans;
    return 0;
}

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

int main(){
  int N, K; cin >> N >> K;
  int h[100010];
  int res = 0;
  for(int i = 0; i < N; i++){
    cin >> h[i];
    if(h[i] >= K) res++;
  }
  cout << res << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

  int n, k, h[100010];
  cin >> n >> k;
  int ans=0;
  for(int i=0; i<n; i++){
    cin >> h[i];
    if(k<=h[i]){
      ans++;
    }
  }
  cout << ans << endl;

	return 0;
}

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

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(ll it=0;it<n;it++) cout<<a[it]<<" ";cout<<endl;
#define pcont(a)                     for(auto it:a) cout<<it<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

/*constants*/
#define MAXN                         100005
#define PI                           3.14159265358979323846

/*debug*/
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>void __f(const char* name, Arg1&& arg1){ std::cout << name << " : " << arg1 << '\n';}
    template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ','); std::cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

using namespace std;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	ll i,j,n,m,k,cnt=0,ans=0,t=1;
	string s;
	cin>>s;
	n=s.length();
	rep(i,0,n){
		if(s[i]=='A'|| s[i]=='T' || s[i]=='C' || s[i]=='G') cnt++;
		else cnt=0;
		ans=max(ans,cnt);
	}	
	ret(ans)
	return 0;
}

Measured memory_bytes: 256
from sys import setrecursionlimit, exit
setrecursionlimit(1000000000)

from heapq import heapify, heappush, heappop, heappushpop, heapreplace
from bisect import bisect_left, bisect_right

from math import atan, degrees

n, m = map(int, input().split())
a = [int(x) // 2 for x in input().split()]

t = 0
while a[0] % 2 == 0:
    a[0] //= 2
    t += 1

for i in range(1, n):
    t2 = 0
    while a[i] % 2 == 0:
        a[i] //= 2
        t2 += 1
    if t2 != t:
        print(0)
        exit()

def gcd(x, y):
    return gcd(y, x%y) if y else x
def lcm(x, y):
    return x // gcd(x, y) * y

m >>= t
l = 1
for i in a:
    l = lcm(l, i)
    if l > m:
        print(0)
        exit()
print((m // l + 1) // 2)

Measured memory_bytes: 63984
#include<stdio.h>

int main(void){
  int A,B,C,D,Sa,Sb;
  scanf("%d%d%d%d",&A,&B,&C,&D);
  Sa = A * B;
  Sb = C * D;
  if(Sa >= Sb){
    printf("%d\n",Sa);
  }else printf("%d\n",Sb);


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) ((a).begin(),(a).end())
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;

ll gcd(ll a, ll b){
  return b?gcd(b,a%b):a;
}

ll extgcd(ll a, ll b, ll& x, ll& y){
  ll d = a;
  if(b!=0){
    d = extgcd(b,a%b,y,x);
    y -= (a/b)*x;
  }else{
    x = 1; y = 0;
  }
  return d;
}

ll mod_inverse(ll a, ll m){
  ll x,y;
  extgcd(a,m,x,y);
  return (m+x%m) % m;
}

pii linear_congruence(const vi& A, const vi& B, const vi& M){
  ll x = 0, m = 1;
  rep(i,A.size()){
    ll a = A[i]*m, b = B[i] - A[i] * x, d = gcd(M[i],a);
    if(b%d != 0)return make_pair(0,-1);
    ll t = b/d * mod_inverse(a/d, M[i]/d) % (M[i]/d);
    x = x+m*t;
    m *= M[i]/d;
  }
  return make_pair( (x%m + m) % m , m);
}

int main(){
  ll n,m,d;
  cin >> n >> m >> d;
  vi a(m);
  rep(i,m)cin >> a[i];

  rep(i,d){
    vi r, aa, e;
    rep(j,m){
      ll  tmp;
      cin >> tmp;
      if(tmp<0)continue;
      r.push_back(tmp);
      aa.push_back(a[j]);
      e.push_back(1);
    }
    if(r.size()==0)continue;
    
    pii ans = linear_congruence(e,r,aa);
    ll b = ans.first, mod = ans.second;
    if(mod<0){
      cout << -1 << endl;
      return 0;
    }

    ll tmp = (n/mod+100) * mod + b;
    while(tmp<n)tmp += mod;
    while(n<tmp)tmp -= mod;
    if(tmp<0){
      cout << -1 << endl;
      return 0;
    }
    n = tmp;

  }

  cout << n << endl;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> p(n);
    rep(i,n) cin>>p[i];
    int ans=0;
    FOR(i,1,n-1){
        vector<int> vec;
        vec.push_back(p[i-1]);
        vec.push_back(p[i]);
        vec.push_back(p[i+1]);
        sort(begin(vec),end(vec));
        if(vec[1]==p[i]) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3652