akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

vint e[500];
bool dfs(int v, vint &color, int c);
bool isBipartite(int n) {
    vint color(n, -1);
    rep(i, n) {
        if (color[i] != -1) continue;
        if (!dfs(i, color, 0)) return false;
    }
    return true;
}
bool dfs(int v, vint &color, int c) {
    color[v] = c;
    for (auto u : e[v]) {
        if (color[u] != -1) {
            if (color[u] == c) return false;
            continue;
        }
        if (!dfs(u, color, 1-c)) return false;
    }
    return true;
}

int main() {
    int n;
    cin >> n;
    vstr s(n);
    rep(i, n) cin >> s[i];

    vvint d(n, vint(n, INF));
    rep(i, n) rep(j, n) {
        if (i==j) d[i][j] = 0;
        if (s[i][j] == '0') continue;
        e[i].push_back(j);
        e[j].push_back(i);
        d[i][j] = 1;
    }

    if (!isBipartite(n)) {
        puts("-1");
        return 0;
    }

    rep(k, n) rep(i, n) rep(j, n) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }

    int ans = 0;
    rep(i, n) ans = max(ans, vmax(d[i]));
    ++ans;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4228
#include <iostream>
#include <vector>

using namespace std;

struct UnionFind {
    vector<int> par, sz;

    UnionFind(int N): par(N), sz(N) {// Constructor
        for (int i = 0; i < N; i++) {
            par[i] = i; sz[i] = 1;
        }
    }

    int root(int x) {
        if (par[x] == x) return x;
        else {
            par[x] = root(par[x]);
            return par[x];
        }
    }

    void unite(int x, int y) {
        if (root(x) != root(y)) {
            sz[root(x)] += sz[root(y)];
            par[root(y)] = root(x);
        }
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x) {
        return sz[root(x)];
    }
};

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

    vector<int> a(M), b(M);
    for (int i = 0; i < M; i++) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }

    int ans = 0;
    for (int i = 0; i < M; i++) {
        UnionFind uf(N);
        for (int j = 0; j < M; j++) {
            if (j != i) {
                uf.unite(a[j], b[j]);
            }
        }
        if (uf.size(0) != N) ans++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define EPS 10e-8
#define MAX_N 50

using namespace std;
typedef pair<int, int> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

int main(int argc, char **argv) {
    int N;
    cin >> N;
    priority_queue<double> pq;

    for(int i = 0; i < N; ++i) {
        double v;
        cin >> v;
        pq.push(-v);
    }

    while(pq.size() > 1) {
        double sum = -pq.top();   pq.pop();
        sum += -pq.top();   pq.pop();
        pq.push(-sum / 2);
    }

    double res = -pq.top();
    cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
#include<set>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
    string s,t;
    cin >> s >> t;
    int n=(int)(s.size());
    int m=(int)(t.size());
    int flg = 0;
    rep(i,n){
        if(s[i] != t[i]){
            flg=1;
        }
    }
    if(m!=(n+1)){
        flg=1;
    }
    if(flg==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main(void)
{
	char s[3];
	int total=0;
	
	scanf("%s", s);
	
	for(int i=0; i<5; i++){
		if(s[i] == '1') total += 1;
	}
	
	printf("%d\n", total);
	return 0;
}

Measured memory_bytes: 128
n, m = map(int, input().split())
broken = [0]*(n+1)
#m個階段が壊れているからそれをbrokenに入れる
for i in range(m):
    a = int(input())
    broken[a] = 1
dp = [0]*(n+1)
dp[0] = 1
mod = 1000000007
for i in range(1, n+1):
    if broken[i]:
        continue
    #dp[-1]は0だから上手く回る
    dp[i] = (dp[i-1] + dp[i-2]) % mod
print(dp[n])


Measured memory_bytes: 13360
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>


#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define DOUT(obj,n) cout << fixed << setprecision(n) << obj << endl

#define PI 3.14159265359

using namespace std;
typedef long long unsigned int ll;

int main() {
	int n;
	cin >> n;
	vector<string>s;
	REP(i, n) {
		string tmp;
		cin >> tmp;
		s.emplace_back(tmp);
	}
    sort(ALL(s));
	string x = s[0];
	int cnt = 1;
	REP(i, n) {
		if (x != s[i]) {
			x = s[i];
			cnt++;
		}
	}
	cout << cnt;
	return 0;
}

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

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        for (int i = 0; i < n; i++) {
            int pm, pe, pj;
            cin >> pm >> pe >> pj;
            char output;
            if ((pm == 100 || pe == 100 || pj == 100)
                || (180 <= pm + pe)
                || (240 <= pm + pe + pj)) {
                output = 'A';
            } else if ((210 <= pm + pe + pj)
                       || (150 <= pm + pe + pj && (80 <= pm || 80 <= pe))) {
                output = 'B';
            } else {
                output = 'C';
            }
            cout << output << endl;
        }
    }
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	int n=sc.nextInt();
	int k=sc.nextInt();
		String s=sc.next();
	char c[]=s.toCharArray();
k--;
if(c[k]=='A'){
	c[k]='a';
}else if(c[k]=='B'){
	c[k]='b';
}else{
	c[k]='c';
}

for(int i=0;i<n;i++){
	System.out.print(c[i]);
}System.out.println();

	}}

