akhauriyash/Code-Regression huggingface dataset:
// Author :
// Date :
// Problem:
// Solution:
// Comment:

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstring>

#define pp push
#define pb push_back
#define mp make_pair
#define xx first
#define yy second

using namespace std;

void play(int n,int m){
    int a[105]={0} , b[105]={0};
    int aa = 0 , bb = 0;
    int q;
    
    for(int i = 0 ; i < n ; i++){
        cin >> q;
        a[q]++;
        aa+=q;
    }
    
    for(int i = 0 ; i < m ; i++){
        cin >> q;
        b[q]++;
        bb+=q;
    }
    
    for(int i = 0 ; i < 103 ; i++){
        if(a[i]){
            int dif = bb+2*i-aa;
            if(dif >=0 && dif%2==0 && dif <=200 && b[dif/2]){
                cout << i << " " << dif/2 << endl;
                return;
            }
        }
    }
    
    cout << "-1" << endl;
}

main(){
    //freopen("1153-input.txt","r",stdin);
    int n,m;
    
    while(cin >> n >> m){
        if(n == 0) break;
        
        play(n,m);
    }
    #ifdef GEREL
        for(;;);
    #endif

    return 0;
}

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

int64_t gcd(int64_t a, int64_t b) {
	if (a < b) return gcd(b, a);
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main() {
	int T;
	cin >> T;
	int64_t A, B, C, D, G;
	for (int i = 0;i < T;i ++) {
		cin >> A >> B >> C >> D;
		
		G = gcd(B, D); // これでA+Gxの形の数式であることが分かる
		if (A < B || D < B || B - G + A % G > C) cout << "No" << endl;
		else cout << "Yes" << endl;
	}
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

まず、B>Dなら答えはfalse、以下B≦Dとする
また、初期の本数はAの代わりにE=A%Bを、在庫の追加数はDの代わりにF=D%Bを用いるものとする
そうすると、mod B上で考えることができるな

さて、この時において永遠に買えない時とは？
これは、現在の本数+F=現在の本数+F mod Bの時
一度でも現在の本数がB-F未満になるとアウトと言える

以下、拡張ユークリッドの考え方でACできる
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;
#define sz(v) ((int)(v).size())
const int MAXN = 200005;

struct disj{
	int pa[MAXN];
	pi a[MAXN];
	void init(int n, int *p){
		iota(pa, pa + n + 1, 0);
		for(int i=1; i<=n; i++){
			a[i].first = (p[i] == 0);
			a[i].second = (p[i] == 1);
		}
	}
	int find(int x){
		return pa[x] = (pa[x] == x ? x : find(pa[x]));
	}
	lint uni(int p, int q){
		p = find(p); q = find(q);
		if(p == q) return 0;
		lint ret = 1ll * a[p].second * a[q].first;
		a[p].first += a[q].first;
		a[p].second += a[q].second;
		pa[q] = p; 
		return ret;
	}
	pi get(int x){
		return a[find(x)];
	}
}disj;

struct node{
	pi p; int idx;
	bool operator<(const node &n)const{
		return 1ll * p.first * n.p.second < 1ll * n.p.first * p.second;
	}
};

priority_queue<node> pq;
int n, p[MAXN], a[MAXN];

int main(){
	scanf("%d",&n);
	for(int i=2; i<=n; i++) scanf("%d",&p[i]);
	for(int i=1; i<=n; i++) scanf("%d",&a[i]);
	disj.init(n, a);
	for(int i=2; i<=n; i++) pq.push((node){disj.get(i), i});
	lint ret = 0;
	while(true){
		while(sz(pq) && disj.get(pq.top().idx) != pq.top().p) pq.pop();
		if(pq.empty()) break;
		auto x = pq.top(); pq.pop();
		x.idx = disj.find(x.idx);
		ret += disj.uni(p[x.idx], x.idx);
		if(disj.find(x.idx) != 1){
			pq.push((node){disj.get(x.idx), disj.find(x.idx)});
		}
	}
	cout << ret << endl;
}


Measured memory_bytes: 8820
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

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

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

//最長回文の長さを求める。
//O(N)

int Manarcher(const string &_s) {
  int n = _s.size();
  string s(2 * n + 1, '#');
  for (int i = 0; i < n; i++) s[2 * i + 1] = _s[i];
  n = 2 * n + 1;

  vector<int> rad(n);
  for (int i = 0, j = 0; i < n;) {
    while (i - j >= 0 && i + j < n && s[i - j] == s[i + j]) j++;
    rad[i] = j;

    int k;
    for (k = 1; i - k >= 0 && rad[i] - k > rad[i - k]; k++) rad[i + k] = rad[i - k];

    i += k;
    j = max(j - k, 0LL);
  }
  return *max_element(rad.begin(), rad.end()) - 1;
}

signed main() {
  string s;
  int ans = 0;
  while (cin >> s) {
    if (s.size() == Manarcher(s)) ans++;
  }

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



Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
int n,k,x,t,a,b,m,sx,sy,dx,dy;
string s;
vi v;
int dp[1005][1005];
vector<string>mat;

bool inside(int x,int y){
	return x>=0 && x<n && y>=0 && y<k;
}

void solve(){
	cin >> n >> k;
	cin >> sx>>sy >> dx>>dy;
	sx--,sy--,dx--,dy--;
	for(int i =0;i<n;i++){
		for(int j=0;j<k;j++){
			dp[i][j]=1e9;
		}
	}
	for(int i =0;i<n;i++){
		cin >> s;
		mat.push_back(s);
	}
	deque<pair<int,int>>q;
	q.push_front({sx,sy});
	dp[sx][sy] = 0;
	while(q.size()){
		pair<int,int> front = q.front();
		int curX = front.F;
		int curY = front.S;
		q.pop_front();
		if(curX == dx && curY == dy)break;
		for(int i =-1;i<=1;i++){
			for(int j=-1;j<=1;j++){
				if(((!i&&!j) || (i && j) || !inside(i+curX,j+curY) || mat[i+curX][j+curY] == '#'))continue;
				if(dp[i+curX][j+curY]>dp[curX][curY]){
					dp[i+curX][j+curY] = dp[curX][curY];
					q.push_front({i+curX,j+curY});
				}
			}
		}
		for(int i =-2;i<=2;i++){
			for(int j=-2;j<=2;j++){
				if((!i&&!j) || !inside(i+curX,j+curY) || mat[i+curX][j+curY] == '#')continue;
				if(dp[i+curX][j+curY] > dp[curX][curY]+1){
					dp[i+curX][j+curY] = min(dp[curX][curY]+1,dp[i+curX][j+curY]);
					q.push_back({i+curX,j+curY});
				}

			}
		}
	}
	cout << (dp[dx][dy] == 1e9?-1:dp[dx][dy]);
 
}

int main(){

	t=1;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 8532
void main()
{
    long x, y, z;
    rdVals(x, y, z);

    writeln(z, " ", x, " ", y);
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
Int mod = 1e9+7;

int main() {
    Int r, d, x;
    cin >> r >> d >> x;
    for (Int i = 0; i < 10; i++) {
        x = r * x - d;
        dump(x);
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
typedef long long LL;
typedef long double Lf;
#define in (void)scanf
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
//#define Rep(i,a,n)for(LL i=(LL)(a);i<(LL)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Repp(i,l,r,k)for(int i=(int)(l);i<(int)(r);i+=(int)(k))
//#define Repp(i,l,r,k)for(LL i=(LL)(l);i<(LL)(r);i+=(LL)(k))
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define MOD 1000000007//998244353,1000000007,1000000009,4999999999999997
int upi(const void* a, const void* b) { return*(int*)a<*(int*)b ? -1 : *(int*)a> * (int*)b ? 1 : 0; }
int downi(const void* a, const void* b) { return*(int*)a<*(int*)b ? 1 : *(int*)a> * (int*)b ? -1 : 0; }
void sortupi(int* a, int n) { qsort(a, n, sizeof(int), upi); } //1,2,3,4,...
void sortdowni(int* a, int n) { qsort(a, n, sizeof(int), downi); }
int upLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? -1 : *(LL*)a> * (LL*)b ? 1 : 0; }
int downLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? 1 : *(LL*)a> * (LL*)b ? -1 : 0; }
void sortupLL(LL* a, int n) { qsort(a, n, sizeof(LL), upLL); }
void sortdownLL(LL* a, int n) { qsort(a, n, sizeof(LL), downLL); }
int cmp_char(const void* a, const void* b) { return *(char*)a - *(char*)b; } // a,b,c,d
int cmp_str(const void* a, const void* b) { return strcmp(*(const char**)a, *(const char**)b); } // aaa,aab
LL gcd(LL p, LL q) { while (q) { LL t = p % q; p = q; q = t; }return p; }
LL modpow(LL a,LL n,int m){LL x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invmodpow(b,p)modpow(b,p-2,p)// a/b≡a*b^{-1}(mod p)...return b^{-1}(mod p)
typedef struct fac { LL n, exp; }F;
LL fact(LL n,F*a){LL x=n,i,j,c=0;for(i=2;i*i<=x;i++){for(j=1;x%i==0;j++)x/=i;if(j>1){a[c].n=i;a[c++].exp=j-1;}}if(x-1){a[c].n=x;a[c++].exp=1;}return c;}
LL nibtan(LL* a,LL n,LL x){LL p=0,q=n/2,r=n-1;while(r-p>1){if(x>=a[q])p=q;if(x<=a[q])r=q;q=(p+r)/2;}return a[p]==x?p:r;}
//snippet

#define N 1000009

int b[N], c[N] = { 0 };

int frset(int k) {
	int i = 0, a[N];
	while (b[k] != k) {
		a[i] = k;
		i++;
		k = b[k];
	}
	rep(j, i)b[a[j]] = k;
	return k;
}

void run() {
	int n, m, x, y, ans = 0;
	in("%d %d", &n, &m);
	rep(i, n) { b[i] = i; c[i] = 1; }
	while (m--) {
		in("%d %d", &x, &y);
		int X = frset(x), Y = frset(y);
		if (X - Y) { b[X] = Y; c[Y] += c[X]; }
	}
	rep(i, n)ans = Ma(ans, c[i]);
	printf("%d\n", ans);
}

int main() {
	int test = 1;
//	in("%d", &test);
	while (test--) {
		run();
	}
	return 0;
}

Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

int n, m;

int main() {
    while(1) {
        cin >> n >> m;
        if(n == 0 && m == 0) break;
        vector<int> avec(n, 0);
        for(int i = 0; i < n; ++i) cin >> avec[i];
        int ans = -1;
        for(int i = 0; i < n; ++i) {
            for(int j = i+1; j < n; ++j) {
                int sum = avec[i]+avec[j];
                if(sum <= m) {
                    chmax(ans, sum);
                }
            }
        }
        if(ans == -1) cout << "NONE" << endl;
        else cout << ans << endl;
    }
}


Measured memory_bytes: 3108
package main

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

// Define disjoint-set forests

type vertexNo int

type vertex struct {
	number vertexNo
	rank int
	parent *vertex
}

func makeSet(number vertexNo) vertex {
	return vertex {
		number: number,
		rank: 0,
		parent: nil,
	}
}

func union(x, y *vertex) *vertex {
	return link(findSet(x), findSet(y))
}

func link(x, y *vertex) *vertex {
	if x.rank > y.rank {
		y.parent = x
		return x
	} else {
		x.parent = y
		if x.rank == y.rank {
			y.rank += 1
		}
		return y
	}
}

func findSet(v *vertex) *vertex {
	if v.parent == nil {
		return v
	}
	v.parent = findSet(v.parent)
	return v.parent
}

// Function to calculate minimum spanning tree

type matrix [][]int

type edge struct {
	one vertexNo
	two vertexNo
	weight int
}

const(
	MAX_VERTICES = 100
)

func newEdgesFromMatrix(matrix matrix) []edge {
	edges := make([]edge, 0, MAX_VERTICES * MAX_VERTICES)

	for i := 0; i < len(matrix); i++ {
		row := matrix[i]
		for j := i; j < len(row); j++ {
			if row[j] >= 0 {
				edge := edge{one: vertexNo(i+1), two: vertexNo(j+1), weight: row[j]}
				edges = append(edges, edge)
			}
		}
	}

	return edges
}

func solve(matrix matrix) int {
	nVertices := len(matrix)

	// initialize vertices
	vertices := make([]vertex, nVertices)
	for i := 0; i < nVertices; i++ {
		vertices[i] = makeSet(vertexNo(i+1))
	}

	// prepare edges sorted in the ascending order of weight
	edges := newEdgesFromMatrix(matrix)
	sort.Slice(edges, func(i, j int) bool {
		return edges[i].weight < edges[j].weight
	})

	unionCount := 0
	weightSum := 0
	for unionCount < nVertices-1 {
		for i := 0; i < len(edges); i++ {
			edge := edges[i]
			v1 := &vertices[edge.one-1]
			v2 := &vertices[edge.two-1]
			rep1 := findSet(v1)
			rep2 := findSet(v2)
			if rep1.number == rep2.number {
				continue
			}
			union(rep1, rep2)
			edges = append(edges[0:i], edges[i+1:]...)
			weightSum += edge.weight
			unionCount++
			break
		}
	}

	return weightSum
}

// main

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}

	matrix := parseMatrix(n, sc)

	edges := newEdgesFromMatrix(matrix)
	sort.Slice(edges, func(i, j int) bool {
		return edges[i].weight < edges[j].weight
	})

	fmt.Println(solve(matrix))
}

func parseMatrix(n int, sc *bufio.Scanner) [][]int {
	matrix := make([][]int, n)
	for i := 0; i < n; i++ {
		matrix[i] = make([]int, n)
		for j := 0; j < n; j++ {
			x, err := nextInt(sc)
			if err != nil {
				panic(err)
			}
			matrix[i][j] = x
		}
	}
	return matrix
}

func nextText(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextInt(sc *bufio.Scanner) (int, error) {
	return strconv.Atoi(nextText(sc))
}


Measured memory_bytes: 1444
N, Y = list(map(int, input().split()))

xx, yy, zz = -1,-1,-1

flag = False
for x in range(min(Y//10000, N)+1):
    for y in range(min((Y-x*10000)//5000, N)+1):
        z = N-x-y
        if x*10000+y*5000+z*1000 == Y:
            xx = x
            yy = y
            zz = z
            flag = True
            break
    if flag:
        break
print(xx, yy, zz)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
 #define SPEED ios_base :: sync_with_stdio(false), cin.tie(NULL), cout.tie(0)
int main() 
{
	SPEED; 
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++)
      cout<<"x";
	return 0;
}

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

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

	int a[200001];
	rep1(i,n) cin >> a[i];

	for(int i=1;i <= n-k;i++){
		if(a[i+k] > a[i]){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 4412
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)

typedef struct UnionFind{
	vector<lli> par; //par[i]:iの親番号 par[3] = 2 : 3の親が2
	vector<lli> size;//size[i]:iの大きさ 自分のみのときは1,根っこにsizeを持たせる*/

	UnionFind(int N){/*最初はすべてが根であると初期化*/
		REP(i,0,N){
			par.push_back(i);
			size.push_back(1);
		}
	}

	lli root(lli x){/*データxが属する木の根を再起で得る root(x) = {xの木の根}}*/
		if(par[x] == x)return x;
		return par[x] = root(par[x]);
	}

	void unite(lli x,lli y){/*xとyの併合*/
		lli rx = root(x);
		lli ry = root(y);
		if(rx == ry)return;
		par[rx] = ry; /*xとyの根が同じじゃない: xの根をrxをyの根ryに変更する */
		lli resize = size[rx] + size[ry];
		size[rx] = resize;
		size[ry] = resize;
	}

	bool same(lli x,lli y){
		lli rx = root(x);
		lli ry = root(y);
		return rx == ry;
	}

	lli getSize(lli x){
		lli rx = root(x);
		return size[rx];
	}
};

signed main(){

	lli n,m;
	cin>>n>>m;

	UnionFind u(n);
	vector<lli> a(m),b(m);

	REP(i,0,m){
		cin>>a[i]>>b[i];
		a[i]--,b[i]--;
	}

	lli sum = (n-1)*(n)/2;
	vector<lli> ans;

	for(lli i=m-1;i>=0;i--){
		//cout<<sum<<endl;
		ans.push_back(sum);
		if(u.same(a[i],b[i]))continue;

		lli diff = u.getSize(a[i])*u.getSize(b[i]);
		u.unite(a[i],b[i]);
		
		sum -= diff;
	}
	for(lli i=m-1;i>=0;i--)cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 5356
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string c;
  cin>>c;
  if(c=="a" || c=="i" || c=="u" || c=="e" || c=="o"){
   cout << "vowel" << endl;
  }else{
   cout<< "consonant"<<endl;
  }
}

Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from math import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
n = I()

A = readInts()

is_ok = [0] * (10**6+1)
se = set(A)
C = Counter(A)
for a in se:
    for b in range(a,10**6+1,a):
        is_ok[b] += 1
ans = 0
for i in range(n):
    if C[A[i]] >= 2:
        continue
    if is_ok[A[i]] == 1:
        ans += 1
print(ans)


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

#define a first
#define b second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 2e5;
const int MAXV = 4000;
const ll MOD = 1e9+7;

ll fact[8010], invfact[8010];

int n;
pii arr[MAXN+10];
ll dp[4010][4010], ans;

ll pow(ll x, ll y)
{
    if(y==0) return 1;
    if(y%2) return x*pow(x, y-1)%MOD;
    ll ret=pow(x, y/2);
    return ret*ret%MOD;
}

int main()
{
    int i, j;

    fact[0]=1;
    for(i=1; i<=8000; i++) fact[i]=fact[i-1]*i%MOD;
    invfact[8000]=pow(fact[8000], MOD-2);
    for(i=7999; i>=0; i--) invfact[i]=invfact[i+1]*(i+1)%MOD;

    scanf("%d", &n);
    for(i=1; i<=n; i++)
    {
        scanf("%d%d", &arr[i].a, &arr[i].b);
        dp[2000-arr[i].a][2000-arr[i].b]++;
        ans+=fact[(arr[i].a+arr[i].b)*2]*invfact[2*arr[i].a]%MOD*invfact[2*arr[i].b]%MOD;
        ans%=MOD;
    }
    ans=(MOD-ans)%MOD;

    for(i=1; i<=4000; i++) dp[0][i]+=dp[0][i-1], dp[i][0]+=dp[i-1][0];
    for(i=1; i<=4000; i++) for(j=1; j<=4000; j++) dp[i][j]+=dp[i-1][j]+dp[i][j-1], dp[i][j]%=MOD;
    for(i=1; i<=n; i++) ans+=dp[2000+arr[i].a][2000+arr[i].b], ans%=MOD;
    ans*=invfact[2]; ans%=MOD;
    printf("%lld", ans);
}


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

int main() {
	int k,x;
    cin >> k >> x;
    for(int i=x+1-k;i<x+k;i++){
        if((i>-1000001)&&(i<1000001)){
             cout << i << " ";
        }
    }
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;
int par[300001];
int dep[300001];
// n要素で初期化
void init (int n) {
    for (int i = 0; i < n; i++) {
        par[i] = i;
        dep[i] = 0;
    }
}

// 木の根を求める
int find(int x) {
    if (par[x] == x) {
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

// xとyの属する集合を併合
void unite(int x, int y){
    x = find(x);
    y = find(y);
    if (x == y) return;

    if (dep[x] < dep[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (dep[x] == dep[y]) dep[x]++;
    }
}

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


int par2[300001];
int dep2[300001];
// n要素で初期化
void init2 (int n) {
    for (int i = 0; i < n; i++) {
        par2[i] = i;
        dep2[i] = 0;
    }
}

// 木の根を求める
int find2(int x) {
    if (par2[x] == x) {
        return x;
    } else {
        return par2[x] = find2(par2[x]);
    }
}

// xとyの属する集合を併合
void unite2(int x, int y){
    x = find2(x);
    y = find2(y);
    if (x == y) return;

    if (dep2[x] < dep2[y]) {
        par2[x] = y;
    } else {
        par2[y] = x;
        if (dep2[x] == dep2[y]) dep2[x]++;
    }
}

bool same2(int x, int y){
    return find2(x) == find2(y);
}

int main(){
    int N, K, L;
    cin >> N >> K >> L;
    init(N);
    init2(N);

    int p, q;
    rep(i, K){
        cin >> p >> q;
        unite(p-1, q-1);
    }

    rep(i, L){
        cin >> p >> q;
        unite2(p-1, q-1);
    }

    using pint = pair<int,int>;
    map<pint, int> ma;
    for (int v = 0; v < N; ++v) {
        pint p(find(v), find2(v));
        ma[p]++;
    }

    for (int v = 0; v < N; ++v) {
        pint p(find(v), find2(v));
        cout << ma[p] << " ";
    }


}

Measured memory_bytes: 15872
//Practice
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 2e5 + 5;
const ll INF = 1e9 + 5;
const ll mxN = 1000000007;
const double E = 1e-9;

//------------------------------------------------------------------------------
string s, t;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	/*ifstream cin("input.txt");
	ofstream cout("output.txt");*/
	cin >> s >> t;
	ll ans = INF;
	for (int i = 0; i + t.size() <= s.size(); i++)
	{
		ll lans = 0;
		for (int j = 0; j < t.size(); j++)
		{
			if (t[j] != s[i + j])
				++lans;
		}
		ans = min(ans, lans);
	}
	cout << ans << "\n";
	return 0;
}
//30-08-2020 11:29:51
//------------------------------------------------------------------------------

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#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(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N;
    cin >> N;
    cout << (N + 1) / 2;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

const int MAX_N = 100050;

int A[MAX_N];
int K, N;



int main(int argc, char **argv) {
    std::cin >> N >> K;

    for (int i = 1; i <= N; i++) {
        std::cin >> A[i];
    }
    
    int num = 0;
    int left = 1;

    while (true) {
        left = left - 1 + K;
        num++;
        if (N <= left) {
            break;
        }
    }
    std::cout << num << std::endl;

    return 0;
}

Measured memory_bytes: 640
from bisect import bisect_right, bisect_left
_, q = map(int, input().split())
s = input()
b = "B"
a = []
for i, c in enumerate(s) :
    if b+c == "AC" :
        a.append(i)
    b = c
for _ in range(q) :
    l, r = map(int, input().split())
    il = bisect_left(a, l)
    ir = bisect_right(a, r-1)
    print(ir-il)

Measured memory_bytes: 5768
#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() {
	ll a;
  	long double b;
 	cin >> a >> b;
  	
  	ll B = b * 100 + 0.5;
  	ll ans = a * B / 100;
	
  	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3724
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using vi = vector<int>;
using vs = vector<string>;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repp(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define repd(i, n) for(ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(), x.end()

ll k, l, m, n;
const ll M = 1e9 + 7;



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

    int n;
    cin >> n;

    string s;
    int sum = 0, aum = 0, bum = 0, abum = 0;
    rep(i, n) {
        cin >> s;
        int k = s.size();

        rep(i, k - 1) {
            if(s[i] == 'A' && s[i + 1] == 'B') sum++;
        }

        if(s[0] == 'B' && s[k - 1] == 'A') abum++;
        else {
            if(s[0] == 'B') bum++;
            if(s[k - 1] == 'A') aum++;
        }
    }

    if(abum == 0) sum += min(aum, bum);
    else {
        if(aum + bum == 0) sum += abum - 1;
        else sum += min(aum, bum) + abum;
    }

    cout << sum << endl;
}

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

long long w[105] , v[105] ;

long long dp[100005][105] ;

int main(){
	int N ;
	long long W ;
	scanf("%d%lld",&N,&W);
	for( int i = 1 ; i <= N ; i++ ){
		scanf("%lld%lld",&w[i],&v[i]);
	}
	for(  int i = 0 ; i <= N ; i++ ){
		dp[0][i] = 1000000001 ;
	}
	for( int i = 0 ; i <= 100000 ; i++ ){
		dp[i][0] = 1000000001 ; 
	}
	for( int i = 1 ; i<= N ; i++ ){
		dp[v[i]][i] = w[i] ;
	}
	// for( int i = 0 ; i <= 14 ; i++ ){
	// 	for( int j = 0 ; j <= N ; j++ ){
	// 		printf("%lld ",dp[i][j]);
	// 	}
	// 	puts("") ;
	// }
	for( int i = 1 ; i <= 100000 ; i++ ){
		for( int j = 1 ; j <= N ; j++ ){
			if(dp[i][j] == 0 ) dp[i][j] = 1000000001 ;
			dp[i][j] = min(dp[i][j],dp[i][j-1]) ;
			if( i - v[j] >= 0 ) dp[i][j] = min(dp[i][j],dp[i-v[j]][j-1] + w[j]) ;
		}
	}
	// for( int i = 0 ; i <= 14 ; i++ ){
	// 	for( int j = 0 ; j <= N ; j++ ){
	// 		printf("%lld ",dp[i][j]);
	// 	}
	// 	puts("") ;
	// }
	for( int i = 100000 ; i >= 0 ; i-- ){
		for( int j = 1 ; j <= N ; j++ ){
			// printf("%lld ",dp[i][j]);
			
			if( dp[i][j] <= W ) {
				printf("%d\n",i);
				return 0 ;
			}
		}
		// puts("");
	}

	return 0 ;
}

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

using namespace std;

int main(int argc, char* argv[]) {
  int N, M;
  cin >> N;

  int total = 0;
  vector<int> times(N);
  for (int i = 0; i < N; ++i) {
    int tmp;
    cin >> tmp;
    times[i] = tmp;
    total += tmp;
  }

  cin >> M;
  vector<int> rets(M);
  for (int i = 0; i < M; ++i) {
    int p, x;
    cin >> p >> x;
    rets[i] = total - times[p - 1] + x;
  }

  for (int i = 0; i < M; ++i)
    cout << rets[i] << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>/*toupperとかが入っている*/
#include<vector>/*可変長配列vectorのインクルード*/
 
const int MOD=1000000007;/* 1,000,000,007 で割った余りを出力する　のとき使う*/
using namespace std;/*標準名前空間を利用する。cinやcoutはこれによって利用可能になる*/
 
int X;
int H=0;

int main(void) {
  cin >> X;
  H = H + 1000*(X/500);
  X = X % 500;
  H = H + 5*(X/5);
  cout << H << endl;
  
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    pll x=pll(c-a,d-b);
    pll y=pll(b-d,c-a);
    pll p,q;
    p=pll(c+y.fi,d+y.sc);
    q=pll(p.fi-x.fi,p.sc-x.sc);
    cout<<p.fi<<" "<<p.sc<<" "<<q.fi<<" "<<q.sc<<endl;



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(x, to) for (int x = 0; x < (to); x++)
#define REP(x, a, to) for (int x = (a); x < (to); x++)
#define EPS (1e-14)
#define _PA(x,N) rep(i,N){cout<<x[i]<<" ";}cout<<endl;
#define _PA2(x,H,W) rep(i,(H)){rep(j,(W)){cout<<x[i][j]<<" ";}cout<<endl;}

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef complex<double> Complex;
typedef vector< vector<int> > Mat;

int K, T;
int a[105];
int ans;

void solve() {
	int z = 0;
	sort(a, a + T);
	reverse(a, a + T);
	for (int i = 0; i < T; i++) {
		z = max(z, a[i]) - min(z, a[i]);
	}
	if (z >= 2) {
		ans = z - 1;
	} else {
		ans = 0;
	}
	printf("%d\n", ans);
}

int main() {
	cin >> K >> T;
	for (int i = 0; i < T; i++) {
		cin >> a[i];
	}
	solve();
	return 0;
}




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

int main(){
    int N;
    cin >> N;
    int A[N+1], a;
    rep2(i, 1, N+1){
        cin >> a;
        A[a] = i;
    }
    rep2(i, 1, N+1){
        cout << A[i] << endl;
    }
}

Measured memory_bytes: 1152
#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)
#define SORT(c) sort((c).begin(),(c).end())
#define REVETSE(c) reverse((c).begin(),(c).end())
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define ALL(a)  (a).begin(),(a).end()
// int gcd(int a,int b){return b?gcd(b,a%b):a;}
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> T maxt(T x,T y) {
    if (x>y) return x;
    else return y;
}
template<class T> T mint(T x,T y) {
    if (x>y) return y;
    else return x;
}
//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
//cout << fixed << setprecision(10) << ans << defaultfloat << endl;
typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<double> Vd;
typedef vector<string> Vs;

//小数出力
double print_double(double d){printf("%.8f", d);}

long long m = 1e9+7, mod = 1e9+7;
//逆元　a/b の modをとるとき -> a*modinv(b)%mod
long long modinv(long long a, long long m = 1e9+7) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

//約数列挙
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

// int bfs

int main() {
  int H,A;
  cin >> H >> A;
  cout << (H+A-1)/A << endl;

}

Measured memory_bytes: 256
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto rd = readln.split.to!(size_t[]), n = rd[0], k = rd[1];
  auto wi = n.iota.map!(_ => readln.chomp.to!int).array;

  bool canCarry(int _, int p)
  {
    auto r = 1, c = 0;
    foreach (w; wi) {
      if (p < w) return false;
      if (p - c < w) {
        ++r; c = w;
      } else {
        c += w;
      }
    }
    return r <= k;
  }

  auto r = iota(1, wi.sum + 1).assumeSorted!(canCarry).upperBound(0);
  writeln(r.front);
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
// Begin Header {{{
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const double PI = acos(-1);
using namespace std;
using Graph = vector<vector<lli>>;
using P = pair<int, int>;
// }}} End Header
typedef struct {
	lli to;
	lli cost;
}edge;
vector<vector<edge>> G(100010);
vector<lli> dist(100010, 0);
lli K;

int main(){
	int n, a;
	cin >> n >> a;
	cout << n*n-a << endl;
	return 0;
}

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



int main() {
    int a, b;
    cin >> a >> b;
    
    int mn = min(a,b);
    int mx = max(a,b);
    //cout << mn << endl;
    
    ll ans = mn;
    while(ans % mx != 0) {
        ans += mn;
    }
    
    cout << ans << endl;
    
    
    return 0;
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

const ll INF = 1e15;
int main(){

  int n;
  cin >> n;
  ll dp[n+10][3];
  rep(i,3) dp[0][i] = 0;

  FOR(i,1,n)rep(j,3) dp[i][j] = INF;

  rep(i,n){
    ll cost[3];
    rep(j,3) cin >> cost[j];
    rep(j,3) dp[i+1][j] = max<ll>(dp[i][(j+1)%3] ,dp[i][(j+2)%3])  + cost[j];
  }
  ll ans = 0;
  rep(i,3) ans = max<ll>(ans,dp[n][i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
#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() {
  int n, k;
  cin >> n >> k;
  vector<int> l(n);
  rep(i, n) cin >> l[i];

  sort(l.begin(), l.end(), greater<int>());
  ll sum = 0;
  rep(i, k) sum += l[i];

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<climits>
#include<set>
#include<map>
#include<stack>
#define ll long long
using namespace std;

int main() {
	ll n;
    cin>>n;
    vector<pair<ll,ll>>a(n);
    vector<ll>a2(n);
    for(ll i=0;i<n;i++){
        cin>>a[i].first;
        a[i].second=i;    
    }
    sort(a.begin(),a.end());
    for(ll i=0;i<n;i++){
        a2[i]=a[i].first;
        //cout<<a2[i]<<endl;
    }
    for(ll i=0;i<n;i++){
        swap(a[i].first,a[i].second);
    }
    sort(a.begin(),a.end());
    for(ll i=0;i<n;i++){
        if(a[i].second>=a2[n/2]){
            cout<<a2[n/2-1]<<endl;
        }
        else{
            cout<<a2[n/2]<<endl;
        }
 
    
    
    }
}

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

int main() {
  
  int N=0;
  
  cin >> N;
  
  if(N<=10) {
    
    cout << "Yes" << endl;
    
  } else if(N==12 || N==14){
    
    cout << "Yes" << endl;
    
  } else if(N==15 || N==16){
    
    cout << "Yes" << endl;
    
  } else if(N==18 || N==20){
    
    cout << "Yes" << endl;
    
  } else if(N==21 || N==24){
    
    cout << "Yes" << endl;
    
  } else if(N==25 || N==27){
    
    cout << "Yes" << endl;
    
  } else if(N==28 || N==30){
    
    cout << "Yes" << endl;
    
  } else if(N==32 || N==35){
    
    cout << "Yes" << endl;
    
  } else if(N==36 || N==40){
    
    cout << "Yes" << endl;
    
  } else if(N==42 || N==45){
    
    cout << "Yes" << endl;
    
  } else if(N==48 || N==49){
    
    cout << "Yes" << endl;
    
  } else if(N==54 || N==56){
    
    cout << "Yes" << endl;
    
  } else if(N==63 || N==64){
    
    cout << "Yes" << endl;
    
  } else if(N==81){
    
    cout << "Yes" << endl;
    
  } else {
    
    cout << "No" << endl;
    
  }
  
  return 0;
  
}

Measured memory_bytes: 256
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define mod  1073741824
#pragma GCC optimization ("O3")
using namespace std;
const long long int N = 6999999;
#define all(x) begin(x),end(x)
int main()
{
   
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  	int n,k;
  	cin >> n;
  	vector <int> v(n);
  	for (int i = 0; i < n; ++i)
  	{
  		cin >> v[i];
  	}
  	sort(all(v));
  	for (int i = 1; i < n; ++i)
  	{
  		if(v[i-1] == v[i])
  		{
  			cout << "NO";
  			return 0;
  		}
  	}
  	cout << "YES";	
  	return 0;
}	

Measured memory_bytes: 1024
import std.algorithm, std.array, std.container, std.range, std.bitmanip;
import std.numeric, std.math, std.bigint, std.random, core.bitop;
import std.string, std.conv, std.stdio, std.typecons;

void main()
{
  auto rd = readln.split.map!(to!int);
  auto a = rd[0], b = rd[1], c = rd[2];

  auto d = 0;
  foreach (i; a..b + 1)
    if (c % i == 0) ++d;

  writeln(d);
}

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

#define TRACE(x) cerr << #x << " :: " << x << endl
#define _ << " " <<
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for (int i=(a);i>=(b);--i)

const int mod = 998244353;
const int mxK = 305;

string S;
int K, N;
vector<int> C;
int dp[2][mxK][mxK], px[2][mxK][mxK], py[2][mxK][mxK];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> S >> K;
    C.push_back(-1);
    int cur = 0;
    for(auto& x : S){
        if (x == '0') C.push_back(cur), cur = 0;
        else ++cur;
    }
    if (cur) C.push_back(cur);
    
    N = SZ(C)-1;
    K = min(K,SZ(S));
    FOR(x,0,K) FOR(y,0,K) {
        dp[0][x][y] = (x == y && x <= K);
        px[0][x][y] = (x > 0 ? px[0][x-1][y] : 0) + dp[0][x][y];
        px[0][x][y] %= mod;
        py[0][x][y] = (y > 0 ? py[0][x][y-1] : 0) + dp[0][x][y];
        py[0][x][y] %= mod;
    }
    FOR(i,1,N){
        int c = i&1, p = !c;
        FOR(x,0,K){
            FOR(y,0,x) {
                dp[c][x][y] = dp[p][x][y];

                dp[c][x][y] += (px[p][x+min(C[i],K-x)][y] - px[p][x][y] + mod) % mod;
                dp[c][x][y] %= mod;
                dp[c][x][y] += (py[p][x][x] - py[p][x][y] + mod) % mod;
                dp[c][x][y] %= mod;

                px[c][x][y] = (x > 0 ? px[c][x-1][y] : 0) + dp[c][x][y];
                px[c][x][y] %= mod;
                py[c][x][y] = (y > 0 ? py[c][x][y-1] : 0) + dp[c][x][y];
                py[c][x][y] %= mod;
            }
        }
    }
    cout << dp[N&1][0][0] << '\n';
}



Measured memory_bytes: 5816
#include"bits/stdc++.h"
using namespace std;
int function1(int a)
{
	int sum=0;
	while(a)
	{
		sum+=a%10;
		a/=10;
	}
	return sum;
}
int main()
{
	int a,b,c;
	int i;
	int sum=0;
	scanf("%d %d %d",&a,&b,&c);
	for(i=1;i<=a;i++)
	{
		if(function1(i)>=b&&function1(i)<=c)
		{
			sum+=i;
		}
	}
	printf("%d",sum);
} 

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

using namespace std;

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

	int n;
	cin >> n;

	vector<int> a(n), b(n, INT_MAX);

	for(int i = 0; i < n-1; i++) {
		cin >> b[i];
	}

	a[0] = b[0];

	for(int i = 1; i < n; i++) {
		a[i] = min(b[i-1], b[i]);
	}

	long long ans = 0;

	for(auto i : a) {
		ans += i;
	}

	cout << ans;

	return 0;
}



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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int t, x;
    std::cout<<std::fixed<<std::setprecision(10);
    cin>>t>>x;
    cout << (double)t/x <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 1000000000
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    int ret = 0;
    for(int i = 1; i <= n; i++)
    {
        if(i + k - 1 <= n)
            ret += 1;
    }
    cout << ret << endl;
   
    return 0;
}


Measured memory_bytes: 256
from bisect import bisect_right
from math import ceil
N,K=map(int, input().split())
A=list(map(int, input().split()))
if K==0:
    print(max(A))
    exit()

A=sorted(A)
# 最小値で二分探索 してまだ行けるかどうか
# 回数で二分探索
left=0
right=max(A)

ans=float("INF")
pre=ans
flag=False
count=0
while True:
    now=0
    mid=(left+right)/2
    idx=bisect_right(A, mid)
    for i in range(idx, N):
        now+=ceil(A[i]/mid)-1
    if now==K:
        if ans!=float("INF"):
            if ans==ceil(mid):
                flag=True
        ans=min(ans, ceil(mid))
        right=mid
        
        #if flag:
        #    break
        pre=ans
    if now>K:
        left=mid
        pre=mid
    if now<K:
        ans=min(ans, ceil(mid))
        right=mid
        pre=mid
    count+=1
    if count>=10**2:
        break
    


if ans==float("INF"):
    ans=max(A)
print(ceil(ans))

Measured memory_bytes: 104956
#define _USE_MATH_DEFINES
#include <math.h>
#include <time.h>
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)

#define PI M_PI
#define INF 1000000000
#define MOD 1000000007;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<bool>> vvb;

int main()
{
	int A, B;
	string S;
	cin >> A >> B >> S;

	if (S[A] != '-')
	{
		cout << "No" << endl;
		return 0;
	}

	rep(i, A + B + 1)
	{
		if (i == A) continue;

		if (S[i] < '0' || S[i] > '9')
		{
			cout << "No" << endl;
			return 0;
		}
	}
	
	cout << "Yes" << endl;

	return 0;
}



Measured memory_bytes: 256