akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  map<ll, vector<int> > mp;
  rep(i, N) {
    cin >> A[i];
    mp[A[i]+(i+1)].push_back(i);
  }
  ll ans = 0;
  rep(i, N) {
    ll tmp = -A[i]+(i+1);
    if(mp.count(tmp)) {
      auto v = mp[tmp];
      ans += (upper_bound(all(v), i) - v.begin());
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 26540
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,k;

int main(void){
	scanf("%d%d",&n,&k);
	double ans=0.0;
	for(int i=1;i<=n;i++){
		if(i>=k){
			ans+=(double)1.0;
		}else{
			double per=1.0;
			int v=i;
			while(v<k){
				v*=2;
				per/=2.0;
			}
			ans+=per;
		}
	}
	ans/=(double)n;
	printf("%.15f\n",ans);
	return 0;
}


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

int main()
{
  int N,M,Q;
  int dsum = 0;
  cin >> N >> M >> Q;
  vector<vector<int>> kumi(Q,vector<int>(4));
  for(int i = 0;i < Q;i++){
    cin >> kumi[i][0] >> kumi[i][1] >> kumi[i][2] >> kumi[i][3];
  }
  vector<int> A(N);
  for (int tmp = 0; tmp < (1 << 19); tmp++){
    bitset<19> s(tmp);
    if(s.count() != M-1) continue;
    if(N+M-1 != 19){
      if(s.test(N+M-1)) break;
    }
    int kazu = 1;
    int j = 0;
    int sum = 0;
    for(int i = N+M-2;i >= 0;--i){
      if(s.test(i)){
        ++kazu;
      }
      else{
        A[j] = kazu;
        ++j;
      }
    }
    for(int i = 0;i < Q;i++){
      if(A[kumi[i][1]-1] - A[kumi[i][0]-1] == kumi[i][2]) sum += kumi[i][3];
    }
    dsum = max(dsum,sum);
  }
  cout << dsum << endl;
}


Measured memory_bytes: 3556
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        p: [(String, isize); n],
    }

    let mut ans = vec![];
    for i in 0..n {
        ans.push(
            (p[i].0.clone(),
            -p[i].1,
            i+1)
        );
    }
 
    ans.sort();

    for a in ans {
        println!("{}", a.2);
    }

}


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

int main(){
    int H, W;  cin >> H >> W;
    vector<string> a(H);
    for(int h=0; h<H; h++) cin >> a[h];
    const int mod = 1000000007;

    vector<vector<int>> dp;
    dp = vector<vector<int>>(H, vector<int>(W, 0));

    dp[0][0] = 1;
    for(int h=0; h<H; h++){
        for(int w=0; w<W; w++){
            if(h==0 && w == 0) continue;
            if(a[h][w]=='#'){
                dp[h][w] = 0;
            }else{
                int up = 0, left = 0;
                if(h-1>=0) up = dp[h-1][w];
                if(w-1>=0) left = dp[h][w-1];
                dp[h][w] = (up + left)%mod;
            }
        }
    }
    cout << dp[H-1][W-1] << endl;
}

Measured memory_bytes: 5248
#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() {
  int64_t n,a,b;
  cin >> n;
  cin >> a;
  cin >> b;
  int64_t ans=0;
  ans += (n/(a+b))*a;
  int64_t c=n%(a+b);
  if (c>a) {
      ans+=a;
  }
  else ans+=c;
  cout << ans << endl;
}


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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int X, A;
  cin >> X >> A;
  cout << (X < A ? 0 : 10) << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
 <url:https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_c>
 問題文============================================================
 XXXX年のCODE FESTIVALには、世界中から高橋君を含めて N+1 人の参加者が集まりました。
 
 高橋君の都市と他の N 人の都市の時刻の差を調べてみたところ、i 番目の人の都市との時刻の差は Di 時間でした。
 ただし 2 つの都市について、片方の都市で 0 時の瞬間にもう一方の都市で d 時であるようなとき、
 これらの都市の時刻の差は min(d,24−d) であるものとします。
 ここで、時刻の表記には 24 時間表記を用いるものとします。
 つまり、例えば高橋君の都市で 0 時の瞬間には i 番目の人の都市は Di 時または 24−Di 時のいずれかとなります。
 
 高橋君は次に、N+1 人のうちの全ての 2 人組についてその人の都市どうしの時刻の差を書き出し、
 それらの時刻の差のうちの最小値を s としました。
 
 s として考えられる最大値を求めて下さい。
 =================================================================
 
 解説=============================================================
 
 ================================================================
 */
