akhauriyash/Code-Regression huggingface dataset:
/*==============================================*\
ID:          shahidul_brur
 
Name:     Md. Shahidul Islam
Study:      CSE, BRUR
Address:  Rangpur, Bangladesh
 
 mail: shahidul.cse.brur@gmail.com
 FB  : fb.com/shahidul.brur
 Blog: shahidul-brur.blogspot.com(in Bengali),
       shahidul-brur-en.blogspot.com(in English)
\*===============================================*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};

const double pi = acos(-1.0);
const double eps = 1e-6;
const int mod = (int)1e9+7;
const int maxn = (int)2e5+5;
const int logn = 20;
ll a[maxn];
vi g[maxn];
void dfs(int u, int p){
    for(int v:g[u]) if(v!=p)
    {
        a[v]+=a[u];
        dfs(v,u);
    }
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int q;
    int n; cin>>n>>q;
    f0(i,n-1) 
    {
        int a, b;
        cin>>a>>b;
        g[a].pb(b);
        g[b].pb(a);
    }
    while(q--){
        int u, x;
        cin>>u>>x;
        a[u]+=x;
    }
    dfs(1,1);
    f1(i,n) cout << a[i] << " ";
    return 0;
}


Measured memory_bytes: 24320
def main():
    x, k, d = map(int, input().split())

    kyori = abs(x)
    kaisuu = kyori // d
    sa = k - kaisuu
    amari = kyori % d

    if kaisuu >= k:
        print(kyori- k*d)
    else:
        if sa % 2 == 0:
            print(amari)
        else:
            print(d - amari)




if __name__ == "__main__":
    main()

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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)


int main()
{
	int n;
	cin>>n;
	int sum=0,maxx=INT_MIN;
	ffor(i,0,n)
	{
		int x;
		cin>>x;
		sum+=x;
		if(x>maxx) maxx=x;
	}
	sum-=maxx;
	if(sum>maxx) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
  char s[128];
  scanf("%s",s);
  
  int month =(s[5]-'0')*10+(s[6]-'0');
  
  if(month<5)
    printf("Heisei");
  else
    printf("TBD");
  
	return 0;
}

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

typedef long long ll;
#define mod 1000000007
#define pb push_back
#define mk make_pair
#define precise(x) cout<<fixed<<setprecision(12)<<x
#define test cout<<"#";

const ll INF = 1e18L + 5;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll n, k;
	cin>>n>>k;
	vector<ll> v(n);
	for(ll x = 0; x < n; x++)
		cin>>v[x];
	ll ans[k+1];
	memset(ans, 1, sizeof(ans));
	ans[0]=0;
	
	for(ll x = 1; x <= k; x++)
	{
		for(auto u:v)
		{
			if(u<=x)
				ans[x]&=ans[x-u];

		}
		ans[x]=1-ans[x];
	}
	if(ans[k]==1)
		cout<<"First\n";
	else
	{
		cout<<"Second\n";
	}	
}

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

typedef long long ll;
typedef pair<ll,ll> pll;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 2e5 + 5;
const int OO = 2e9;

int n,a[N],ok,ans;

void init() {



}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;

    for(int i=0;i<n;++i) {

        cin >> a[i];

    }

    ok = 1;

    while(ok) {

        for(int i=0;i<n;++i) {

            if(a[i]&1) ok = 0;

        }

        if(ok) {
            
            ++ans;

            for(int i=0;i<n;++i) {

                a[i] /= 2;

            }

        }

    }

    cout << ans << '\n';

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  int n;
  cin >> n;
  vector<int> s(n);
  for (auto &x: s) cin >> x;

  vector<vector<int> > dp(n+2, vector<int>(10, -1000000007));
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) dp[i+1][j] = dp[i][j];
    for (int j = 0; j < 10; j++) {
      dp[i+1][(dp[i][j] + s[i]) % 10] = max(dp[i+1][(dp[i][j] + s[i]) % 10], dp[i][j] + s[i]);
    }
  }

  int ans = 0;
  for (int i = 1; i < 10; i++) ans = max(ans, dp[n][i]);

  cout << ans << endl;

  return 0;
}


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

using namespace std;

const int N = 2e5 + 100;

int n;
int Beauty[N];
ll Seg[N << 2];

void Update (int idx, ll val, int Node = 1, int L = 1, int R = n)
{
    if (L == R) {
        Seg[Node] = max(Seg[Node], val);
        return;
    }

    int Mid = L + R >> 1;
    if (idx <= Mid)
        Update (idx, val, Node << 1, L, Mid);
    else
        Update (idx, val, Node << 1 | 1, Mid + 1, R);

    Seg[Node] = max(Seg[Node << 1], Seg[Node << 1 | 1]);
}

ll Query (int i, int j, int Node = 1, int L = 1, int R = n)
{
    if (i > R || j < L || i > j)    return 0;
    if (L >= i && R <= j)
        return Seg[Node];

    int Mid = L + R >> 1;
    ll Q1 = Query (i, j, Node << 1, L, Mid);
    ll Q2 = Query (i, j, Node << 1 | 1, Mid + 1, R);

    return max(Q1, Q2);
}


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

    vector <pair<ll, ll>> Arr;
    for (int i = 1; i <= n; i++) {
        int x;  scanf("%d", &x);
        Arr.push_back({x, i});
    }
    for (int i = 1; i <= n; i++)
        scanf("%d", Beauty + i);


    sort(Arr.begin(), Arr.end());

    for (auto flower : Arr) {
        int idx = flower.second;
        
        ll cur = Query(1, idx - 1);

        Update(idx, cur + Beauty[idx]);
    }

    printf("%lld\n", Query(1, n));
    return 0;
}


Measured memory_bytes: 11372
package main

import (
	"bufio"
	"fmt"
	"math"
	"math/cmplx"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}
func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0
	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 1
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	a := getNextFloat64(scanner)
	b := getNextFloat64(scanner)
	h := getNextFloat64(scanner)
	m := getNextFloat64(scanner)
	fmt.Fprintln(writer, cmplx.Abs(cmplx.Rect(a, degToRad((60*h+m)/2))-cmplx.Rect(b, degToRad(m*6))))
}

func degToRad(deg float64) float64 {
	return deg * math.Pi / 180.0
}


Measured memory_bytes: 1772
#include<iostream>
using namespace std;
int main(){
  	int r,g,b;
  	cin >> r >> g >> b;
  	if((r*100+g*10+b)%4==0){
    	cout << "YES\n";
    }
  	else{
    	cout << "NO\n";
    }
	return 0;
}

Measured memory_bytes: 256
n = int(input())
c = input()

cnt = 0
i = 0
j = n-1
while i < j:
    if c[i] == 'W':
        while i < j:
            if c[j] == 'R':
                cnt += 1
                j -= 1
                break
            j -= 1
    i += 1

print(cnt)

Measured memory_bytes: 9412
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class CUbiquity {
        private static final int mod = 1000000007;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            long ans = 0;

            if (n == 1) {
                ans = 0;
            } else {
                ans = (powAndMod(10, n) - powAndMod(9, n) - powAndMod(9, n) + powAndMod(8, n)) % mod;
            }
            // 出力
            out.println((ans + mod) % mod);

        }

        private static long powAndMod(long a, long b) {
            long x = 1;
            while (b > 0) {
                if (b % 2 == 1) {
                    x = (x * a) % mod;
                    b--;
                } else {
                    a = (a * a) % mod;
                    b /= 2;
                }
            }
            return x;
        }

    }
}



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

using namespace std;

struct UnionFind {
    vector<int> par;

    UnionFind(int N) : par(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]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry; 
    }

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

int main() {
    int N, M;
    cin >> N >> M;
    UnionFind uf = UnionFind(N);
    
    int a, b, c;

    for(int i = 0; i < M; i++) {
        cin >> a >> b >> c;
        a--; b--;
        uf.unite(a, b);
    }

    vector<bool> used(N, false);
    int ans = 0;
    for(int i = 0; i < N; i++) {
        int v = uf.root(i);
        if(!used[v]) {
            ans++;
            used[v] = true;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
 
using namespace std;
 
#define f(i,a,b) for(int i=a;i<b;i++)
#define fll(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define vvi vector<vector<int> >
#define ss second
#define ff first
#define ll long long
#define lld long double
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pq priority_queue< int >
#define pqll priority_queue< ll >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define INF 1000000000
#define NINF -1000000000

void solve(){
    
    int n;
    cin >> n;
    vl a(n);
    for(int i = 0 ; i < n ; i++){
        cin >> a[i];
    }
    sort(a.begin() , a.end());
    vl sol;
    sol.pb(a[n-1]);
    for (int i = n-2 ; i >= 0 ; i--){
        for (int j = 0; j < 2; j++){
            sol.pb(a[i]);
        }
    }
    ll ans = 0;
    for (int i =0 ; i < n - 1 ; i++){
        ans += sol[i];
    }
    cout << ans << endl;
}

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

    int t = 1;
    // cin >> t;
    
    while(t--){    
        solve();
    }
}

Measured memory_bytes: 8968
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int r = sc.nextInt();
    int b = sc.nextInt();
    int g = sc.nextInt();
    int sum = 100*r + 10*b + g;
    
    if(sum % 4 == 0){
      System.out.println("YES");
    }else {
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 21844
/*
      author : nishi5451
      created: 11.08.2020 21:08:59
*/

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


