akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define fr(i,n) for(i=0;i<n;i++)
#define frv(i,n) for(i=n-1;i>=0;i--)
#define rep(i,st,en) for(i=st;i<=en;i++)
#define repv(i,en,st) for(i=en;i>=st;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(x,a) memset(x,a,sizeof(x))
#define fout cout<<fixed<<setprecision(7)
#define bi(n) __builtin_popcount(n)
#define bil(n) __builtin_popcountll(n)

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef long double ld;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ods;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the iterator to kth element.(0-based)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());      // Use mt19937_64 for 64 bit random nos.
ll myrand(ll n){ return rng()%n;}

ll mod = 1e9+7;
void add(ll &a,ll b,ll md=mod){ a+=b; if( a>=md)a-=md;if(a<0)a+=md;}
ll mul(ll a,ll b){ return (a*b)%mod;}
ll mulmod(ll a,ll b,ll M){ a%=M;b%=M;if(M<=mod)return mul(a,b);ll res=0;while(a>0){
    if (a&1ll){res+=b;if(res>=M)res-=M;}a>>=1;b<<=1;if(b>=M)b-=M;}return res;
}ll ffmod(ll b,ll exp,ll md=mod){ll res =1;while(exp){
    if(exp&1ll)res=(res*b)%md;b =(b*b)%md;exp/=2ll;}return res;
}ll powmod(ll b,ll exp,ll md=mod){ll res =1;while(exp){
        if(exp&1ll)res=mulmod(res,b,md);b =mulmod(b,b,md);exp/=2ll;}return res;
}void mxupd(pii &a,pii b){if(a.f > b.f)a.s=max(a.s,b.f);else{a.s=max(a.f,b.s);a.f=b.f;}
}


const int N = 200010;
const int M = 200010;
const int LN = 20;



int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n,m,i,j,x,q;
    int t=1;
	ll a,b,c,k;
	cin >> a>> b >> c >> k;
	if ( k <=a){
		cout << k << "\n";
	}
	else if ( k <= a+b ){
		cout << a << "\n";
	}
	else{
		ll ans = k-a-b;
		cout << a-ans << "\n";
	}



    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



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


Measured memory_bytes: 3564
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            int R = int.Parse(Console.ReadLine());
            string ans = "AGC";
            if (R < 1200) { ans = "ABC"; }
            else if (R < 2800) { ans = "ARC"; }

            Console.WriteLine(ans);

            Console.Out.Flush();
        }
    }
    


    public class Calculation
    {

    }

    public class Graph
    {

    }
}
    

Measured memory_bytes: 11092
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define tll tuple<ll, ll, ll>
#define all(c) c.begin(),c.end()
 
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;

int main() {
  ll n, m;
  cin >> n >> m;
  deque<ll> que;
  ll rt = sqrt(m);
  ll mi = m;
  for (ll i=1;i<=rt;i++){
    if (m%i == 0){
      if (n <= i) mi = min(mi,i);
      if (i*i != m){
        ll cand2 = m/i;
        if (n <= cand2) mi = min(mi,cand2);
      }
    }
  }
  
  cout << m/mi << endl;
}

Measured memory_bytes: 256
n, m = list(map(int, input().split()))
hs =  list(map(int, input().split()))
ans = [1]*n
for i in range(m):
    road = list(map(int, input().split()))
    if hs[road[0]-1] <= hs[road[1]-1]:
        ans[road[0]-1] = 0
    if hs[road[0]-1] >= hs[road[1]-1]:
        ans[road[1]-1] = 0
print(ans.count(1))


Measured memory_bytes: 20052
#include <iostream>
#include <string>
#include <iomanip>
#include <math.h>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
  long long L, R;
  cin >> L >> R;

  set<int> s_i;
  int min_mod = 2019;
  for (long long i = L; i <= R; ++i)
  {
    if (s_i.size() == 2019) break;
    s_i.insert(i % 2019);

    set<int> s_j;
    for (long long j = i + 1; j <= R; ++j)
    {
      if (s_j.size() == 2019) break;
      s_j.insert(j % 2019);

      if (min_mod > (i*j) % 2019) min_mod = (i*j) % 2019;
      if (min_mod == 0) break;
    }
    if (min_mod == 0) break;
  }
  cout << min_mod << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<cmath>

#ifndef M_PI
#define M_PI 3.14159265358979
#endif

#define deg_to_rad(deg) (((deg)/360.0)*2.0*M_PI)

using namespace std;

int main(){
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double x1, y1, x2, y2;
    x1 = a * cos(deg_to_rad(h * 30.0 + m / 2.0));
    y1 = a * sin(deg_to_rad(h * 30.0 + m / 2.0));
    x2 = b * cos(deg_to_rad(m * 6.0));
    y2 = b * sin(deg_to_rad(m * 6.0));
    double ans = sqrt(pow(x1-x2,2) + pow(y1-y2,2));
    printf("%.20f\n",ans);
    return 0;
}

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