ll solve(){
    ll ret = INF;
    ll N; cin >> N;
    vector<ll> D(N);
    for(auto& in:D) cin >> in;
    sort(D.begin(),D.end());
    vector<ll> t; t.push_back(0);
    for(int i = 0; i < N;i++){
        ret = min(ret,D[i]);
        
        ll t1 = D[i],t2 = 24 - D[i];
        ll dif1 = INF, dif2 = INF;
        for(auto T:t){
            dif1 = min(dif1,min(abs(t1-T),abs(24+t1-T)));
            dif2 = min(dif2,min(abs(t2-T),abs(24+t2-T)));
        }
        ret = min(ret,max(dif1,dif2));
        if(dif1 > dif2){
            t.push_back(t1);
        }else{
            t.push_back(t2);
        }
    }
    return ret;
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << 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;

int main(){
    int n, m; cin >> n >> m;
    vector<int> a(n);
    rep(i, n) {
        cin >> a.at(i);
    }

    float sum = accumulate(a.begin(), a.end(), 0);
    float num = sum / (4*m);

    int count = 0;
    rep(i, n){
        if(num <= a.at(i)){
            count++;
        }
    }
    
    if(count >= m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
class union_find():
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.rank = [1 for i in range(n + 1)]

    def find(self, c):
        if self.par[c] == c:
            return c

        ret = self.find(self.par[c])
        self.par[c] = ret
        return ret

    def union(self, x, y):
        xr = self.find(x)
        yr = self.find(y)
        if xr == yr:
            return

        if self.rank[yr] > self.rank[xr]:
            self.par[xr] = yr
        else:
            self.par[yr] = xr
            if self.rank[xr] == self.rank[yr]:
                self.rank[xr] += 1

    def show(self):
        print('parent', self.par[1:])
        print('rank', self.rank[1:])

N, M = map(int, input().split())
uf = union_find(N)

for i in range(M):
    x, y, z = map(int, input().split())
    uf.union(x, y)


print([i == v for i, v in enumerate(uf.par)].count(True) - 1)






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

int main() {
  int A, B;
  int coins = 0;
  int times = 2;

  cin >> A >> B;

  while (times--) {
    if (A >= B) {
      coins += A;
      A--;
    }
    else {
      coins += B;
      B--;
    }
  }
  cout << coins;

  return 0;
}

Measured memory_bytes: 256
"""
E
"""
N=list(map(int,list(input())))

cnt1=0
cnt2=0
kkk=0

for i in range(len(N)):
    if N[i]<=3:
        cnt1+=N[i]
        kkk=0
    
    elif N[i]==4:
        if kkk==0:
            cnt1+=4
        else:
            if i+1<len(N) and N[i+1]>=5:
                cnt1+=5  
            else:
                cnt1+=4
                kkk=0
                
    elif N[i]==5:
        
        if kkk==1:
            cnt1+=4
            
        else:
            if i+1==len(N):
                cnt1+=5
            elif N[i+1]<=4:
                cnt1+=5  
            else:
                cnt2+=1
                cnt1+=4
                kkk=1
                
    else:
        if kkk==0:
            cnt2+=1
            kkk=1
            
        cnt1+=9-N[i]

ans=cnt1+2*cnt2
print(ans)

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


int calc_dist(int x1, int y1, int x2, int y2) {
	return abs(x1 - x2) + abs(y1 - y2);
}


int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> stu(n);
	vector<pair<int, int>> points(m);
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		stu[i] = make_pair(a, b);
	}
	for (int i = 0; i < m; i++) {
		int c, d;
		cin >> c >> d;
		points[i] = make_pair(c, d);
	}

	for (int i = 0; i < n; i++) {
		int min_dist = INT_MAX;
		int index = -1;
		for (int j = 0; j < m; j++) {
			int dist = calc_dist(stu[i].first, stu[i].second, points[j].first, points[j].second);
			if (dist < min_dist) {
				min_dist = dist;
				index = j + 1;
			}
		}
		cout << index << endl;
	}
	return 0;
}


Measured memory_bytes: 384
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

res = 0
for i, a in enumerate(A):
  res += B[a-1]
  if i != N-1:
    if A[i+1] == a + 1:
      res += C[a-1]

print(res)

Measured memory_bytes: 9052
# include <bits/stdc++.h>
//# pragma GCC optimize("Ofast")
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define forn(i, n) for (int i = 0; i < int(n); i++)
# define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define fore(i, l, r) for (int i = int(l); i < int(r); i++)
# define fors(i, s) for (int i = 0; s[i]; i++)
# define in freopen("input.txt", "r", stdin)
# define out freopen("output.txt", "w", stdout)
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define mkp make_pair
//# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"

using namespace std;

const int mod = 1e9 + 7;
const int N = 2e5 + 7;
const ll INF = 1e18 + 7;

vector < int > adj[207];

string y ;

int main()
{
	speed;

    string s ;
    cin >> s ;
    for(int i = 0 ; i < s.size(); i += 2 ){
        y+=s[i];
    }
    for(int i = 0 ; i < y.size(); i ++ ){
        cout<<y[i];
    }

	time;
}


Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() 
{
 ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll N,D,ans=0;
cin>>N>>D;
while(N--)
{
    ll a,b;
    cin>>a>>b;
    if(((a*a)+(b*b))<=(D*D))
    ans++;
}
cout<<ans<<endl;
return(0);
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>

using namespace std;

int main(){
    int k;
    string s;

    cin >> k >> s;

    if(s.size() <= k){
        cout << s << endl;
    }
    else{
        cout << s.substr(0, k) << "..." << endl;
    }

    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair
using namespace std;

int inf = 1e18;
const int N = 6e5+5;
int mod = 1e9+7;
/*
    int ncr(int n , int r ){
    	r = min(r,n-r);
    	int res = 1 ;
    	for(int i = 1 ; i <= r ; i++ ){
    		( res *= n-i+1 )%= mod;
    		res /= i ;
    	}
    	return res ;
    }
*/
//int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
        int n;
        cin>>n;
        if(n&1)
        {
            cout<<"0";
            exit(0);
        }
        n/=2;
        int sum = 0;
        int xxx = 5;
        while(n/xxx>0)
        {
            sum+= n/xxx;
            xxx*=5;
        }
        cout<<sum<<el;

    }
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template <class T>
bool chmax(T &a, const T &b) {if (a < b){ a = b; return 1;} return 0;}
template <class T>
bool chmin(T &a, const T &b) {if (a > b){ a = b; return 1;}return 0;}
template <class T>
void printv(vector<T> v) {for (T t : v) {cout << t << " ";}cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" <<endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    REP(i,n) {
        double x = (i+1) * 1.08;
        int ix = (int) x;

        if (ix == n) {
            cout << (i+1) << endl;
            return 0;
        }
    }

    cout << ":(" << endl;
    
    return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

using Tup = tuple<int64, int64, int64>;

int main(void){
	int64 T, P, R;
	while(cin >> T >> P >> R && T+P+R){
		vector<vector<int64>> cnt(T, vector<int64>(P, 0));
		vector<Tup> res(T);
		REP(i, T) get<2>(res[i]) = -i;
		REP(i, R){
			int32 t, p, time; string s;
			cin >> t >> p >> time >> s; t--; p--;
			if(s[0] == 'C'){
				get<0>(res[t])++;
				get<1>(res[t]) -= 1200*cnt[t][p]+time;
			}else{
				cnt[t][p]++;
			}
		}
		sort(all(res), greater<Tup>());
		REP(i, T){
			cout << -get<2>(res[i])+1 << " " << get<0>(res[i]) << " " << -get<1>(res[i]) << endl;
		}
	}
}



Measured memory_bytes: 3192
#include<stdio.h>
#define ARRAY_MAX 50
#define COUNT_RESET 0
#define RETURN 0
#define ARRAY_END -1
#define TEST_ABSENT -1
#define BORDER_A 80
#define BORDER_B 65
#define BORDER_C 50
#define BORDER_D 30

struct test_result{
    signed short ssW_D_mid;
    signed short ssW_D_fin;
    signed short ssW_D_re;
    unsigned char ubW_D_eval;
};

unsigned char s_EVALUATE(signed short ssW_D_mid, signed short ssW_D_fin, signed short ssW_D_re);

int main(){
    struct test_result test[50];
    unsigned short usW_C_i;
    unsigned short usW_C_count = 0;

    for(usW_C_i = 0;usW_C_i < 50;usW_C_i++){
        scanf("%d %d %d", &test[usW_C_i].ssW_D_mid, &test[usW_C_i].ssW_D_fin, &test[usW_C_i].ssW_D_re);
        if(test[usW_C_i].ssW_D_mid == -1 && test[usW_C_i].ssW_D_fin == -1 && test[usW_C_i].ssW_D_re == -1){
            break;
        }
        test[usW_C_i].ubW_D_eval = s_EVALUATE(test[usW_C_i].ssW_D_mid, test[usW_C_i].ssW_D_fin, test[usW_C_i].ssW_D_re);
        usW_C_count++;
    }

    for(usW_C_i = 0;usW_C_i < usW_C_count;usW_C_i++){
        printf("%c\n", test[usW_C_i].ubW_D_eval);
    }

    return 0;
}

unsigned char s_EVALUATE(signed short ssW_D_mid, signed short ssW_D_fin, signed short ssW_D_re){
    signed short ssW_D_sum;
    unsigned char ubW_D_result;

    ssW_D_sum = ssW_D_mid + ssW_D_fin;

    if(ssW_D_mid == -1 || ssW_D_fin == -1){
        ubW_D_result = 'F';
    }
    else if(ssW_D_sum >= 80){
        ubW_D_result = 'A';
    }
    else if(ssW_D_sum >= 65){
        ubW_D_result = 'B';
    }
    else if(ssW_D_sum >= 50){
        ubW_D_result = 'C';
    }
    else if(ssW_D_sum >= 30){
        if(ssW_D_re >= 50){
            ubW_D_result = 'C';
        }
        else{
            ubW_D_result = 'D';
        }
    }
    else{
        ubW_D_result = 'F';
    }

    return ubW_D_result;
}


Measured memory_bytes: 2032
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int n, k;
VL a;
string s;
map<char, int> m = { {'r',0},{'s',1},{'p',2} };
vector<VL> memo;

bool win(ll x, ll y) {
    if (x == 0)return y == 1;
    else if (x == 1)return y == 2;
    else return y == 0;
}

ll solve(int x, int y) {
    if (n <= x)return 0;
    if (memo[x][y] != -1)return memo[x][y];

    ll ret = 0;
    FOR(j, 0, 3) {
        if (j == y)continue;
        chmax(ret, solve(x + k, j));
    }
    if (win(y, m[s[x]]))ret += a[y];

    return memo[x][y] = ret;
}

int main() {
    init();

    cin >> n >> k;
    a.resize(3); cin >> a;
    cin >> s;

    
    memo = defvec<ll>(-1, n, 3);

    ll ans = 0;
    FOR(i, 0, k) {
        ll cnt = 0;
        FOR(j, 0, 3)chmax(cnt, solve(i, j));
        ans += cnt;
    }
    cout << ans << "\n";
}


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

int main() {
  string c;
  cin >> c;
  
  if( c == "a" || c == "i" || c == "u" || c == "e" || c == "o" ){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }

}

Measured memory_bytes: 3596
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 1000000000;
const int K = 19;

main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
   // freopen("input.txt", "r", stdin);
    int n, k, s;
    cin >> n >> k >> s;
    if (k == 0){
        if (s > n){
            for (int i = 1; i <= n; i++) cout << 1 << " ";
        } else
        for (int i = 1; i <= n; i++) cout << N << " ";
        return 0;
    }
    if (s < N){
        for (int i = 1; i <= k; i++){
            cout << s << " ";
        }
        for (int i = k + 1; i <= n; i++) cout << N << " ";
    }
    if (s == N){
        for (int i = 1; i <= k; i++){
            cout << s << " ";
        }
        for (int i = k + 1; i <= n; i++) cout << 1 << " ";
    }
}


Measured memory_bytes: 1280
#include<stdio.h>

main(){

  int i,j,k,n,q,S[10001],T[501],U[501],frag;
  int count = 0, sumcount = 0;
  
  scanf("%d",&n);
  
  for(i = 0; i < n; i++){
    scanf("%d",&S[i]);
  }
  
  scanf("%d",&q);
  
  for(i = 0; i < q; i++){
    scanf("%d",&T[i]);
  }
  
  
  for(i = 0; i < n; i++){
    for(j = 0; j < q; j++){

      frag = 0;

      if(S[i] == T[j]){	
	for(k = 0; k < count; k++){
	  if(U[k] == T[j] && U[k] == S[i]){
	    frag = 1;
	    break;
	  }
	}
	
	if(frag == 1) continue;
	sumcount++;
	U[count] = T[j];
	count++;
      }
      
    }
    
  }
  
  printf("%d\n",sumcount);
  
  return 0;
}

Measured memory_bytes: 0
/*
  Contest 115
  C - Christmas Eve
  Rakesh Kumar --> 28/09/2020
 */

#include <bits/stdc++.h>

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

    int n = 0, k = 0;
    std::cin >> n >> k;
    std::vector<int> ped;
    while (n--) {
        int h = 0;
        std::cin >> h;
        ped.emplace_back(h);
    }
    std::sort(ped.begin(), ped.end());
    int min_diff = ped[ped.size() - 1];
    for (std::size_t i = 0; i <= ped.size() - k; ++i)
        min_diff = std::min(min_diff, ped[i + k - 1] - ped[i]);
    std::cout << min_diff << std::endl;

    return 0;
}


