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

map<pair<int,int>,int> cells;
long long H,W,N;
int dx[] = {-1,-1,-1,0,0,0,1,1,1};
int dy[] = {-1,0,1,-1,0,1,-1,0,1};
long long f[10];
int main()
{
    cin>>H>>W>>N;
    for(int i = 0; i<N; i++)
    {
        int x, y;
        cin>>x>>y;
        for(int k = 0; k<9; k++) {
            int nx = x+dx[k];
            int ny = y+dy[k];
            if(nx<2||ny<2||nx>H-1||ny>W-1) continue;
            cells[{nx,ny}]++;
        }
    }
    for(auto&& p : cells)
    {
        f[p.second]++;
    }
    cout<<(H-2)*(W-2)-cells.size()<<endl;
    for(int i = 1; i<=9; i++)
    {
        cout<<f[i]<<endl;
    }
}

Measured memory_bytes: 58496
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int N = fs.nextInt();
        int[] arr = new int[26];
        List<Integer> li = new ArrayList<>();

        for (int i = 0; i < N; ++i) {
            String s = fs.next();
            if (s.charAt(0) == 'M' || s.charAt(0) == 'A' || s.charAt(0) == 'C'
            || s.charAt(0) == 'R' || s.charAt(0) == 'H') {
                ++arr[s.charAt(0)-65];
            }
        }

        for (int i = 0; i < 25; ++i) {
            if (arr[i] != 0) {
                li.add(arr[i]);
            }
        }

        long ans = 0;
        for (int i = 0; i <= li.size()-3; ++i) {
            for (int j = i+1; j < li.size()-1; ++j) {
                for (int k = j+1; k < li.size(); ++k) {
                    ans += (long)li.get(i) * (long)li.get(j) * li.get(k);
                }
            }
        }

        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}

    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() { return Double.parseDouble(next());}
}




Measured memory_bytes: 43236
from collections import Counter

n = int(input())
v = list(map(int, input().split()))

# Return the list of 2 most common numbers and each appearance
e = Counter(v[::2]);e[0] = 0
o = Counter(v[1::2]);o[0] = 0

e1,e2 = e.most_common(2)
o1,o2 = o.most_common(2)

if e1[0] != o1[0]:
    print(n - (e1[1] + o1[1]))
else:
    print(n - max(e1[1]+o2[1],e2[1]+o1[1]))

Measured memory_bytes: 18656
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
	vector<int>v(3);
	for(auto&e:v)cin>>e;

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

	cout<<v[2]*10+v[1]+v[0]<<endl;

	return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

bool comp(l_l a, l_l b){
    return (a.first + a.second) < (b.first + b.second);
}
ll dp[5005][5005];

int main() {
    for(int i = 0; i <= 5000; i++){
        for(int j = 0; j <= 5000; j++){
            dp[i][j] = 1e16;
        }
    }
    dp[0][0] = 0;
    //cout.precision(10);
    int n;
    cin >> n;
    vector<l_l> people(n);
    for(int i = 0; i < n; i++){
        int h, p;
        cin >> h >> p;
        people[i] = {h, p};
    }
    people.push_back({0, 0});
    sort(people.begin(), people.end(), comp);
    //cout << people[0].first << " " << people[0].second << endl;
    for(int i = 1; i <= n; i++){
        l_l now = people[i];
        ll h = now.first;
        ll p = now.second;
        for(int j = 1; j <= i; j++){
            dp[i][j] = dp[i - 1][j];
            if(dp[i - 1][j - 1] <= h){
                dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + p);
            }
            //cout << i << " " << j << " " << dp[i][j] << endl;
        }
    }
    for(int i = n; i >= 0; i--){
        if(dp[n][i] > 0 && dp[n][i] < 1e16){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 196096
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:108777216")
#define _FORTIFY_SOURCE 0
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <utility>
#include <algorithm>
#include <ctime>
#include <cstdarg>
#include <sstream>
#include <functional>
using namespace std;

int const MAX_N = 512 * 1024;
long long const LL_INF = 5000000000000000000LL;

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	long long a, b;
	cin >> a >> b;
	if (a <= 5) cout << 0;
	else if (a <= 12) cout << (b / 2);
	else cout << b;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	for (int i = 0;a > 0 && c > 0; ++i)
	{
		a -= d * (i % 2 == 1);
		c -= b * (i % 2 == 0);
	}
	cout << ((a > c)?"Yes":"No") << endl;
	return 0;
}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

long long INF=LLONG_MAX;

ll a[11111],b[11111],ready[11111],value[11111],h,n;

ll solve(ll x){
	if(x<=0)return 0;
	if(ready[x])return value[x];
	ll best = INF;
	for(int i = 0; i < n; i++){
		best = min(best,solve(x-a[i])+b[i]);
	}
	value[x] = best;
	ready[x] = 1;
	return best;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	cin >> h >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
	}
	cout << solve(h) << endl;
}	


