akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <map>
using namespace std;

int main() {
    string s; int k ;
    cin >> s >>k;
    priority_queue<string, vector<string>, greater<string> > q;
    for (int i = 0; i < s.length(); ++i) {
        for (int j = i; j < s.length(); ++j) {
            const basic_string<char, char_traits<char>, allocator<char>> &v = s.substr(i, j-i+1);
            q.push(v);
            if(j - i + 1 == k) break;
        }
    }

    string prev = q.top();q.pop();
    int i = 1;
    while(i < k) {
       string ss=  q.top() ; q.pop();
       if(ss != prev) {
           i++;
           prev = ss;
       }
    }
    cout << prev << endl;

    return 0;
}


Measured memory_bytes: 1660
#include "bits/stdc++.h"
#include <unordered_set>

#define _CRT_SECURE_NO_WARNINGS

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

const int dy[] = { 0, 1, 0, -1 };
const int dx[] = { 1, 0, -1, 0 };

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin >> a >> b;

	if (a < b) {
		cout << "a" << " < " << "b" << endl;
	} else if (a > b) {
		cout << "a" << " > " << "b" << endl;
	} else {
		cout << "a" << " == " << "b" << endl;
	}
	return 0;
}

Measured memory_bytes: 3164
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;
ll mypow(ll x, ll n, ll m) {
	if (n == 0) {
		return 1;
	}
	if (n % 2 == 0) {
		return mypow(x*x%m, n / 2, m);
	}
	else {
		return x * mypow(x, n - 1, m) % m;
	}
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
//テーブルをつくる前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;//mod pにおける1,2,,,nの逆元
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i%INF;
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}

ll COM(int n, int k) {
	if (n < k)return 0;
	if (n < 0 || k < 0)return 0;
	return fac[n] * (finv[k] * finv[n - k] % INF) % INF;
}
///////////////////////////////////////