Measured memory_bytes: 3852
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            //_reads = new string[] { "200000", string.Join(" ", Enumerable.Repeat("1000000000", 200000)) };
            Console.WriteLine(Get());
        }

        static int Get()
        {
            int result = 0;
            var list = ReadLine().Split(' ').Select(int.Parse).ToList();
            list.Sort();
            int diff = list[1] - list[0];
            if (diff % 2 == 0)
            {
                return diff / 2 + list[2] - list[1];
            }
            else
            {
                return diff / 2 + list[2] - list[1] + 2;
            }
        }
}}

Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int func(int n)
{
    int count = 0;
    int sqrt_n = sqrt(n);

    for (int x = 1; x < sqrt_n; x++)
    {
        for (int y = 1; y < sqrt_n; y++)
        {
            for (int z = 1; z < sqrt_n; z++)
            {
                if (x * x + y * y + z * z + x * y + y * z + z * x == n)
                {
                    count++;
                }
            }
        }
    }
    return count;
}

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

    for (int i = 0; i < N; i++)
    {
        cout << func(i + 1) << endl;
    }
    return 0;
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int a[2005], mn[2005], idx[2005];
int main(){
	int n, x;
	scanf("%d%d", &n, &x);
	for(int i=1;i<=n;i++){
		scanf("%d", &a[i]);
		idx[i] = i;
		mn[i] = a[i];
	}
	LL ans = 1e18;
	for(int i=0;i<=n-1;i++){
		LL res = (LL)i*x;
		for(int j=1;j<=n;j++){
			mn[j] = min(mn[j], a[idx[j]]);
			res += mn[j];
			idx[j]--;
			if(idx[j] == 0) idx[j] = n;
		}
		ans = min(ans, res);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n,p[100005],j[100005];
  long long sum=0,max=0,sum2;
  cin>>n;
  while(n!=0){
    for(int i=0;i<n;i++){
      cin>>p[i];
    }
    for(int i=0;i<n-1;i++){
      cin>>j[i];
    }
    for(int i=0;i<n;i++){
      sum+=p[i];
    }
    sum2=sum;
    max=sum*n;
    sort(j,j+n-1,greater<int>());
    for(int i=0;i<n-1;i++){
      sum2+=j[i];
      if(max<sum2*(n-(i+1))){
	max=sum2*(n-(i+1));
      }
    }
    cout<<max<<"\n";
    cin>>n;
    sum=0;
    sum2=0;
  }
  return 0;
}



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

int main(){
  string S;
  cin >> S;
  
  string year, month, day;
  string y0{S[0]};
  string y1{S[1]};
  string y2{S[2]};
  string y3{S[3]};
  string m0{S[5]};
  string m1{S[6]};
  string d0{S[8]};
  string d1{S[9]};
  
  year = y0+y1+y2+y3; 
  month = m0+m1; 
  day = d0+d1; 
  
  if(year < "2019"){
    cout << "Heisei" << endl;
  }
  
  else if(year > "2019"){
    cout << "TBD"<<endl;
  }
  else if(year == "2019" && month > "04"){
    cout << "TBD" << endl;
  }

else{
cout << "Heisei" << endl;
}
  
  return 0;
}

Measured memory_bytes: 256
using AtCoderBeginnerContest116.Questions;
using AtCoderBeginnerContest116.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest116.Questions
{
    public class QuestionC : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var n = inputStream.ReadInt();
            var heights = inputStream.ReadIntArray();
            var current = 0;
            var count = 0;
            foreach (var height in heights)
            {
                if (height > current)
                {
                    count += height - current;
                }
                current = height;
            }

            yield return count;
        }
    }
}