Measured memory_bytes: 21716
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        t: f32,
        a: f32,
        h: [f32; n],
    }
    let mut min = std::f32::MAX;
    let mut nearest = std::usize::MAX;
    for i in 0..n {
        let temp = t - h[i] * 0.006;
        let diff = (temp - a).abs();
        if diff < min {
            min = diff;
            nearest = i;
        }
    }
    println!("{}", nearest + 1);
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cstring>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
using namespace std;
int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
long long READ(){
    long long xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=xx*10+ch-'0';ch=getchar();}
    return xx*ff;
}
char one(){
	char ch=getchar();
	while(ch==' '||ch=='\n')
		ch=getchar();
	return ch;
}
const int maxn=1010;
const long long INF=1LL<<61;
int N,a[maxn],b[maxn];
long long bsearch(long long q,long long w,long long e,long long r){
	long long L=0,R=min(INF/e,INF/r),mid;
	while(L+1<R){
		mid=L+R>>1;
		if(e*mid>=q&&r*mid>=w)
			R=mid;
		else
			L=mid;
	}
	return R;
}
int main(){
	//freopen("in","r",stdin);
	N=read();
	for(int i=1;i<=N;i++)
		a[i]=read(),b[i]=read();
	long long A=a[1],B=b[1];
	for(int i=2;i<=N;i++){
		long long t=bsearch(A,B,a[i],b[i]);
		A=a[i]*t,B=b[i]*t;
	}
	printf("%lld\n",A+B);
	return 0;
}



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

int main(){
    ll H, W, A, B;
    cin >> H >> W >> A >> B;
    vector<vector<ll>> ans(H, vector<ll>(W,0));
    rep(h, 0, B){
        rep(w, 0, A){
            ans[h][w] = 0;
        }
        rep(w, A, W){
            ans[h][w] = 1;
        }
    }
    rep(h, B, H){
        rep(w, 0, A){
            ans[h][w] = 1;
        }
        rep(w, A, W){
            ans[h][w] = 0;
        }
    }

    rep(h, 0, H){
        rep(w, 0, W){
            cout << ans[h][w];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 9088
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int, X: int, Y: int):
    print(min(
        A * X + B * Y + min(X, Y) * min(0, C * 2 - A - B),
        max(X, Y) * (C * 2),
    ))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(A, B, C, X, Y)


if __name__ == '__main__':
    main()


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int n, l; cin >> n >> l;
  vector<string> s(n); for(int i = 0; i < n; i++) cin >> s[i];
  sort(s.begin(), s.end());
  for(int i = 0; i < n; i++) cout << s[i];
  cout << endl;

  return 0;
}


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

int main()
{
    int n,m;
    int sum=0,cnt=0;
    double biao;
    int a[1005];
    
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    biao=(double)sum/(double)(4*m);
    for(int i=0;i<n;i++)
    {
        if(a[i]>=biao)
        {
            cnt++;
        }
    }
    if(cnt<m)
    {
        printf("No\n");
    }
    else
    {
        printf("Yes\n");
    }
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    cout << N * (N-1) / 2 + M * (M - 1) / 2;
    return 0;
}


Measured memory_bytes: 256
import itertools

N, M, Q = map(int, input().split())
comb = list(itertools.combinations_with_replacement(range(1,M+1), N))

ans = [0]*len(comb)
if ans == []:
    print(0)
else:
    for i in range(Q):
        a,b,c,d = map(int, input().split())
        for j in range(len(comb)):
            if comb[j][b-1] - comb[j][a-1] == c:
                ans[j] += d
    print(max(ans))

Measured memory_bytes: 25244
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

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

    vector<ll> l;
    rep(i,n+1) {
        if (i == 0)
            l.push_back(2);
        else if (i == 1) 
            l.push_back(1);
        else
            l.push_back(l[i-1] + l[i-2]);
    }

    cout << l[n] << endl;
    return 0;
}


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