int main() {
	int n;
	cin >> n;
	ll sum = 0;
	for (ll i = 1; i <= n; ++i) {
		if (i % 3 !=0 && i % 5 != 0) {
			sum += i;
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
using namespace std;
int main()
{
	int a, b, c , x, y;
	scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);
	int ans1,ans2,ans3,ans4;
	ans2 = a * x + b * y;
	if(x >= y)
	{
		ans1 = y * c * 2 + (x - y) * a;
	}
	else
	{
		ans1 = x * c * 2 + (y - x) * b;
	}
	ans3 = max(x,y) * c * 2;
	printf("%d\n", min(ans3,min(ans1,ans2)));
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i=0; i<N; i++){
    cin >> a.at(i);
  }
  
  int loop=0;
  int button=1;
  while (loop <= N){
    
    button=a.at(button-1);
 //   cout << button << endl;
  	if (button==2) {break;}
    loop++;
  }
  
  if (loop==N+1){
  	cout << -1 << endl;
  } else {
    cout << loop+1 << endl;
  }
}

Measured memory_bytes: 640
import sys
put = sys.stdin.readline

n, x = map(int,put().split())
ls = list(map(int,put().split()))
ls.append(0)
ans = 0

for i in range(n):
    if ls[i] != 0:
        if x < ls[i]+ls[i+1] :
            ans += (ls[i]+ls[i+1]) - x
            ls[i+1] = max(x - ls[i],0)
print(ans)

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

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;
 
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;

int main() {
  
  int n;
  cin >> n;
  
  vector<string> w(n);
  for ( int i = 0; i < n; i++){
    cin >> w[i];
    for ( int j = 0; j < i; j++){
      if ( w[j] == w[i] ){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  
  for ( int i = 0; i < n - 1; i++){
    if ( w[i+1][0] != w[i][w[i].size()-1] ){
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;

}

Measured memory_bytes: 256
use itertools::{iproduct, izip, Itertools};
use proconio::input;

const WIDTH: usize = 41;

trait OrdTools: Ord + Clone + Sized {
    fn chmin(&mut self, x: Self) {
        *self = std::cmp::min(self.clone(), x);
    }
    fn chmax(&mut self, x: Self) {
        *self = std::cmp::max(self.clone(), x);
    }
}

impl<T: Ord + Clone + Sized> OrdTools for T {}

fn main() {
    input!(n: usize, orig: [u64; n]);
    let make_seq = |x| (0..WIDTH).map(|i| (x >> i & 1) as usize).collect_vec();
    let a = make_seq(orig[0]);
    let b = make_seq(orig[1]);
    let c = make_seq(orig.iter().skip(2).fold(0, |x, y| x ^ y));
    let mut dp = vec![vec![[std::u64::MAX; 2]; 2]; WIDTH + 1];
    dp[0][0][0] = 0;
    izip!(a, b, c).enumerate().for_each(|(i, (x, y, z))| {
        iproduct!((0..2), (0..2), (0..2))
            .filter(|&(j, k, _)| x ^ y ^ z ^ j ^ k == 0)
            .for_each(|(j, k, l)| {
                let crr = dp[i][j][k];
                if crr != std::u64::MAX {
                    let nj = (x < j + l) as usize;
                    let nk = (2 <= y + l + k) as usize;
                    dp[i + 1][nj][nk].chmin(crr + l as u64 * (1 << i));
                }
            });
    });
    let ans = *dp[WIDTH]
        .iter()
        .map(|v| v.iter().min().unwrap())
        .min()
        .unwrap();
    println!("{}", if orig[0] <= ans { -1 } else { ans as i64 });
}


Measured memory_bytes: 2160
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int a[SIZE];
int main(){
    int N; R(N);
    REP(i,N){
        R(a[i]);
    }
    sort(a,a+N);
    int an=0;
    REPP(i,1,N){
        int it=0;
        REPP(j,i+1,N){
            while(it<i&&a[it]+a[i]<=a[j])it++;
            an+=i-it;
        }
    }
    W(an);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;

const int N = 100005;

int n, m, v, p, ans = 0;
long long a[N], pre[N];

int main () {
	scanf("%d%d%d%d", &n, &m, &v, &p);
	for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
	sort(a, a + n);
	
	for (int i = 0; i < n; i++) debug(i), debug(a[i]);
	pre[0] = a[0];
	for (int i = 1; i < n; i++) pre[i] = a[i] + pre[i - 1];
	for (int i = 0, j = 0; i < n; i++) {
		if (!i || a[i] != a[i - 1]) j = 0;
		j++;

		if (i < n - 1 && a[i] == a[i + 1]) continue;
		int pos = upper_bound(a, a + n, a[i] + m) - a;
		if (n - i < p) ans += j;
		if (n - pos >= p || n - i < p) continue;

		int q = (p - 1) - (n - pos), r = (pos - 1) - (i + q);
		long long val = 1ll * (p - 1 + i) * m;
		if (val + (a[i] + m) * r - (pre[i + r] - pre[i]) >= 1ll * m * (v - 1)) ans += j;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1920
import java.lang.reflect.Array;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();

        if (N % 2 == 0) {
            System.out.println(0.5);
        } else {
            System.out.println((float) (N / 2 + 1) / N);
        }

    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int mod = 1e9+7;
int modpow(int_fast64_t a, int p) {
    if (p == 0) return 1;
    if (p%2 == 0) {
        int_fast64_t half = modpow(a, p/2);
        return half * half % mod;
    }
    else return a * modpow(a, p-1) % mod;
}
int dp[2001][2001];
int cmb(int n, int r) {
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    r = min(r, n-r);
    if (dp[n][r] != 0) return dp[n][r];
    int_fast64_t tmpM = 1, tmpD = 1;
    for (int i = 0; i<r; i++) {
        tmpM *= n-i;
        tmpD *= i+1;
        tmpM %= mod;
        tmpD %= mod;
    }
    dp[n][r] = tmpM * modpow(tmpD, mod-2) % mod;
    return dp[n][r];
}
int spl(int n, int r) {
    return cmb(n-1, r-1);
}
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int_fast64_t ans;
    int N, K;
    cin >> N >> K;
    for (int i = 1; i<=K; i++) {
        if (N == K && i == 1) {
            printf("1\n");
            continue;
        }
        ans = spl(N-K, i)*2;
        ans += spl(N-K, i+1);
        ans += spl(N-K, i-1);
        ans %= mod;
        ans *= spl(K, i);
        ans %= mod;
        printf("%d\n", (int)ans);
    }
    return 0;
}

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

int main(){
	int n,q;
	string s;
	cin >> n >> q >> s;

	vector<int> t(n+1,0);
	for(int i=0; i<n; i++) t[i+1] = t[i]+((s[i]=='A'&&s[i+1]=='C')?1:0);
	
	for(int i=0; i<q; i++){
		int l,r;
		cin >> l >> r;
		cout << t[r-1]-t[l-1] << endl;
	}

	return 0;
}

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

int main(){
    long double  w,h,x,y;
    cin>>w>>h>>x>>y;
    long double square= (long double)w*h/2.0;
    char a;
    if(h==2*y && w==2*x) a='1';
    else a='0';
    cout<<fixed<<setprecision(20)<<square<<" "<<a<<endl;
}

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

string s, t;

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> s >> t;
    int ans = INT_MAX;
    for (int i = 0; i <= s.length()-t.length(); i++) {
        string d = s.substr(i, t.length());
        int cnt = 0;
        for (int j = 0; j < t.length(); j++) {
            if (d[j] != t[j]) cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3660
# atcoder problem solving

# Built?
import sys
input=sys.stdin.readline
N = int(input())
d = []

for i in range(N):
    x, y = map(int, input().split())
    d.append((i+1, x, y))

edge = []

# x座標に関する辺の設定

d.sort(key=lambda x: x[1])

for i in range(N-1):
    a, px, py = d[i]
    b, qx, qy = d[i+1]
    dis = abs(px-qx)

    edge.append((dis, a, b))
    edge.append((dis, b, a))

# y座標に関する辺の設定

d.sort(key=lambda x: x[2])

for i in range(N-1):
    a, px, py = d[i]
    b, qx, qy = d[i+1]
    dis = abs(py-qy)

    edge.append((dis, a, b))
    edge.append((dis, b, a))


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * (n+1)

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

edge.sort()
# 最小全域木（クラスかるほう）
def kruskal():
    res = 0
    G = UnionFind(N)
    for cost, p, q, in edge:
        if not G.same(p, q):
            G.union(p, q)
            res += cost
    return res


ans = kruskal()

print(ans)


Measured memory_bytes: 60916
<?php
list($n) = explode(" ", trim(fgets(STDIN)));

$len=strlen($n);

$x=$n;
$p=0;
for($i=$len-1;$i>=0;$i--){
  $p+=intdiv($x, pow(10,$i));
  $x%=pow(10,$i);
//echo $p.PHP_EOL;
}
if($n%$p==0) echo "Yes";
else echo "No";

Measured memory_bytes: 16072
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7 #998244353
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    n = int(ipt())
    min_pri = [i for i in range(10**6+1)]
    ps = []
    for i in range(2,10**3):
        if min_pri[i] != i:
            continue
        else:
            ps.append(i)
            for j in range(i,10**6+1,i):
                if min_pri[j] == j:
                    min_pri[j] = i

    a = [int(i) for i in ipt().split()]
    g = a[0]
    d = defaultdict(bool)
    f1 = True
    for i in a:
        g = math.gcd(g,i)
        if f1 and i != 1:
            ni = i
            pi = bisect.bisect_left(ps,min_pri[i])
            for j in ps[pi::]:
                ff = True
                while ni%j == 0:
                    if ff:
                        if d[j]:
                            f1 = False
                            break
                        d[j] = True
                        ff = False
                    ni //= j
                if not f1 or ni == 1:
                    break
            if ni != 1:
                if d[ni]:
                    f1 = False
                d[ni] = True

    if f1:
        print("pairwise coprime")
    elif g == 1:
        print("setwise coprime")
    else:
        print("not coprime")




    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 199200
/**
 *    author:  FromDihPout
 *    created: 2020-05-26
**/

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    vector<int> pen(n);
    vector<bool> ac(n);
    for (int i = 0; i < m; i++) {
        int p;
        string ver;
        cin >> p >> ver;
        p--;
        if (ver == "AC") {
            ac[p] = 1;
        }
        else if (ver == "WA" && !ac[p]) {
            pen[p]++;
        }
    }
    
    int a_cnt = 0, p_cnt = 0;
    for (int i = 0; i < n; i++) {
        if (ac[i]) {
            a_cnt++;
            p_cnt += pen[i];
        }
    }
    cout << a_cnt << ' ' << p_cnt << '\n';
}

Measured memory_bytes: 640
#include <stdio.h>

#define INPUT_NUMBER 3

int main(void){
    int a,b;
    double fb;
    

    scanf("%d",&a);
    scanf("%d",&b);
    fb=(double)b;

    printf("%d %d %f\n",a/b,a%b,a/fb);

    return 0;
}


Measured memory_bytes: 1876
#include <iostream>

using namespace std;
int main(){
	int i,j,n,h[30],cnt = 1;
	cin >> n;
	for(i=0;i<n;i++) cin >> h[i];
	for(i=1;i<n;i++){
		for(j=0;j<i;j++){
			if(h[j]>h[i]) break;
			if(j==i-1) cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
import itertools as it

n,m=map(int,input().split())
path=[]
for i in range(m): path.append(list(map(int,input().split())))
ls=list(it.permutations(range(1,n+1)))
cnt=0
for l in ls:
    if l[0]!=1: break
    flag=1
    for i in range(n-1):
        if ([l[i],l[i+1]] not in path) and ([l[i+1],l[i]] not in path):
            flag=0
            break
    if flag: cnt+=1
print(cnt)

Measured memory_bytes: 13900
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll mod=1e9+7;

int main() {
  ll n,c;
  cin >> n >> c;
  vector<ll> x(n);
  vector<ll> v(n);
  for(ll i=0;i<n;i++) {
    cin >> x[i] >> v[i];
  }
  vector<ll> slv(n+1);
  vector<ll> srv(n+1);
  for(ll i=1;i<=n;i++) {
    srv[i]=srv[i-1]+v[i-1];
    slv[n-i]=slv[n-i+1]+v[n-i];
  }
  vector<ll> mslv(n+1);
  vector<ll> msrv(n+1);
  for(ll i=1;i<=n;i++) {
    msrv[i]=max(msrv[i-1],srv[i]-x[i-1]);
    mslv[n-i]=max(mslv[n-i+1],slv[n-i]-(c-x[n-i]));
  }
  ll ans=max(mslv[0],msrv[n]);
  for(ll i=0;i<n;i++) {
    ans=max(ans,srv[i+1]-2*x[i]+mslv[i+1]);
    ans=max(ans,slv[n-i-1]-2*(c-x[n-i-1])+msrv[n-1-i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4992
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
using ld = long double;
 
// ------------------------------------------------------------------------------------------------

ll k, s, ans;

int main() {
    fast_io; cout_precision;
    cin >> k >> s;
    ans = 0;
    for (ll z = 0; z <= k && s >= 0; z++, s--) {
        if (s <= k) {
            ans += s + 1;
        } else if (s <= 2 * k) {
            ans += 2 * k - s + 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
#define mp make_pair
#define pb push_back
#define f first
#define s second


//var 
LL n, a[100001], ts;

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

	cin >> n;
	for(int i = 1; i<=n; i++){
		cin >> a[i];
		ts += a[i];
	}
	sort(a+1, a+n+1);
	for(int i = 1; i<n; i+=2){
		if(a[i] + a[i+1] < 0)
			ts += 2 * abs(a[i] + a[i+1]);
	}

	cout << ts << endl;

	cout.flush();
	return 0;
}

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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

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

    vector<string> lunlun;
    for(int i=1;i<10;i++){
        lunlun.push_back(to_string(i));
//        cout<<lunlun.at(i-1)<<endl;;
    }

    vec_int keta_num;
    keta_num.push_back(-1);
    keta_num.push_back(8); //1の位はlunlun.at(8)まで
    int index=2; // これは10の位の数から始めるということ

    int bangou=9;
    while(bangou<pow(10,5)+1){
        for(int i=keta_num.at(index-2)+1;i<=keta_num.at(index-1);i++){
            string prev = lunlun.at(i);
 //           cout<<prev<<endl;
            int length = prev.size();
            int last_num = charToInt(prev.at(length-1));
            for(int j=0;j<10;j++){
                if(j==last_num){
                    if(j==0){
                        lunlun.push_back(prev+"0");
                        lunlun.push_back(prev+"1");
                        bangou+=2;
                    }else if(j==9){
                        lunlun.push_back(prev+"8");
                        lunlun.push_back(prev+"9");
                        bangou+=2;
                    }else{
                        for(int k = -1;k<2;k++){
                        lunlun.push_back(prev+to_string(j+k));
                        }
                        bangou+=3;
                    }
                    if(bangou>pow(10,5))goto OUT;
                    break;
                }
            }
            if(bangou>pow(10,5))break;
        }
        //前の桁が終わったときの処理
        index++;
        keta_num.push_back(lunlun.size()-1);
    }
    OUT:
    cout<<lunlun.at(K-1)<<endl;


    return 0;
}

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

int main(){
	int n,p,a;
	cin>>n>>p;
	bool flag=true;
	for (int i = 0; i < n; i++){
		cin>>a;
		if(a%2==1)
			flag=false;
	}

	if(flag&&p==1)
		cout<<0<<endl;
	else if(flag)
		cout<<(long)pow(2,n)<<endl;
	else
		cout<<(long)pow(2,n-1)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int N;
cin >> N;
vector<int> vec(N);
bool ans = true;
for (int i = 0;i < N;i++) cin >> vec.at(i);

int maxi = 0;
for (int i = 1;i < N;i++) {
    if (vec.at(i-1) -1 > vec.at(i)) {
        ans = false;
        break;
    }
    if (maxi < vec.at(i-1)-1) maxi = vec.at(i-1)-1;
    if (vec.at(i) < maxi) {
        ans = false;
        break;
    }

}
if (ans == true) cout << "Yes" << endl;
else cout << "No" << endl;

return 0;
}


Measured memory_bytes: 640
/* long long or int & the MAX_INT or MIN_INT */
/* the size of a[] & inline */
/* xx 396 */

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

typedef long long ll;

ll N;

signed main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>N;
	ll ans=(N-1)*N/2LL;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

import scala.io.StdIn._
object Main extends App {

//  val n: Int = readInt()
//  val testimoniesPerPerson: Seq[Seq[(Int, Int)]] = (1 to n).map { _ =>
//    val numOfTestimonies = readInt()
//    val testimonies: Seq[(Int, Int)] = Seq.fill(numOfTestimonies) {
//      val testimony: Array[Int] = readLine().split(" ").map(_.toInt)
//      (testimony(0) - 1, testimony(1)) // Modify to 0 origin
//    }
//    testimonies
//  }
  val sc = new Scanner(System.in)
  val n = sc.nextInt
  val testimoniesPerPerson: Array[Map[Int, Boolean]] = Array.fill(n){
    Array.fill(sc.nextInt)(sc.nextInt - 1 -> (sc.nextInt == 1)).toMap
  }


  def solve(): Int = {
    val valids = (0 until (1 << n)).map{ i =>
      val valid = (0 until n)
        .filter{j => isBitOn(i, j)}
        .forall{j => isHonestPerson(j, i)}
      if (valid) Integer.bitCount(i) else 0
    }
    valids.max
  }

  def isHonestPerson(personIndex: Int, bit: Int): Boolean =
    testimoniesPerPerson(personIndex).forall { case (x, y) =>
      y == isBitOn(bit, x)
    }

  def isBitOn(bit: Int, digit: Int): Boolean =
    ((bit >> digit) & 1) != 0

  def countHonest(bit: Int): Int=
    Integer.bitCount(bit)


  println(solve())

}


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

using namespace std;

using ll = long long;

bool isSquare(ll v) {
    ll ok = 0, ng = 2e8;
    while (ng - ok > 1) {
        ll mid = (ng + ok) / 2;
        if (mid * mid <= v) ok = mid;
        else ng = mid;
    }
    return (ok * ok == v);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, d;
    cin >> n >> d;
    vector< vector<ll> > x(n, vector<ll>(d));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) {
            cin >> x[i][j];
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < i; j++) {
            ll s = 0;
            for (int k = 0; k < d; k++) {
                ll y = (x[i][k] - x[j][k]);
                s += y * y;
            }
            ans += isSquare(s);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,a,b,x[100005],y[100005],ans[100005],f[100005],nt[100005];
pair<pair<long long,long long>,long long>nd[100005];
long long dist(long long a,long long b){return max(abs(x[a]-x[b]),abs(y[a]-y[b]));}
long long fnd(long long x){return ((f[x]!=x)?(f[x]=fnd(f[x])):(f[x]));}
void uni(long long x,long long y)
{
	x=fnd(x);y=fnd(y);
	if(x==y)return;
	f[x]=y;
}
int main()
{
	scanf("%lld%lld%lld",&n,&a,&b);
	for(long long i=1;i<=n;i++)f[i]=i;
	for(long long i=1;i<=n;i++)
	{
		long long u,v;
		scanf("%lld%lld",&u,&v);
		x[i]=u+v;
		y[i]=u-v;
	}
	long long dis=dist(a,b);
	for(long long i=1;i<=n;i++)nd[i]=make_pair(make_pair(x[i],y[i]),i);
	sort(nd+1,nd+n+1);
	for(long long i=1;i<=n;i++)
	{
		long long id=nd[i].second;
		pair<pair<long long,long long>,long long> d=make_pair(make_pair(x[id]-dis,y[id]-dis),1);
		pair<pair<long long,long long>,long long> u=make_pair(make_pair(x[id]-dis,y[id]+dis),n);
		long long l=lower_bound(nd+1,nd+n+1,d)-nd;
		long long r=lower_bound(nd+1,nd+n+1,u)-nd-1;
		if(l>r)continue;
		ans[id]+=r-l+1;
		uni(id,nd[l].second);
		for(long long j=max(nt[l],l);j<=r-1;j++)uni(nd[j].second,nd[j+1].second);
		nt[l]=max(nt[l],r);
	}
	for(long long i=1;i<=n;i++)nt[i]=0;
	for(long long i=1;i<=n;i++)swap(x[i],y[i]);
	for(long long i=1;i<=n;i++)nd[i]=make_pair(make_pair(x[i],y[i]),i);
	sort(nd+1,nd+n+1);
	for(long long i=1;i<=n;i++)
	{
		long long id=nd[i].second;
		pair<pair<long long,long long>,long long> d=make_pair(make_pair(x[id]-dis,y[id]-dis+1),1);
		pair<pair<long long,long long>,long long> u=make_pair(make_pair(x[id]-dis,y[id]+dis-1),n);
		long long l=lower_bound(nd+1,nd+n+1,d)-nd;
		long long r=lower_bound(nd+1,nd+n+1,u)-nd-1;
		if(l>r)continue;
		ans[id]+=r-l+1;
//		cout<<l<<" "<<r<<" "<<id<<" "<<ans[id]<<endl;
		uni(id,nd[l].second);
		for(long long j=max(nt[l],l);j<=r-1;j++)uni(nd[j].second,nd[j+1].second);
		nt[l]=max(nt[l],r);
	}
	long long res=0;
	for(long long i=1;i<=n;i++)if(fnd(i)==fnd(a))
//	{
//		cout<<i<<" "<<ans[i]<<endl;
		res+=ans[i];
//	}
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, K;
    cin >> N >> K;
    int ans;
    ans = 0;
    while(N / K > 0){
        N /= K;
        ans++;
    }
    cout << ans + 1 << endl;
    return 0;
}

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

namespace ABC115
{
    class Program
    {
        static void Main(string[] args)
        {
            int D;
            string s = "Christmas ";

            D = int.Parse(Console.ReadLine());
            for (int I = 0; I < 25 - D; I++) 

            {
                s += "Eve ";
            }
            Console.WriteLine(s);
            Console.ReadKey();
        }
    }
}

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

int main(){
    int n,k; cin >> n >> k;
    int ans = 0;
    vector<int> sunuke(n,0);
    for(int i=0; i<k; ++i){
        int d; cin>>d;
        for(int j=0; j<d; ++j){
            int a; cin >> a;
            sunuke[a-1]++;
        }
    }
    for(int su:sunuke){
        ans += (su==0);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++) 
#define fs first
#define sc second
#define _GLIBCXX_DEBUG

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}

template <class S>
void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){
		cerr << v[i] << ' ';
	}
	cerr << endl;
}
template <class S>
void print(vector<vector<S>> &v) {
  	for (ll i = 0; i < (ll)v.size(); i++) {
    	for (ll j = 0; j < (ll)v[i].size(); j++) {
      		cerr << v[i][j] << ' ';
    	}
    	cerr << endl;
  	}
}

int main(void){
	map<ll,ll> b,c;
	int a;
	int n; cin >> n;
	rep(i,n){
		cin >> a;
		b[i-a]++;
		c[i+a]++;
	}
	ll ans = 0;
	for(auto [k,v]: b){
		ans += v * c[k];
	}
	cout << ans << endl;
}

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

int main()
{
	int a[100005],b[100005],s=0,n;
	cin>>n;
	for(int i=1;i<n;i++)
	cin>>b[i];
	for(int i=1;i<n;i++)
	{
		if(i==1)
		a[i]=b[i];
		a[i+1]=min(b[i],b[i+1]);
	}
	for(int i=1;i<=n;i++)
	s=s+a[i];
	s=s+b[n-1];
	cout<<s<<endl;
} 

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(){
	char clima[10];
	scanf("%s", clima);
	if(clima[0]== 'S')
		printf("Cloudy");
	else if( clima[0]== 'C')
		printf("Rainy");
	else if(clima[0]== 'R')
		printf("Sunny");
	printf("\n");
}

Measured memory_bytes: 1720
#include <stdio.h>
int main(){
  int M, N;
  int A[1000];
  scanf("%d %d", &N, &M);
  for (int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }
  int total = 0;
  for (int i = 0; i < N; i++) {
    total += A[i];
  }
  int count = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] >= total / (4.0 * M)) {
      count += 1;
    }
  }
  if (count >= M) {
    printf("Yes");
  }
  else {
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 1740
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, total;
  string dight;
  cin >> N;
  
  for(int i = 1;i <= N;i++){
  dight = to_string(i);
    if(dight.size() % 2 != 0){
    total++;
    }
  }
  cout << total << endl;
}

Measured memory_bytes: 256
def s()
  gets().chomp
end
def i()
  gets.to_i
end
def li()
  gets.split.map(&:to_i)
end
def ili()
  n = gets.to_i
  as = gets.split.map(&:to_i)
  [n, as]
end
class Array
  def sum
    total = 0
    self.each do |item|
      total += item
    end
    total
  end
end

def eratosthenes(size)
  prime_list = []
  is_prime = Array.new(size, true)
  is_prime[0] = false
  is_prime[1] = false

  2.upto(size-1){|i|
    if is_prime[i]
      prime_list << i
      (2).upto((size.to_f/i).ceil-1){|j|
        is_prime[j*i] = false
      }
    end
  }
  [prime_list, is_prime]
end

def dijkstra(s, e, cost)
  size = cost.length
  if s==e
    return 0
  end
  dp = {}
  dp[s] = 0
  undefined_node = {}
  size.times{|i|
    if i != s
      undefined_node[i] = cost[s][i]
    end
  }
  while undefined_node.length != 0
    min = undefined_node.min_by{|_, v| v}
    stock = {}
    temp = undefined_node.clone
    temp.each{|k, v|
      if min[1] == v
        undefined_node.delete(k)
        if k == e
          return v
        end
        dp[k] = v
        stock[k] = v
      end
    }

    stock.each{|k, v|
      undefined_node.each{|k2, v2|
        undefined_node[k2] = v + cost[k][k2] < v2 ?  v + cost[k][k2] : v2
      }
    }
  end
end

def get_bits(len)
  res =  []
  (2**len).times{|i|
    res << i.to_s(2).rjust(len, '0')
  }
  res
end
a, b = li()
puts (a-1)*(b-1)

Measured memory_bytes: 1788
#include<bits/stdc++.h>				//written by thidailoc
using namespace std;				//team three wolves
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
#define fu(i,a,b)   for(ll i=a;i<b;i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define ms(a, x) 	memset(a, x, sizeof a)
#define prec(n) 	fixed<<setprecision(n)
#define pb(i)	    push_back(i)
#define popb()    	pop_back()
#define sc(a) 	    scanf("%lld",&a)
#define sc2(a,b)    scanf("%lld%lld",&a,&b)
#define pr(a)	    printf("%lld ",a)
#define pr2(a,b)    printf("%lld %lld",a,b)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)	lower_bound(a.begin(),a.end(),x) -a.begin()
#define all(x) 		(x).begin(), (x).end()
#define sz(a) 		(ll)a.size()
#define le			length()						
#define re 			return 	
#define	mp(a,b)  	make_pair(a,b)
#define se			second
#define fi			first 
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)

double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17;

ll arr[100005];

ll Solves(){
	//INPUT;
	ll n,k,cnt=0,ans=0,x,y,query,l,r;
	// PROCESSING IN HERE
	sc(n);
	bitset<10005> bi;
	bi[0]=1;
	fu(i,0,n){
		sc(x);
		bi=(bi|(bi<<x));
	}
	x=10000;
	while((!bi[x] or x%10==0) and x)x--;
	pr(x);
	re 0;
}


int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	Solves();
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────────────────

int main() {
	int n, m;
	cin >> n >> m;
	if (n == m) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>

 using namespace std;

 
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;
    else if(a <= c && c <= b)
        cout << a << " " << c << " " << b << endl;
    else if (b <= a && a <= c)
        cout << b << " " << a << " " << c << endl;
    else if   (b <= c && c <= a)
        cout << b << " " << c << " " << a << endl;
    else if   (c <= a && a <= b)
         cout << c << " " << a << " " << b << endl;
    else
          cout << c << " " << b << " " << a << endl;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define fs first
#define sc second
#define pb push_back
#define sz size() 
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1e8;
const D EPS = 1e-8;
const ll mod = 1e9+7;

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

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

vector<ll> fact, inv_fact;

ll mod_comb(ll n, ll k){
  return fact[n] * inv_fact[k] % mod * inv_fact[n-k] % mod;
}

int main(){
  ll h,w,a,b;
  cin >> h >> w >> a >> b;

  ll n = h+w;
  fact = vector<ll>(n+1,1);
  inv_fact = vector<ll>(n+1,mod_inverse(1));
  rep(i,n){
    fact[i+1] = fact[i] * (i+1) % mod;
    inv_fact[i+1] = mod_inverse(fact[i+1]);
  }

  ll y = h-a-1, x = b;
  ll res = 0;
  while(y>=0 && x<w){
    res += mod_comb(y+x,x) * mod_comb(h-1-y + w-1-x, w-1-x) % mod;
    res %= mod;
    y--; x++;
  }
  cout << res << endl;
}


Measured memory_bytes: 3328
#include<iostream>
            using namespace std;
             
            int main()
            {
            string s;
            cin >> s;
            int ans = 700;
            if(s[0] == 'o')ans += 100;
            if(s[1] == 'o')ans += 100;
            if(s[2] == 'o')ans += 100;
           cout  << ans << endl;
             
            return 0;
    }

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

ll dist[10][10];

// ワーシャルフロイド
void warshall_floyd(int n) {
  for (int k = 0; k < n; k++){       // 経由する頂点
    for (int i = 0; i < n; i++) {    // 始点
      for (int j = 0; j < n; j++) {  // 終点
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
}

int main()
{
    cout << fixed << setprecision(15);
    ll H, W;
    cin >> H >> W;

    vector<vector<ll>> C(10, vector<ll>(10));
    vector<vector<ll>> A(H, vector<ll>(W));

    REP(i, 10){
        REP(j, 10){
            cin >> C[i][j];
        }
    }

    REP(i, H){
        REP(j, W){
            cin >> A[i][j];
        }
    }

    Fill(dist, INF);

    REP(i, 10){
        REP(j, 10){
        dist[i][j] = C[i][j];
        }
    }
    
    warshall_floyd(10);

    ll ans = 0;
    REP(i, H){
        REP(j, W){
            if(A[i][j] == -1) continue;
            ans += dist[A[i][j]][1]; 
        }
    }

    cout << ans << endl;

    return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define all(v) (v).begin(),(v).end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define pb push_back
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;



int main(){
    int a,b;
    cin>>a>>b;
    if(a*b%2==0)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

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

using namespace std;

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

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

    sort(a.begin(), a.end(), greater<int>());

    int res = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            res += a[i];
        } else {
            res -= a[i];
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int N,K,Q; cin >> N >> K >> Q;
    VI A(N);
    int ans = INF;
    REP(i,N) cin >> A[i];
    REP(i,N){
        VVI array;
        VI buff;
        REP(j,N){
            if(A[j] >= A[i]){
                buff.eb(A[j]);
            }else{
                if(SZ(buff) != 0){
                    array.eb(buff);
                    buff.clear();
                }
            }
        }

        if(SZ(buff) != 0){
            array.eb(buff);
            buff.clear();
        }
        VI cand;
        for(VI x : array){
            sort(x.begin(),x.end());
            int sz = SZ(x);
            REP(j,sz-K+1){
                cand.eb(x[j]);
            }
        }
        if(SZ(cand) < Q) continue;
        sort(cand.begin(), cand.end());
        chmin(ans, cand[Q-1] - cand[0]);
    }
    cout << ans << endl;

}


Measured memory_bytes: 384
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int p = 1000000007;
    
    List<Integer> list = new ArrayList<>();
    for(int i = 2; i <= N; i++){
      boolean c = true;
      for(int j = 2; j < i; j++){
        if(i % j == 0){
          c = false;
          break;
        }
      }
      if(c){
        list.add(i);
      }
    }
    
    int ls = list.size();
    int[] sum = new int[ls];
    for(int i = 2; i <= N; i++){
      for(int j = 0; j < ls; j++){
        int n = list.get(j);
        if(n > i){
          break;
        }
        int M = i;
        while(M % n == 0){
          M /= n;
          sum[j]++;
        }
      }
    }

    long ans = 1;
    for(int i = 0; i < ls; i++){
      ans *= sum[i]+1;
      ans %= p;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23636
N, M, C = map(int, input().split(" "))
B = list(map(int, input().split(" ")))
A = [list(map(int, input().split(" "))) for _ in range(N)]

count = 0
for a in A:
    if sum(a_i*b_i for a_i, b_i in zip(a, B)) + C > 0:  
        count += 1

print(count)

Measured memory_bytes: 3060