namespace AtCoderBeginnerContest116
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionC();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest116.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest116.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
import numpy as np
from collections import defaultdict

N, K = map(int, input().split())
As = np.array([0] + list(map(int, input().split())))
#Find (i, j) that satisfies "sum(As[i:j]) % K == j - i"
#If 0 < j - i < K then 
#sum(As[i:j]) % K == j - i % K
#<-> (sum(As[:j]) - j) % K == (sum(As[:i]) - i) % K

mods = As % K
csum_mods = np.cumsum(mods)
magic_array = (csum_mods - np.arange(0, N+1)) % K

indices = defaultdict(list)
for i, m in enumerate(magic_array.tolist()):
    indices[m].append(i)

ans = 0
for ls in indices.values():
    j = 1
    for i in range(len(ls)):
        while j < len(ls):
            if ls[j] - ls[i] < K:
                j += 1
            else:
                break
        ans += j - i - 1
        
print(ans)


Measured memory_bytes: 80992
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using static System.Math;

namespace _20190511
{
    class Program
    {
        public static void Main(string[] args)
        {
            using (var sc = new SetConsole())
            {
                var nk = GetArray<int>();
                int n = nk[0];
                int k = nk[1];

                var count = 0;
                for (int i = 0; i < n; i++)
                {
                    var length = i + k;
                    if (n >= length)
                    {
                        count++ ;
                    }
                }

                CWrite(count);
            }
        }

