akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long ll;
#define rep(i, n) for (int i=0; i < n; i++)
#define repran(i, a,b) for (int i = a; i<b;i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using LP = pair<ll,ll>;
using P = pair<int,int>;
const ll inf = 1e9;


int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> g(h);
    vector<vector<int>> L(h, vector<int>(w, 0));
    vector<vector<int>> R(h, vector<int>(w, 0));
    vector<vector<int>> U(h, vector<int>(w, 0));
    vector<vector<int>> D(h, vector<int>(w, 0));
    rep(i, h) cin>> g[i];
    rep(i, h) rep(j, w){
        if (g[i][j]=='#') continue;
        if (i == 0) U[i][j] = 1;
        else U[i][j] = U[i-1][j]+1;
        if (j == 0) L[i][j] = 1;
        else L[i][j] = L[i][j-1]+1;
    }
    repd(i, h) repd(j, w){
        if (g[i][j]=='#') continue;
        if (i == h-1) D[i][j] = 1;
        else D[i][j] = D[i+1][j]+1;
        if (j == w-1) R[i][j] = 1;
        else R[i][j] = R[i][j+1]+1;
    }
    int ans = 0;
    rep(i, h) rep(j, w){
        int tmp = L[i][j]+R[i][j]+U[i][j]+D[i][j]-3;
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 74036
#include<bits/stdc++.h>
using namespace std;
int n,T,b[200003],dp[200003],a[200003],dat[500003];
vector<int>v[200003];
void upd(int l,int r,int x){
	while(l<=r){
		dat[l]=min(dat[l],x);
		dat[r]=min(dat[r],x);
		l=(l+1)/2;
		r=(r-1)/2;
	}
}
int fnd(int x){
	int ret=1234567;
	while(x){
		ret=min(ret,dat[x]);
		x/=2;
	}
	return ret;
} 
int main(){
	memset(dat,31,sizeof(dat));
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",b+i);
	scanf("%d",&T);
	for(int i=1;i<=n;i++)a[i]=a[i-1]+1-b[i];
	while(T--){
		int l,r;scanf("%d%d",&l,&r);
		v[r].push_back(l);
	}
	for(int i=1;i<=n;i++)
	{
		upd(i+262143,i+262143,dp[i-1]-a[i-1]);
		dp[i]=dp[i-1]+b[i];
		for(int j=0;j<v[i].size();j++)
			upd(v[i][j]+262144,i+262144,fnd(v[i][j]+262143));
		dp[i]=min(dp[i],a[i]+fnd(i+262144));
	}
	cout<<dp[n];
}

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

ll dp[maxn];
ll wt[maxn], vt[maxn];

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

    //freopen("d.in", "r", stdin);

    int n, w;cin>> n >> w;
    for (int i = 1; i <= n; i++){
        cin >> wt[i] >> vt[i];
    }

    for (int i = 1; i <= n; i++){
        for (int j = w - wt[i]; j >= 0; j--){
            dp[j + wt[i]] = max (dp[j + wt[i]], dp[j] + vt[i]);
        }
    }

    ll sol = 0;
    for (int i = 1; i <= w; i++){
        sol = max(sol, dp[i]);
    }

    cout << sol;

    return 0;
}


Measured memory_bytes: 1024
package main

import "fmt"

func main(){
  var s string
  fmt.Scan(&s)
  if s == "abc" || s == "acb" || s == "bac" || s == "bca" || s == "cab" || s =="cba"{
    fmt.Println("Yes")
  }else{
    fmt.Println("No")
  }
}

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

using namespace std;

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

    vector<int> t(n);
    for (int i = 0; i < n; ++i) {
        cin >> t[i];
    }
    sort(t.begin(), t.end());

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

    int ans = 0;
    int curr = 0;
    for (int i = 1; i < n; ++i) {
        if (t[i] > t[curr] + k || passengers[ans] == c) {
            ans++;
            curr = i;
        } else {
            passengers[ans]++;
        }
    }
    cout << ans + 1 << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}