int main(){
    int x,y;
    cin >> x >> y;
    cout << x + y/2 << endl;
    return 0;
}

Measured memory_bytes: 3648
from collections import defaultdict
class UnionFind:
    def __init__(self, n):
        class KeyDict(dict):
            # 辞書にないときの対応
            def __missing__(self,key):
                self[key] = key
                return key
        self.parent = KeyDict()
        self.rank = defaultdict(int)
        self.weight = defaultdict(int)

    # 根を探す
    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            # 経路圧縮
            # 自分自身じゃない場合は、上にさかのぼって検索(再帰的に)
            y = self.find(self.parent[x])           
            self.weight[x] += self.weight[self.parent[x]]   #圧縮時にweightを更新(和)
            self.parent[x] = y      #親の置き換え(圧縮)
            return self.parent[x]

    # 結合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        # 低い方を高い方につなげる(親のランクによる)
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
        
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1

    ### 重み付き
    def weighted_union(self, x, y, w):
        # print("unite",x,y,w,self.weight)
        px = self.find(x)
        py = self.find(y)
        # 低い方を高い方につなげる(親のランクによる)
        # if px == py: return 0
        if self.rank[px] < self.rank[py]:
            self.parent[px] = py
            self.weight[px] = - w - self.weight[x] + self.weight[y]
        else:
            self.parent[py] = px
            self.weight[py] =  w + self.weight[x] - self.weight[y]
        if self.rank[px] == self.rank[py]:
            self.rank[px] += 1
        return 0

    # 判定
    def judge(self, x, y):
        return self.find(x) == self.find(y)