int main() {
    string S;
    cin >> S;
    if (S == "Sunny") {
        cout << "Cloudy" << endl;
    } else if (S == "Cloudy") {
        cout << "Rainy" << endl;
    } else {
        cout << "Sunny" << endl;
    }
}

Measured memory_bytes: 256
h, w = gets.split.map(&:to_i)
a = Array.new(h).map{Array.new(w)}
for i in 0..(h-1)
  a[i] = gets.chomp.split("")
end

col = Array.new(h)
row = Array.new(w)
for i in 0..([h,w].max-1)
  col[i] = i if i < h
  row[i] = i if i < w
end

for i in 0..(h-1)
  flag = 1
  for j in 0..(w-1)
    if a[i][j] == "#"
      flag = 0
      break
    end
  end
  col.delete(i) if flag == 1
end
for i in 0..(w-1)
  flag = 1
  for j in 0..(h-1)
    if a[j][i] == "#"
      flag = 0
      break
    end
  end
  row.delete(i) if flag == 1
end

col.each do |i|
  row.each do |j|
    print a[i][j]
  end
  puts ""
end

Measured memory_bytes: 2812
import Control.Monad -- for replicateM_
import Data.List -- for sort


{-
deal :: IO()
deal = do 
    [n, x] <- map read . words <$> getLine
    info <- replicateM (n-1) getWeight
    -- graph <- buildTree info [[[]]]
    putStrLn $ show info

main :: IO()
main = getLine >>= flip replicateM_ deal . read 
-}

convert :: String -> [Int]
convert xs = map (\x -> read [x] :: Int) xs 

solve :: [Int] -> Int
solve (x:xs) 
    | null xs = mod x 9
    | otherwise = mod (mod x 9 + solve xs) 9

multiple9 :: Int -> String
multiple9 x  
    | mod x 9 == 0 = "Yes"
    | otherwise = "No"

main :: IO()
main = do 
    s <- getLine
    putStrLn $ multiple9 $  sum $ convert s


Measured memory_bytes: 11932
#include<cstdio>
using namespace std;
#define N 300500
int st[N],v[N],s[N],n,l;
long long as;
int main()
{
	scanf("%d%d",&n,&l);as=l*2;
	for(int i=1;i<=n;i++)scanf("%d",&s[i]);
	for(int i=1;i<=n;i++)scanf("%d",&v[i]);
	for(int i=1;i<=n;i++)
	{
		as+=(1ll*v[i]+l*2-1)/(l*2)*l*2;
		v[i]=(v[i]-1)%(l*2)+1;
		if(v[i]<=s[i]*2)st[i]++;
		if(v[i]<=(l-s[i])*2)st[i]+=2;
	}
	int l1=0,l2=0;
	for(int i=1;i<n;i++)
	if((st[i]&2)&&l1)l1--,as-=l*2,l2+=st[i]&1;
	else if((st[i]&2)&&l2)l1++,l2--,l2+=st[i]&1;
	else l1+=st[i]&1;
	if((st[n]&2))as-=l*2;
	printf("%lld\n",as);
}//

Measured memory_bytes: 3712
def main():
    N, X = map(int, input().split())
    min_m = float('inf')
    cnt = 0
    for i in range(N):
        m = int(input())
        X -= m
        cnt += 1
        if min_m > m:
            min_m = m

    cnt += X // min_m
    print(cnt)

main()

Measured memory_bytes: 38428
#include<iostream>
#include<string>
#include<algorithm>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef int status;
typedef long long ll;
typedef unsigned long long ull;
const ull base = 343;
const int INF = int(1e9);
const ll INF1 = ll(1e15);
const int MAX = 20002;

int min1 = INF;

int a[10];