int main(){
  fastIO();
  ll n,red,blue;
  cin>>n>>blue>>red;
  ll div=n/(red+blue);
  ll rest=n%(red+blue);
  ll ans = (div*blue) + min(rest,blue);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string str;
    cin>>str;
    int t=0;
    for(int i=0;i<str.length();i++){
        if(str[i]=='C'){
            t=1;
        }
        if(str[i]=='F'&&t==1){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#pragma comment(linker, "/STACK:512000000")
#include <bits/stdc++.h>
using namespace std;

#define all(a) a.begin(), a.end()
typedef long long li;
typedef long double ld;
void solve(__attribute__((unused)) bool);
void precalc();
clock_t start;
#define FILENAME ""

int main() {
#ifdef AIM
    string s = FILENAME;
//    assert(!s.empty());
    freopen("/home/alexandero/ClionProjects/cryptozoology/input.txt", "r", stdin);
#else
//    freopen(FILENAME ".in", "r", stdin);
//    freopen(FILENAME ".out", "w", stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    start = clock();
    int t = 1;
#ifndef AIM
    cout.sync_with_stdio(0);
    cin.tie(0);
#endif
    precalc();
    cout.precision(10);
    cout << fixed;
    //cin >> t;
    int testNum = 1;
    while (t--) {
        //cout << "Case #" << testNum++ << ": ";
        solve(true);
    }
    cout.flush();
#ifdef AIM1
    while (true) {
      solve(false);
  }
#endif

#ifdef AIM
    cout.flush();
    auto end = clock();

    usleep(10000);
    print_stats(end - start);
    usleep(10000);
#endif

    return 0;
}

void precalc() {
}

template<typename T>
inline T nxt() {
    T cur;
    cin >> cur;
    return cur;
}
#define int li
//const int mod = 1000000007;

void solve(__attribute__((unused)) bool read) {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    cout << (a - b) * (k % 2 == 1 ? -1 : 1) << "\n";
}

Measured memory_bytes: 764
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		List<Long> list = new ArrayList<>();
		int n = sc.nextInt();
		for(int i = 0; i < n; i++) {
			list.add(sc.nextLong());
		}
		Collections.sort(list);
		long num = 0;
		boolean ans = true;
		for(int i = 0; i < list.size(); i++) {
			if(num == list.get(i)) {
				ans = false;
				break;
			}
			num = list.get(i);
		}
		System.out.println(ans ? "YES" : "NO");
	}

}


Measured memory_bytes: 92380
#include<stdio.h>
#define INF 10000000
void warshall_floyd(void);
int min(int,int);
long long graph[101][101];
int n,c,d;

int main(void){
  int k,i,j,x,e,a,b;

  while(1){

    scanf("%d %d",&n,&k);

    for(i=0;i<=n;i++)
      for(j=0;j<=n;j++)
	graph[i][j] = (i==j?0:INF);

    if(n==0 && k==0)break;
    
    for(i=0;i<k;i++){
      scanf("%d",&x);
      
      if(x){

	scanf("%d %d %d",&c,&d,&e);
	if(graph[c][d]>e){
	graph[c][d]=graph[d][c]=e;
	warshall_floyd();
	}
      }
      else{
	scanf("%d %d",&a,&b);
	if(graph[a][b]<INF)printf("%d\n",graph[a][b]);
	else printf("-1\n");
      }

    }

  }
  
  return 0;
}

void warshall_floyd(void){
  int i,j;

    for(i=1;i<=n;i++){
      for(j=1;j<=n;j++){
	graph[i][j]=graph[j][i]=min(graph[i][j],graph[i][c]+graph[c][d]+graph[d][j]);
	graph[i][j]=graph[j][i]=min(graph[i][j],graph[i][d]+graph[d][c]+graph[c][j]);
      }
    }
}

int min(int x,int y){
  return (x<y)?x:y;
}

Measured memory_bytes: 500
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
use std::collections::VecDeque;

fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line: Vec<usize> = read_as_vec();
    let mut queue: VecDeque<(usize, usize)> = VecDeque::new();
    let (h, w) = (line[0], line[1]);

    let mut table: Vec<Vec<char>> = Vec::new();

    for _ in 0..h{
        table.push(read_as_string().chars().collect::<Vec<char>>());
    }
    //println!("{:?}", table);

    for i in 0..h{
        for j in 0..w{
            if table[i][j] == '#'{
                queue.push_back((i,j));
            }
        }
    }

    //println!("{:?}", queue);
    let mut num_ops: usize = queue.len();
    let mut depth_counter = 0;
    while true{
        for _ in 0..num_ops{
            let black: (usize, usize) = queue.pop_front().unwrap();
            if black.0 > 0 && table[black.0-1][black.1] == '.'{
                table[black.0-1][black.1] = '#';
                queue.push_back((black.0-1, black.1));
            }

            if black.0 < h-1 && table[black.0+1][black.1] == '.'{
                table[black.0+1][black.1] = '#';
                queue.push_back((black.0+1, black.1));
            }

            if black.1 > 0 && table[black.0][black.1-1] == '.'{
                table[black.0][black.1-1] = '#';
                queue.push_back((black.0, black.1-1));
            }

            if black.1 < w-1 && table[black.0][black.1+1] == '.'{
                table[black.0][black.1+1] = '#';
                queue.push_back((black.0, black.1+1));
            }
        }
        num_ops = queue.len();
        if num_ops == 0{
            println!("{}", depth_counter);
            return;
        }
        depth_counter += 1
    }
    
}


Measured memory_bytes: 23800
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

