akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#define int long long
#define inf (int)(1e14)

int min(int a, int b){
	return a <= b ? a : b;
}

signed main(){
	int N, A, B, i, j;
	scanf("%lld%lld%lld", &N, &A, &B);
	int *p = (int *)malloc(sizeof(int) * (N + 1));
	int *p_inv = (int *)malloc(sizeof(int) * (N + 1));
	for(i = 1; i <= N; i++){
		scanf("%lld", &p[i]);
		p_inv[p[i]] = i;
	}
	int **dp1 = (int **)malloc(sizeof(int *) * (N + 1));
	int **dp2 = (int **)malloc(sizeof(int *) * (N + 1));
	int **m1 = (int **)malloc(sizeof(int *) * (N + 1));
	int **m2 = (int **)malloc(sizeof(int *) * (N + 1));
	for(i = 0; i <= N; i++){
		dp1[i] = (int *)malloc(sizeof(int) * (N + 1));
		dp2[i] = (int *)malloc(sizeof(int) * (N + 1));
		m1[i] = (int *)malloc(sizeof(int) * (N + 1));
		m2[i] = (int *)malloc(sizeof(int) * (N + 1));
	}
	for(j = 0; j <= N; j++){
		dp1[0][j] = 0;
		dp2[0][j] = 0;
		m1[0][j] = 0;
		m2[0][j] = 0;
	}
	for(i = 1; i <= N; i++){
		dp1[i][0] = inf;
		for(j = 1; j <= N; j++){
			dp1[i][j] = min(m1[i - 1][j - 1], m2[i - 1][j - 1]);
			if(j < p_inv[i]){
				dp1[i][j] += B;
			}
			if(j > p_inv[i]){
				dp1[i][j] += A;
			}
		}
		for(j = 0; j <= N; j++){
			dp2[i][j] = min(m1[i - 1][j], m2[i - 1][j]);
			if(j < p_inv[i]){
				dp2[i][j] += B;
			}
			else{
				dp2[i][j] += A;
			}
		}
		m1[i][0] = dp1[i][0];
		for(j = 1; j <= N; j++){
			m1[i][j] = min(m1[i][j - 1], dp1[i][j]);
		}
		m2[i][0] = dp2[i][0];
		for(j = 1; j <= N; j++){
			m2[i][j] = min(m2[i][j - 1], dp2[i][j]);
		}
	}
	printf("%lld\n", min(m1[N][N], m2[N][N]));
	return 0;
}

Measured memory_bytes: 782080
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,N;
  a=0;
  b=0;
  cin >> N;
  vector<int> vec(N);
  
  for(int i=0;i<N;i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  for(int j=0;j<N;j++){
    if(j%2==0){
      a+=vec.at(j);
    }else{
      b+=vec.at(j);
    }
  }
  
  cout << a-b << endl;
}

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int a, b, c, d, n, x, y;
    string s, t;


    auto Yes = [&](bool t){
        cout << (t ? "Yes" : "No") << endl;
    };
    auto YES = [&](bool t){
        cout << (t ? "YES" : "NO") << endl;
    };
    auto tri = [&](bool t, string a, string b){
        cout << (t ? a : b) << endl;
    };

    int k;
    cin >> k;
    cout << (k / 2) * ((k + 1) / 2) << endl;
}


Measured memory_bytes: 256
from collections import deque
N = int(input())
a = deque()


for i in range(N):
    c = input()
    if c == 'deleteFirst':
        a.popleft()
    elif c == 'deleteLast':
        a.pop()
    else:
        c, n = c.split()
        if c == 'insert':
            a.appendleft(n)
        elif c == 'delete':
            try:
                a.remove(n)
            except:
                pass

for i in range(len(a)):
    if i != len(a) - 1:
        print(a[i], end=" ")
    else:
        print(a[i])


Measured memory_bytes: 69736
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int a[105];
int main(){
	int n, m;
	cin >> n >> m;
	int sum = 0;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		sum += a[i];
	}
	sort(a + 1, a + n + 1, greater<int>());
	printf("%s\n", a[m] * 4 * m < sum ? "No" : "Yes");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
  long long N,K;
  cin>>N>>K;
  long long A[N];
  long long a;
  long long a_sum=0;
  vector<long long> GCD;
  for(int i=0;i<N;++i){
    cin>>a;
    A[i]=a;
    a_sum+=a;
  }
  long long i=1;
  long long num_gcd=0;
  while(i*i<=a_sum){
    if(a_sum%i==0){
      GCD.push_back(i);
      GCD.push_back(a_sum/i);
      num_gcd+=2;
    }
    i+=1;
  }
  long long target=0;
  std::sort(GCD.begin(),GCD.end(),std::greater<long long>());
  for(int j=0;j<num_gcd;++j){
    target=GCD[j];
    vector<long long> amari;
    long long plus=0;
    long long minus=0;
    int minus_point=0;
    int plus_point=N-1;
    for(int k=0;k<N;++k){
      amari.push_back((A[k]+target)%target);
    }
    std::sort(amari.begin(),amari.end());
    minus=amari[minus_point];
    plus=target-amari[plus_point];
    while(plus_point-minus_point>1){
      if(minus<=plus){
        minus_point+=1;
        minus+=amari[minus_point];
      }
      else{
        plus_point-=1;
        plus+=(target-amari[plus_point]);
      }
    }
    long long move;
    move=max(minus,plus);
    if(move<=K){
      cout<<target<<"\n";
      break;
    }
  }