n, m = map(int, input().split())
uf = UnionFind(n)
for i in range(m):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    if not uf.judge(a,b):
        uf.union(a,b)

d = defaultdict(int)
for i in range(n):
    d[uf.find(i)] += 1
print(len(d)-1)

Measured memory_bytes: 28680
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    char c;
    cin >> c;
    c++;
    cout << c << "\n";
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)

anss = []
t = -1
for i in range(n):
    if t == a[i]:
        anss.append(t)
        t = -1
        if len(anss) >= 2:
            break
    else:
        t = a[i]

if len(anss) >= 2:
    ans = 1
    for x in anss:
        ans *= x
else:
    ans = 0
print(ans)

Measured memory_bytes: 15020
#include <iostream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cmath>
#include <iomanip>
using namespace std;

#define PI 3.14159265358979323846264338327950L

int A, B, H, M;
double res;

int main()
{
    cin >> A >> B >> H >> M;

    res = sqrt(A * A + B * B - 2 * A * B * cos(abs((H * 30 + M * 0.5) - (M * 6)) * PI / 180));
    cout << fixed << setprecision(10) << res << endl;

    return 0;
}

Measured memory_bytes: 4148
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int x = sc.nextInt();
		int y = sc.nextInt();
        String ans = "";
        if (x == 2 || y == 2) {
          ans = "No";
        } else {
          ArrayList<Integer> list = new ArrayList<>();
          list.addAll(Arrays.asList(4, 6, 9, 11));
          if (list.contains(x) && list.contains(y)) {
            ans = "Yes";
          } else if ((!list.contains(x)) && (!list.contains(y))) {
            ans = "Yes";
          } else {
            ans = "No";
          }
        }
    
		// 出力
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
double p,f[3005],ans;int n;
int main()
{
    scanf("%d",&n);f[0]=1;
    for(int i=1;i<=n;i++){
        scanf("%lf",&p);
        for(int j=i;j>=1;j--){
            f[j]=(f[j]*(1-p)+f[j-1]*p);
        }
        f[0]*=1-p;
    }
    for(int i=n/2+1;i<=n;i++) ans+=f[i];
    printf("%.11lf",ans);
    return 0;
}