struct UnionFind {
    vector<long long> par;
    vector<long long> rank;
    vector<long long> time;
    const long long INF = 1e18;

    void initialize(long long n){
        par.resize(n);
        rank.resize(n);
        time.resize(n);
        for(long long i=0; i<n; i++){
            par[i] = i;
            rank[i] = 0;
            time[i] = INF;
        }
    }

    long long find(long long x, long long t){
        if(time[x] > t){
            return x;
        }else{
            return find(par[x], t);
        }
    }

    void unite(long long x, long long y, long long t){
        x = find(x, t);
        y = find(y, t);
        if(x == y) return;
        if(rank[x] < rank[y]){
            par[x] = y;
            time[x] = t;
        }else{
            par[y] = x;
            time[y] = t;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }

    bool same(long long x, long long y, long long t){
        return find(x, t) == find(y, t);
    }
};

struct edge{long long u, v, cost;};
bool comp(const edge& e1, const edge& e2){
    return e1.cost < e2.cost;
}

UnionFind uf;

long long kruskal(long long N, vector<edge> es){
    sort(es.begin(), es.end(), comp);
    uf.initialize(N);
    long long res = 0;
    for(long long i=0; i<es.size(); i++){
        edge e = es[i];
        if(!uf.same(e.u, e.v, e.cost)){
            uf.unite(e.u, e.v, e.cost);
            res += e.cost;
        }
    }
    return res;
}


int main(){
    long long i, j, k;
    long long N, M;
    cin >> N >> M;
    vector<edge> es;
    for(i=0; i<M; i++){
        long long a, b, c;
        cin >> a >> b >> c;
        es.push_back({a, b, c});
    }
    long long sum = kruskal(N+1, es);

    long long Q;
    cin >> Q;
    for(i=0; i<Q; i++){
        long long s, t;
        cin >> s >> t;
        long long ok=0, ng=1e10; 
        while(ng-ok>1){
            long long mid = (ng+ok)/2;
            if(uf.same(s, t, mid)){
                ng = mid;
            }else{
                ok = mid;
            }
        }
        cout << (sum-ok-1) << endl;
    }
    return 0;
}

Measured memory_bytes: 20584
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func main() {
	// sc.Split(bufio.ScanWords)
	var N int
	fmt.Scanf("%d", &N)
	// N = nextInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		// A[i] = nextInt()
		fmt.Scanf("%d", &A[i])
	}

	sort.Ints(A)
	ans := A[N/2] - A[N/2-1]
	fmt.Println(ans)

}


Measured memory_bytes: 5504
N,W = map(int, input().split())

import numpy as np
dp = np.full(N*1000+1, W+1, dtype=int)
dp[0] = 0


for _ in range(N):
  w,v = map(int, input().split())
  dp[v:] = np.minimum(dp[v:], dp[:-v]+w)

print(np.max(np.where(dp<=W)))

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N,a;

    Scd2(N,a);
    N = N*2-1;
    YesNo( a%(N-1) != 1 );
    if( a%(N-1) == 1 ) return 0;

    vector<int> ans(N);
    Rep(i,N){
        ans[i] = i+1;
    }

    swap(ans[a-1],ans[N/2]);
    swap(ans[0],ans[N/2-1]);
    swap(ans[N-1],ans[N/2+1]);

    Rep(i,N){
        printf ("%d%c", ans[i], i==N-1 ? 10 : ' ' );
    }

    return 0;
}



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

int a,b;
char op; 

while(scanf("%d %c %d\n", &a, &op, &b)){

if(op == '?') break;
else if (op == '+') printf("%d\n", a+b);
else if (op == '-') printf("%d\n", a-b);
else if (op == '/') printf("%d\n", a/b);
else if (op == '%') printf("%d\n", a%b);
else if (op == '*') printf("%d\n", a*b);
}

}


Measured memory_bytes: 2064
import math
n=int(input())
if n==4:
    print(2)
elif n<=5:
    print(n-1)
else:
    ans=n-1
    for i in range(math.floor(n**0.5),1,-1):
        if n%i==0:
            ans=i+n//i-2
            break
    print(ans)

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

int main() {
    int H, W;
    cin >> H >> W;
    int mass[H][W] = {0};
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> mass[i][j];
        }
    }
    vector<pair<int, int>> answer;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W - 1; ++j) {
            if (mass[i][j] % 2 == 1) {
                ++mass[i][j + 1];
                answer.emplace_back(make_pair(i + 1, j + 1));
                answer.emplace_back(make_pair(i + 1, j + 2));
            }
        }
    }
    for (int i = 0; i < H - 1; ++i) {
        if (mass[i][W - 1] % 2 == 1) {
            ++mass[i + 1][W - 1];
            answer.emplace_back(make_pair(i + 1, W));
            answer.emplace_back(make_pair(i + 2, W));
        }
    }
    cout << answer.size() / 2 << endl;
    for (int i = 0; i < answer.size(); i += 2) {
        cout << answer[i].first << " " << answer[i].second << " " << answer[i + 1].first << " " << answer[i + 1].second << endl;
    }
}

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