return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>
#include<functional>
#include<numeric>
#include <tuple>

using namespace std;
#define ll long long
#define ld long double
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define mkp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
#define ssp(i,n) (i==n-1?"\n":" ")
#define pb push_back
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll Inf = 3 * 1e18;
const int inf = 15 * 1e8;
ll read() {
	ll u, k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}
ll bitcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 60; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
/*const int fn_ = 2000000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % Mod;
			comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}*/
//---------------------------------------------------
bool b[200000];
signed main() {
	int n, k;
	int r, s, p;
	string t;
	cin >> n >> k >> r >> s >> p >> t;
	int ans = 0;
	for (int i = 0; i < k; i++) {
		for (int j = i; j < n; j += k) {
			if (j == i || t[j] != t[j - k] || b[j - k]) {
				if (t[j] == 'r') ans += p;
				else if (t[j] == 's') ans += r;
				else ans += s;
			}
			else b[j] = 1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N;//団体
  cin >>N;
  int x;//人数
  x=0;
  
  rep(i,N){
    int l,r;
    cin>>l>>r;
    x=x+1+r-l;
  }
  
  cout<<x<<endl;
}

Measured memory_bytes: 256
def main():
    *s, = map(int, input())  # <= 2*10**5

    r = [0] * 2019
    r[0] = 1

    ans = 0

    t = 0
    p = 1
    for x in reversed(s):
        t = (t + x * p) % 2019
        p = (p * 10) % 2019
        ans += r[t]
        r[t] += 1

    print(ans)


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


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

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

const ll MOD = 1E+09 + 7;
const ll INF = 1E18;
const int MAX_H = 100;
const int MAX_N = MAX_H * MAX_H;

int H, W, N;

int A[MAX_N + 1];

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

    cin >> H >> W >> N;

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

    int c = 1;
    for (int i = 0; i < H; i++) {
        vector<int> v;
        int col = 0;
        while (true) {
            if (col + A[c] > W) {
                for (int j = 0; j < W - col; j++) {
                    v.push_back(c);
                }
                A[c] -= W - col;
                break;
            }
            col += A[c];
            for (int j = 0; j < A[c]; j++) {
                v.push_back(c);
            }
            c++;
        }
        if (i & 1) {
            for (auto ite = v.rbegin(); ite != v.rend(); ite++) {
                cout << *ite << " ";
            }
        } else {
            for (auto ite = v.begin(); ite != v.end(); ite++) {
                cout << *ite << " ";
            }
        }
        cout << "\n";
    }

    return 0;
}

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

using namespace std;

int J, Y;


void solve(int j, int y, string result) {
	if (j == J && y == Y) {
		cout << result << endl;
		return;
	}
	if (j <= 3 && y == 5 || y <= 3 && j == 5) {
		return;
	}
	if (j == 5 && y == 5) {
		return;
	}
	
	if (j + 1 <= J) {
		solve(j + 1, y, result + "A");
	}
	if (y + 1 <= Y) {
		solve(j, y + 1, result + "B");
	}	
}

int main() {
	
	cin >> J >> Y;
	solve(0, 0, "");

	return 0;
}



Measured memory_bytes: 3172
#include <iostream>
#include <string>
#define REP(i, n) for(int i=0; i<(n); i++)
using namespace std;


int main(){
    string s;cin>>s;
    int len = s.size();
    bool flag = true;
    if(len % 2 == 0){
        for(int i=0; i<len/2; i++){
            if(s[i] == 'p' && s[len-1-i] != 'q') flag = false;
            else if (s[i] == 'q' && s[len-1-i] != 'p') flag = false;
            else if (s[i] == 'b' && s[len-1-i] != 'd') flag = false;
            else if (s[i] == 'd' && s[len-1-i] != 'b') flag = false;
        }
    }else{
        flag = false;
    }

    string ans = flag ? "Yes" : "No";
    cout << ans << endl;
    return 0;
}

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

int main (void) {
  int N;
  int P[200000];
  
  cin >> N;
  int minVal = N+1;
  int cnt = 0;
  for (int i = 0; i < N; i++){
    cin >> P[i];
    if (minVal >= P[i]) {
      minVal = P[i];
      cnt++;
    }
  }
  
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int n, k;
    int p[max];
    
    scanf("%d%d", &n, &k);
    rep(i, n){
        scanf("%d", &p[i]);
    }
    
    qsort(p, n, sizeof(int), up_comp);
    
    int ans=0;
    
    rep(i, k){
        ans+=p[i];
    }
    
    printf("%d", ans);
    
    return 0;
}



Measured memory_bytes: 1756
#-*- coding: utf-8
#  -*-
"""
oj dl https://atcoder.jp/contests/abc116/tasks/abc116_d -d test-d
oj test -d test-d -c "python abc116d.py"
oj test -d test-d -c "python abc116d.py" test-d/sample-3.in
"""
from collections import defaultdict
import sys
import math
from datetime import datetime

def sol(a, b):
    return "Yes" if a == b else "No"
    #if a + b + c <= 21: return 'win'
    #else: return 'bust'



do_submit = True
#do_submit = False

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(str, line.split())) for line in lines]
    print(parsed_lines)
    n = int(parsed_lines[0][0])
    k = int(parsed_lines[0][1])
    S = parsed_lines[1][0]
    return n, k, S