Measured memory_bytes: 256
import heapq

N, M = map(int, input().split())
work = [[] for _ in range(M)]
for _ in range(N):
    a, b = map(int, input().split())
    if a <= M:
        work[a-1].append(b)
ans = 0
q = []
heapq.heapify(q)
for i in range(M):
    for x in work[i]:
        heapq.heappush(q, -x)
    if q != []:
        ans += heapq.heappop(q)*(-1)
print (ans)

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

typedef long long ll;
using namespace std;

#define all(x) x.begin(), x.end()
#define f(i,a,b) for(int i = (a); i <= (b); i++)
#define fd(i,a,b) for(int i = (a); i >= (b); i--)
#define mp make_pair
#define faster_io() ios_base::sync_with_stdio(false)
#define pb push_back
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
#define vii vector<pair<int,int>>

const int INF = 1000000005;
const ll INFLL = 1000000000000000002ll;
const ll MOD = 1000000007;

inline ll min(ll a, ll b, ll c){return min(min(a,b),c);}
inline ll min(ll a, ll b, ll c, ll d){return min(min(min(a,b),c),d);}
inline ll max(ll a, ll b, ll c){return max(max(a,b),c);}
inline ll max(ll a, ll b, ll c, ll d){return max(max(max(a,b),c),d);}

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

int A[200005], R[200005], N;

int work(int l)
{
    int m = 0, r = l;
    while(r <= N)
    {
        if((A[r] & m) > 0) break;
        m |= A[r];
        r = R[r];
    }
    return r-1;
}

int main()
{
    cin >> N;
    int val = 0;
    f(i,1,N) cin >> A[i];
    R[N] = N+1;
    fd(i,N-1,1) R[i] = A[i+1] > 0 ? i+1 : R[i+1];
    ll ans = 0;
    f(i,1,N)
    {
        int j = work(i);
        ans += j-i+1;
    }
    cout << ans;
}


Measured memory_bytes: 1792
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
//using Graph = vector<vector<int>>;
typedef long long ll;
using Graph = vector<vector<pair<ll,ll>>>;
const int mod =1e+9+7;

const int dy[4]={0,1,0,-1};
const int dx[4]={1,0,-1,0};
const ll INF=1e10;

ll prime_factorize(ll n){
    ll A=1;
    for(ll p = 2;p <= sqrt(n);p++){
        ll cnt=0;
      if (n%p != 0) continue;
      while(n % p == 0){
        n /= p;
        cnt++;
      
      }
        A*=(cnt+1);
      
    }
    if (n != 1) A*=(2);
    return A;
}
int main(){
    ll n; cin>>n;
    ll ans=0;
    for(int i=1;i<n;i++){
        ans+=prime_factorize(n-i);
    }
    cout<<ans<<endl;
}











Measured memory_bytes: 3676
//atcoder "maze master"

#include <bits/stdc++.h>
int h;
int w;
char maze[20][20];
int dis[20][20];

using namespace std;

struct Lat
{
    int x;
    int y;
};
//a point on a lattice
Lat sides[] = {
    {1, 0},
    {0, 1},
    {-1, 0},
    {0, -1}};