int main()
{
    cin>>a[1]>>a[2]>>a[3];
    sort(a+1,a+4);
    int t1 = a[3] - a[1];
    int t2 = a[3] - a[2];
    int sum = 0;
    sum +=t2;
    t1 -= t2;

    sum += t1/2;
    sum += (t1%2)*2;

    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 256
program range_set
  implicit none
  integer(8), parameter :: modu = 1000000007
  integer :: n, a, b, i, j
  integer(8) :: x = 1, f(0:5000, 2) = 0, g(0:5000, 2) = 0
  read(*,*) n, a, b
  if (a > b) then
    i = a
    a = b
    b = i
  end if
  g(1, 2) = 1
  do i = 2, b - 1
    g(i, 2) = mod(g(i - 1, 1) + g(i - 1, 2), modu)
    g(i, 1) = mod(sum(g(1:i - a, 2)), modu)
  end do
  f(0, :) = 1
  do i = 1, n
    x = mod(x * 2, modu)
    f(i, 1) = mod(sum(f(max(i - a + 1, 0):i - 1, 2)), modu)
    do j = 1, min(b - 1, i)
      if (i == n) f(i, 1) = mod(f(i, 1) + f(i - j, 1) * g(j, 1), modu)
      f(i, 2) = f(i, 2) + merge(g(j, 1) + g(j, 2), mod(f(i - j, 1) * g(j, 2), modu), j == i)
    end do
    f(i, 2) = mod(f(i, 2), modu)
  end do
  write(*,'(i0)') modulo(x - f(n, 1) - f(n, 2), modu)
end program range_set

Measured memory_bytes: 3000
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0))return 0;
  long long x = 1;
  while (b > 0) {
    if (b & 1)x = (mod!=-1)?(x * a) % mod:x*a;
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

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

  ll n,l;
  std::cin>>n>>l;

  std::vector<ll> a(n);
  std::iota(all(a),l);

  ll sum=std::accumulate(all(a),0);
  std::sort(all(a),[](const ll& a,const ll& b){return std::abs(a)<std::abs(b);});

  std::cout<<sum-a[0]<<"\n";



  return 0;
}



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

public class AtCoderD
{
    static void Main()
    {
        long mod = 1000000007;
        int n;
        int a;
        int b;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            n = int.Parse(words[0]);
            a = int.Parse(words[1]);
            b = int.Parse(words[2]);
        }

        long total = 1;
        for (int i = 0; i < n; i++)
        {
            if (n - i > 30)
            {
                total *= (1024 * 1024);
                i = i + 19;
            }
            else
            {
                total *= 2;
            }
            total = total % mod;
        }
        total -= 1;

        // Console.WriteLine(total);

        long ca = Combination(n, a);
        long cb = Combination(n, b);

        long answer = total - ca - cb;
        if (answer < mod)
        {
            answer += mod;
        }
        if (answer < mod)
        {
            answer += mod;
        }

        Console.WriteLine(answer % mod);
    }

    private static long Combination(int n, int k)
    {
        long mod = 1000000007;
        long answer = 1;
        for (int i = n; i > n - k; i--)
        {
            answer = mul(answer, i);
        }
        for (int i = 1; i <= k; i++)
        {
            answer = div(answer, i);
        }
        return answer;
    }

    private static long mul(long a, long b)
    {
        long mod = 1000000007;
        return ((a % mod) * (b % mod)) % mod;
    }

    private static long pow(long a, long b)
    {
        long mod = 1000000007;
        if (b == 0)
        {
            return 1;
        }
        else if (b == 1)
        {
            return a % mod;
        }
        else if (b % 2 == 0)
        {
            long d = pow(a, b / 2);
            return d * d % mod;
        }
        else
        {
            return a * pow(a, b - 1) % mod;
        }
    }

    private static long div(long a, long b)
    {
        long mod = 1000000007;
        return mul(a, pow(b, mod - 2));
    }

}

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

ll v[3004];
ll dp[3005][3005][2];

ll solve(ll i, ll j, int turn) {
	if (i > j)
		return 0;
	if (dp[i][j][turn] != -1)
		return dp[i][j][turn];
	if (turn == 1)
		return dp[i][j][turn] = max(v[i] + solve(i + 1, j, 0), v[j] + solve(i , j - 1, 0));
	else return dp[i][j][turn] = min(solve(i + 1, j, 1), solve(i, j - 1, 1));
}

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

	memset(dp, -1, sizeof(dp));
	ll n;
	cin >> n;
	ll sum = 0;
	for (ll i = 0; i < n; i++)
		cin >> v[i], sum += v[i];
	ll res = solve(0, n - 1, 1);
	ll dif = sum - res;
	cout << res - dif;

	return 0;
}



Measured memory_bytes: 145016
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX-1;
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;
struct edge { ll from; ll to; ll cost; };


int main(){
	string s;
	cin >> s;
	int month = (s[5] - '0') * 10 + (s[6] - '0');
	int day = (s[8] - '0') * 10 + (s[9] - '0');
	if (month > 4)cout << "TBD" << endl;
	if (month <= 4)cout << "Heisei" << endl;
	return 0;
}

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