Measured memory_bytes: 768
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace __init {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    ll M, K;
    cin >> M >> K;
    V<ll> lis;
    ll upper = 1;
    for(ll i = 0; i < M; i++) upper *= 2;
    ll now = 0;
    if(K == 0) {
        for(ll i = 0; i < upper; i++) cout << i << ' ' << i << " \n"[i + 1 == upper];
        return 0;
    }
    for(ll i = 0; i < upper; i++) if(i != K) now ^= i;
    if(now != K) {
        cout << -1 << endl;
    } else {
        V<ll> lis;
        for(ll i = upper - 1; i >= 0; i--) if(i != K) lis.push_back(i);
        lis.push_back(K);
        for(ll i = 0; i < upper; i++) if(i != K) lis.push_back(i);
        lis.push_back(K);
        for(ll i = 0; i < lis.size(); i++) cout << lis[i] << " \n"[i + 1 == lis.size()];
    }
    return 0;
}


Measured memory_bytes: 3952
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const ll INF=1e+18;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//省略
using vi  = vector<int>;
using vii = vector<vector<int>>;
using vl  = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;


int main(){
    ll N;
    cin>>N;
    ll k=-1;
    REP(i,10*N){
        if(pow(i,2)>8*N+1) break;
        if(8*N+1==pow(i,2)){
            k=i;
        }
    }
    if(k==-1){
        cout<<"No"<<endl;
    }else{
        k=(1+k)/2;
        vll ans(k,vl(k-1,0));
        ll cnt=1;
        REP(i,k-1){
            REP(j,k-1-i){
                ans[i][i+j]=cnt;
                ans[i+1+j][i]=cnt;
                cnt++;
            }
        }
        cout<<"Yes"<<endl;
        cout<<k<<endl;
        REP(i,k){
            cout<<k-1<<" ";
            REP(j,k-1){
                cout<<ans[i][j];
                if(j!=k-2) cout<<" ";
                else cout<<endl;
            }
        }
    }
    
}

Measured memory_bytes: 5152
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<iomanip>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005
using namespace std;

void solve(){
	ll n;
	cin>>n;
	ll a[n],sum=0;
	rep(i,0,n){
		cin>>a[i];
		if(i%2==0)sum=sum+a[i];
		else sum=sum-a[i];
	}
	cout<<sum<<" ";
	rep(i,0,n-1){
		sum=(a[i]*2)-sum;
		cout<<sum<<" ";
	}
}
int main()
{
	waste;
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}


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

public class Hello
{
    private const int MOD_N = 1000000000 + 7;

    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var list = Console.ReadLine().Split(' ');
        var hs = new int[n];
        for (int i = 0; i < hs.Length; ++i)
            hs[i] = int.Parse(list[i]);

        Console.WriteLine(aaaa(hs) ? "Yes" : "No");
    }
    private static bool aaaa(int[] hs)
    {
        int min = hs[hs.Length - 1];
        for (int i = hs.Length - 2; i >= 0; --i)
        {
            if (hs[i] - min > 1)
                return false;
            if (hs[i] < min)
                min = hs[i];
        }
        return true;
    }

    private static int GCD(int a, int b) => a > b ? GCD_impl(a, b) : GCD_impl(b, a);
    private static int GCD_impl(int a, int b) => b == 0 ? a : GCD_impl(b, a % b);
    private static long LCM(int a, int b) => (long)a * b / GCD(a, b);

    private static int Comb(int m, int n)
    {
        var t = m - n;
        if (n > t)
            n = t;

        long numerator = 1;
        for (int i = 0; i < n; ++i)
        {
            numerator *= m - i;
            numerator %= MOD_N;
        }
        long denominator = 1;
        for (; n != 0; --n)
        {
            denominator *= n;
            denominator %= MOD_N;
        }

        var inv_denominator = ModInv((int)denominator, MOD_N);
        var ret = (int)(numerator * inv_denominator % MOD_N);

        return ret >= 0 ? ret : ret + MOD_N;
    }

    private static int ModInv(int a, int m)
    {
        int b = m, x = 1, y = 0;
        while (b != 0)
        {
            var t = a / b;
            a -= t * b;
            Swap(ref a, ref b);
            x -= t * y;
            Swap(ref x, ref y);
        }
        x %= m;
        return x >= 0 ? x : x + m;
    }

    private static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
}


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

using namespace std;