void resetdis()
{
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            dis[j][i] = INT32_MAX;
        }
    }
}
int main()
{
    cin >> h;
    cin >> w;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            dis[j][i] = INT32_MAX;
        }
    }
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            char input;
            cin >> input;
            maze[j][i] = input;
        }
    }
    //. road
    //# wall
    int dismax = 0;
    for (int sx = 0; sx < w; sx++)
    {
        for (int sy = 0; sy < h; sy++)
        {
            if (maze[sx][sy] != '.')
            {
                continue;
            }
            resetdis();
            dis[sx][sy] = 0;
            Lat pos = Lat();
            vector<Lat> a;
            vector<Lat> b;
            vector<Lat> *reserved = &a;
            vector<Lat> *next = &b;
            reserved->push_back(Lat());

            Lat *sp = &reserved->at(0);
            sp->x = sx;
            sp->y = sy;

            for (;;)
            {
                if (reserved->size() == 0)
                {
                    break;
                }
/*
                cout << endl;
                for (int i = 0; i < w; i++)
                {
                    for (int j = 0; j < h; j++)
                    {
                        cout << dis[i][j] << " ";
                    }
                    cout << endl;
                }
                cout << endl;
*/
                for (int i = 0; i < reserved->size(); i++)
                {
                    Lat l = reserved->at(i);
                    //cout << l.x << "," << l.y << endl;
                    int d = dis[l.x][l.y] + 1;
                    for (int n = 0; n < 4; n++)
                    {
                        Lat l1 = Lat();
                        l1.x = l.x + sides[n].x;
                        l1.y = l.y + sides[n].y;
                        if (l1.x < 0 || w <= l1.x || l1.y < 0 || h <= l1.y)
                        {
                            continue;
                        }
                        if (maze[l1.x][l1.y] != '.')
                        {
                            continue;
                        }
                        if ((dis[l1.x][l1.y] <= d))
                        {
                            //cout << "already passed" << endl;
                            //cout << dis[l1.x][l1.y] << endl;
                            continue;
                        }
                        dis[l1.x][l1.y] = d;
                        dismax = max(d, dismax);
                        next->push_back(l1);
                    }
                }
                reserved->clear();
                swap(reserved, next);
            }
        }
    }
    cout << dismax;
    //cout << dis[w - 1][h - 1];
    return 0;
}