if not do_submit:
    a, b, c = input_parse("""
    3 1
    ABC
    """)
    print(sol(a, b, c))

    a, b, c = input_parse("""
    4 3
    CABA
    """)
    print(sol(a, b, c))

else:
    a, b = list(map(int, input().split()))
    # S = input().split()
    # a = int(input())
    # b = int(input())
    # T = input()
    print(sol(a, b))
    # S = input().strip()
    # print(sol(S))



Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main() {

    int n, k;
    cin >> n >> k;

    ll x = 0;
    ll y = 0;
    for(int i=1; i<=n; i++){
        if(i % k == 0){
            x++;
        }
        if(i % k == k / 2){
            y++;
        }
    }
    ll ans = x * x * x;
    if(k % 2 == 0){
        ans += y * y * y;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<map>
#include<string>
#include<numeric>
#include<set>
using namespace std;

int sqsum(vector<int> x1, vector<int> x2, int d){
    int ans = 0;
    for(int i = 0; i < d; i++){
        ans += (x1[i]-x2[i]) * (x1[i]-x2[i]);
    }

    return ans;
}

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

    vector<vector<int> > x(n, vector<int>(d));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < d; j++) cin >> x[i][j];
    }

    int cnt = 0;

    for(int i = 0; i < n; i++){
        for(int j = i; j < n; j++){
            int k = 1;
            int dist2 = sqsum(x[i], x[j], d);
            while(k*k < dist2) k++;
            if(k*k == dist2) cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

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

int main(){
  
  int x,a,b; cin >> x >> a >> b;
  
  if(abs(x - a) < abs(x - b)){
	cout << "A" << endl;
  }
  
  else{
    cout << "B" << endl;
  }
  
  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = long long ;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

struct Sieve {
    ll n;
    vi f;
    vi primes;
    // constructor
    Sieve(ll n=1) : n(n), f(n+1,0) {
        f.at(0) = -1;
        f.at(1) = -1;
        for(ll i = 2; i <= n; ++i){
            if (f.at(i)!=0) continue;
            primes.push_back(i);
            f.at(i) = i;
            for (ll j = i*i; j <= n; j += i) {
                if(f.at(j)==0) f.at(j) = i;
            }
        }
    }
    // xが素数かを判定
    bool isPrime(ll x) {
        return f.at(x) == x;
    }
    // xを素因数分解する関数(分解後の値を昇順の配列にして返す)
    // (100) => ([2,1,5,5]);
    vi primeFactorizedList(ll x) {
        vi res;
        while (x != 1) {
            res.push_back(f.at(x));
            x /= f.at(x);
        }
        return res;
    }
    // 素因数分解したときの各因数の個数をsecondに持つpairにする
    vector<P> primeFactorizedPair(ll x) {
        vi fl = primeFactorizedList(x);
        if (fl.size() == 0) return {};
        vector<P> res(1, P(fl.at(0), 0));
        for (ll p : fl) {
            if (res.back().first == p) {
                res.back().second++;
            } else {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
};

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll n;
    cin >> n;
    Sieve si = Sieve(1000007);
    ll res = 0;
    for(ll p: si.primes){
        ll f = 0;
        while(n%p==0) n/=p, f++;
        if(f==0) continue;
        ll count = 0;
        for(ll i=1; i<1000007; i++){
            count += i;
            if(count > f){
                res += i-1;
                break;
            }
        }
    }
    if(n > 1000007) res += 1;
    cout << res << endl;
}

Measured memory_bytes: 12052
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import Counter

n = ni()
blue = []
for _ in range(n):
    blue.append(ns())
    
m = ni()
red = []
for _ in range(m):
    red.append(ns())
    
blc = Counter(blue)
rdc = Counter(red)

ans = 0
for bk, bv in blc.items():
    if bk in rdc.keys():
        ans = max(ans, bv - rdc[bk])
    else:
        ans = max(ans, bv)
        
        
print(ans)


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

int main() {
  // ここにプログラムを追記
  int a, b;
  cin >> a >> b;
  if((a+b) % 2  == 0)
  {
   	cout << (a+b)/2 << endl; 
  }else{
  	cout << (a+b)/2 + 1 << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int W = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    int ans = 0; 
    if(b - a - W > 0 ){
      ans = b-a-W;
    }else if(a - b - W > 0 ){
      ans = a-b-W;
    }else{
      ans = 0;
    }
    System.out.println(ans);
  }
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    int x;cin >>x;
    int q=x/100;
    int r=x%100;
    int cnt=(r+4)/5;
    if(cnt<=q)puts("1");
    else puts("0");
}


Measured memory_bytes: 3556
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(x) cout << fixed << setprecision(x);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll a; cin >> a; ll sum = 0;
  for(ll i=0; i < 6; i++){
    sum += a % 10; a /= 10;
  }
  
  cout << sum << endl;
  return 0; 
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int h = sc.nextInt();
        int n = sc.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
            a[i] = sc.nextInt();
        }

        int ws = 0;
        int we = w;
        int hs = 0;
        int he = h;
        for (int i = 0; i < n; i++) {
            if (a[i] == 1) {
                if (x[i] > ws) {
                    ws = x[i];
                }
            } else if (a[i] == 2) {
                if (x[i] < we) {
                    we = x[i];
                }
            } else if (a[i] == 3) {
                if (y[i] > hs) {
                    hs = y[i];
                }
            } else if (a[i] == 4) {
                if (y[i] < he) {
                    he = y[i];
                }
            }
            if (we - ws < 0 || he - hs < 0) {
                System.out.println(0);
                return;
            }
        }
        System.out.println((we - ws) * (he - hs));
    }

}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N; cin>>N;
    vector<pair<int,int>> X(N);
    rep(n,0,N){
        int x; cin>>x;
        X.at(n)=make_pair(x,n);
    }
    sort(ToEnd(X));

    vector<int> Ans(N);
    rep(n,0,N){
        if(n<N/2) Ans.at(X.at(n).second)=X.at(N/2).first;
        else Ans.at(X.at(n).second)=X.at(N/2-1).first;
    }

    for(auto ans:Ans) cout<<ans<<endl;
}

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

using namespace std;

int main(void)
{
    int black_pos;
    int successive_black_count;

    cin >> successive_black_count >> black_pos;

    for(int i = black_pos - successive_black_count + 1; i < black_pos + successive_black_count; i++ ){
        cout << i << ' ';
    }

    cout << endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define It set<node>::iterator
#define endl '\n'
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

string s1,s2,s;
int a,b;

int main(){
	cin>>s1>>s2>>a>>b>>s;
	if(s==s1) --a;
	if(s==s2) --b;
	cout<<a<<" "<<b<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define fast ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const int N=100002;
vector<vector<int>>g;
int dp[N];
bool vis[N];
void dfs(int node)
{
    vis[node]=true;
    for(auto u:g[node]){
        if(!vis[u])dfs(u);
        dp[node]=max(dp[node],dp[u]+1);
    }
}


int main()
{
    fast
    int ans=0,n,m;cin>>n>>m;
    g.assign(n+1,vector<int>());
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        g[u].push_back(v);
    }
    for(int i=1;i<=n;i++)
        if(!vis[i])dfs(i);
    for(int i=1;i<=n;i++)
        ans=max(ans,dp[i]);
cout<<ans;
return 0;
}


Measured memory_bytes: 8320
# coding: utf-8
# Your code here!
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

if a<40:
    a=40
if b<40:
    b=40
if c<40:
    c=40
if d<40:
    d=40
if e<40:
    e=40

print(int(sum((a,b,c,d,e))/5))


Measured memory_bytes: 5604
# 下記ページを参考に実装している
# https://qiita.com/drken/items/56a6b68edef8fc605821#%E5%95%8F%E9%A1%8C-2-atcoder-abc-084-d---2017-like-number

# エラトステネスのふるいで最大値までの素数をO(1)で判別できるようにする

MAX = 10 ** 5 + 10
is_prime = [True] * MAX
is_prime[0] = False
is_prime[1] = False
for i in range(2, MAX):
  if not is_prime[i]:
    continue
  for j in range(i*2, MAX, i):
    is_prime[j] = False

# 2017と似た数字かどうか
like2017 = [0] * MAX
for i in range(2, MAX):
  if is_prime[i] and is_prime[(i+1)//2]:
    like2017[i] = 1

# 累積和
s = [0] * (MAX+1)
for i in range(MAX):
  s[i+1] = s[i] + like2017[i]
#print(is_prime[:10])
#print(like2017[:10])
#print(s[:10])

# クエリ処理
q = int(input())
for i in range(q):
  l, r = map(int, input().split())
  print(s[r+1] - s[l])

Measured memory_bytes: 52568
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<(int)N;i++)
 
int main() {
  int N, Alice=0, Bob=0;
  vector<int> card(111);
  cin >> N;
  rep(i,N){cin >> card.at(i);}
  sort(card.begin(),card.end(),greater<int>());
  rep(j,N)
  {
    if(j%2==0) Alice=Alice+card.at(j);
    else Bob=Bob+card.at(j);
  }
  cout << Alice-Bob << endl;
}

Measured memory_bytes: 256
n=int(input())
m=len(str(n))
k=int(input())
N=[int(i) for i in str(n)]
dp0=[[0]*(k+1) for _ in range(m+1)]
dp1=[[0]*(k+1) for _ in range(m+1)]
dp1[0][0]=1
for i,e in enumerate(str(n)):
    e = int(e)
    for j in range(k+1):
        dp1[i+1][j]+=dp1[i][j]*(e==0)
        dp0[i+1][j]+=dp0[i][j]+dp1[i][j]*(e!=0)
        if j<k:
            dp1[i+1][j+1]+=dp1[i][j]*(e!=0)
            dp0[i+1][j+1]+=dp0[i][j]*9+dp1[i][j]*max(0,e-1)
print(dp1[m][k]+dp0[m][k])

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<long,long>
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; }
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<int, int> mp;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
class Union_Find {
private:
	vector<int> par;
	vector<int> rank;
public:
	Union_Find(int n) {
		rep(i, n) {
			par.push_back(i);
			rank.push_back(0);
		}
	}
	int find(int x) {
		if (par.at(x) == x) return x;
		else return par.at(x) = find(par.at(x));
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (rank.at(x) < rank.at(y)) {
			par.at(x) = y;
		}
		else {
			par.at(y) = x;
			if (rank.at(x) == rank.at(y)) rank.at(x)++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n);
	rep(i, n)cin >> a[i];
	rep(i, n)cin >> b[i];
	rep(i, n)cin >> c[i];
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());

	vector<int> bc(n), ab(n);
	rep(i, n) {
		bc[i] = c.end() - upper_bound(c.begin(), c.end(), b[i]);
	}
	rep(i, n) {
		ab[i] = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
	}
	int ans = 0;
	rep(i, n) {
		ans += ab[i] * bc[i];
	}
	cout << ans << endl;
	return 0;
}

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

const int maxn = 1e7+1;

int n;
long long d[maxn];

void sieve() {
	for (int i = 1; i < maxn; ++i) {
		for (int j = i; j < maxn; j += i) {
			d[j]++;
		}
	}
}

int main() {
	cin >> n;
	sieve();
	long long ans = 0;
	for (int i = 1; i <= n; ++i) {
		ans += d[i] * i;
	}
	cout << ans << '\n';
}

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

int main(){
  int n,u,k,v;
  int g[102][102];
  
  memset(g,0,sizeof(g));

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>u>>k;
    for(int j=0;j<k;j++){
      cin>>v;
      g[u][v]=1;
    }
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      if(j!=1)cout<<" ";
      cout<<g[i][j];
    }
    cout<<endl;
  }
  return(0);
}