struct modint{
    ll a;
    const ll MOD=1e9+7;
    modint(ll a_=0){
        a=a_%MOD;
        if(a<0) a+=MOD;
    }
    modint inv()const{
        ll n=1,m=MOD-2,A=a;
        while(m){
            if(m&1)(n*=A)%=MOD;
            (A*=A)%=MOD;
            m>>=1;
        }
        modint y(n);
        return y;
    }
    bool operator==(const modint& x){
        return a==x.a;
    }
    bool operator!=(const modint& x){
        return a!=x.a;
    }
    modint& operator=(const modint& x){
        a=x.a;
        return *this;
    }
    modint operator+(const modint& x){
        modint y(a+x.a);
        return y;
    }
    modint operator-(const modint& x){
        modint y(a-x.a);
        return y;
    }
    modint operator*(const modint& x){
        modint y(a*x.a);
        return y;
    }
    modint operator/(const modint& x){
        return *this * x.inv();
    }
    modint& operator+=(const modint& x){
        *this=*this+x;
        return *this;
    }
    modint& operator-=(const modint& x){
        *this=*this-x;
        return *this;
    }
    modint& operator*=(const modint& x){
        *this=*this*x;
        return *this;
    }
    modint& operator/=(const modint& x){
        *this=*this/x;
        return *this;
    }
};
istream& operator>>(istream &in,modint& x){
    ll a_;
    in>>a_;
    modint y(a_);
    x=y;
    return in;
}
ostream& operator<<(ostream &out,const modint& x){
    out<<x.a;
    return out;
}
modint pwr(ll a,ll b){
    modint n(1),A(a);
    while(b){
        if(b&1) n*=A;
        A*=A;
        b>>=1;
    }
    return n;
}

vector<modint> fc;
modint fct(ll x) {
    if(fc.empty()) fc.resize(100010);
    if(x==0) return 1;
    if(fc[x]==0) fc[x]=fct(x - 1)*x;
    return fc[x];
}

vector<modint> ifc;
modint ifct(ll x) {
    if(ifc.empty()) ifc.resize(100010);
    if(x==100010-1) return ifc[x]=fct(x).inv();
    if(ifc[x] == 0) ifc[x]=ifct(x+1)*(x+1);
    return ifc[x];
}

modint perm(ll n, ll r) {
    if (n < 0 || r < 0 || n < r) return 0;
    return fct(n)*ifct(n-r);
}

void bfs(modint& ans,vector<vector<int>>& v,int k,int i=0,int p=-1){
    if(p<0) ans*=perm(k-1,v[0].size());
    else ans*=perm(k-2,v[i].size()-1);
    for(auto j:v[i]) if(j!=p) bfs(ans,v,k,j,i);
}

class EVirusTree2 {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int n,k,a,b;
        in>>n>>k;
        vector<vector<int>> v(n);
        fr(i,n-1){
            in>>a>>b;
            v[--a].emplace_back(--b);
            v[b].emplace_back(a);
        }
        modint ans(k);
        bfs(ans,v,k);
        out<<ans<<endl;
    }
};

int main() {
    EVirusTree2 solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 16640
h,w,k=map(int,input().split())
s=[input()for _ in range(h)]
ki=0
ans=[]
ansi=''
for i in range(h):
    if s[i].count('#')>1:
        b=[n for n,v in enumerate(s[i]) if v=='#']
        b.append(w)
        ki+=1
        ansi=(' '+str(ki))*b[1]
        for l in range(2,len(b)):
            ki+=1
            ansi+=(' '+str(ki))*(b[l]-b[l-1])
        while len(ans)<i+1:
            ans.append(ansi)
    elif s[i].count('#')==1:
        ki+=1
        ansi=(' '+str(ki))*w
        while len(ans)<i+1:
            ans.append(ansi)
while len(ans)<h:
    ans.append(ansi)
for ai in ans:
    print(ai[1:])


Measured memory_bytes: 4212
package main

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

type pair struct {
	x, y int
}
type byX []pair

func (a byX) Len() int           { return len(a) }
func (a byX) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a byX) Less(i, j int) bool { return a[i].x < a[j].x }

func main() {
	n := getInt()
	s := make([]pair, n)
	for i := range s {
		s[i].x = getInt()
		s[i].y = i + 1
	}

	sort.Sort(byX(s))

	for _, a := range s {
		fmt.Println(a.y)
	}
}

// -----------------------------------------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 4224
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_STR_MAX		200005									// 最大文字列長

// 内部変数
static FILE *szpFpI;											// 入力
static char sc1Str[D_STR_MAX];									// 文字列

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
long long
fMain(
)
{
	int i;

	// 文字列 - 取得
	fgets(sc1Str, sizeof(sc1Str), szpFpI);

	// 回数 - 取得
	int liBCnt = 0;
	long long llOCnt = 0;
	for (i = 0; ; i++) {
		if (sc1Str[i] == 'B') {
			liBCnt++;
		}
		else if (sc1Str[i] == 'W') {
			llOCnt += liBCnt;
		}
		else {
			break;
		}
	}

	return llOCnt;
}