Measured memory_bytes: 256
// Problem : B - Crane and Turtle
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <iostream>
using namespace std;
int main()
{
 int x,y;
 cin>>x>>y;
 for(int i=0;i<=x;i++)
  if(2*i+4*(x-i)==y)
  {
   cout<<"Yes"<<endl;
   return 0;
  }
 cout<<"No"<<endl;
 return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define ll long long
using namespace std;

struct nCk {
	int n;
	int k;
	int size;
	void next(int* ar);
	nCk(int a, int b, int* ini);
};

int main()
{
	int n, k;
	cin >> n;
	vector<int> len(n);
	int c[2];
	nCk ob(n, 2, c);
	ll ans = 0LL;

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

	sort(len.begin(), len.end());
	int min;
	int max;
	int left, right;

	for (int i = 0; i < ob.size; i++) {

		c[0]--;
		c[1]--;
		min = len[c[1]] - len[c[0]];
		max = len[c[1]] + len[c[0]];
		left = c[1];
		//printf("[%d,%d] = (%d:%d) -> ", len[c[0]], len[c[1]], min, max);
		left = c[1];
		while (left < n && len[left] <= min) {
			//printf("left++");
			left++;
		}
		right = left;
		while (right < n && len[right] < max) {
			//printf("right++");
			right++;
		}
		ans += (ll)right - (ll)left - 1LL;
		//printf("[%d,%d]\n", left, right);
		c[0]++;
		c[1]++;
		ob.next(c);
	}

	printf("%lld", ans);

	return 0;
}

void nCk::next(int* ar)
{
	for (int i = 0; i < k; i++) {
		if (ar[k - i - 1] != n - i) {
			ar[k - i - 1]++;
			for (int j = k - i; j < k; j++) {
				ar[j] = ar[j - 1] + 1;
			}
			break;
		}
	}
}

nCk::nCk(int a, int b, int* ini)
{
	n = a;
	k = b;
	size = 1;

	for (int i = 0; i < k; i++) {
		size *= (n - i);
		ini[i] = i + 1;
	}
	for (int i = 0; i < k; i++) {
		size /= (1 + i);
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Maxn 500007
using namespace std;
int n;
char s[Maxn];
int f[Maxn],a[Maxn];
int main()
{
    scanf("%d",&n);
    scanf("%s",s+1);
    for (int i=1;i<=n;i++)
        if (s[i]=='1') a[i]=a[i-1]; else a[i]=i;
    memset(f,0,sizeof(f));
    for (int i=1;i<=n;i++)
    {
        f[i]=f[i-1];
        if (s[i]=='1')
        {
           if (s[i-1]=='0'&&s[i-2]=='1')
           {
              f[i]=max(f[i],f[a[i-2]]+i-2-a[i-2]);
              f[i]=max(f[i],f[a[i-2]+1]+i-2-a[i-2]-1);
           }
           if (s[a[i]-1]=='1') f[i]=max(f[i],f[a[i]-2]+i-a[i]);
        }
    }
    printf("%d\n",f[n]);
    return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define ll long long
int main(){
  int N;
  cin>>N;
  vector<ll> A(N),B(N),C(N);
  rep(i,N) cin>>A[i];
  rep(i,N) cin>>B[i];
  rep(i,N) cin>>C[i];
  sort(all(A));
  sort(all(C));
  ll ans=0;
  rep(j,N){
    ll I=lower_bound(all(A),B[j])-A.begin();
    ll K=N-(upper_bound(all(C),B[j])-C.begin());
    ans+=I*K;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <limits>
#include <math.h>
#include <cmath>
#include <cctype>
#include <cstdio>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int> ;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vvll = vector<vector<long long >>;
#define PI 3.141592653
#define rep(i, k, n) for(ll i = k; i < n; i++)



int main(){
  ll n; cin >> n;
  ll m = n % 10;
  if(m == 3){cout << "bon" << endl;}
  else if(m == 0 || m == 1 || m == 6 || m == 8){
    cout << "pon" << endl;
  }
  else{cout << "hon" << endl;}
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define ll long long int
#define pl pair<ll, ll>
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535;
const ll MOD = 1e9+7;
const ll NUM = 1e3+10;
void solve()
{
    ll k;
    cin>>k;
    string str;
    cin>>str;
    ll n=str.length();
    if(n<=k)
    {
        cout<<str;
        return;
    }    
    else
    for(ll i=0; i<k; i++)
    {
        cout<<str[i];
    }
    cout<<"...";
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
/*    #ifndef ONLINE_JUDGE
      // for getting input from input.txt
      freopen("input.txt", "r", stdin);
      // for writing output to output.txt
      freopen("output.txt", "w", stdout);
  #endif*/
fast();
//ll  t;cin>>t;while(t--)
{
  ll n,f=0;
  string s;
  cin>>s;
  n=s.length();
  map<char,int>m;
  for(int i=0;i<n;i++)
  {
    m[s[i]]++;
  }
  for(auto it=m.begin();it!=m.end();it++)
  {
    if(it->second&1)
     { f=1;
      break;
    }

  }
  if(f)
  {
    No
  }
  else
  {
    Yes
  }
  

}
return 0;
}

Measured memory_bytes: 256
N=int(input())

sum=0
Total=int((1+N)*N/2)

m15=int(N//15)
T15=(1+m15)*m15/2*15
#print(T15)

m5=int(N//5)
T5=(1+m5)*m5/2*5
#print(T5)

m3=int(N//3)
T3=(1+m3)*m3/2*3
#print(T3)

print(int(Total-T3-T5+T15))

  

Measured memory_bytes: 9124
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);++i)
constexpr long long INF = (1LL<<60);

ll LIS(const vector<ll>& v){
  ll n=((ll)v.size());
  vector<ll> lis(n+1,INF);
  lis[0]=-INF;
  for(ll i=0;i<n;++i){
    auto itr = lower_bound(lis.begin(),lis.end(),v[i]);
    *itr=min(*itr,v[i]);
  }
  ll len=0;
  for(ll i=1;i<=n;++i){
    if(lis[i]!=INF)len=i;
  }
  return len;
}

main(){

  ll n;
  cin>>n;
  vector<ll> a(n);
  for(auto& element:a)cin>>element;

  cout<<(LIS(a))<<endl;

}


Measured memory_bytes: 4356
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext())
		{
			double n = sc.nextDouble(), m = sc.nextDouble();
			if (n < 35.50 && m < 71.00)
			{
				System.out.println("AAA");
			}
			else if (n < 37.50 && m < 77.00)
			{
				System.out.println("AA");
			}
			else if (n < 40.00 && m < 83.00)
			{
				System.out.println("A");
			}
			else if (n < 43.00 && m < 89.00)
			{
				System.out.println("B");
			}
			else if (n < 50 && m < 105.00)
			{
				System.out.println("C");
			}
			else if (n < 55.00 && m < 116.00)
			{
				System.out.println("D");
			}
			else if (n < 70.00 && m < 148.00)
			{
				System.out.println("E");
			}
			else
			{
				System.out.println("NA");
			}
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

string s,t;

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


Measured memory_bytes: 3832
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

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;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    string S,T; cin >> S >> T;
    bool f=true;
    for(int i=0;i<S.size();i++){
        if(S[i]!=T[i]){
            f=false;
            break;
        }
    }
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3596
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) REV(SORT(V)) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V).at(i) << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V).at(i) << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c=0,x,y,z;
double d,e,f;
string s,t;
//

signed main() {
  RAPID;
  IN(n);
  Vi A(n+1);
  Vi B(n);
  VIN(A)
  VIN(B)
  REP(i,n){
    if(A.at(i)<=B.at(i)) {
      c += A.at(i);
      B.at(i) -= A.at(i);
      A.at(i) = 0;
    } else {
      c += B.at(i);
      A.at(i) -= B.at(i);
      B.at(i) = 0;
    }
    if(A.at(i+1)<=B.at(i)) {
      c += A.at(i+1);
      B.at(i) -= A.at(i+1);
      A.at(i+1) = 0;
    } else {
      c += B.at(i);
      A.at(i+1) -= B.at(i);
      B.at(i) = 0;
    }
  }
  OUT(c);
}

Measured memory_bytes: 1792
import scala.io.StdIn.{readInt, readLine}

object Main extends App {
  val n = readInt()
  val values = readLine().split(' ').map(_.toInt)
  val costs = readLine().split(' ').map(_.toInt)
  
  val result = values.zip(costs).foldLeft(0) { case (sum, (value, cost)) =>
    val gain = value - cost
    if (gain > 0)
      sum + gain
    else
      sum
  }
  println(result)
}

Measured memory_bytes: 54736
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
  int n,k;
  cin >> n >> k;
  vi a(n);
  rep(i,n) cin >> a[i];
  combination c(n+5);
  sort(rng(a));
  mint ans = 0;
  rep(ri,2){
    rep(i,n){
      mint now = c(i,k-1);
      if(ri == 1)now = -now;
      ans+=now*a[i];
    }
    reverse(rng(a));
  }
  cout<<ans.x<<endl;
  return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

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

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

  int out[100000];
  for (int i = 0; i < n; i++) {
    int num = a[i];
    out[num - 1] = i + 1;
  }

  for (int i = 0; i < n; i++) cout << out[i] << " ";

  return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)

vector<ll> divisor_enumerate(ll N){
    vector<ll> front,back;
    for(ll i=1;i*i<N+1;i++){
        if(N%i==0){
            front.push_back(i);
            back.push_back(N/i);
        }
    }
    while(!back.empty()){
        if(back.back()==front.back()) back.pop_back();
        else{
            front.push_back(back.back());
            back.pop_back();
        }
    }
    return front;
}

bool cheack(ll n,ll s,ll b){
    while(n!=0){
        s-=n%b;
        n=n/b;
    }
    return(s==0);
}

int main(){
    ll n,s;
    cin>>n>>s;
    if(n==s){
        cout<<n+1<<endl;
        return 0;
    }
    vector<ll> vec;
    vec=divisor_enumerate(max(n-s,s-n));
    while(!vec.empty()){
        if(cheack(n,s,vec.front()+1)){
            cout<<vec.front()+1<<endl;
            return 0;
        }
        vec.erase(vec.begin());
    };
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <assert.h>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector < vector <int> > vvi;
const int HUGEI = 2147483647;  // (1 << 31) - 1
const ll HUGEL = 9223372036854775807;  // (1 << 63) - 1
const string ABC = "abcdefghijklmnopqrstuvwxyz";

int main(void) {
    int n;
    vector <int> an, bn;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        an.push_back(a);
        bn.push_back(a);
    }
    sort(bn.begin(), bn.end());
    for (int i = 0; i < n; i++) {
        int a = an[i];
        if (a <= bn[n / 2 - 1]) {
            cout << bn[n / 2] << endl;
        } else {
            cout << bn[n / 2 - 1] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3948
sx,sy,tx,ty=map(int,input().split())
root='U'*(ty-sy)+'R'*(tx-sx)+'D'*(ty-sy)+'L'*(tx-sx)+'L'+'U'*(ty-sy+1)+'R'*(tx-sx+1)+'D'+'R'+'D'*(ty-sy+1)+'L'*(tx-sx+1)+'U'
print(root)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define  rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef vector<int> vi;
typedef long int li;
typedef unsigned long long ull;

int main(int argc,char* argv[])
{
    string s;
    li K,len;
    cin>>s>>K;
    len=s.size();
    rep(i,len){
        if(i!=len-1 && s[i]=='a') continue;
        if('z'-s[i]+1<=K) { K-='z'-s[i]+1; s[i]='a'; }
        if(i==len-1) s[i] += K%26;
    }
    cout<<s<<endl;
    return 0;
}

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

int main() {
  int x;
  cin >> x;
  int ans = x == 0 ? 1 : 0;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3548
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF=1<<30;


int main(void) {


    ll N,A,B; cin>>N>>A>>B;

    if((A+B)% N==0){
        cout<<(N/(A+B))*A<<endl;
    }else{
        ll tmp = floor(N/(A+B));
        ll amari = N % (A+B);
        cout<<tmp*A + min(amari, A)<<endl;

    }

    return 0;
}

Measured memory_bytes: 256
#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 s[100000];

int main() {
  int n;
  while(cin>>n) {
    inputs(s,n);
    ll ans = 0;
    for (int d=1; d<n; d++) {
      int bk = d;
      ll bsum = 0;
      ll asum = 0;
      int ng = n;
      for (int k=n-1-d; k>0; k-=d) {
        int A = k;
        int B = A - d;
        if (A <= B || B <= 0) continue;
        if (k % d == 0) ng = k;
        if (ng <= bk) {
          break;
        }
        asum += s[k];
        bsum += s[bk];
        bk += d;
        chmax(ans, asum + bsum);
        // cout << tpl(A, B, k, bk, asum, bsum, asum + bsum) << endl;
        // A = k
        // d = A - B
        // B = A - d
        // (s[A] + S[A+d] ... S[n-1]) + (s[d] + s[2*d] + ... + s[n-1-A])
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <map>
#define ll long long
#define REP(i, x) for(int (i) = 0; (i) < (x); (i) ++)
#define pi 3.1415926535
const int MOD = 1000000007;
using namespace std;

int main() {
	int W, a, b;
	cin >> W >> a >> b;
	if (a > b) {
		swap(a, b);
	}
	if (b - W - a <= 0) {
		cout << 0 << endl;
		return 0;
	}
	cout << b - W - a << endl;
	return 0;
}

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

typedef long long ll;
using namespace std;

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

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


int main()
{
  char x,y;
  cin>>x>>y;
  if(x-'A'>y-'A'){
    cout<<'>'<<endl;
  }else if(x==y){
    cout<<'='<<endl;
  }else{
    cout<<'<'<<endl;
  }
  return 0;
}


Measured memory_bytes: 3608
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, s, e) for(int i=s; i<e; i++)
#define REF(i, s, e) for(int i=s; i>e; i--)
typedef long long ll;

vector<int> list753({7,5,3});

//numで始まるn以下の753数計算
ll count753(ll num, ll n) {
	if (num > n) return 0;

	//num自身が753数ならcnt+1
	ll cnt;
	string num_s = to_string(num);
	if (num_s.find("7") != string::npos && num_s.find("5") != string::npos && num_s.find("3") != string::npos) cnt = 1;
	else cnt = 0;

	//後ろの桁に7,5,3をつけて次に渡す
	for (int e : list753) {
		cnt += count753(10 * num + e, n);
	}

	return cnt;
}

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

	ll n;
	cin >> n;

	cout << count753(0, n) << endl;

}

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

using namespace std;
using ll = long long;

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

  ll a, b;
  cin >> a >> b;

  ll d = a * b;

  for(int _ = 0; _ < 2; ++_, swap(a, b))
    for(int i = 1; i < b; ++i) {
      ll x = a * i;
      ll y = a / 2 * (b-i);
      ll z = (a / 2 + a % 2) * (b-i);
      ll mn = min(x, min(y, z));
      ll mx = max(x, max(y, z));
      d = min(d, mx - mn);

      y = (b-i) / 2 * a;
      z = ((b-i) / 2 + (b-i) % 2) * a;
      mn = min(x, min(y, z));
      mx = max(x, max(y, z));
      d = min(d, mx - mn);
    }

  cout << d << endl;
}

Measured memory_bytes: 256