        static void CWrite<T>(T str) => Console.WriteLine(str);
        static string GetString() => Console.ReadLine();
        static T[] GetArray<T>()
        {
            var t = typeof(T);
            var str = Console.ReadLine();
            if (t == typeof(string))
            {
                return (T[])(object)str.Split();
            }
            if (t == typeof(int))
            {
                return (T[])(object)str.ToNumArray<T>();
            }
            if (t == typeof(long))
            {
                return (T[])(object)str.ToNumArray<T>();
            }
            if (t == typeof(double))
            {
                return (T[])(object)str.ToNumArray<T>();
            }
            throw new NotSupportedException($"{t} is not supported.");
        }
    }



    class SetConsole : IDisposable
    {
        readonly StreamWriter sw = new StreamWriter(Console.OpenStandardOutput());
        public SetConsole()
        {
            sw.AutoFlush = false;
            Console.SetOut(sw);
        }
        public void Dispose()
        {
            Console.Out.Flush();
            sw.AutoFlush = true;
            Console.SetOut(sw);
        }
    }

    static class ExtentionsLibrary
    {
        public static T[] ToNumArray<T>(this string str)
        {
            var t = typeof(T);
            if (t == typeof(int))
            {
                return (T[])(object)str.Split().Select(int.Parse).ToArray();
            }
            if (t == typeof(long))
            {
                return (T[])(object)str.Split().Select(long.Parse).ToArray();
            }
            if (t == typeof(double))
            {
                return (T[])(object)str.Split().Select(double.Parse).ToArray();
            }
            throw new NotSupportedException();
        }
        public static int ToInt(this string str) => int.Parse(str);
    }
}