int main(void){

    int price, money, desire;

    cin >> price >> money >> desire;

    int possible;

    possible = money / price;

    if(possible >= desire){
        
        cout << desire << endl;

    }
    else{

        cout << possible << endl;
    }

    return 0;



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define N 200100
#define MOD 1000000007
#define fn(i,n) for(int i=0;i<n;i+=1)
#define rep(i,l,r) for(int i=l;i<=r;i+=1)
#define INF 100000000000000
#define pii pair<int,int>
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


signed main()
{
    
    speed
    int k;cin>>k;
    int ans=0;
    rep(a,1,k){
        rep(b,1,k){
            rep(c,1,k){
                ans+=(__gcd(a,__gcd(b,c)));
            }
        }
    }
    cout<<ans<<endl;
   
    
    
    
    return 0;
}

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

using namespace std;



int main(){
    string s;
    cin >>s;
    int ans,i;
    string date[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    REP(i,7){
        if(date[i]==s){
            ans=7-i;
            break;
        }
    }
    
    cout<< ans << endl;
    
    
    return 0;
}


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

typedef int INT;
const int SIZE = 4194304;
bool HA[SIZE];

inline INT get( char c ) {
    char T[5] = "ACGT";
    for ( INT i = 0; i < 4; ++ i ) {
        if ( c == T[i] ) return i + 1;
    }
    return 0;
}

int main() {
    INT n, sum, t, c;
    while ( scanf("%d", &n) != EOF ) {
        memset( HA, false, sizeof(HA) );
        while ( getchar() != '\n' );
        for ( register INT i = 0; i < n; ++ i ) {
            sum = 0;
            t = 1;
            bool flag = ( c = getchar() ) == 'i';
            while ( ( c = getchar() ) != ' ' );
            while ( ( c = get( getchar() ) ) != 0 ) {
                sum += c * t;
                t *= 4;
            }
            if ( flag ) {
                HA[sum] = true;
            } else {
                puts( HA[sum] ? "yes" : "no" );
            }
        }
    }
    return 0;
}

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

int main(){
  int n; cin>>n;
  map<ll,ll> mp;
  ll ans=0;
  rep(i,n){
    int a;
    cin>>a;
    mp[a]++;
    ans+=a;
  }
  int q; cin>>q;
  rep(qi,q){
    int b,c;
    cin>>b>>c;
    ans=ans-mp[b]*b+mp[b]*c;
    mp[c]+=mp[b];
    mp[b]=0;
    cout<<ans<<endl;
  }
}

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

#define ll long long 
#define sz(x) (int)x.size()

using namespace std;

int main(){
	int n;
	cin>>n;
	vector<ll>a(n+1);
	a[0]=2,a[1]=1;
	for(int i=2;i<=n;i++){
		a[i]=a[i-1]+a[i-2];
	}
	cout<<a[n];
	
	
}

Measured memory_bytes: 3560
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

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

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

bool keta(int x){
    int k = 0, num = x; 
    while(num > 0){
        num /= 10;
        k++;
    }
    if(k % 2 == 1) return true;
    else return false;
}

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++){
        if(keta(i)) ans++;
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 3624
/*
  1   2   3   4   5   6   7   8   9  10
 10   9   8   7   6   5   4   3   2   1
 10  18  24  28  30  30  28  24  18  10
     28  52  80 110 140 168 192 210 220
*/
#include<vector>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<cstdio>
using namespace std;
#define intl long long
const intl LINF=1e18;
int main(void){
	//N人の入力と修行の最大回数の入力
	intl N,K;cin>>N>>K;
	//a[N]消化コストとf[N]（食べ物の食べにくさ
	vector<intl> a(N),f(N);
	for(intl i=0;i<N;i++)cin>>a[i];
	for(intl i=0;i<N;i++)cin>>f[i];
	sort(a.begin(),a.end());
	sort(f.rbegin(),f.rend());
	intl l=-1,r=LINF;
	while(r-l>1)
	{
		intl m=(r+l)>>1;
		intl cnt=0;
		for(intl i=0;i<N;i++){
			if(a[i]*f[i]>m){
				cnt+=(a[i]*f[i]-m)/f[i];
				if((a[i]*f[i]-m)%f[i])cnt++;
			}
		}
		if(cnt>K)l=m;
		else r=m;
	}
	cout<<r<<endl;
	return 0;
}
/*
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int LINF=1e18;
 
signed main(){
  int N,K;cin>>N>>K;
  vector<int> a(N),f(N);
  for(int i=0;i<N;i++)cin>>a[i];
  for(int i=0;i<N;i++)cin>>f[i];
  sort(a.begin(),a.end());
  sort(f.rbegin(),f.rend());
  int l=-1,r=LINF;
  while(r-l>1){
    int m=(r+l)>>1;
    int cnt=0;
    for(int i=0;i<N;i++){
      if(a[i]*f[i]>m){
        cnt+=(a[i]*f[i]-m)/f[i];
        if((a[i]*f[i]-m)%f[i])cnt++;
      }
    }
    if(cnt>K)l=m;
    else r=m;
  }
  cout<<r<<endl;
}
*/

Measured memory_bytes: 3328
n = int(input())
H = list(map(int,input().split()))
ans = 0
size = sum(H)
while(size > 0):
    count = 0
    temp = 0
    for h in H:
        if(h == 0 and temp > 0):
            ans += 1
            break
        elif(h != 0):
            temp += 1
            H[count] -= 1
            size -= 1
            if(count == n-1):
                ans += 1
        count += 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i,n)  for(int i = 0; i < (int)(n);    i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


template <typename T> 
class PrimeFact {
  public:
  std::vector<T> spf;
  std::map<T,T> m;

  PrimeFact(T N) : spf(N+1,0) { init(N); }

  void init(T N) {
    for (T i = 0; i <= N; i++) spf[i] = i;
    for (T i = 2; i*i <= N; i++) {
      if ( spf[i] != i ) continue;
      for (T j = i * i; j <= N; j += i) {
        if (spf[j] == j) spf[j] = i;
      }
    }
    /*
    spf[1] = 1;
    for(int i=2; i<=N; i++) {
      if ( spf[i] == 0 ) {
        for(int j=i; j <= N; j += i ) {
          spf[j] = i;
        }
      }
    }
    */
    return;
  }

  auto get(T n) { 
    m.clear();
    while (n != 1) {
      m[spf[n]]++;
      n /= spf[n];
    }
    ll count = 1;
    for(auto&& s : m) count *= (1+s.second);
    return count;
  }
};


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int n; std::cin >> n;
  PrimeFact<int> pf(n);
  ll ans = 0;
  for(int k=1; k<=n; k++) ans += k*pf.get(k);
  std::cout << ans << std::endl;
  return 0;
}



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

void chmax(int &a, int b) { if (a < b) a = b; return; }

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

    int n; cin >> n;
    vector<int> v(n + 1), w(n + 1);
    for (int i = 1; i <= n; i++) cin >> v[i] >> w[i]; // 1-index

    int q; cin >> q;
    vector<int> vv(q), l(q);
    for (int i = 0; i < q; i++) cin >> vv[i] >> l[i];

    int L = *max_element(l.begin(), l.end());
    vector<int> depth(n + 1, 0);
    for (int i = 2; i <= n; i++) depth[i] = depth[i / 2] + 1;
    int K = depth[n] / 2 + 1;

    vector<vector<int>> dp(1 << K, vector<int>(L + 1, 0));
    for (int i = 1; i < (1 << K); i++) {
        for (int j = 0; j <= L; j++) {
            dp[i][j] = dp[i / 2][j];
            if (j) chmax(dp[i][j], dp[i][j - 1]);
            if (j >= w[i]) chmax(dp[i][j], dp[i / 2][j - w[i]] + v[i]);
        }
    }

    for (int i = 0; i < q; i++) {
        int id = vv[i], cap = l[i];
        if (depth[id] < K) {
            cout << dp[id][cap] << '\n';
            continue;
        }

        vector<pair<int,int>> check;
        for ( ; depth[id] >= K; id /= 2) {
            check.emplace_back(v[id], w[id]);
        }

        int ans = 0;
        int s = (int)check.size();
        for (int j = 0; j < (1 << s); j++) {
            int count = 0, cost = 0;
            for (int k = 0; k < s; k++) {
                if (j & (1 << k)) {
                    count += check[k].first;
                    cost += check[k].second;
                }
            }
            if (cost > cap) continue;
            count += dp[id][cap - cost];
            chmax(ans, count);
        }
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 208312
class SegTree():
    def __init__(self,size,unit,f):
        self.size=size
        self.data=[unit for _ in range(2*size)]
        self.unit=unit
        self.f=f
    def update(self,i,x):
        c,f=self.data,self.f
        i+=self.size
        c[i]=f(c[i],x)
        while i>1:
            i>>=1
            c[i]=f(c[i+i],c[i-~i])
    def query(self,l,r):
        c,f=self.data,self.f
        x,y=self.unit,self.unit
        l+=self.size
        r+=self.size
        while l<r:
            if l&1:
                x=f(x,c[l])
                l+=1
            if r&1:
                r-=1
                y=f(c[r],y)
            l>>=1
            r>>=1
        return f(x,y)
def main():
    n,*a=map(int,open(0).read().split())
    dp=SegTree(n+1,0,lambda a,b:a if a>b else b)
    for h,a in zip(a,a[n:]):dp.update(h,dp.query(0,h)+a)
    print(dp.data[1])
main()

Measured memory_bytes: 125048
import java.util.*;
import java.io.*;
class Main
{
	public static void main(String args[]) throws java.lang.Exception
	{
		BufferedReader inp = new BufferedReader (new InputStreamReader(System.in));
			// String h[]=inp.readLine().split(" ");
			String h[]=inp.readLine().split(" ");
			int n=Integer.parseInt(h[0]);
			int k=Integer.parseInt(h[1]);
			String hh[]=inp.readLine().split(" ");
			int a[]=new int[n];
			for(int i=0;i<n;i++){a[i]=Integer.parseInt(hh[i]);}
			long dp[]=new long[k+1];

			long MOD=1000000007;
			// dp[0]=1;
			dp[0]=1;
			
			for(int i=0;i<n;i++)
			{
				long pre[]= new long[k+1];
				// long dp1[]=new long[k+1];
				for(int j=0;j<=k;j++)
				{
					int l=j;
					int r=Math.min(k,j+a[i]);
					// long temp=dp[j];
					pre[l]+=dp[j];
					// pre[r+1]+=1;
					if(r!=k){pre[r+1]-=dp[j];}	
					// for(int u=l;u<=r;u++)
					// {
					// 	dp1[u]+=temp;
					// }		
					

				}
				// dp=dp1;
				dp=new long[k+1];
				dp[0]=pre[0];
				for(int j=1;j<=k;j++)
				{
					pre[j]+=pre[j-1];
					dp[j]=(dp[j]%MOD+pre[j]%MOD)%MOD;

				}
				// System.out.println(Arrays.toString(dp));
				

			}
			// for(int i=1;i<=k;i++)
			// {
			// 	dp[i]=(dp[i]%MOD+dp[i-1]%MOD)%MOD;
			// }
			System.out.println(dp[k]%MOD);
			
					
		
	}

	
}
class Pair
{
	int a;
	long b;
	
	Pair(int e, long f)
	{
		a=e;
		b=f;
		
	}
}

Measured memory_bytes: 89900
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define vvi vector<vi >
#define str string
#define vs vector<str>
#define vb vector<bool>
#define slli set<lli>
#define mii map<int, int>
#define mlli map<int, lli>
#define msi map<str, int>
#define mp make_pair
#define pii pair<int, int>
#define pll pair<lli, lli>
#define vpii vector<pii >
#define vpll vector<pll >
#define pb push_back
#define loop(i, s, l, j) for(int i = s; i < l; i += j)
#define rloop(i, s, l, j) for(int i = s; i >= l; i -= j)
#define rep(i, n) loop(i,0,n,1)
#define rrep(i, n) rloop(i,n-1,0,1) 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ft first
#define sd second   
#define mit mii::iterator
#define vit vi::iterator
#define all(a) a.begin(),a.end()
#define min3(a, b, c) min(a, min(b, c))
#define mod 1000000007
#define inf 1000000000000000000
#define minval -100000000
#define idf -1000000000
/**********************************************************************************************************************************************/
int dx4[4] = {0, -1, 0, 1};
int dy4[4] = {1, 0, -1, 0};
int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int Power(int base,int exp){int ans=1;  while(exp > 0){if(exp&1)ans=(1LL*ans*base)%mod; exp=exp>>1; base=(1LL*base*base)%mod;}  return ans;}
/**********************************************************************************************************************************************/
lli t[1000000];
void update(int node, int i, int j, int idx, lli val)
{
    if(i == j)
    {
        t[node] = val;
        return;
    }

    int left = (node<<1);
    int right = (left|1);
    int m = (i+j)>>1;

    if(idx <= m)
        update(left, i, m, idx, val);
    else
        update(right, m+1, j, idx, val);
    t[node] = max(t[left], t[right]);
}
lli query(int node, int i, int j, int l, int r)
{
    int left = (node<<1);
    int right = (left|1);
    int m = (i+j)>>1;
    if(r < i || l > j)
        return 0;
    else if(l <= i && r >= j)
        return t[node];
    return max(query(left, i, m, l, r), query(right, m+1, j, l, r));
}
void input()
{
    int n;
    cin >> n;
    lli h[n], a[n];
    rep(i,n)
        cin >> h[i];
    rep(i,n)
        cin >> a[i];

    lli ans = 0;
    rep(i,n)
    {
        lli val = a[i];
        if(h[i] > 1)
            val += query(1,1,n,1,h[i]-1);
        ans = max(ans, val);
        update(1,1,n,h[i],val);
    }
    cout << ans << '\n';

}

int main()
{
    fastio();
    int q = 1;
    //cin >> q;
    while(q--)
        input();
}

Measured memory_bytes: 9472
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
bool bo[100];
#define ll long long 
#define mod 1000000007

int main()
{
	int n;
	cin>>n;
	vector<string>v(n+10);
	for(int i=0;i<n;i++)
	{
		cin>>v[i];
	}
	string s="";
	for(int i='a';i<='z';i++)
	{
		int mi=INT_MAX;
		for(int j=0;j<n;j++)
		{
			int c=0;
			for(int k=0;k<(int)v[j].size();k++)
			{
				if(v[j][k]==i) c++;
			}
			if(c!=0)
			{
				mi=min(c,mi);
			}
			else
			{
				mi=0;
				break;
			}
		}
		s+=string(mi,i);
	}
	cout<<s<<endl;
}

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

class B
{
	static void Main()
	{
		var h = new int[5].Select(_ => int.Parse(Console.ReadLine())).OrderBy(x => (x %= 10) > 0 ? -x : -10).ToArray();
		Console.WriteLine(h.Take(4).Sum(x => x % 10 == 0 ? x : x / 10 * 10 + 10) + h[4]);
	}
}


Measured memory_bytes: 11476
#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>;

void Main()
{
  int N; cin >> N;
  vector<int> C(N-1), S(N-1), F(N-1);
  rep(i,N-1) cin >> C[i] >> S[i] >> F[i];
  vector<int> ans(N);
  rep(i,N) {
    int t = 0;
    for(int j = i; j < N-1; j++) {
      //cout << "(t - S[j])%F[j]" << F[j] << endl;
      while ((t - S[j]) < 0 or (t - S[j])%F[j] != 0) {
        //cout << "(t - S[j])%F[j]" << (t - S[j])%F[j] << endl;
        t++;
      }
      //cout << "t" << t << endl;
      t += C[j];
      //cout << "t" << t << endl;
    }
    ans[i] = t;
    cout << ans[i] << endl;
  }
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}


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

using namespace std;

int main(){
    double a, b;
    double t1 = 0.08, t2 = 0.1, dif = 0.001;

    scanf("%lf %lf", &a, &b);

    bool ans = false;

    int N = 1001;

    for (double i=1;i<=N;i++){
        //cout << floor(i * t1) << " " << floor(i*t2) << endl;
        int x = floor(i * t1), y = floor(i*t2);
        if (x == int(a) && y == int(b)){
            printf("%.0lf\n", i);
            ans = true;
            break;
        }
    }

    if (!ans) printf("-1\n");

    return 0;
}


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

#define all(x) (x).begin(),(x).end()

#define MOD 1000000007

using namespace std;

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

	if( a <= k ){
		cout << "0 ";
		if( a+b-k < 0 )	cout << "0" << endl;
		else	cout << a+b-k << endl;
	}else{
		cout << a-k << " " << b << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    int n,m,p;
    int[] x;

    public static void main(String[] args){
	new Main().calc();
    }

    void calc(){
	Scanner sc = new Scanner(System.in);
	n = sc.nextInt();
	while(n!=0){
	    m = sc.nextInt();
	    p = sc.nextInt();
	    x = new int[n];
	    int sum = 0;
	    for(int i=0; i<n; i++){
		x[i] = sc.nextInt();
		sum += x[i];
	    }
	    
	    double ans = 0;
	    if(x[m-1]!=0)ans = (sum*(100-p))/x[m-1];
	    
	    System.out.println((int)ans);
	    
	    n = sc.nextInt();
	}
    }
}

Measured memory_bytes: 12000
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n = I()
A = LI()
A.sort()
if all([a > 0 for a in A]):
    now = min(A)
    print(sum(A) - now * 2)
    A.remove(now)
    last = A.pop()
    while A:
        nxt = A.pop()
        print(now, nxt)
        now -= nxt
    print(last, now)
elif all([a < 0 for a in A]):
    now = max(A)
    print(-sum(A) + now * 2)
    A.remove(now)
    while A:
        nxt = A.pop()
        print(now, nxt)
        now -= nxt
else:
    print(sum([abs(i) for i in A]))
    minus = []
    plus = []
    for a in A:
        if a > 0:
            plus += [a]
        elif a < 0:
            minus += [a]
        else:
            if not plus:
                plus += [a]
            else:
                minus += [a]
    ret = minus.pop()
    for j in range(len(plus) - 1):
        print(ret, plus[j])
        ret -= plus[j]
    print(plus[-1], ret)
    ret = plus[-1] - ret
    for k in range(len(minus)):
        print(ret, minus[k])
        ret -= minus[k]

Measured memory_bytes: 62488
using LIB;
using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        string s = io.r<string>();
        string p = io.r<string>();
        int sc = s.Count();
        int pc = p.Count();
        bool dtct = false;
        for (int i = 0; i < sc; i++)
        {
            bool f = true;
            for (int j = 0; j < pc; j++)
            {
                if (s[(i + j) % sc] != p[j]) { f = false; break; }
            }
            if (f) { dtct = true; io.w("Yes"); break; }
        }
        if (!dtct) { io.w("No"); }
        io.wflush();
    }
}