// １回実行
int
fOne(
)
{
	long long llRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	llRet = fMain();

	// １行出力
	sprintf(lc1Buf, "%lld\n", llRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



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

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back

int main() {
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    scanf("%d", &n);
    int mn = 1e9, res = 0;
    for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		mn = min(mn, x);
		if (mn >= x) res++;
	}
	printf("%d", res);
    return 0;
}


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

using namespace std;

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

    for (size_t i = 0; i <= N/4; i++) {
        for (size_t j = 0; j <= N/7; j++) {
            int p = 4*i + 7*j;
            if( N == p ) {
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
}


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


void solve(long long N, long long K, std::vector<long long> A, std::vector<long long> F){
    sort(A.begin(),A.end());
    sort(F.begin(),F.end());
    long long l=-1,r=A[N-1] * F[N-1] + 1;
    while(r-l>1){
        long long tmp = K, m = (l+r) / 2;
        for(int i=0;i<N;++i){
            if(F[i] * A[N-1-i] > m){
                tmp -= A[N-1-i] - m/F[i];
            }
        }
        if(tmp >= 0){
            r = m;
        }
        else l = m;
    }
    cout<<r<<endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> F(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&F[i]);
    }
    solve(N, K, std::move(A), std::move(F));
    return 0;
}


Measured memory_bytes: 3328
#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)

signed main(){

	string s;
	cin>>s;

	lli flag1,flag2;
	flag1 = s.at(0) == s.at(s.size()-1);
	flag2 = s.size()%2;

	if(flag1^flag2)cout<<"First"<<endl;
	else cout<<"Second"<<endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

struct M {
  using T = struct mms { lint min, max, sum; mms(lint a = numeric_limits<lint>::max(), lint b = numeric_limits<lint>::min(), lint c = 0) : min(a), max(b), sum(c) {} };
  using U = struct lf { lint a, b; lf(lint a = 1, lint b = 0) : a(a), b(b) {} };
  static T op(const T& a, const T& b) { return T{min(a.min, b.min), max(a.max, b.max), a.sum + b.sum}; }
  static void ap(T& a, const U& g, lint k) {
    a.min = g.a * a.min + g.b;
    a.max = g.a * a.max + g.b;
    if (g.a < 0) swap(a.min, a.max);
    a.sum = g.a * a.sum + k * g.b;
  }
  static void ap(U& f, const U& g) { f.a *= g.a; f.b = g.a * f.b + g.b; }
};

template<class M> struct ST {
  using T = typename M::T;
  using U = typename M::U;
  lint n;
  unordered_map<lint, T> t;
  unordered_map<lint, U> u;

  ST(lint n) : n(1LL << 8 * sizeof(lint) - __builtin_clzll(max(n - 1, 1LL))) {}

  void _ap(lint i, const U& f) {
    M::ap(t[i], f, 1 << __builtin_clzll(i) - __builtin_clzll(n));
    if (i < n) M::ap(u[i], f);
  }

  T get(lint l, lint r) {
    _push(l, r);
    T resl, resr;
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) resl = M::op(resl, t[l++]);
      if (r & 1) resr = M::op(t[--r], resr);
    }
    return M::op(resl, resr);
  }

  void _push(lint l, lint r) {
    for (lint hl = 8 * sizeof(lint) - __builtin_clzll(l + n) - 1, hr = 8 * sizeof(lint) - __builtin_clzll(r - 1 + n) - 1; hr > 0; hl--, hr--) {
      lint i = r - 1 + n >> hr;
      _ap(2 * i, u[i]);
      _ap(2 * i + 1, u[i]);
      u.erase(i);
      i = l + n >> hl;
      if (i == r - 1 + n >> hr or i >= n) continue;
      _ap(2 * i, u[i]);
      _ap(2 * i + 1, u[i]);
      u.erase(i);
    }
  }

  void set(lint l, lint r, const U& f) {
    _push(l, r);
    for (lint i = l + n, j = r + n; i < j; i >>= 1, j >>= 1) {
      if (i & 1) _ap(i++, f);
      if (j & 1) _ap(--j, f);
    }
    for (l += n; !(l & 1);) l >>= 1;
    while (l >>= 1) t[l] = M::op(t[2 * l], t[2 * l + 1]);
    for (r += n; !(r & 1);) r >>= 1;
    while (r >>= 1) t[r] = M::op(t[2 * r], t[2 * r + 1]);
  }
};

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n, q; cin >> n >> q;
  ST<M> st(1e7);
  st.set(0, n, M::U(0, 0));
  for (int i = 0; i < q; i++) {
    int t; cin >> t;
    if (t) {
      int l, r; cin >> l >> r;
      cout << st.get(l, r + 1).min << '\n';
    } else {
      int l, r, x; cin >> l >> r >> x;
      st.set(l, r + 1, M::U(1, x));
    }
  }
}


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

int main() {
	int n;
	int i, j, k;
	int a, b;
	long long map[50][30];
	int c[50][30];

	while(cin >> n, n) {

		for(i=0;i<50;i++) {
			for(j=0;j<30;j++) {
				map[i][j] = (long long)1<<i;
				c[i][j] = 0;
			}
		}

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

		for(i=0;i<30;i++) {
			long long m = 0;
			for(j=0;j<n;j++) {
				if(c[j][i])
					m = m|map[j][i];
			}
			for(j=0;j<n;j++) {
				if(c[j][i]) {
					for(k=i;k<30;k++) {
						map[j][k] = m;
					}
				}
			}
		}

		long long end = ((long long)1<<n) - 1;
		int ans = -1;
		for(i=0;i<30;i++) {
			for(j=0;j<n;j++) {
				if(map[j][i] == end) {
					ans = i+1;
					break;
				}
			}
			if(ans != -1)
				break;
		}

		cout << ans << endl;

	}

	return 0;
}

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