Measured memory_bytes: 13268
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<map>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
int main() {
	int K, S, z;
	ll c = 0;
	scanf("%d%d", &K, &S);
	rep(x, 0, K + 1) {
		rep(y, x, K + 1) {
			z = S - x - y;
			if (z < y || z > K)continue;
			//printf("%d %d %d\n", x, y, z);
			if (x == z)c++;
			else if (x == y || y == z)c += 3;
			else c += 6;
		}
	}
	printf("%lld\n", c);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;
const int maxn = 200005;

int a[maxn];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	ll ans=a[n-1];
	for(int i=n-2,j=2;j<n;i--,j++){
		if(j%2==1)i++;
		ans+=a[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4416
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int

using namespace std;


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

	if (a <= 5)b = 0;
	else if (5 < a&&a <= 12)b /= 2;
	cout << b;

	ed;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define pa pair<int,int>
#define mod 998244353
#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define cl(x) memset(x,0,sizeof x)
#ifdef Devil_Gary
#define bug(x) cout<<(#x)<<" "<<(x)<<endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define bug(x)
#define debug(...)
#endif

const int INF = 0x7fffffff;
const int N=5e5+5;
/*
char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=(TT=but)+fread(but,1,1<<15,stdin),TT==mo))?-1:*TT++)//*/
inline int read(){
    int x=0,rev=0,ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')rev=1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
    return rev?-x:x;
}/*
struct Edge{
	int nxt,v;
//	int w;
//	int id;
}e[N<<1];
void add(int u,int v){
	e[++tot].v=v,e[tot].nxt=head[u],head[u]=tot;
	e[++tot].v=u,e[tot].nxt=head[v],head[v]=tot;
}*/

struct datat{
	int l,r;
	int id;
	int an;
}a[N];
int ans,n,Q,sq,c[N],t[N],d[N];
bool cmp (datat a,datat b){
	if(t[a.l]==t[b.l]) return a.r<b.r;
	return a.l<b.l;
}
bool cmp2(datat a,datat b){
	return a.id<b.id;
}
void up(int x){
	++d[c[x]];
	if(d[c[x]]==1) ++ans;
}
void down(int x){
	--d[c[x]];
	if(d[c[x]]==0) --ans;
}
int main(){
#ifdef Devil_Gary
    freopen("in.txt","r",stdin);
//  freopen("out.txt","w",stdout);
#endif
	n=read(),Q=read();sq=sqrt(n+1); 
	for(int i=1;i<=n;i++) c[i]=read();
	for(int i=1,x,y;i<=Q;i++) x=read(),y=read(),a[i]=datat{x,y,i,0};
	for(int i=1;i<=n;i++){
		t[i]=(i+1)/sq;
	}
	sort(a+1,a+Q+1,cmp);
	for(int i=1,l=0,r=0;i<=Q;i++){
		int L=a[i].l,R=a[i].r;
		while(l<L) {
			down(l);
			++l; 
		} 
		while(l>L){
			--l;
			up(l);
		}
		while(r<R){
			++r;
			up(r);
		}
		while(r>R){
			down(r);
			--r;
		}
		a[i].an=ans;
	}
	sort(a+1,a+Q+1,cmp2);
	for(int i=1;i<=Q;i++) printf("%d\n",a[i].an);
	return 0;
}


Measured memory_bytes: 17376
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

const long long MOD = 1000000007;

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

void normalize(long long& A, long long &B) {
    if (A < 0) {
        A = -A;
        B = -B;
    } else if (A == 0) {
        if (B < 0) {
            B = -B;
        }
    }
}

long long twoPowMod(long long n) {
    if (n == 0) {
        return 1;
    }

    if (n == 1) {
        return 2;
    }

    long long half = twoPowMod(n/2);
    long long ret = half*half % MOD;

    if (n%2) {
        ret *= 2;
        ret %= MOD;
    }

    return ret;
}

int main() {
    int N;
    cin >> N;
    map < pair<long long, long long>, long long> cnt;
    long long spec = 0;

    for (int i = 0; i < N; ++i) {
        long long A;
        long long B;
        cin >> A >> B;
        long long g = gcd(A, B);
        if (g != 0) {
            A /= g;
            B /= g;
        }
        normalize(A, B);
        if (A != 0 || B != 0) {
            ++cnt[make_pair(A, B)];
        } else {
            ++spec;
        }
    }

    auto iter = cnt.begin();
    long long ans = 1;

    while (iter != cnt.end()) {
        long long A = iter->first.first;
        long long B = iter->first.second;
        long long OB = -A;
        long long OA = B;
        normalize(OA, OB);

        long long res = 0;

        if (OA != A || OB != B) { // avoid mirror
            res += twoPowMod(cnt[make_pair(A, B)]);
            res += twoPowMod(cnt[make_pair(OA, OB)]);
            --res; // empty set
        } else {
            res = cnt[make_pair(A, B)]+1;
        }

        res = (res + MOD)%MOD;
        cnt[make_pair(A, B)] = cnt[make_pair(OA, OB)] = 0;

        ans *= res;
        ans %= MOD;

        ++iter;
    }

    cout << ((ans+MOD-1) + spec)%MOD << endl;
    return 0;
}


Measured memory_bytes: 28516
def main():
    import numpy as np

    h,w = map(int,input().split())
    d = np.zeros((10,10))
    for i in range(10):
        a = list(map(int,input().split()))
        d[i] = a
    def WF(b):
        for k in range(10):
            for i in range(10):
                for j in range(10):
                    d[i][j] = min(d[i][j],d[i][k] + d[k][j])
        return d
    WF(d)
    L = []
    for i in range(h):
        b = list(map(int,input().split()))
        L.append(b)
    ans = 0
    for i in range(h):
        for j in range(w):
            if L[i][j] == 1 or L[i][j] == -1:
                continue
            else:
                ans += d[L[i][j]][1]
    print(int(ans))

if __name__ == '__main__':
	main()

Measured memory_bytes: 21652
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	int n,m;
	cin>>n>>m;
	if(n>m)cout<<"safe";
	else cout<<"unsafe"; 
	return 0;
}



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

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

  int n;
  cin >> n;

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

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

  int ans = accumulate(s.begin(), s.end(), 0);

  if (ans % 10 == 0) {
    for (int i = 0; i < n; i++) {
      if ((ans - s[i]) % 10 != 0) {
        ans -= s[i];
        break;
      }
    }

    if (ans % 10 == 0) ans = 0;
  }

  cout << ans << endl;

  return 0;
}

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

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

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int A=a+b,B=c+d;
    if(A>B){
        cout<<"Left"<<endl;
    }else if(A==B){
        cout<<"Balanced"<<endl;
    }else{
        cout<<"Right"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll a,b,n;
int main(){
	cin >> n >> a >> b;
	n -= 2;
	if (n == -1 && a == b)	cout << 1;
	else if (a > b || n < 0)	cout << 0;
	else {
	cout << (b-a)*n+1;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int n,m;
int d[310],a[310][310],now[310];
bool open[310];
int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++)d[i]=0,open[i]=true;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			int k;cin>>k;k--;
			a[i][k]=j;
			if(j==0)d[k]++,now[i]=k;
		}
	}
	int p=0;
	for(int i=0;i<m;i++)if(d[i]>d[p])p=i;
	int ans=d[p];
	for(int u=0;u<m;u++){
		open[p]=false;
		for(int i=0;i<n;i++){
			int q;
			for(int j=0;j<m;j++)if(open[j])q=j;
			for(int j=0;j<m;j++){
				if(open[j]&&a[i][j]<a[i][q])q=j;
			}
			d[now[i]]--;d[q]++;now[i]=q;
		}
		p=0;
		for(int i=0;i<m;i++)if(d[i]>d[p])p=i;
		ans=min(ans,d[p]);
	}
	cout<<ans<<endl;
	return 0;
}


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