namespace LIB
{
    public class io
    {
        private const int WMAX = 1000;
        private static StringBuilder S = new StringBuilder();
        public static T r<T>() { return util.parse<T>(r()); }
        public static T[] r<T>(char s = ' ') { return r().Split(s).Select(util.parse<T>).ToArray(); }
        public static T[] r<T>(int l) { T[] r = new T[l]; for (int i = 0; i < l; i++) { r[i] = r<T>(); } return r; }
        public static T[][] r<T>(int l, char s = ' ') { T[][] r = new T[l][]; for (int i = 0; i < l; i++) { r[i] = r<T>(s); } return r; }
        private static string r() { return Console.ReadLine(); }
        public static void w(object v, bool lf = true) { S.Append(util.parse<string>(v)); if (lf == true) { S.Append('\n'); } if (S.Length >= WMAX) { wflush(); } }
        public static void wflush() { Console.Write(S.ToString()); S.Length = 0; }
    }
    public class util
    {
        public static T parse<T>(object value) { return (T)(Convert.ChangeType(value, typeof(T))); }
    }
    public class memo<Key, Result>
    {
        private Dictionary<Key, Result> R;
        public memo() { R = new Dictionary<Key, Result>(); }
        public Result exec(Key k, Func<Key, Result> f) { Result r; if (R.ContainsKey(k)) { r = R[k]; } else { r = f(k); R.Add(k, r); } return r; }
    }
}