int main() {
  
  int a;
  cin >> a;
  
  if(a < 1000) cout << "ABC" << endl;
  else cout << "ABD" << endl;
  
  
}


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

//UF Tree

struct UnionFind{

    //親番号の配列。自身が親なら木の頂点数*(-1)

    vector<int> r;

    //最初はバラバラなので全部親として初期化

    UnionFind(int N){
        r = vector<int>(N, -1);
    }

    //xの親を根にする関数

    int root(int x){
        if(r[x] < 0)return x;
        return r[x] = root(r[x]);
    }

    //二つの子を同じ根に結び付ける関数

    bool unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return false;
        if(r[x] > r[y])swap(x,y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }

    //木の枝の数

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

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

    UnionFind UF(N); //集合の生成,インスタンス化
    for(int i = 0; i < M; i++){
        int A,B;
        cin >> A >> B;
        A -= 1; B -= 1;
        UF.unite(A,B); //AとBは辺で結ばれる
    }

    int ans = 0;
    for(int i = 0; i < N; i++){
        ans = max(ans, UF.size(i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 4032
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

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

    map<int, int> mp;
    rep(i, n){
        mp[a.at(i)]++;
    }

    int ans = 0;
    for(int i=1; i<=1e5+1; i++){
        int tmp = i-1;
        ans = max(ans, mp[tmp]+mp[tmp-1]+mp[tmp+1]);
    }

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


Measured memory_bytes: 8272
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
#include<deque>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	i64 n;
	cin >> n;
	int ans = 10000000;
	rep2(i, 1, sqrt(n)) {
		if (n%i == 0) {
			string a = to_string(i);
			string b = to_string(n / i);
			int x = max(a.size(), b.size());
			ans = min(ans, x);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AMultiplication1 solver = new AMultiplication1();
        solver.solve(1, in, out);
        out.close();
    }

    static class AMultiplication1 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            out.println(a * b);
        }

    }

    static class Scanner {
        private final InputStream in;
        private final byte[] buffer;
        private int ptr;
        private int buflen;

        public Scanner(InputStream in) {
            this.in = in;
            this.buffer = new byte[1024];
            this.ptr = 0;
            this.buflen = 0;
        }

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

        private byte readByte() {
            if (hasNextByte()) return buffer[ptr++];
            return -1;
        }

        private boolean isPrintableChar(byte c) {
            return '!' <= c && c <= '~';
        }

        private void skipUnprintable() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
                ptr++;
            }
        }

        public boolean hasNext() {
            skipUnprintable();
            return hasNextByte();
        }

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

    }
}



Measured memory_bytes: 25572
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

#define MAX_N 8

bool isjr(int n, int N)
{
	int d[MAX_N + 2];
	int i, j;

	for(i = 0; n > 0; i++) {
		d[i] = n % 10;
		n /= 10;
		if(d[i] > N || d[i] == 0) return false;
		for(j = 0; j < i; j++) {
			if(d[j] == d[i]) {
				return false;
			}
		}
	}
	return true;

}


int main()
{
	int P[MAX_N + 2];
	int Q[MAX_N + 2];

	int i;
	int cnt = 0;
	int N;

	int p1 = 0, q1 = 0;
	cin >> N;
	for(i = 1; i <= N; i++) {
		cin >> P[i];
		p1 = p1*10 + P[i];
	}
	for(i = 1; i <= N; i++) {
		cin >> Q[i];
		q1 = q1*10 + Q[i];
	}
//	cout << p1 << endl << q1 << endl;

	if(p1 == q1) {
		cout << 0 << endl;
		return 0;
	}
	int p2, q2;
	p2 = min(p1, q1);
	q2 = max(p1, q1);

	for(i = p2 + 1; i < q2; i++) {
		if(isjr(i, N)) {
			cnt ++;
//			cout << i << endl;
		}
	}

	cout << cnt + 1 << endl;

	return 0;	
	

}


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