int n, m, h[101010];
vector<vector<int>> graph(101010, vector<int>(0));

int main()
{
    cin >> n >> m;
    rep(i, n) cin >> h[i + 1];
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        graph[a].emplace_back(b);
        graph[b].emplace_back(a);
    }

    int res = 0;
    for(int i = 1; i <= n; i++)
    {
        bool flag = true;
        for(int x : graph[i])
        {
            if(h[x] >= h[i])
            {
                flag = false;
                break;
            }
        }
        if(flag) res++;
    }

    cout << res << endl;

    
    return 0;
}

Measured memory_bytes: 8736
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <map>
#include <iomanip>
#include <limits>
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;

int asc(const void* a, const void* b) {
	return *(int*)a- *(int*)b;
}

int main()
{
	int n, m, ans = 0, maxL = 0, minR = 999999;
	cin >> n >> m;
	vector <int> l(m);
	vector <int> r(m);
	rep(i, m) {
		cin >> l[i] >> r[i];
		if (l[i] > maxL) maxL = l[i];
		if (r[i] < minR) minR = r[i];
	}
	if (minR >= maxL) {
		cout << minR - maxL + 1 << endl;
	}
	else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 1024
// yukicoder@csharp

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.CompilerServices;
//using System.Web.UI;
using Debug = System.Diagnostics.Debug;
// using System.Drawing.Primitives;
//using System.Drawing;
using System.Windows;
using System.Numerics;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            new Solver().Solve();
        }
    }

    //class Cout {
    //    public static Cout operator >>(
    //        Cout a, int b)
    //    {
    //        Console.WriteLine(b);
    //        return a;
    //    }
    //    //public void Cout(long a) { Console.WriteLine(a); }
    //    //public void Cout(double a) { Console.WriteLine(a); }
    //}

    class GeneralPurposeClass {
        //public const double inf = double.PositiveInfinity;
        public const long inf = 1L << 50;
        public readonly TextWriter error = Console.Error;

        public void Rep(long n_, Action<int> action)
        {
            for (int i = 0; i < n_; i++)
            {
                action(i);
            }
        }

        public void Rep2(int a, long n_, Action<int> action)
        {
            for (int i = a; i < n_; i++)
            {
                action(i);
            }
        }

        public string ReadLine()
        {
            return Console.ReadLine();
        }

        public string ReadNext()
        {
            var s = "";
            while (true)
            {
                var c = Console.Read();
                if (c != ' ' && c != '\n' && c != '\r')
                {
                    s += (char)c;
                    break;
                }
            }
            while (true)
            {
                var c = Console.Read();
                if (c == ' ' || c == '\n' || c == '\r') break;
                s += (char)c;
            }
            return s;
        }

        public long ReadLong()
        {
            return Stol(ReadNext());
        }

        public long Stol(string s)
        {
            return long.Parse(s);
        }

        public static void Write<T>(T a)
            where T : IComparable
        { Console.Write(a); }

        public static void WriteL<T>(T a)
            where T : IComparable
        { Console.WriteLine(a); }
    }

    class Solver : GeneralPurposeClass
    {
        public void Solve()
        {
            var n = ReadLong();
            //WriteL("n: " + n);

            var a = 0;
            Rep2(1, 10, (i) =>
            {
                if (n % i == 0) a = i;
            });
            var b = n / a;
            //WriteL("a: " + a);
            //WriteL("b: " + b);
            var c = 1 <= a && a <= 9 
                && 1 <= b && b <= 9;
            WriteL(c ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 11220
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int c = Integer.parseInt(sc.next());
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        System.out.println(a * c / 2);
    }
}


Measured memory_bytes: 23124
n,k,*a=map(int,open(i:=0).read().split())
a.sort()
p=a.pop
s=b=~k%2or p()
for _ in k//2*'_':
 if(x:=a[i]*a[i+1])*b>a[-1]*a[-2]*b:s*=x;i+=2
 else:s*=p()*p()
 s%=10**9+7
print(s)

Measured memory_bytes: 31760