Measured memory_bytes: 9528
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) break;
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    if ((i + j) % 2 == 0) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 35496
import sys
input = sys.stdin.readline
H, W = [int(x) for x in input().split()]
a = []
for _ in range(H):
    a.append(input().rstrip())
ans = []
ans.append("#" * (W + 2))
for i in a:
    i = "#" + i + "#"
    ans.append(i)
ans.append("#" * (W + 2))
for j in ans:
    print(j)

Measured memory_bytes: 3064
from itertools import combinations
N, X, Y = map(int, input().split())
X -= 1
Y -= 1

table = [0]*N

for i, j in combinations(range(N), 2):
    distance = min(j-i, abs(j-Y)+abs(i-X)+1)
    table[distance] += 1

for k in range(1, N):
    print(table[k])


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

using namespace std;

const int MAXN = 1E3;
const int MAXH = 1E4;
int a[MAXN];
int b[MAXN];
int dp[MAXH + 1];

int main()
{
    int h, n;
    cin >> h >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i] >> b[i];
    for (int i = 1; i <= h; i++)
    {
        dp[i] = 1E9;
        for (int j = 0; j < n; j++)
        {
            dp[i] = min(dp[i], b[j] + dp[max(0, i - a[j])]);
        }
    }
    cout << dp[h] << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]