Measured memory_bytes: 1208
sub f{$p[$_]=$_-(local$_=$p[$_])?&f:$_}map{@p=0..$`;($==f$_=<>=~$"*$')-($%=f$_=$`)and$p[$%]=$=for 1..$_;@{$|--}=map f,@p}<>=~/ \d+/g;print$$_,$/for map{++${$t=\${$0[$_]}{$1[$_]}};$t}1..$`

Measured memory_bytes: 164480
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;
using namespace std;

#define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (int i = (a); i < (b); i++)
#define rrrep(i, a, b) for (int i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl

ll n, cnt, ans, a[ohara], b, c, d, tmp, tmpp, m, h, w, x, y, pos, k;
ld doua;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
bool fl;
struct edge
{
    int to, cost;
};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin >> n;
    ll sum[ohara] = {};
    rep(i, n) cin >> a[i];
    //rrep(i, 1, n) sum[i] += sum[i - 1];
    sort(a, a + n);
    rep(i, n) sum[i] = a[i];
    rrep(i, 1, n) sum[i] += sum[i - 1];
    reverse(a, a + n);
    ans = 1;
    rep(i, n - 1)
    {
        ll boss, te;
        te = sum[n - i - 2];
        if (a[i] <= te * 2)
            ans++;
            else break;
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 8832
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

	int n, k;
	cin >> n >> k;
	double res = 0;
	for (int sc = 1; sc <= n; sc++) {
		double p = (double)1 / n;
		int t = sc;
		while (t < k) {
			t *= 2;
			p /= 2;
		}
		res += p;
	}
	cout << fixed << setprecision(16);
	cout << res << endl;
}


Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    private static final PrintStream so = System.out;
    private static final Scanner     sc = new Scanner(System.in);
    static final String KEYENCE = "keyence";
    public static void main(String[] args) {
        String s = sc.next();
        if (s.startsWith(KEYENCE)) {
            so.println("YES");
        } else if (s.endsWith(KEYENCE)) {
            so.println("YES");
        } else {
            for (int i = 0; i < KEYENCE.length(); i++) {
                if (s.startsWith(KEYENCE.substring(0, i)) && s.endsWith(KEYENCE.substring(i, KEYENCE.length()))) {
                    so.println("YES");
                    return;
                }
            }
            so.println("NO");
        }
    }
}


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

int main()
{
    ll N,K;
    cin >> N >> K;
    vector<ll> h(N);
    for(int i = 0; i < N; i++)
    {
        cin >> h[i];
    }

    sort(h.begin(),h.end());
    ll minDiff = 1e9;

    for(int i = 0; i <= N-K; i++)
    {
        minDiff = min(minDiff,h[i+K-1]-h[i]);
    }

    cout << minDiff << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;


int main()
{
	int input[3];
	for (int i = 0; i < 3; i++) {
		cin >> input[i];
	}

	sort(input, input + 3);
	cout << input[0] + input[1] << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a[10],f=0,s=0,t=0;
	for(int i=0;i<=9;i++){
		cin>>a[i];
		if(a[i]>t){
			t=a[i];
			if(s<t){
				swap(s,t);
				if(f<s){
					swap(f,s);
				}
			}
		}
	}
	cout<<f<<endl<<s<<endl<<t<<endl;
}

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

int main(){
    // あとで消す
    //std::ifstream in("ain3.txt");
    //std::cin.rdbuf(in.rdbuf());

    int a,b;
    cin >> a >> b;

    int sum, sub, mul;

    sum = a+b;
    sub = a-b;
    mul = a*b;

    if(sum>sub){
        if(sum>mul){
            cout << sum << endl;
        }else{
            cout << mul << endl;
        }
    }
    else{
        if(sub>mul){
            cout << sub << endl;
        }
        else{
            cout << mul << endl;
        }
    }

    return 0;
}


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

int main() {
    // your code goes here
    ll h,n,i,j,k,a[1005],b[1005],dp[1005][10005];
    cin >> h >> n;
    for(i=1;i<=n;i++){
        cin >> a[i] >> b[i];
    }
    for(i=0;i<=n;i++){
        for(j=0;j<=h;j++) dp[i][j]=1e12;
    }
    dp[0][0]=0;
    for(i=1;i<=n;i++){
        for(j=0;j<=h;j++){
            dp[i][j]=min(dp[i-1][j],dp[i][max(0ll,j-a[i])]+b[i]);
        }
    }
    cout << dp[n][h] << endl;
    return 0;
}

Measured memory_bytes: 78720
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val s = sc.nextLine()
    if ((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])) {
        println("Yes")
    } else {
        println("No")
    }
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 34364
N,M,Q = [int(v) for v in input().split()]

querys = [[int(v) for v in input().split()] for _ in range(Q)]

ans = 0
L = []

def dfs(now,last = 1):
    if len(now) == N:
        L.append(now)
        return

    for i in range(1,M+1):
        if i >= last:
            c = now[:]
            c.append(i)
            dfs(c,last=i)

dfs([1])

for l in L:
    tmp = 0
    for q in querys:
        a,b,c,d = q
        if l[b-1] - l[a-1] == c: tmp+= d
    ans = max(ans,tmp)
print(ans)


Measured memory_bytes: 19316
#include <iostream>
#include <cstdint>
#include <unordered_map>
#include <numeric>
#include <algorithm>
#include <array>

std::uint_fast64_t make_key(const std::int_fast64_t y, const std::int_fast64_t x) {
  return (static_cast<std::uint_fast64_t>(y) << 32u) | static_cast<std::uint_fast64_t>(x);
}

int main() {
  std::int_fast64_t h, w, n;
  std::cin >> h >> w >> n;

  std::unordered_map<std::uint_fast64_t, std::int_fast64_t> sparse_grid;
  for (std::int_fast64_t i = 0; i < n; ++i) {
    std::int_fast64_t a, b;
    std::cin >> a >> b;
    for (std::int_fast64_t y = std::max<std::int_fast64_t>(a - 1, 2); y <= std::min<std::int_fast64_t>(a + 1, h - 1); ++y) {
      for (std::int_fast64_t x = std::max<std::int_fast64_t>(b - 1, 2); x <= std::min<std::int_fast64_t>(b + 1, w - 1); ++x) {
        ++sparse_grid[make_key(y, x)];
      }
    }
  }

  std::array<std::int_fast64_t, 10> results = {0};
  for (const auto& kv : sparse_grid) {
    ++results[kv.second];
  }
  results[0] = (h - 2) * (w - 2) - std::accumulate(results.begin() + 1, results.end(), 0, [](const std::int_fast64_t sum, const std::int_fast64_t x) { return sum + x; });

  for (const std::int_fast64_t& result : results) {
    std::cout << result << std::endl;
  }
  return 0;
}

Measured memory_bytes: 36624
#include<stdio.h>
int main(){
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    if( A== 5 && B == 5 &&  C == 7){
        printf("YES");
    }
    else if(A == 5 && B == 7&& C == 5){
        printf("YES");
    }
    else if(A == 7 && B==5 && C == 5){
        printf("YES");
    }
    else{
        printf("NO");
    }
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(void){
    int a, b, c, k;
    scanf("%d %d %d %d", &a, &b, &c, &k);
    if(a>= k){
        printf("%d", k);
    }
    else if ((a + b) >= k)
    {
        printf("%d", a);
    }
    else
    {
        k = k - a - b;
        printf("%d", a - k);
    }
    
    return 0;
}

Measured memory_bytes: 1684
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 08/02/20 20:55:48
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int x; cin>>x;
  cout << (x >= 30 ? "Yes" : "No") << endl;

  return 0;
}


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

vector<vector<int> >adj;

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(0);   
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif

  int x;
  cin>>x;
  for(int i=1;i<=200;i++)
  {
    for(int j=-200;j<=200;j++)
    {
      int z=pow(i,5)-pow(j,5);
      if(z==x)
      {
        cout<<i<<" "<<j;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 4100
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

  public static void main(String[] args) {

    new Main().run();
  }
  public void run() {
    
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(in.readLine());
      String line = in.readLine();
      int[] ax = new int[n];
      long sum = 0;

      int m;
      int offset=0,next=0;
      char regex = ' ';
      boolean isContinue = true;
      for(int i=0; isContinue; i++) {
        if((next = line.indexOf(regex,offset)) == -1) {
          next = line.length();
          isContinue = false;
        }
        m = Integer.parseInt(line.substring(offset,next));
        ax[i] = m - (i+1);
        offset = ++next;
      }

      Arrays.sort(ax);
      int b = ax[n/2];

      for (int i : ax) {
        sum += Math.abs(i-b);
      }

      System.out.println(sum);

    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

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

struct vector {
	int max;
	int count;
	int *value;
	vector() {
		max = 100;
		count = 0;
		value = new int[max];
	}
	void push_back(int x) 
	{
		if (count >= 0.8 * max)
		{
			max *= 2;
			int *temp = value;
			value = new int[max];
			for (int i = 0; i < count; i++)
				value[i] = temp[i];
			delete temp;
		}
		value[count++] = x;
	}
	void pop_back()
	{
		if (max != 100 && count <= 0.1 * max)
		{
			max /= 2;
			int *temp = value;
			value = new int[max];
			for (int i = 0; i < count; i++)
				value[i] = temp[i];
			delete temp;
		}
		count--;
	}
	int operator[] (int x) {
		return value[x];
	}
};

int main(void) 
{
	int q, i, com, x;
	vector v;
	scanf("%d", &q);
	for (i = 0; i < q; i++)
	{
		scanf("%d", &com);
		switch (com) 
		{
			case 0:
				scanf("%d", &x);
				v.push_back(x);
				break;
			case 1:
				scanf("%d", &x);
				printf("%d\n", v[x]);
				break;
			case 2:
				v.pop_back();
		}
	}
}


Measured memory_bytes: 4072
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const int MOD = 1e9 + 7;

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

	for (int i=0; i<S.size(); i++) {
		cout << 'x';
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    string S;
    cin >> S;
    ll ans = 0;
    for (char c : S) {
        if (c == '+') {
            ans++;
        } else {
            ans--;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define P pair<int,int>
int n,k;
int r,s,p;
string t;
char c[200000];
int ans=0;
signed main(){
    cin>>n>>k;
    cin>>r>>s>>p;
    cin>>t;
    rep(i,n){
        if(i<k){
            if(t[i]=='r'){
                c[i]='p';
                ans+=p;
            }
            else if(t[i]=='s'){
                c[i]='r';
                ans+=r;
            }
            else{
                c[i]='s';
                ans+=s;
            }
        }
        else{
            if(t[i]=='r'){
                if(c[i-k]!='p'){
                    c[i]='p';
                    ans+=p;
                }
                else c[i]='?';
            }
            else if(t[i]=='s'){
                if(c[i-k]!='r'){
                    c[i]='r';
                    ans+=r;
                }
                else c[i]='?';
            }
            else{
                if(c[i-k]!='s'){
                    c[i]='s';
                    ans+=s;
                }
                else c[i]='?';
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 512
n = int(input())
*A, = map(int, input().split())
inf = 10**18
# DP[i][0]=i番目まででi//2個選んだ最大値
# DP[i][1]=i番目まででi//2+1個選んだ最大値
DP = [[-inf]*2 for i in range(n)]
DP[0][0] = 0
DP[0][1] = A[0]
DP[1][0] = 0
DP[1][1] = max(A[0], A[1])
for i in range(2, n):
    if i % 2 == 0:
        DP[i][0] = max(DP[i-2][0]+A[i], DP[i-1][1])
        DP[i][1] = DP[i-2][1]+A[i]
    else:
        DP[i][0] = max(DP[i-2][0]+A[i], DP[i-1][0])
        DP[i][1] = max(DP[i-2][1]+A[i], DP[i-1][1])
if n % 2 == 0:
    print(DP[n-1][1])
else:
    print(DP[n-1][0])


Measured memory_bytes: 55432
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 100000
#define MAX_M 100000
#define vec vector<int>
#define vecst vector<string>
#define vecch vector<char>
#define vecf vector<float>
#define vecvec vector<vector<int>>
#define vecHvec vector<vector<char>>
using ll=int long long;
const int INF = 1e9;
#define PI 3.141592653589793
// cout << setprecision(15) << std::fixed;

int main(){
  int n,s,ans=0;
  cin>>n>>s;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      if(s-(i+j)<=n&&s-(i+j)>=0) ans++;
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 384
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

int main() {
	ll a, b, c; cin >> a >> b >> c;
	if (c - a - b < 0) cout << "No" << endl;
	else {
		ll left = (c - a - b) * (c - a - b);
		ll right = 4 * a * b;
		if (left > right) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import string
t=input()
n=len(t)
ans=[]
for i in string.ascii_lowercase:
    cnt=0
    s=list(t)
    while s.count(i)!=n-cnt:
        for j in range(1,len(s)):
            if s[j]==i or s[j-1]==i:
                s[j-1]=i
            else:
                s[j-1]=s[j-1]
        cnt+=1
        s.pop()
    ans.append(cnt)
print(min(ans))


Measured memory_bytes: 3772
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll x, ll y) {
	ll res = 1;
	for (ll i = 0; i < y; i++) res = res * x % mod;
	return res;
}

int main() {
	int n;
	cin >> n;
	vector<int> cnt(n + 1);
	for (int i = 0; i < n - 1; i++) {
		int x;
		cin >> x;
		cnt[x]++;
	}
	
	for (int i = 1; i <= n; i++) {
		cout << cnt[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3968
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <random>
#include <cstdlib>
using namespace std;
int N;
int a[128];
bool flag[128];

#define MAX_N 128

class dinic {
private:
	struct edge { int to, cap, rev; };
	vector<edge> G[MAX_N];
	//sからの深さを記憶
	vector<int> level;
	int V;

	//深さ優先で経路を検索
	//経路を見つけたら流して更新
	int dfs(int v, int t, int f) {
		if (v == t) return f;
		for (int i = 0; i < G[v].size(); i++) {
			edge &e = G[v][i];
			if (e.cap <= 0) continue;
			if (level[v] >= level[e.to]) continue;
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
		return 0;
	}

	//幅優先
	void bfs(int s) {
		level.assign(V, -1);
		queue<int> q;
		q.push(s);
		level[s] = 0;
		for (; !q.empty();) {
			int v = q.front(); q.pop();
			for (int i = 0; i < G[v].size(); i++) {
				struct edge e = G[v][i];
				if (e.cap <= 0) continue;
				//既に通った辺なら
				if (level[e.to] >= 0) continue;
				level[e.to] = level[v] + 1;
				q.push(e.to);
			}
		}
	}


public:
	dinic(int v) {
		V = v;
	}
	void add_edge(int from, int to, int cap) {
		struct edge tmp;
		tmp = { to, cap, int(G[to].size()) };
		G[from].push_back(tmp);
		tmp = { from, 0, int(G[from].size() - 1) };
		G[to].push_back(tmp);
	}

	long long run(int s, int t) {
		long long f = 0;
		for (;;) {
			bfs(s);
			if (level[t] < 0) break;
			f += dfs(s, t, std::numeric_limits<int>::max());
		}
		return f;
	}
};

void MUL() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	//後半で負の宝石は問答無用で叩き割る
	for (int i = (N + 1 / 2); i < N; i++) {
		a[i] = a[i] < 0 ? 0 : a[i];
	}

	long long ideal = 0;
	for (int i = 0; i < N; i++) {
		ideal += a[i] > 0 ? a[i] : 0;
	}

	memset(flag, 0, sizeof(flag));

	dinic d(N + 2);
	for (int i = 0; i < N; i++) {
		if (a[i] > 0) {
			d.add_edge(0, i + 1, a[i]);
			d.add_edge(i + 1, N + 1, 0);
		}
		else {
			d.add_edge(i + 1, N + 1, -a[i]);
			d.add_edge(0, i + 1, 0);
		}
		for (int j = (i + 1) * 2; j < N + 1; j += i + 1) {
			d.add_edge(j, (i + 1), std::numeric_limits<int>::max());
		}
	}
	cout << ideal - d.run(0, N + 1) << endl;
}

int main() {
	MUL();
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <math.h>
 
using namespace std;
 
bool rangeCheck(int row,int col){
    if(row >= 0 && row <= 7 && col >= 0 && col <= 7)return true;
    else{
        return false;
    }
}
 
void bomb(char table[8][9],int row,int col){
    table[row][col] = '0';
 
    for(int i=1; i <=3; i++){
        if(rangeCheck(row,col-i)&&table[row][col-i] == '1')bomb(table,row,col-i);
        if(rangeCheck(row,col+i)&&table[row][col+i] == '1')bomb(table,row,col+i);
        if(rangeCheck(row-i,col)&&table[row-i][col] == '1')bomb(table,row-i,col);
        if(rangeCheck(row+i,col)&&table[row+i][col] == '1')bomb(table,row+i,col);
    }
}
 
int main(){
 
    int n,row,col,count = 1;
    char table[8][9];
 
    scanf("%d",&n);
    getchar();
 
    for(int i=0;i<n;i++){
        for(int k=0;k < 8; k++){
            scanf("%s",table[k]);
        }
 
        scanf("%d",&col);
        scanf("%d",&row);
        getchar();
        row = row-1;
        col = col-1;
        bomb(table,row,col);
 
        printf("Data %d:\n",count++);
        for(int k = 0; k < 8; k++){
            printf("%s\n",table[k]);
        }
    }
 
    return 0;
}


Measured memory_bytes: 2700
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int h, w;
    cin >> h >> w;
    int a, b;
    cin >> a >> b;
    cout << (h-a)*(w-b) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#define int long long
const int inf=1145141919;
const int mod=1000000007;
using namespace std;
template<class T>void debug(T *a,int l,int r,const char *name){
	for(int i=l;i<r;i++)
		cout<<name<<"["<<i<<"]="<<a[i]<<endl;
}
int N,K;
int p[100];
signed main(){
	int i,j;
	int A,B,C;
	cin>>A>>B>>C;
	if(A==B)
		cout<<C<<endl;
	else if(A==C)
		cout<<B<<endl;
	else
		cout<<A<<endl;
}

Measured memory_bytes: 256