int main(void)
{
  int a, b;
  cin >> a >> b;
  if (a * b % 2 == 0)
  {
    cout << "Even" << endl;
  }
  else
  {
    cout << "Odd" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($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:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input!(a: i64, b: i64);
    let d = b - a;
    puts!("{}\n", d * (d - 1) / 2 - a);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<int, int>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int x, y, a, b, c;
    cin, x, y, a, b, c;
    vector<ll> aa(a), bb(b), cc(c);
    REP(i, 0, a) {
        cin, aa[i];
    }
    REP(i, 0, b) {
        cin, bb[i];
    }
    REP(i, 0, c) {
        cin, cc[i];
    }
    sort(aa.rbegin(), aa.rend());
    sort(bb.rbegin(), bb.rend());
    sort(cc.rbegin(), cc.rend());
    ll sum = 0;
    vector<ll> combine;
    REP(i, 0, x) {
        sum += aa[i];
        combine.emplace_back(aa[i]);
    }
    REP(i, 0, y) {
        sum += bb[i];
        combine.emplace_back(bb[i]);
    }
    sort(combine.begin(), combine.end());
    ll ans = sum;
    REP(i, 0, min(c, (int)combine.size())) {
        sum += cc[i];
        sum -= combine[i];
        chmax(ans, sum);

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


Measured memory_bytes: 4852
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  ll n;
  cin >> n;
  vector<pair<ll, ll> > a(n);
  rep(i, 0, n) cin >> a[i].first >> a[i].second;
  sort(all(a));
  ll ans = (a[0].first-1) + (a[n-1].first-a[0].first+1) + (a[n-1].second-0);
  cout << ans << "\n";
}

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

vector <int> from[100010];
int vis[100010];
queue <int> q;

int main () {
	int n, m; scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		from[x].push_back(y);
		from[y].push_back(x);
	}
	q.push(1), vis[1] = 1;
	while (!q.empty()) {
		int x = q.front(); q.pop();
		for (int i = 0; i < from[x].size(); i++) {
			int v = from[x][i];
			if (vis[v]) continue;
			vis[v] = x;
			q.push(v);
		}
	}
	printf("Yes\n");
	for (int i = 2; i <= n; i++) {
		printf("%d\n", vis[i]);
	}
	return 0;
}


Measured memory_bytes: 10660
#include<iostream>
#include<vector>
 
int main(){
  int N;
  std::cin>>N;
  
  std::vector<long long> value(N);
  for(int i=0;i<N;i++)
    std::cin>>value[i];
  
  long long answer=0;
  int right=0;
  long long SUM=0;
  
  for(int left=0;left<N;++left){
    while(right<N && (SUM^value[right]) == (SUM+value[right])){
      SUM+=value[right];
      ++right;
    }
    
     answer+=right-left;     
     if(left==right)
       ++right;
     else
       SUM-=value[left];
  }
  
  std::cout<<answer<<std::endl;
      
  
  return 0;
}

Measured memory_bytes: 1792
a = int(input())
l = []
c = 0
f = 0
for i in range(a):
    ta,tb = map(int,input().split())
    if ta==tb : c+=1
    else: c = 0
    if c>=3 : f = 1
if f:
    print("Yes")
else:
    print("No")

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

int m, w;
int bm[22], bw[22];
int memo[22][1<<13];

int e(int a, int b){

  int p = abs(bm[a] - bw[b]);
  return p * (p-30) * (p-30);

}

int solve(int cntm, int bitw){

  if(~memo[cntm][bitw]) return memo[cntm][bitw];
  if(cntm == m) return 0;
  
  int ret = 0;
  for(int i=0;i<w;i++)
    if(!(bitw & (1<<i)))
    ret = max(ret, solve(cntm+1, (bitw | (1<<i))) + e(cntm, i));
  
  ret = max(ret, solve(cntm+1, bitw));
  
  return memo[cntm][bitw] = ret;
  
}

int main(){

  while(cin >> m >> w, m|w){
    for(int i=0;i<m;i++) cin >> bm[i];
    for(int i=0;i<w;i++) cin >> bw[i];
    
    memset(memo, -1, sizeof(memo));
    cout << solve(0, 0) << endl;
  }
  
}

Measured memory_bytes: 1876
program main
	implicit none
    integer::a,i,b
    character::s
    read(*,*) a
    s='f'
    do i=1,3
    	b=mod(a,10)
        a=a/10
        if(b==7)then
        	s='t'
        end if
    end do
    
    if (s=='t')then
    	write(*,*) 'Yes'
    else
    	write(*,*) 'No'
    end if
    stop
end program main
        


Measured memory_bytes: 2860
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
int main() {
    string s;cin>>s;
    vector<int> num(s.size()+1);
    rep(i,s.size()+1){
        num[i]=0;
    }
    rep(i,s.size()){
        if(s.at(i)=='<') num[i+1]=num[i]+1;
    }
    for(ll i=s.size()-1;i>=0;i--){
        if(s.at(i)=='>') num[i]=max(num[i+1]+1,num[i]);
    }
    ll sum=0;
    rep(i,s.size()+1){
        sum+=num[i];
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 2820
# -*- coding: utf-8 -*-
from itertools import product
"""
-> は @と表記する
"""

def parse(S):
    """
    構文木を返す
    Sは普通の記法の式
    opは優先順序　通常は(*/: 1, +-: 2)
    """
    S = "{}".format(S)
    V = []
    op = {"-": 1,
          "+": 2,
          "*": 2,
          "@": 2}
    variables = list("abcdefghijk")

    for x in list("()+-*@"):
        S = S.replace(x, " {} ".format(x))
    i = 0
    rank = 0
    O = []
    for s in S.split():
        if s == "(":
            rank += 1
        elif s == ")":
            rank -= 1
        elif s in variables + ["T", "F"]:
            V.append(s)
            i += 1
        else:
            V.append(s)
            O.append([-rank, op[s], i])
            i += 1
 
    G = [[] for _ in range(len(V))]
    P = [-1]*len(V)
    O = sorted(O)
     
    def get_pair(i):
        while P[i] != -1:
            i = P[i]
        return i
    
    if len(O):
        for _, _, i in O:
            if V[i] == "-": # 単項演算子
                r = get_pair(i+1)
                G[i].append(r)
                P[r] = i
            else: # 二項演算子
                l, r = get_pair(i-1), get_pair(i+1)
                G[i].extend([l, r])
                P[l], P[r] = i, i
        p = P.index(-1)
    else:
        assert len(V) == 1
        p = 0
    return G, V, p
 

def calculate(G, V, p, X):
    variables = set(list("abcdefghijk"))
    def call(i):
        if V[i] in variables:
            return X[V[i]]
        elif V[i] == "T":
            return True
        elif V[i] == "F":
            return False
        elif V[i] == "-":
            return not call(G[i][0])
        elif V[i] == "@":
            x = call(G[i][0])
            y = call(G[i][1])
            return not (x==True and y==False)
        elif V[i] == "*":
            x = call(G[i][0])
            y = call(G[i][1])
            return x & y
        elif V[i] == "+":
            x = call(G[i][0])
            y = call(G[i][1])
            return x | y
        else:
            raise
    return call(p)


S = input()
while S != "#":
    L, R = S.replace("->", "@").split("=")
    abc = list("abcdefghijk")
    for Y in product([True, False], repeat=11):
        X = dict()
        for i in range(11):
            X[abc[i]] = Y[i]
        G, V, p = parse(L)
        l = calculate(G, V, p, X)
        G, V, p = parse(R)
        r = calculate(G, V, p, X)
        if l != r:
            print("NO")
            break
    else:
        print("YES")
    S = input()



Measured memory_bytes: 8908
N = int(input())
A = list(map(int, input().split()))
A.sort()                  #エラトステネスの篩にかけるためソート
Amax = A[-1]
dp = [1]*(Amax+1)         #Aの最大値までのエラトステネスの篩を作る。
ans = 0
for i in range(len(A)-1):
  p = A[i]
  if dp[p] == 1:          #A[i]がA[j]の倍数でないかをエラトステネスの篩でチェック
    for q in range(Amax//p+1):
      dp[p*q] = 0         #A[i]の倍数をすべて0にする
    if A[i] != A[i+1]: 
      ans += 1            #A[i]が重複していなければカウント
if dp[Amax] == 1:         #重複チェック時にレンジオーバーするためAmaxだけ別で判定 
  ans += 1
print(ans)

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

int gcd(int a,int b) {
  if (a>b) {
    swap(a,b);
  }
  if (b%a == 0) {
    return a;
  }
  return gcd(b%a,a);
}

int main() {
  long long N,M;
  cin >> N >> M;
  long long ans = 0;
  vector <pair<long long,long long>> nu(N+M);
  for (int i=0; i<N; i++) {
    cin >> nu[i].first;
    nu[i].second = 1;
  }
  for (int i=0; i<M; i++) {
    cin >> nu[N+i].second >> nu[N+i].first;
  }
  
  sort(nu.begin(),nu.end());
  reverse(nu.begin(),nu.end());
  for (int i=0; i<10101010; i++) {
    if (nu[i].second >= N) {
      ans += N * nu[i].first;
      break;
    }
    ans += nu[i].first * nu[i].second;
    N -= nu[i].second;
  }
  cout << ans << endl;
  return 0;
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n>>m;

	(n<=8 && m<=8)?cout<<"Yay!"<<endl:cout<<":("<<endl;



}


Measured memory_bytes: 3592
#include<iostream> 
#include<string> 
#include<vector> 
#include<algorithm> 
#include<cmath>
#include<set>
#include<utility>

using namespace std;


int main()
{
	int x, y, z;
	cin >> x >> y >> z;
	cout << (x - z) / (y + z) << endl;

}

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

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

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int main()
{
    ll n,k; cin >> n >> k;
    ll from = 0,to = 0;
    for(ll i = 0; i < k; i++){
        from += i;
    }
    for(ll i = n; i >= n-k+1; i--){
        to += i;
    }
    ll ans = 0;
    for(int i = k; i <= n+1; i++){
        ans += (to - from + 1);
        ans %= mod;
        to += (n-i);
        from += i;
        
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>

#define max(a, b) (a > b ? a : b)

struct Item {
  int weight;
  int value;
};

int dp[105][10005];
int main(void) {
  int n;
  int W;
  struct Item items[105];
  scanf("%d %d", &n, &W);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &items[i].value, &items[i].weight);
  }

  for (int i = 0; i < n; i++) {
    for (int w = 0; w <= W; w++) {
      if (items[i].weight <= w) {
        dp[i + 1][w] = max(dp[i][w], dp[i][w - items[i].weight] + items[i].value);
      }
      else {
        dp[i + 1][w] = dp[i][w];
      }
    }
  }

  printf("%d\n", dp[n][W]);

  return (0);
}



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

using Graph=vector<vector<int>>;
Graph g0;
Graph t;
vector<int> used;
int root=-1;

void buildTree(int v){
    used[v]=true;
    for(int i=0;i<g0[v].size();i++){
        int to=g0[v][i];
        if(!used[to]){
            t[v].push_back(to);
            buildTree(to);
        }
    }
    return;
}

int dfs(int v){
    if(t[v].size()==0) return 0;
    int res=0;
    int cnt0=0;
    for(int i=0;i<t[v].size();i++){
        auto ret=dfs(t[v][i]);
        cnt0+=(ret==0);
        res+=ret;
    }
    if(cnt0>=1){
        res+=cnt0-1;    
    }
    
    return res;
}

int main(){
    int n;
    cin>>n;
    g0.assign(n,vector<int>());    
    t.assign(n,vector<int>());
    used.assign(n,0);
    
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        g0[a].push_back(b);
        g0[b].push_back(a);
    }
    for(int i=0;i<n;i++){
        if(g0[i].size()>=3){
            root=i;
        }
    }
    if(root==-1){
        cout<<1<<endl;
        return 0;
    }
    buildTree(root);
    auto ret=dfs(root);    
    cout<<ret<<endl;
    return 0;
}

Measured memory_bytes: 13696
#include <iostream>
#include <math.h>
#include <iomanip>
#include <string>
#define ll long double

using namespace std;


int main()
{

    int a, b, h, m;
	double pi = 3.141592653589;
	cin >> a >> b >> h >> m;
  	double ah = (double)(h / 12.0) * 360.0;


  	double am = (double)(m / 60.0) * 360.0;
  	ah += (double)(am / 12.0);

  	if (ah == 360)
  		ah = 0;

    double ang = abs(ah - am);
    ang = ang * (pi/180.0);

    double dist = (a * a) + (b * b) - (2 * (a * b * cos(ang)));

    cout << setprecision(20) << sqrt(dist) << endl;



    return 0;
}



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

const int MAXN = 1e6;

bool is_prime[MAXN];
int prime_count[MAXN];

void init() {
	fill(is_prime, is_prime + MAXN, true);
	int cnt = 0;
	for (int i = 2; i < MAXN; ++i) {
		if (is_prime[i]) {
			++cnt;
			for (int j = i + i; j < MAXN; j += i) {
				is_prime[j] = false;
			}
		}
		prime_count[i] = cnt;
	}
}

int main() {
	//freopen("0009.txt", "r", stdin);
	init();
	int n;
	while (cin >> n) {
		cout << prime_count[n] << "\n";
	}
}

Measured memory_bytes: 7976
// --------------
// Tejas Pandey  |
// 19 - 06 - 20  |
// Atcoder BC 171|
// --------------

#include <bits/stdc++.h>
using namespace std;
     
#define mod 1000000007
#define vi vector<int>
typedef long long int ll;
     
int main (void){
  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n;
  cin >> n;
  string ans = "";
  while(n){
	char f = 'a' + (n%26) - 1;
	n /= 26;
	
	if(f == 'a' - 1) f = 'z',n--;
	ans += f;
  }
  reverse(ans.begin(),ans.end());
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3652
n, q = map(int, input().split())

childs = [[] for _ in range(n+1)]
parent = [-1 if i == 1 else None for i in range(n+1)]
plus = [0 for i in range(n+1)]

for _ in range(n-1):
  a, b = map(int, input().split())
  childs[a].append(b)
  parent[b] = a

for _ in range(q):
  p, x = map(int, input().split())
  plus[p] += x
  
nodes = [1]
while nodes:
  node = nodes.pop()
  if childs[node]:
    for cn in childs[node]:
      plus[cn] += plus[node]
      nodes.append(cn)

print(' '.join([str(num) for num in plus[1:n+1]]))

Measured memory_bytes: 116684
#include <iostream>
#include <string>
#include <vector>

int main(void)
{
  std::vector<std::string> tango;
  for(int i=0;i<3;i++)
  {
    std::string a;
    std::cin >> a;
    tango.push_back(a);
  }
  
  std::cout << tango[0][0] << tango[1][1] << tango[2][2] << std::endl;
  
  return 0;
}


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

typedef long long STATES;

int main( void )
{
	STATES free_days[31], dp[51];
	STATES goal_state, next;
	register int i, j;
	int n, answer, free_day, k;

	while ( scanf( "%d", &n ) == 1 && n )
	{
		memset( free_days, 0, sizeof(free_days) );
		memset( dp, 0, sizeof(dp) );

		goal_state = 0;
		for ( i = 0; i < n; i++ ) goal_state |= 1LL << i;

		for ( i = 0; i < n; i++ )
		{
			scanf( "%d", &k );
			for ( j = 0; j < k; j++ )
			{
				scanf( "%d", &free_day );
				free_days[free_day] |= 1LL << i;
			}
		}

		answer = -1;
		for ( i = 0; i < n; i++ ) dp[i] = 1LL << i;
		for ( i = 1; answer == -1 && i <= 30; i++ )
		{
			next = 0;
			for ( j = 0; j < n; j++ ) if ( free_days[i] & 1LL << j ) next |= dp[j];
			for ( j = 0; j < n; j++ ) if ( free_days[i] & 1LL << j ) dp[j] |= next;
			if ( next == goal_state ) answer = i;
		}

		printf( "%d\n", answer );
	}

	return 0;
}

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

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (i%2 == 1) continue;
    else {
      if (a%2 == 0) continue;
      else ans++;
    }
  }
  cout << ans << endl;
}

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

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e16;
const int MOD = 1e9 + 7;
const int MB = 20;

void solve() {
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	string res;
	for (int i = 0; i < n; i++) {
		res.pb(s[i]);
		res.pb(t[i]);
	}
	cout << res;
}

signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}

Measured memory_bytes: 256
#coding:utf-8
#?????¬???????????????

def draw_topbottom(n):
    a = ""
    for i in range(n):
        a += "#"
    print a

def draw_middle(n):
    a = "#"
    for i in range(n-2):
        a += "."
    a += "#"
    print a

while 1:
    HW = raw_input().split()
    H = int(HW[0])
    W = int(HW[1])

    if H == 0 and W == 0:
        break

    draw_topbottom(W)
    for i in range(H-2):
        draw_middle(W)
    draw_topbottom(W)
    print ""

Measured memory_bytes: 6356
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>

using namespace std;

int N, K, x, y;
int a[3001][3001], b[3001][3001], c[3001][3001];
int p, pmax, pmin, ans;
char col;

int main() {
	scanf("%d %d", &N, &K);

	for (int i = 0; i < 3 * K; i++) {
		for (int j = 0; j < 3 * K; j++) {
			a[i][j] = 0;
		}
	}

	for (int i = 0; i < N; i++) {
		scanf("%d %d %c", &x, &y, &col);
		if (col == 'B') { a[x%(2*K)][y%(2*K)]++; }
		else { a[x%(2*K)][y%(2*K)]--; }
	}

	for (int i = 2 * K; i < 3 * K; i++) {
		for (int j = 0; j < 2 * K; j++) {
			a[i][j] = a[i - 2 * K][j];
			a[j][i] = a[j][i - 2 * K];
		}
	}
	for (int i = 2 * K; i < 3 * K; i++) {
		for (int j = 2 * K; j < 3 * K; j++) {
			a[i][j] = a[i - 2 * K][j - 2 * K];
		}
	}

	for (int i = 0; i < 3 * K + 1; i++) {
		b[i][0] = 0;
		for (int j = 0; j < 3 * K; j++) {
			b[i][j + 1] = b[i][j] + a[i][j];
		}
	}
	
	for (int i = 0; i < 3 * K + 1; i++) {
		c[i][0] = 0; c[0][i] = 0;
	}
	for (int j = 0; j < 3 * K + 1; j++) {
		for (int i = 0; i < 3 * K; i++) {
			c[i + 1][j] = c[i][j] + b[i][j];
		}
	}

	/*a,b,cをとりあえず出力*/
	
	/*printf("matrix a:\n");

	for (int i = 0; i < 3 * K + 1; i++) {
		for (int j = 0; j < 3 * K + 1; j++) {
			printf("%d ", a[i][j]);
		}
		printf("\n");
	}

	printf("matrix b:\n");

	for (int i = 0; i < 3 * K + 1; i++) {
		for (int j = 0; j < 3 * K + 1; j++) {
			printf("%d ", b[i][j]);
		}
		printf("\n");
	}

	printf("matrix c:\n");

	for (int i = 0; i < 3 * K + 1; i++) {
		for (int j = 0; j < 3 * K + 1; j++) {
			printf("%d ", c[i][j]);
		}
		printf("\n");
	}
	*/
	pmax = 0; pmin = 0;
	for (int i = 0; i < K;i++) {
		for (int j = 0; j < K; j++) {
			p = c[i][j] - 2 * c[i][j + K] + c[i][j + 2 * K] - 2 * c[i + K][j] + 4 * c[i + K][j + K]
				- 2 * c[i + K][j + 2 * K] + c[i + 2 * K][j] - 2 * c[i + 2 * K][j + K] + c[i + 2 * K][j + 2 * K];
			if (p > pmax) { pmax = p; }
			if (p < pmin) { pmin = p; }
		}
	}

	if (pmax < -pmin) { ans = -pmin; }
	else { ans = pmax; }


	ans = (N - ans) / 2 + ans;

	printf("%d\n", ans);
}

Measured memory_bytes: 105728
import Control.Applicative
import qualified Data.Set as Set
import Data.Set ((\\))
import qualified Data.Maybe as Maybe

seive :: Integer -> Set.Set Integer -> Set.Set Integer
seive p xs
  | p*p > Set.findMax xs = xs
  | otherwise        = seive nextP (xs \\ mults)
    where mults = Set.fromAscList [p*p, (p+1)*p .. Set.findMax xs]
          nextP = Maybe.fromJust $ Set.lookupGT p xs

primes :: Integer -> [Integer]
primes m = Set.toList $ seive 2 $ Set.fromAscList [2..m]

solve n = f 1 $ map (\p -> iterate (* p) p) (primes 2000) where
   f y ((pps@(p:_)):ppss)
     | p <= n = f (y * (sum (map (div n) $ takeWhile (<= n) pps) + 1)) ppss
     | otherwise = y

main = do
  n <- read <$> getLine :: IO Integer
  print $ solve n `mod` 1000000007


Measured memory_bytes: 1404
def f(exponent):
	#reurns how many times a prime raised to exponent can be used
	lo,hi = 1, exponent + 1
	while(lo < hi):
		med = (lo + hi)/2
		if med * (med + 1)/2 > exponent:
			hi = med
		else:
			lo = med +1
	return lo -1

def answer(n):
	if n == 1: return 0
	res = 0
	for d in range(2, int(n ** 0.5) + 2):
		if n % d == 0:
			e = 0
			while(n%d == 0): 
				e +=1
				n/=d
			res+= f(e)
	if n > 1: res += 1
	return res

print answer(int(raw_input()))

Measured memory_bytes: 85880
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/
#define poyo 8000

string s;
int x,y;
vi x_num, y_num;
bool dpx[8005][8005*2],dpy[8005][8005*2];

void DEBUG(){
  cout<<'x'<<endl;
  rep(i,x_num.size()){
    cout<<x_num[i]<<endl;
  }
  cout<<'y'<<endl;
  rep(i,y_num.size()){
    cout<<y_num[i]<<endl;
  }
}

void Compress(){
  bool turn=false;
  int cnt=0;
  rep(i,s.size()){
    if(s[i]=='F'){
      cnt++;
    }else{
      if(!turn)x_num.pb(cnt);
      else y_num.pb(cnt);
      cnt=0;
      turn=(!turn);
    }
  }
  if(cnt){
    if(!turn)x_num.pb(cnt);
    else y_num.pb(cnt);
    cnt=0;
  }
}

bool DP(){
  dpx[0][poyo]=dpy[0][poyo]=true;
  rep(i,x_num.size()){
    REP(j,-8000,8001){
      if(dpx[i][j+poyo]){
	dpx[i+1][j+poyo+x_num[i]]=true;
	if(i!=0)dpx[i+1][j+poyo-x_num[i]]=true;
       	//cout<<i<<" "<<j+x_num[i]<<endl;
	//cout<<i<<" "<<j-x_num[i]<<endl;
      }
    }
  }
  rep(i,y_num.size()){
    //cout<<i<<endl;
    REP(j,-8000,8001){
      if(dpy[i][j+poyo]){
	dpy[i+1][j+poyo+y_num[i]]=true;
	dpy[i+1][j+poyo-y_num[i]]=true;
	//cout<<j+y_num[i]<<endl;
      }
    }
  }
  return (dpx[x_num.size()][x+poyo] && dpy[y_num.size()][y+poyo]);
}

int main(){
  cin>>s;
  cin>>x>>y;
  Compress();
  //DEBUG();
  if(DP())cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 125696
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 20 10:11:22 2020

@author: NEC-PCuser
"""

N, K = map(int, input().split())

A = list(map(int, input().split()))

tele_set = set()
tele_set.add(1)
junkai_town = -1 
junkai_first = -1
town = 1
for i in range(N):
    if A[town - 1] not in tele_set:
        tele_set.add(A[town - 1])
    else:
        junkai_town = A[town - 1]
        break
    town = A[town - 1] 

town = 1
start_flg = False
junkaimae_list = []
junkai_list = []
for i in range(N):
    if town == junkai_town and start_flg == False:
        junkai_first = i
        start_flg = True
    elif town == junkai_town:
        break
    if start_flg == True:
        junkai_list.append(town)
    else:
        junkaimae_list.append(town)
    town = A[town - 1]


if K < len(junkaimae_list):
    print(junkaimae_list[K])
else:
    kaisu = K - len(junkaimae_list)
    print(junkai_list[kaisu % len(junkai_list)])
        
        
        


Measured memory_bytes: 32684
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
using namespace std;

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

  int result = INT_MAX;
  for (i = -100; i <= 100; i++) {
    int sum = 0;
    for (j = 0; j < n; j++) {
      sum += pow(a[j] - i, 2);
    }
    result = min(result, sum);
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int A, B, K;
	cin >> K >> A >> B;




	int div = A / K;
	int min_Kx = (div + 1) * K;
	if (min_Kx <= B) {

		cout << "OK" << endl;

	}
	else if (A % K == 0) {

		cout << "OK" << endl;

	}
	else{
		cout << "NG" << endl;


	}
	return 0;




}


Measured memory_bytes: 3556
r, c = map(int, input().split())
sums = [0] * (c + 1)
for x in range(0, r):
    raw = list(map(int, input().split()))
    raw_t = 0
    for x in range(0, c):
        sums[x] += raw[x]
        raw_t += raw[x]
    raw.append(raw_t)
    sums[c] += raw_t
    print(*raw)
print(*sums)



Measured memory_bytes: 5636