a_max = max(a)
a_max_index = a.index(max(a))

check = 0
for i,j in enumerate(a):
    if i != a_max_index:
        check += j
        
if check > a_max:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > piii;
#define pb push_back
#define debug(x) cout << x << endl
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
#define PI acos(-1)
#define all(c) c.begin(), c.end()
#define SET(x, y) memset((x), y, sizeof(x))
const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;
const LL INF64 = 1e18;

const int N = 1e5 + 5;

int main() {
	fastio;
	LL capacity[5];
	LL n;
	cin >> n;
	LL mn = INF64;
	for (int i = 0; i < 5; i++) {
		LL a;
		cin >> a;
		mn = min(mn, a);
	}
	cout << n / mn + 4 + (n % mn != 0) << endl;
	return 0;
}
		

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

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
  int A, B, C;
  get(A, B, C);
  print(!(C < B ^ A < C) ? "Yes" : "No");
  return 0;
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t h, n;
  std::cin >> h >> n;
  std::vector<int64_t> a(n);
  std::cin >> a;

  if (summation(a.cbegin(), a.cend()) < h) {
    std::cout << "No" << std::endl;
  } else {
    std::cout << "Yes" << std::endl;
  }
  return 0;
}

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

signed main() {
    int k;
    cin >> k;

    int ans = 0;
    for(int i = 1; i <= k; i++){
        for(int j = 1; j <= k; j++){
            for(int t = 1; t <= k; t++){
                int ij = gcd(i,j);
                int g = gcd(ij,t);
                ans += g;
            }
        }
    }
    cout << ans << endl;
}

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