int main() {
  int n, s = 0;
  cin >> n;
  for(int i = n; i; i /= 10) s += i % 10;
  puts(n % s? "No" : "Yes");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	string s;
	cin >> s;
	int n = s.size();
	int ans = 0;
	int sc = 0;
	for(int i = 0;i<n;++i)
	{
		if(s[i]=='S')
		{
			sc++;
		}
		else if(s[i]=='T'&&sc)
		{
			sc--;
		}
		else
		{
			ans ++;
		}
	}
	cout<<ans+sc<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
int main(){
    cin>>N;
    cout<<(N+1)/2<<endl;
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	i64 a, b; scanf("%lld%lld", &a, &b);
	
	if((a + b) % 2) printf("IMPOSSIBLE\n"); 
	else printf("%d\n", (a + b) >> 1);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<stdio.h>
using namespace std;
int main(){

    int a,b;
    cin>>a>>b;
    int ans=0;
    for(int i=1;i<=a;i++){
        
        if(i==a){
            if(b>=a){
                ans++;
            }
        }else{
            ans++;
        }
    }
    cout<<ans<<endl;
    
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
  string S, T;
  cin >> S >> T;
  int ans = 0;
  for (int i = 0; i < S.length(); i++) {
    if (S[i]!=T[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3864
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#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 <memory>
#include <regex>
using namespace std;

const long long INF = LLONG_MAX / 2;

int n;
vector<long long> x, y;
vector<int> dx, dy;

long long solve(long long t)
{
    long long xmin = INF;
    long long ymin = INF;
    long long xmax = -INF;
    long long ymax = -INF;
    for(int i=0; i<n; ++i){
        long long x2 = x[i] + dx[i] * t;
        long long y2 = y[i] + dy[i] * t;
        xmin = min(xmin, x2);
        xmax = max(xmax, x2);
        ymin = min(ymin, y2);
        ymax = max(ymax, y2);
    }
    return (xmax - xmin) * (ymax - ymin);
}

int main()
{
    cin >> n;
    x.assign(n, 0);
    y.assign(n, 0);
    dx.assign(n, 0);
    dy.assign(n, 0);
    for(int i=0; i<n; ++i){
        char d;
        cin >> x[i] >> y[i] >> d;
        x[i] *= 2;
        y[i] *= 2;
        if(d == 'R')
            ++ dx[i];
        else if(d == 'L')
            -- dx[i];
        else if(d == 'U')
            ++ dy[i];
        else
            -- dy[i];
    }

    long long left = 0;
    long long right = 400000000;
    while(right - left > 3){
        long long mid1 = (left * 2 + right) / 3;
        long long mid2 = (left + right * 2) / 3;
        if(solve(mid1) < solve(mid2))
            right = mid2;
        else
            left = mid1;
    }

    long long ans = INF;
    for(long long i=left; i<=right; ++i)
        ans = min(ans, solve(i));
    printf("%.10f\n", ans / 4.0);

    return 0;
}


Measured memory_bytes: 2560
N,M=list(map(int,input().split()))
l=[]
for i in range(N):
   l.append(list(map(int,input().split())))
point=[]
for i in range(M):
   point.append(list(map(int,input().split())))
for i in range(N):
   X1,Y1=l[i]
   ans=float("INF")
   f_ans=0
   for j in range(M):
      X2,Y2=point[j]
      distance=abs(X1-X2)+abs(Y1-Y2)
      if ans > distance:
         ans=distance
         f_ans=j
   print(f_ans+1)
   

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

using namespace std;
int main() {
	int K;
	cin >> K;
	if (0==K%2||0==K%5) {
		cout << -1<<  endl;
		return 0;
	}
	int num = 0;
	for (int i = 0;i<=K;++i) {
		num = num * 10 + 7;
		num%=K;
		if (0 == num) {
			cout << i+1<< endl;
			return 0;
		}
	}
}


Measured memory_bytes: 3592
import itertools

while(True):
  n = int(input())
  k = int(input())
  if (n,k) == (0,0):
    break
  num_lis = []
  for _ in range(n):
    num_lis.append(input())
  word_list = []
  
  for item in list(itertools.permutations(num_lis,k)):
    word_list.append("".join(item))
  
  print(len(set(word_list)))


Measured memory_bytes: 6564
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var A = cin.ReadInt;
            var B = cin.ReadInt;
            Console.WriteLine(Max(0, A - B * 2));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13268
# -*- coding: utf-8 -*-
n = int(input())
arr = [list(map(int, input().split())) for i in range(n)]
arm = [list(map(int, input().split())) for j in range(n)]  # 入力

ans = -9999999999  # 最小
for item in range(1, 1024):  # 2 ** 10 == 1024
    fund = 0
    for i in range(n):  # 店の数
        cou = 0  # かぶる数
        for x in range(10):  # 月-金(5) * 2
            if (item >> x) % 2 == 1 and arr[i][x] == 1:  # その時間で被るかどうか
                cou += 1
        fund += arm[i][cou]
    ans = max(ans, fund)  # 最大値更新

print(ans)


Measured memory_bytes: 3188
package main

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

/*-----------Main-----------*/

func main() {
	n := readI()
	s := readSs(n)

	fmt.Println(len(uniqueMap(s)))
}

func uniqueMap(a []string) map[string]bool {
	u := make(map[string]bool)
	for _, v := range a {
		u[v] = true
	}
	return u
}

/*-----------Utilities-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

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

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

func readI() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}

func max(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] > m {
			m = a[i]
		}
	}
	return m
}

func min(a []int) int {
	l := len(a)
	m := a[0]
	for i := 1; i < l; i++ {
		if a[i] < m {
			m = a[i]
		}
	}
	return m
}

func sortI(a []int) []int {
	sort.Ints(a)
	return a
}

func reverse(a []int) []int {
	l := len(a)
	r := make([]int, l)
	for i := 0; i < l; i++ {
		r[i] = a[l-i-1]
	}
	return r
}

func countI(a []int, b int) int {
	l := len(a)
	var c int
	for i := 0; i < l; i++ {
		if a[i] == b {
			c++
		}
	}
	return c
}


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

using ll = long long;

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

    int N;
    cin >> N;
    const int MAX_NUM = (int) 1e9 + 1;
    int min_num = MAX_NUM;
    ll sum = 0;
    int minus_count = 0;
    while (N--) {
        int a;
        cin >> a;
        min_num = min(min_num, abs(a));
        sum += abs(a);
        minus_count += a < 0;
    }

  	if (minus_count % 2 == 1) {
        cout << sum - min_num * 2 << '\n';
    } else {
        cout << sum << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<queue>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
#include<cstdlib>
#include<stack>
#include<ctime>
#include<map>
#include<list>
using namespace std;

string s,t;

int main()
{
	cin>>s>>t;
	int len=s.length();
	int ans=0;
	for(int i=0; i<len; i++)
	{
		if(s[i]!=t[i]) ans++;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3876
<?php
	fscanf(STDIN, "%s", $s);
	$n = substr_count($s, "+");
	switch ($n){
		case 0: 
			$ans = -4;
			break;
		case 1:
			$ans = -2;
			break;
		case 2:
			$ans = 0;
			break;
		case 3:
			$ans = 2;
			break;
		case 4:
			$ans = 4;
			break;
	}
	echo $ans;
?>

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


def solve(A: int, B: int):
    print(max(A+B, A-B, A*B))
    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <stdio.h>
#include <string.h>

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

void debug(char * string, long int target) {
  printf("%s", string);
  printf("%ld", target);
  printf("%c", '\n');
}

int main() {
  short K, n;
  char S[max];

  scanf("%hd%s", &K, S);
  n = strlen(S);

  if (n <= K) {
    printf("%s", S);
  } else {
    rep(i, K) {
      printf("%c", S[i]);
    }
    printf("...");
  }

  return 0;
}


Measured memory_bytes: 1712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T> inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

class unionfind {
    VI par, rank;
    int forest_num;
public:
    unionfind(int n) : par(n), rank(n, 1) {
        forest_num = n;
        for (int i = 0; i < n; i++)par[i] = i;
    }
    void init(int n) {
        par.clear(); par.resize(n);
        rank.clear(); rank.resize(n, 1);
        forest_num = n;
        for (int i = 0; i < n; i++)par[i] = i;
    }
    int root(int x) {
        if (par[x] == x)return x;
        return par[x] = root(par[x]);
    }
    int size(int x) {
        if (par[x] == x)return rank[x];
        return size(par[x]);
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)return;
        if (rank[rx] < rank[ry]) {
            par[rx] = ry;
            rank[ry] += rank[rx];
        }
        else {
            par[ry] = rx;
            rank[rx] += rank[ry];
        }
        forest_num--;
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    int fnum() {
        return forest_num;
    }
};

int main() {
    init();
    
    int n;
    cin >> n;
    VI a(n), s;
    cin >> a;
    s = a; SORT(s);
    VI pl(100001, -1);//ソート後の位置
    FOR(i, 0, n)pl[s[i]] = i;

    unionfind uf(100001);
    FOR(i, 0, n) {
        int p = a[i];
        for (int j = 2; j * j <= p; j++) {
            if (p % j == 0)uf.unite(a[i], j);
            while (p % j == 0)p /= j;
        }
        if (p != 1)uf.unite(a[i], p);
    }

    int ans = 1;
    FOR(i, 0, n)if (!uf.same(a[i], s[i])) {
        ans = 0;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 5028
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int n;
	cin >> n;
	long long int m, a, r, c, h;
	m = 0;
	a = 0;
	r = 0;
	c = 0;
	h = 0;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		if (s[0] == 'M') {
			m++;
		}
		else if (s[0] == 'A') {
			a++;
		}
		else if (s[0] == 'R') {
			r++;
		}
		else if (s[0] == 'C') {
			c++;
		}
		else if (s[0] == 'H') {
			h++;
		}
	}
	long long int ans = 0;
	ans = ans + m * a * r;
	ans = ans + m * a * c;
	ans = ans + m * a * h;
	ans = ans + m * r * c;
	ans = ans + m * r * h;
	ans = ans + m * c * h;
	ans = ans + a * r * c;
	ans = ans + a * r * h;
	ans = ans + a * c * h;
	ans = ans + r * c * h;
	cout << ans;
}

Measured memory_bytes: 256
open System

let N = Console.ReadLine() |> int
let A = Console.ReadLine().Split() |> Array.map int
let B = Console.ReadLine().Split() |> Array.map int
let C = Console.ReadLine().Split() |> Array.map int

let saticfuction i = B.[A.[i]-1] + if (i>0 && A.[i-1] + 1 = A.[i]) then C.[A.[i-1]-1] else 0

[0 .. N-1] |> List.map (fun i -> saticfuction(i))
           |> List.sum
           |> Console.WriteLine
           |> ignore


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
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 Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int mx = 1000000000;

int main() {
  int n,k,s;
  while(input(n,k,s)) {
    if (s != mx) {
      REP(i,n) {
        if (i<k) printf("%d", s);
        else printf("%d", mx);
        printf("%c", i!=n-1?' ':'\n');
      }
      continue;
    }
      REP(i,n) {
        if (i<k) printf("%d", mx);
        else printf("%d", 1);
        printf("%c", i!=n-1?' ':'\n');
      }
  }
}


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

using namespace std;
typedef long long ll;
ll n,m;
const int mx=1000009;
vector<ll>edg[mx];
int visited[mx];
ll dp[mx];
void dfs(int node){
    visited[node]=1;
    for(auto i:edg[node]){
        if(!visited[i]){
            dfs(i);
         
        }   dp[node]=max(dp[node],dp[i]+1);
    }
}
int main() {
  cin>>n>>m;ll x,y;
  for(int i=0;i<m;i++){
      
      cin>>x>>y;
      edg[x].push_back(y);
  }
    for(int i=1;i<=n;i++){
        
      if(!visited[i]){
          dfs(i);
      }
  }ll ans=0;
      for(int i=1;i<=n;i++){
        
     ans=max(ans,dp[i]);
  }
  cout<<ans;
    
}

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

// edit by  (xcode)

using namespace std;

#define int         long long
#define ll          long long
#define double      long double
#define pb          push_back
#define in          insert
#define mp          make_pair
#define f           first
#define s           second
//#define x           first
//#define y           second
#define all(el)     el.begin(), el.end()
#define allr(el)    el.rbegin(), el.rend()
#define sz(el)      (int)el.size()
#define endl        "\n"

inline int chkmax(int &x, int y) {
    if (y > x) {
        x = y;
        return true;
    }
    return false;
}

inline int chkmin(int &x, int y) {
    if (y < x) {
        x = y;
        return true;
    }
    return false;
}

signed main() {
    
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans = min(a, k);
    k -= a;
    if (k > 0) {
        k -= b;
    }
    if (k > 0) {
        ans -= k;
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 3652
#include<iostream>
using namespace std;
static const int N = 100;

int main() {
	int M[N][N]; // 0 オリジンの隣接行列
	int n, u, k, v;
	
	cin >> n;
	
	for ( int i = 0; i < n; i++ ) {
		for ( int j = 0; j < n; j++ ) M[i][j] = 0;
	}
	
	for ( int i = 0; i < n; i++ ) {
		cin >> u >> k;
		u--; // 0 オリジンへ変換
		for ( int j = 0; j < k; j++ ) {
			cin >> v;
			v--; // 0 オリジンへ変換
			M[u][v] = 1; // u と v の間に辺を張る
		}
	}
	
	for ( int i = 0; i < n; i++ ) {
		for ( int j = 0; j < n; j++ ) {
			if ( j ) cout << " ";
			cout << M[i][j];
		}
		cout << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3128
n = int(input())
d = {}
for _ in range(n):
    s = input()
    d.setdefault(s,0)
    d[s] -= 1


t = []
for k,v in d.items():
    t.append((v,k))

t.sort()
num = t[0][0]
for v,s in t:
    if v == num:
        print(s)

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

#define MAX_N 1000
#define MAX_M 1000


int main(){
	int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    s.at(k-1) += ('a' - 'A');
    cout << s << endl;

}




Measured memory_bytes: 256
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    X = II()
    dp = [-1] * (X+106)
    dp[0] = 0
    V = [100,101,102,103,104,105]
    for i in range(X):
            if dp[i] != -1:
                for v in V:
                    dp[i+v] = 1
    if dp[X] == 1:
        print(1)
    else:
        print(0)
    


if __name__ == '__main__':
    main()

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

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

  int n;
  cin >> n;
  int m = n;
  int sum = 0;
  while(m != 0){
    sum += m % 10;
    m /= 10;
  }

  if(n % sum == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;

int main(){
   double w,h,x,y;
   cin>>w>>h>>x>>y;
   if(w/2==x && h/2==y){
       cout<<setprecision(11)<<w*h/2<<" "<<1<<endl;
   }
   else cout<<setprecision(11)<<w*h/2<<" "<<0<<endl;
}

   


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
#define ll long long
#define ld long double
#define rep(i,x,y)  for(ll i=x;i<y;++i)
#define For(i,x,y)  for(ll i=x;i<=y;++i) 
#define FOr(i,x,y)  for(ll i=x;i>=y;--i) 
#define pi acos(-1)
#define pa pair<ll,ll>
#define lf else if
#define max(x,y)    ((x)<(y)?(y):(x))
#define min(x,y)    ((x)<(y)?(x):(y))
#define sqr(x)		(x)*(x)
#define Mul(x,y)    x=x*(y)%mod
#define Add(x,y)    x=(x+(y))%mod
#define Max(x,y)	x=x<(y)?(y):x
#define Min(x,y)	x=x>(y)?(y):x
#define E(x) 		return writeln(x),0
#define p(x)		printf("~%d~\n",x)
#define pp(x,y)		printf("~~%d %d~~\n",x,y)
#define ppp(x,y,z)	printf("~~~%d %d %d~~~\n",x,y,z)
#define f_in(x)		freopen(x".in","r",stdin)
#define f_out(x) 	freopen(x".out","w",stdout)
#define open(x)		f_in(x),f_out(x)
#define fi first
#define se second
typedef complex<double> E;
namespace SHENZHEBEI{
#ifdef LOCAL
    struct _{_(){freopen("cf.in","r",stdin);}}_;
#endif 
#define NEG 1
    const int L=2333333;
    char SZB[L],*S=SZB,*T=SZB;
    inline char gc(){   if (S==T){  T=(S=SZB)+fread(SZB,1,L,stdin); if (S==T) return '\n';  }   return *S++;    }
#if NEG
    inline ll read(){    ll x=0,f=1; char ch=gc();   for (;!isdigit(ch);ch=gc()) if (ch=='-') f=-1;  for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x*f; }
    inline void write(ll x){    if (x<0) putchar('-'),x=-x;  if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#else
    inline ll read(){    ll x=0; char ch=gc();   for (;!isdigit(ch);ch=gc());    for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x;   }
    inline void write(ll x){    if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#endif
    inline char readchar(){ char ch=gc();   for(;isspace(ch);ch=gc());  return ch;  }
    inline ll readstr(char *s){ char ch=gc();   int cur=0;  for(;isspace(ch);ch=gc());      for(;!isspace(ch);ch=gc())  s[cur++]=ch;    s[cur]='\0';    return cur; }
    inline void writeln(ll x){  write(x);   puts("");   }
}using namespace SHENZHEBEI;
char s[10];
ll mk[4010][4010][2],answ,k,mx;
ll calc(ll x,ll y,ll w){
	ll sx=x,sy=y,ans=mk[sx][sy][w];
	if (sx-k>=0&&sy-k>=0)	ans+=mk[sx-k][sy-k][w];
	if (sx-k>=0)			ans-=mk[sx-k][sy][w];
	if (sy-k>=0)			ans-=mk[sx][sy-k][w];
	return ans;
}
int main(){
	ll n=read();
	k=read();
	For(i,1,n){
		ll sx=read()%(2*k),sy=read()%(2*k);//pp(sx,sy);
		readstr(s+1);
		if (s[1]=='B')	mk[sx][sy][0]++,mk[sx+2*k][sy][0]++,mk[sx][sy+2*k][0]++,mk[sx+2*k][sy+2*k][0]++;
		else			mk[sx][sy][1]++,mk[sx+2*k][sy][1]++,mk[sx][sy+2*k][1]++,mk[sx+2*k][sy+2*k][1]++;
	}
	rep(i,0,4*k)rep(j,0,4*k)For(w,0,1){
		if (i)mk[i][j][w]+=mk[i-1][j][w];
		if (j)mk[i][j][w]+=mk[i][j-1][w];
		if (i&&j)mk[i][j][w]-=mk[i-1][j-1][w];
		mx=max(mx,i);
	}
	rep(i,0,2*k)rep(j,0,2*k){
		calc(i+2*k-1,j+2*k-1,0);
		ll	ans=calc(i+k-1,j+k-1,0)+calc(i+k-1,j+2*k-1,1)+calc(i+2*k-1,j+k-1,1)+calc(i+2*k-1,j+2*k-1,0);
//		puts("-------------------------------------");
		answ=max(answ,ans);
	}writeln(answ);
}

Measured memory_bytes: 253568
n,m = map(int,input().split())
lis = list(map(int,input().split()))
lis.sort()
li = []
for i in range(m-1):
  li.append(lis[i+1]-lis[i])
li.sort()
ans = 0
cou = max(0,m-n)
for i in range(cou):
  ans += li[i]
print(ans)

Measured memory_bytes: 13968