int main(){
    int h,w;
    cin >> h >> w;
    cout << endl;
    char pic[h+2][w+2],p;
    for(int i=0;i<h+2;i++){
        for(int j=0;j<w+2;j++){
            if(i==0||i==h+1||j==0||j==w+1)
                cout << "#";
            else{
                cin >> p;
                cout << p;
            } 
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

def check_pn(num):
    if (num <2):
        return False
    elif (num==2):
        return True

    if (num%2 == 0):
        return False
    i = 3
    while (i <= num/i):
        if num % i == 0:
            return False
        i += 2

    return True


n = int(input())
listdata = []
for i in range(n):
    listdata.append(int(input()))

n=0
for data in listdata:
    ch = check_pn(data)
    n += ch

print (n)




Measured memory_bytes: 5980
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a;cin>>a;
  if(a=="SUN")cout<<"7"<<endl;
  else if(a=="MON")cout<<"6"<<endl;
  else if(a=="TUE")cout<<"5"<<endl;
  else if(a=="WED")cout<<"4"<<endl;
  else if(a=="THU")cout<<"3"<<endl;
  else if(a=="FRI")cout<<"2"<<endl;
  else if(a=="SAT")cout<<"1"<<endl;
}


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

int main(){
    int N;
    ll K;
    cin >> N >> K;
    vector<int> P(N+1, 0);
    for (int i = 1; i <= N; i++) cin >> P[i];
    vector<ll> C(N+1, 0);
    for (int i = 1; i <= N; i++) cin >> C[i];
    
    ll ans = C[1];
    for (int i = 1; i <= N; i++) {
        ll now = 0;
        ll loop = 0;
        ll loopsize = 0;
        int pos = i;
        vector<ll> get;
        while (pos != i || loopsize == 0) {
            now += C[pos];
            get.push_back(now);
            pos = P[pos];
            loopsize++;
        }
        loop = now;
        for (int i = 0; i < (int)get.size(); i++) {
            ll t = i+1;
            if (t > K) continue;
            if (loop <= 0 || loopsize > K-t) ans = max(ans, get[i]);
            else ans = max(ans, get[i]+(K-t)/loopsize*loop);
        }
    }
    cout << ans << endl;
        
	return 0;
}


Measured memory_bytes: 3788
#include<stdio.h>
int main(){

  int a[100000],b[100000],c,e,i,j,d[100000];
  scanf("%d",&c);
  for(i=1;i<=c;i++){
    scanf("%d",&a[i]);
    b[i]=a[i];
  }
  for(i=1;i<=c;i++){
    j=a[i];
    e=b[j];
    d[e]=j;
  }
  printf("\n");
  for(i=1;i<=c;i++){
    printf("%d  ",d[i]);
  }

   return 0;
}

Measured memory_bytes: 2048
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

//HEADER FILES AND NAMESPACES
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp>   
using namespace std;
using namespace __gnu_pbds;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>; 
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);  

#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r+", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w+", stdout);
#endif  
	
    string t;
    cin >> t;
    int l = t.length();
    if(t[l-1] == 's') {
    	cout << t + "es" << '\n';
    }
    else {
    	cout << t + "s" << '\n';
    }
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;
#define EPS 1e-12

struct point{
    double x,y;
    point(){}
    point(double x,double y):x(x),y(y){}
    point operator + (point p){ return point(x+p.x,y+p.y);}
    point operator - (point p){ return point(x-p.x,y-p.y);}
    void make(){ cin>>x>>y; }
};

double cross(point a,point b){return a.x*b.y - a.y*b.x; }

int ccw(point p0,point p1,point p2){
    point a = p1-p0;
    point b = p2-p0;
    if( cross(a,b) > EPS )return 1;
    else return -1;
}
struct line{
    point s,t;
    line(){}
    line(point s,point t):s(s),t(t){}
};
int main(){
    while(1){
	int n,m,w,h,S;
	cin>>n>>m>>w>>h>>S;
	if(n==0)break;
	point p0 = point(0,0);
	point p1 = point(w,0);
	point p2 = point(0,h);
	point p3 = point(w,h);
	vector<line> ls(m+2);
	vector<double> l(m),r(m),s(m+1);
	ls[0] = line(p0,p1);
	s[0] = 0;
	for(int i=0;i<m;i++){
	    cin>>l[i]>>r[i];
	    s[i+1] = (((double)(l[i]+r[i]))*w)/2.0;
	    ls[i+1] = line( point(0,l[i]),point(w,r[i]) );
	}
	ls[m+1] = line(p2,p3);
	//s[m+1] = w*h;
	vector<int> cnt(m+1,0);
	for(int i=0;i<n;i++){
	    point p;
	    p.make();
	    int upper = m+1,low = 0;
	    while(upper-low>1){
		int mid = (upper+low)/2;
		if( ccw(ls[mid].s,ls[mid].t,p) * ccw(ls[mid+1].s,ls[mid+1].t,p) <= -1 )break;
		if( ccw(ls[mid].s,ls[mid].t,p) > 0 ) low =mid;
		else upper= mid;
	    }
	    int mid = (upper+low)/2;
	 //   if( ccw(ls[mid].s,ls[mid].t,p) * ccw(ls[mid+1].s,ls[mid+1].t,p) <= -1 ) cnt[mid]++;
	    cnt[ mid+1 ]++;
	    //if( mid< m+1&&ccw(ls[mid].s,ls[mid].t,p) * ccw(ls[mid+1].s,ls[mid+1].t,p) <= -1 ) cnt[mid]++;
	}
	for(int i=0;i<m;i++) cnt[i+1] +=cnt[i];
	int res = 0;
	//for(int i=0;i<=m+1;i++){
	  //  cout<<cnt[i]<<' '<<s[i]<<endl;
	//}
	for(int i=0;i<m;i++){
	    double ss = s[i];
	    int cc = cnt[i];
	    auto it = upper_bound(s.begin(),s.end(),w*h - S+ss );
	    //if(it == s.end() ) continue;
	    it--;
	    int index = it-s.begin();
	    res = max(res, cnt[index]-cc);
	}
	cout<<n-res<<endl;
    }
    return 0;
}



Measured memory_bytes: 4932
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define pb push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define all(v) ALL(v)
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr double eps = 1e-14; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int N,M;
    cin >> N >> M;
    vi a(M),b(M);
    rep(i,M){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }

    vector<int> cnt(N,0);
    rep(i,M){
        cnt[a[i]]++;
        cnt[b[i]]++;
    }

    rep(i,N){
        if(cnt[i]%2==1){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 1536
/*
    ##############################
    #  Author: Pratyush Gaurav   #
    #  College: NIT ROURKELA     #
    ##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

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

void solve() {
    string s;
    cin >> s;
    lli pos = 0, ans = 0;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] == 'W') {
            ans += i - pos;
            pos++;
        }
    }
    cout << ans << endl;
}

int main()
{
    IOS;
    lli t = 1;
    //cin >> t;

    while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 720
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素



signed main(){
  int N;
  cin>>N;
  vector<ll> X(N),L(N);
  int i;
  REP(i,N)cin>>X.at(i)>>L.at(i);

  vector< pair<ll,ll> > p(N);
  REP(i,N){
    p[i]=MP((X[i]+L[i]),(X[i]-L[i]));
  }
  sort(p.begin(),p.end());
  ll cur=-1*INF;
  int ans=0;
  for(int i=0;i<N;i++){
    if(p[i].second>=cur){
      ans++;
      cur=p[i].first;
    }
  }
  cout<<ans<<endl;


}

Measured memory_bytes: 3328
from collections import defaultdict, Counter
from itertools import permutations as p

def factorize(n):
    d = defaultdict(int)
    for i in range(2, int(n**0.5)+1):
        while n%i==0:
            d[i] += 1
            n //= i
        if not n:
            break
    if n>1:
        d[n] += 1
    return d

N = int(input())
d = Counter()
for i in range(1, N+1):
    d += factorize(i)
vl = d.values()

ans = sum(1 for i, j, k in p(vl, 3) if i>=2 and j>=4 and k>=4)//2
ans += sum(1 for i, j in p(vl, 2) if i>=2 and j>=24)
ans += sum(1 for i, j in p(vl, 2) if i>=4 and j>=14)
ans += sum(1 for i in vl if i>=74)
print(ans)

Measured memory_bytes: 3316
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=5e5+5;
char s[N];int las[N],f[N],n;
int main(){
	scanf("%d%s",&n,s+1);
	fp(i,1,n)las[i]=(s[i]=='1'?las[i-1]:i);
	fp(i,1,n){
		f[i]=f[i-1];
		if(s[i]=='1'&&las[i]&&s[las[i]-1]=='1'){
			R int x=las[i],y=las[x-1];
			cmax(f[i],f[x-2]+i-x);
			if(i==x+1)fp(j,y,x-2)cmax(f[i],f[j]+x-1-j);
		}
	}
	printf("%d\n",f[n]);
	return 0;
}

Measured memory_bytes: 4608
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int a,b,k;
    cin>>a>>b>>k;
    int cnt=0;
    int n=max(a,b);
    while(1){
        if(a%n==0 && b%n==0){
            cnt++;
            if(cnt==k){
                //cout<<cnt<<endl;
                cout<<n<<endl;
                return 0;
            }
        }
        n--;
    }
    return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    a,b=map(int, input().split())
    print("Odd") if a*b%2 else print("Even")

main()

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

int main()
{
    int n;
    cin >> n;
    int a[n] = {};
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    
    int ans = 0;
    for(int i=0; i<n; i++){
        for(int j =i+1; j<n; j++){
            if(i >= j) continue;
            ans += a[i]*a[j];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  while (A>0 && C>0){
  C = C - B;
  A = A - D;
    if (C <= 0){
      cout << "Yes" << endl;
    }
    else if(A <= 0){
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int main(){
	int a[3];
	rep(i,3) cin>>a[i];
	int res = 1e9;
	rep(tar,101){
		int tmp = 0;
		rep(i,3){
			int x = a[i];
			if(x>tar) tmp += x-tar;
			else if((tar-x)%2==0) tmp += (tar-x)/2;
			else tmp += (tar-x)/2 + 2;
		}
		chmin(res,tmp);
	}
	cout<<res<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 200010
using namespace std;
int n,p[N],d[N];
int main(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>p[i];
    for(int i=1;i<=n;i++) d[p[i]] = d[p[i]-1]+1;
    int ans = 0;
    for(int i=1;i<=n;i++) ans = max(ans,d[i]);
    cout<<(n-ans)<<'\n';
    return 0;
}


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

#define ll long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define SPEED ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sz size()
#define all(x) x.begin(),x.end()
#define OO 1e18
#define iOO INT_MAX
#define Mdp memset(dp,-1,sizeof dp)
#define R return
#define Test int TT;cin>>TT;for(int T=1;T<=TT;T++)
using namespace std;

ll Dp[1000100];
int main()
{

    SPEED;

    int n,a[1000010],k;
    cin >> n >> k;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        Dp[i] = OO;
    }
    Dp[0] = 0;
    for(int i=0;i<n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            if(i+j < n)
                Dp[i+j] = min(Dp[i+j],Dp[i]+abs(a[i]-a[i+j]));
        }
    }

    cout << Dp[n-1] << endl;
    R 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<int> R(n);
	int loop,loop2;
	cin >> R[0];
	cin >> R[1];
	int max=R[1]-R[0];
	int nummin=min(R[0],R[1]);
	
	for(loop=2;loop<n;loop++){
		cin >> R[loop];
		if(R[loop]-nummin>max){
			max=R[loop]-nummin;
		}else if(R[loop]<nummin){
			nummin=R[loop];
		}
	}
	cout << max << endl;
	return 0;
}


Measured memory_bytes: 3612
#include<algorithm>
#include<string.h>
#include<stdio.h>
#include<iostream>
using namespace std;

const int N=2010;
int a[N];
int n;

int main(){
	cin>>n;
	for(int i=0; i<n; i++)
		cin>>a[i];
	sort(a,a+n);
	
	long long cnt=0;
	for(int i=0; i<n; i++)
		for(int j=i+1; j<n; j++)
			for(int k=j+1; k<n; k++)
				if(a[i]+a[j]>a[k] && a[i]+a[k]>a[j] && a[j]+a[k]>a[i])
					cnt++;
				else
					break;
	
	cout<<cnt<<endl;
	
	return 0;
}

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

// https://qiita.com/drken/items/b97ff231e43bce50199a
// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return d;
}

ll f(ll a, ll b){
    return ((a+b-2)*a*b)/2;
}


int main(void){
    ll N, M,K;
    cin >> N >> M >> K ;
    ll P = 1000*1000*1000 + 7; 
    
    ll comb=1; 
    for(ll i=0; i<K-2; i++){
        comb= (comb*(N*M-2-i))%P;
        ll xx, yy;
        extGCD(K-i-2,P,xx,yy);
        if(xx<0){
            xx = (-xx)%P;
            xx = P-xx;
        } 
        comb =(comb*xx)%P;
    }
    
    ll S=0;
    
    for(ll i=1; i<=N; i++){
        for(ll j=1; j<=M; j++){
            S= S + f(i,j) + f(i,M+1-j) + f(N+1-i,j) + f(N+1-i,M+1-j);
            S= S - f(1,j) - f(1,M+1-j) - f(i,1) - f(N+1-i,1); 
            S= S%P;
        }
    }
    
    S= (S*comb)%P; 
    S= (S*((P+1)/2))%P;  
    
    cout<< S << endl; 
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp> 
//using namespace __gnu_pbds; 
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int> >, rb_tree_tag,tree_order_statistics_node_update>
#define standardVar ll n,m,i,j,k,num,num1,num2,flag=0
#define nn <<"\n"
#define __ <<" "<<
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define ittr(x,v) for(auto x=v.begin();x!=v.end();x++)
#define itr(x,n) for(x=0;x<n;x++)
#define itrab(x,a,b) for(x=a;x<b;x++)
#define itpr(v) ittr(x,v)cout<<*x<<" "; cout nn
#define itppr(v) ittr(x,v)cout<<(*x).ff<<" "<<(*x).ss<<"  "; cout nn
#define pi 3.14159265359
#define dTor(x) ((x)*pi)/180.0

typedef long long int ll;       //TYPEDEFS
typedef long double ld;
typedef vector<ll> vl;
typedef map<ll,ll> ml;
typedef set<ll> sl;
typedef string str;
typedef pair<ll, ll> pl;
typedef vector< pl > vpl;
typedef map<pl,ll> mpl;
typedef set< pl > spl;
typedef vector<str> vst;
typedef vector<vl> vvl;

const ll M=1000000007;          //COMMON MODULO
const ll N=998244353;

ll power(ll x, ll y, ll p){     //MODULAR EXPONENTIATION
    ll res=1;
    x=x%p;
    if(x==0)
        return 0;
    while(y>0){
        if(y&1)
            res=(res*x)%p;
        y=y>>1;
        x=(x*x)%p;
    }
    return res;
}
ll inv(ll x, ll m){             //FERMAT INVERSE
    return power(x,m-2,m);
}
struct comp{                    //COMPARISON ON PAIRS
    template<typename T>        
    bool operator()(const T &a, const T &b){
        if (a.ff==b.ff)
            return (a.ss<b.ss);
        else
            return (a.ff<b.ff);
    }
};
bool mod(const pair<ll,ll> &a, const pair<ll,ll> &b){   //COMPARATOR FOR PAIRS (SORTING)
    if(a.ff!=b.ff)
        return (a.ff<b.ff);
    else
        return (a.ss<b.ss);
}
void sieve(vl &prime){          //SIEVE OF ERATOSTHENES
    ll maxN=1e6;
    vector<bool> pr(maxN+1,1);
    for(int i=2;i*i<=maxN;i++)
        if(pr[i]==1)
            for(int j=i*i;j<=maxN;j+=i)
                pr[j]=0;
    for(ll i=2;i<=maxN;i++)
        if(pr[i]==1)
            prime.pb(i);
}
bool isValid(ll i, ll j, ll n, ll m){   //CHECKS FOR OVERFLOW
    if(i>=0&&i<n&&j>=0&&j<m){
        return true;
    }
    return false;
}

bool ok(ll mid, ll k, ll n, vl &v){
    //cout<<mid<<" ";
    for(ll i=0;i<n;i++){
        k-=((v[i]+mid-1)/mid)-1;
    }
    //cout<<k nn;
    if(k>=0)
        return true;
    return false;
}

//MAIN FUNCTION STARTS HERE

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    standardVar;
    cin>>n>>k;
    vl v;
    itr(i,n){
        cin>>num;
        v.pb(num);
    }
    ll mn=1,mx=(ll)1e9+100;
    ll mid;
    while(mn<mx){
        mid=(mn+mx)/2;
        if(ok(mid,k,n,v))
            mx=mid;
        else
            mn=mid+1;
    }
    cout<<mx nn;
    return 0;
}

Measured memory_bytes: 5292
package main

import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}

func main() {
    sc.Split(bufio.ScanWords)
    a := nextInt()
    b := nextInt()
    if a > b {
      fmt.Println("a > b")
    } else if a < b {
      fmt.Println("a < b")
    } else {
      fmt.Println("a == b")
    }
}


Measured memory_bytes: 1088
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, n) for (int i = 1; i < (int)(n+1); i++)
#define rep4(i, s, n) for (int i = (s); i < (int)(n+1); i++)
#define repr(i,n) for (int i = (n-1); i>=0;i--)
#define repr2(i,s,n) for (int i = (n-1); i>=(int)(s);i--)
#define repr3(i,n) for(int i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Grid = vector<vector<int>>;
const ll INF = 10011032323450010;
const ld PI = 3.14159265358979323846;



int main() {
     
     // グリッドの高さ、幅、スタート点、ゴール点の座標受け取り
    ll N;
    int max_div=0;
    cin>>N;
    int sqr=(int)sqrt(N)+1;
    rep3(i,sqr){
        if(N%i==0){
            max_div=max(max_div,i);
            

        }

    }
    cout<<max_div+N/(ll)max_div-2 <<endl;

return 0;
}


Measured memory_bytes: 256