char game(string S_A, string S_B, string S_C, int r_A, int r_B, int r_C, char now_turn) {
    if (r_A == -1) {
        return 'A';
    } else if (r_B == -1) {
        return 'B';
    } else if (r_C == -1) {
        return 'C';
    } else {
        if (now_turn == 'a') {
            now_turn = S_A[S_A.size() - r_A];
            r_A--;
        } else if (now_turn == 'b') {
            now_turn = S_B[S_B.size() - r_B];
            r_B--;
        } else if (now_turn == 'c') {
            now_turn = S_C[S_C.size() - r_C];
            r_C--;
        }
        return game(S_A, S_B, S_C, r_A, r_B, r_C, now_turn);
    }
}

int main(){
string S_A, S_B, S_C;  cin >> S_A >> S_B >> S_C;
int r_A = S_A.size();
int r_B = S_B.size();
int r_C = S_C.size();
char now_turn = 'a';

char ans = game(S_A, S_B, S_C, r_A, r_B, r_C, now_turn);
cout << ans << endl;
}


Measured memory_bytes: 384
K = int(input())
MOD = 10 ** 9 + 7

if K % 2 == 0:
    print('-1')
    exit()

seven = 0
cnt = 0
mod = 0
for _ in range(10**7):
    mod = (mod * 10 + 7) % K
    if mod % K == 0:
        print(cnt+1)
        exit()
    if cnt > 10 ** 6:
        print('-1')
        exit()
    cnt += 1


Measured memory_bytes: 9124
#include"bits/stdc++.h"

using namespace std;

int main()
{
    int n;
    cin >> n;
    int b[n];
    for(int i=0;i<n-1;i++)
        cin >> b[i];
        b[n-1]=1000000;
    int m=b[0];
    for(int i=0;i<n-1;i++)
        m+=min(b[i],b[i+1]);
    cout << m << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define N 300005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
main()
{
    ll h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    m1=60*h1+m1;
    m2=60*h2+m2;
    cout<<max(0LL,m2-m1-k);
}



Measured memory_bytes: 3592
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
const long long INF =  999999999;
ll N,M,s[100100];
vector<ll> A;


int main(){
  cin>>N>>M;
  REP(i,N){
    ll b;
    cin>>b;
    A.push_back(b);
  };
  sort(A.begin(),A.end());
  s[0]=0;
  REP(i,N)s[i+1]=s[i]+A[i];

  ll r=s[N]+1,l=0,m;
  while(r-l>1){
    m=(r+l)/2;
    ll cnt=0;
      REP(i,N){
        cnt+=A.end()-lower_bound(A.begin(),A.end(),m-A[i]);
      }
    if(cnt>=M)l=m;
    else r=m;
  }

  ll ans=0;
  REP(i,N){
    ll j=lower_bound(A.begin(),A.end(),l-A[i])-A.begin();
    ans+=(N-j)*A[i]+s[N]-s[j];
  }
  ll cnt=0;
  REP(i,N){
    cnt+=A.end()-lower_bound(A.begin(),A.end(),l-A[i]);
  }
  if(cnt>M){
    //丁度値がlになるような組が何組もあった場合
    ans-=l*(cnt-M);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1908
#include <cstdio>
#include <cstring>
#include <string>

using namespace std;

int main() {
  char buf[120];
  while (true) {
    fgets(buf, 120, stdin);
    if (buf[strlen(buf)-1] == '\n') buf[strlen(buf)-1] = '\0';
    if (buf[0] == '.' && buf[1] == '\0') break;
    string s = "";
    for (int i=0;buf[i]!='\0';i++) {
      if (buf[i] == '(' || buf[i] == ')'
        || buf[i] == '[' || buf[i] == ']') {
        s += buf[i];
      }
    }
    //printf("%s\n", s.c_str());
    bool yes = true;
    while (!s.empty()) {
      int n = s.find("()");
      if (n == string::npos) {
        n = s.find("[]");
        if (n == string::npos) {
          yes = false;
          break;
        }
      }
      s.erase(n, 2);
    }
    puts(yes ? "yes" : "no");
  }
  return 0;
}

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

int main(){
  int a,b,ans; 
  cin>>a>>b;
  if(a<=5)ans=0;
  else if(a<=12)ans=b/2;
  else{ans=b;}
    
  cout<<ans;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int n = s.length();
		int ans = 0, l = 0, r = n - 1;
		if(n == 1) {
			System.out.println(0);
			return;
		}
		for(; ; ) {
			if(s.charAt(l) == s.charAt(r)) {
				l++; r--;
				if(l >= r) {
					System.out.println(ans);
					return;
				}
			} else {
				if(s.charAt(l) != 'x' && s.charAt(r) != 'x') {
					System.out.println(-1);
					return;
				} else {
					if(s.charAt(l) == 'x') {
						l++;
						ans++;
						if(l == r) {
							System.out.println(ans);
							return;
						}
					}
					if(s.charAt(r) == 'x') {
						r--;
						ans++;
						if(l == r) {
							System.out.println(ans);
							return;
						}
					}
				}
			}
		}
	}
}


Measured memory_bytes: 26324
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

int main() {
	int N;
	cin >> N;
	vector<int> p(N);
	for (int i = 0; i < N; i++) cin >> p[i];
	for (int i = 0; i < N; i++) {
		for (int j = i; j < N; j++) {
			swap(p[i], p[j]);
			bool ok = 1;
			for (int k = 1; k < N; k++) {
				if (p[k - 1] > p[k]) {
					ok = 0;
					break;
				}
			}
			if (ok) {
				cout << "YES" << endl;
				return 0;
			}
			swap(p[i], p[j]);
		}
	}
	cout << "NO" << endl;
}


Measured memory_bytes: 256
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    mod = 10**9 + 7
    H, W = geta(int)
    g = []
    for _ in range(H):
        g.append(gete())

    dp = [[0] * W for _ in range(H)]

    for i, gi in enumerate(g):
        if i == 0:
            w = gi.index("#") if "#" in gi else W
            dp[0] = [1 if j < w else 0 for j in range(W)]
        else:
            for j, gij in enumerate(gi):
                if gij == "#":
                    dp[i][j] = 0
                else:
                    dp[i][j] = (dp[i - 1][j] +
                                (dp[i][j - 1] if j > 0 else 0)) % mod

    print(dp[H - 1][W - 1])


if __name__ == "__main__":
    main()

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

using ll = long long; 

signed main() {
  ll h,w,a,b;
    cin>>h>>w>>a>>b;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(i<b&&j<a) cout<<0;
      else if(i>=b&&j>=a) cout<<0;
      else cout<<1;
    }
    cout<<""<<endl;
  }
}


Measured memory_bytes: 1280